diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index f0ca8ef..076ab90 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -41,6 +41,7 @@ qt_add_library(quickshell-core STATIC colorquantizer.cpp toolsupport.cpp streamreader.cpp + debuginfo.cpp ) qt_add_qml_module(quickshell-core diff --git a/src/core/debuginfo.cpp b/src/core/debuginfo.cpp new file mode 100644 index 0000000..f948d42 --- /dev/null +++ b/src/core/debuginfo.cpp @@ -0,0 +1,68 @@ +#include "debuginfo.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "build.hpp" + +namespace qs::debuginfo { + +QString qsVersion() { + return QS_VERSION " (revision " GIT_REVISION ", distributed by " DISTRIBUTOR ")"; +} + +QString qtVersion() { return qVersion() % QStringLiteral(" (built against " QT_VERSION_STR ")"); } + +QString systemInfo() { + QString info; + auto stream = QTextStream(&info); + + stream << "/etc/os-release:"; + auto osReleaseFile = QFile("/etc/os-release"); + if (osReleaseFile.open(QFile::ReadOnly)) { + stream << '\n' << osReleaseFile.readAll() << '\n'; + osReleaseFile.close(); + } else { + stream << "FAILED TO OPEN\n"; + } + + stream << "/etc/lsb-release:"; + auto lsbReleaseFile = QFile("/etc/lsb-release"); + if (lsbReleaseFile.open(QFile::ReadOnly)) { + stream << '\n' << lsbReleaseFile.readAll(); + lsbReleaseFile.close(); + } else { + stream << "FAILED TO OPEN\n"; + } + + return info; +} + +QString combinedInfo() { + QString info; + auto stream = QTextStream(&info); + + stream << "===== Version Information =====\n"; + stream << "Quickshell: " << qsVersion() << '\n'; + stream << "Qt: " << qtVersion() << '\n'; + + stream << "\n===== Build Information =====\n"; + stream << "Build Type: " << BUILD_TYPE << '\n'; + stream << "Compiler: " << COMPILER << '\n'; + stream << "Compile Flags: " << COMPILE_FLAGS << '\n'; + stream << "Configuration:\n" << BUILD_CONFIGURATION << '\n'; + + stream << "\n===== System Information =====\n"; + stream << systemInfo(); + + return info; +} + +} // namespace qs::debuginfo diff --git a/src/core/debuginfo.hpp b/src/core/debuginfo.hpp new file mode 100644 index 0000000..7759d53 --- /dev/null +++ b/src/core/debuginfo.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include + +namespace qs::debuginfo { + +QString qsVersion(); +QString qtVersion(); +QString systemInfo(); +QString combinedInfo(); + +} // namespace qs::debuginfo diff --git a/src/crash/main.cpp b/src/crash/main.cpp index c406ba6..05927f2 100644 --- a/src/crash/main.cpp +++ b/src/crash/main.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include #include @@ -15,19 +14,18 @@ #include #include #include -#include #include #include #include #include +#include "../core/debuginfo.hpp" #include "../core/instanceinfo.hpp" #include "../core/logcat.hpp" #include "../core/logging.hpp" #include "../core/logging_p.hpp" #include "../core/paths.hpp" #include "../core/ringbuf.hpp" -#include "build.hpp" #include "interface.hpp" namespace { @@ -171,41 +169,15 @@ void recordCrashInfo(const QDir& crashDir, const InstanceInfo& instance) { qCCritical(logCrashReporter) << "Failed to open crash info file for writing."; } else { auto stream = QTextStream(&extraInfoFile); - stream << "===== Build Information =====\n"; - stream << "Git Revision: " << GIT_REVISION << '\n'; - stream << "Buildtime Qt Version: " << QT_VERSION_STR << "\n"; - stream << "Build Type: " << BUILD_TYPE << '\n'; - stream << "Compiler: " << COMPILER << '\n'; - stream << "Complie Flags: " << COMPILE_FLAGS << "\n\n"; - stream << "Build configuration:\n" << BUILD_CONFIGURATION << "\n"; + stream << qs::debuginfo::combinedInfo(); - stream << "\n===== Runtime Information =====\n"; - stream << "Runtime Qt Version: " << qVersion() << '\n'; + stream << "\n===== Instance Information =====\n"; stream << "Signal: " << strsignal(crashSignal) << " (" << crashSignal << ")\n"; // NOLINT stream << "Crashed process ID: " << crashProc << '\n'; stream << "Run ID: " << instance.instanceId << '\n'; stream << "Shell ID: " << instance.shellId << '\n'; stream << "Config Path: " << instance.configPath << '\n'; - stream << "\n===== System Information =====\n\n"; - stream << "/etc/os-release:"; - auto osReleaseFile = QFile("/etc/os-release"); - if (osReleaseFile.open(QFile::ReadOnly)) { - stream << '\n' << osReleaseFile.readAll() << '\n'; - osReleaseFile.close(); - } else { - stream << "FAILED TO OPEN\n"; - } - - stream << "/etc/lsb-release:"; - auto lsbReleaseFile = QFile("/etc/lsb-release"); - if (lsbReleaseFile.open(QFile::ReadOnly)) { - stream << '\n' << lsbReleaseFile.readAll(); - lsbReleaseFile.close(); - } else { - stream << "FAILED TO OPEN\n"; - } - stream << "\n===== Stacktrace =====\n"; if (stacktrace.empty()) { stream << "(no trace available)\n"; diff --git a/src/launch/command.cpp b/src/launch/command.cpp index 151fc24..807eb24 100644 --- a/src/launch/command.cpp +++ b/src/launch/command.cpp @@ -25,12 +25,12 @@ #include #include +#include "../core/debuginfo.hpp" #include "../core/instanceinfo.hpp" #include "../core/logging.hpp" #include "../core/paths.hpp" #include "../io/ipccomm.hpp" #include "../ipc/ipc.hpp" -#include "build.hpp" #include "launch_p.hpp" namespace qs::launch { @@ -519,20 +519,10 @@ int runCommand(int argc, char** argv, QCoreApplication* coreApplication) { } if (state.misc.printVersion) { - qCInfo(logBare).noquote().nospace() << "quickshell " << QS_VERSION << ", revision " - << GIT_REVISION << ", distributed by: " << DISTRIBUTOR; - - if (state.log.verbosity > 1) { - qCInfo(logBare).noquote() << "\nBuildtime Qt Version:" << QT_VERSION_STR; - qCInfo(logBare).noquote() << "Runtime Qt Version:" << qVersion(); - qCInfo(logBare).noquote() << "Compiler:" << COMPILER; - qCInfo(logBare).noquote() << "Compile Flags:" << COMPILE_FLAGS; - } - - if (state.log.verbosity > 0) { - qCInfo(logBare).noquote() << "\nBuild Type:" << BUILD_TYPE; - qCInfo(logBare).noquote() << "Build configuration:"; - qCInfo(logBare).noquote().nospace() << BUILD_CONFIGURATION; + if (state.log.verbosity == 0) { + qCInfo(logBare).noquote() << "Quickshell" << qs::debuginfo::qsVersion(); + } else { + qCInfo(logBare).noquote() << qs::debuginfo::combinedInfo(); } } else if (*state.subcommand.log) { return readLogFile(state);