core: log qt related environment variables in debuginfo

This commit is contained in:
outfoxxed 2026-03-15 21:13:35 -07:00
parent 1b2519d9f3
commit 9e8eecf2b8
No known key found for this signature in database
GPG key ID: 4C88A185FB89301E
2 changed files with 34 additions and 0 deletions

View file

@ -1,4 +1,7 @@
#include "debuginfo.hpp" #include "debuginfo.hpp"
#include <array>
#include <cstring>
#include <string_view>
#include <fcntl.h> #include <fcntl.h>
#include <qconfig.h> #include <qconfig.h>
@ -14,6 +17,8 @@
#include "build.hpp" #include "build.hpp"
extern char** environ; // NOLINT
namespace qs::debuginfo { namespace qs::debuginfo {
QString qsVersion() { QString qsVersion() {
@ -119,6 +124,31 @@ QString systemInfo() {
return info; return info;
} }
QString envInfo() {
QString info;
auto stream = QTextStream(&info);
for (auto** envp = environ; *envp != nullptr; ++envp) { // NOLINT
auto prefixes = std::array<std::string_view, 5> {
"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 combinedInfo() {
QString info; QString info;
auto stream = QTextStream(&info); auto stream = QTextStream(&info);
@ -136,6 +166,9 @@ QString combinedInfo() {
stream << "\n===== System Information =====\n"; stream << "\n===== System Information =====\n";
stream << systemInfo(); stream << systemInfo();
stream << "\n===== Environment (trimmed) =====\n";
stream << envInfo();
return info; return info;
} }

View file

@ -8,6 +8,7 @@ QString qsVersion();
QString qtVersion(); QString qtVersion();
QString gpuInfo(); QString gpuInfo();
QString systemInfo(); QString systemInfo();
QString envInfo();
QString combinedInfo(); QString combinedInfo();
} // namespace qs::debuginfo } // namespace qs::debuginfo