diff --git a/src/core/debuginfo.cpp b/src/core/debuginfo.cpp index f26c72e..ae227f8 100644 --- a/src/core/debuginfo.cpp +++ b/src/core/debuginfo.cpp @@ -1,4 +1,7 @@ #include "debuginfo.hpp" +#include +#include +#include #include #include @@ -14,6 +17,8 @@ #include "build.hpp" +extern char** environ; // NOLINT + namespace qs::debuginfo { QString qsVersion() { @@ -119,6 +124,31 @@ QString systemInfo() { return info; } +QString envInfo() { + QString info; + auto stream = QTextStream(&info); + + for (auto** envp = environ; *envp != nullptr; ++envp) { // NOLINT + auto prefixes = std::array { + "QS_", + "QT_", + "QML_", + "QML2_", + "QSG_", + }; + + for (const auto& prefix: prefixes) { + if (strncmp(prefix.data(), *envp, prefix.length()) == 0) goto print; + } + continue; + + print: + stream << *envp << '\n'; + } + + return info; +} + QString combinedInfo() { QString info; auto stream = QTextStream(&info); @@ -136,6 +166,9 @@ QString combinedInfo() { stream << "\n===== System Information =====\n"; stream << systemInfo(); + stream << "\n===== Environment (trimmed) =====\n"; + stream << envInfo(); + return info; } diff --git a/src/core/debuginfo.hpp b/src/core/debuginfo.hpp index cc13f97..fc766fc 100644 --- a/src/core/debuginfo.hpp +++ b/src/core/debuginfo.hpp @@ -8,6 +8,7 @@ QString qsVersion(); QString qtVersion(); QString gpuInfo(); QString systemInfo(); +QString envInfo(); QString combinedInfo(); } // namespace qs::debuginfo