mirror of
https://git.outfoxxed.me/quickshell/quickshell.git
synced 2026-04-10 06:11:54 +10:00
core: move crash/version debug info to one place
This commit is contained in:
parent
4b77936c80
commit
1123d5ab4f
5 changed files with 89 additions and 46 deletions
|
|
@ -41,6 +41,7 @@ qt_add_library(quickshell-core STATIC
|
||||||
colorquantizer.cpp
|
colorquantizer.cpp
|
||||||
toolsupport.cpp
|
toolsupport.cpp
|
||||||
streamreader.cpp
|
streamreader.cpp
|
||||||
|
debuginfo.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
qt_add_qml_module(quickshell-core
|
qt_add_qml_module(quickshell-core
|
||||||
|
|
|
||||||
68
src/core/debuginfo.cpp
Normal file
68
src/core/debuginfo.cpp
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
#include "debuginfo.hpp"
|
||||||
|
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <qconfig.h>
|
||||||
|
#include <qcontainerfwd.h>
|
||||||
|
#include <qdebug.h>
|
||||||
|
#include <qfile.h>
|
||||||
|
#include <qfloat16.h>
|
||||||
|
#include <qhashfunctions.h>
|
||||||
|
#include <qtversion.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#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
|
||||||
12
src/core/debuginfo.hpp
Normal file
12
src/core/debuginfo.hpp
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <qcontainerfwd.h>
|
||||||
|
|
||||||
|
namespace qs::debuginfo {
|
||||||
|
|
||||||
|
QString qsVersion();
|
||||||
|
QString qtVersion();
|
||||||
|
QString systemInfo();
|
||||||
|
QString combinedInfo();
|
||||||
|
|
||||||
|
} // namespace qs::debuginfo
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
#include <cpptrace/basic.hpp>
|
#include <cpptrace/basic.hpp>
|
||||||
#include <cpptrace/formatting.hpp>
|
#include <cpptrace/formatting.hpp>
|
||||||
#include <qapplication.h>
|
#include <qapplication.h>
|
||||||
#include <qconfig.h>
|
|
||||||
#include <qcoreapplication.h>
|
#include <qcoreapplication.h>
|
||||||
#include <qdatastream.h>
|
#include <qdatastream.h>
|
||||||
#include <qdir.h>
|
#include <qdir.h>
|
||||||
|
|
@ -15,19 +14,18 @@
|
||||||
#include <qloggingcategory.h>
|
#include <qloggingcategory.h>
|
||||||
#include <qtenvironmentvariables.h>
|
#include <qtenvironmentvariables.h>
|
||||||
#include <qtextstream.h>
|
#include <qtextstream.h>
|
||||||
#include <qtversion.h>
|
|
||||||
#include <qtypes.h>
|
#include <qtypes.h>
|
||||||
#include <sys/sendfile.h>
|
#include <sys/sendfile.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "../core/debuginfo.hpp"
|
||||||
#include "../core/instanceinfo.hpp"
|
#include "../core/instanceinfo.hpp"
|
||||||
#include "../core/logcat.hpp"
|
#include "../core/logcat.hpp"
|
||||||
#include "../core/logging.hpp"
|
#include "../core/logging.hpp"
|
||||||
#include "../core/logging_p.hpp"
|
#include "../core/logging_p.hpp"
|
||||||
#include "../core/paths.hpp"
|
#include "../core/paths.hpp"
|
||||||
#include "../core/ringbuf.hpp"
|
#include "../core/ringbuf.hpp"
|
||||||
#include "build.hpp"
|
|
||||||
#include "interface.hpp"
|
#include "interface.hpp"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
@ -171,41 +169,15 @@ void recordCrashInfo(const QDir& crashDir, const InstanceInfo& instance) {
|
||||||
qCCritical(logCrashReporter) << "Failed to open crash info file for writing.";
|
qCCritical(logCrashReporter) << "Failed to open crash info file for writing.";
|
||||||
} else {
|
} else {
|
||||||
auto stream = QTextStream(&extraInfoFile);
|
auto stream = QTextStream(&extraInfoFile);
|
||||||
stream << "===== Build Information =====\n";
|
stream << qs::debuginfo::combinedInfo();
|
||||||
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 << "\n===== Runtime Information =====\n";
|
stream << "\n===== Instance Information =====\n";
|
||||||
stream << "Runtime Qt Version: " << qVersion() << '\n';
|
|
||||||
stream << "Signal: " << strsignal(crashSignal) << " (" << crashSignal << ")\n"; // NOLINT
|
stream << "Signal: " << strsignal(crashSignal) << " (" << crashSignal << ")\n"; // NOLINT
|
||||||
stream << "Crashed process ID: " << crashProc << '\n';
|
stream << "Crashed process ID: " << crashProc << '\n';
|
||||||
stream << "Run ID: " << instance.instanceId << '\n';
|
stream << "Run ID: " << instance.instanceId << '\n';
|
||||||
stream << "Shell ID: " << instance.shellId << '\n';
|
stream << "Shell ID: " << instance.shellId << '\n';
|
||||||
stream << "Config Path: " << instance.configPath << '\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";
|
stream << "\n===== Stacktrace =====\n";
|
||||||
if (stacktrace.empty()) {
|
if (stacktrace.empty()) {
|
||||||
stream << "(no trace available)\n";
|
stream << "(no trace available)\n";
|
||||||
|
|
|
||||||
|
|
@ -25,12 +25,12 @@
|
||||||
#include <qtversion.h>
|
#include <qtversion.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "../core/debuginfo.hpp"
|
||||||
#include "../core/instanceinfo.hpp"
|
#include "../core/instanceinfo.hpp"
|
||||||
#include "../core/logging.hpp"
|
#include "../core/logging.hpp"
|
||||||
#include "../core/paths.hpp"
|
#include "../core/paths.hpp"
|
||||||
#include "../io/ipccomm.hpp"
|
#include "../io/ipccomm.hpp"
|
||||||
#include "../ipc/ipc.hpp"
|
#include "../ipc/ipc.hpp"
|
||||||
#include "build.hpp"
|
|
||||||
#include "launch_p.hpp"
|
#include "launch_p.hpp"
|
||||||
|
|
||||||
namespace qs::launch {
|
namespace qs::launch {
|
||||||
|
|
@ -519,20 +519,10 @@ int runCommand(int argc, char** argv, QCoreApplication* coreApplication) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.misc.printVersion) {
|
if (state.misc.printVersion) {
|
||||||
qCInfo(logBare).noquote().nospace() << "quickshell " << QS_VERSION << ", revision "
|
if (state.log.verbosity == 0) {
|
||||||
<< GIT_REVISION << ", distributed by: " << DISTRIBUTOR;
|
qCInfo(logBare).noquote() << "Quickshell" << qs::debuginfo::qsVersion();
|
||||||
|
} else {
|
||||||
if (state.log.verbosity > 1) {
|
qCInfo(logBare).noquote() << qs::debuginfo::combinedInfo();
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
} else if (*state.subcommand.log) {
|
} else if (*state.subcommand.log) {
|
||||||
return readLogFile(state);
|
return readLogFile(state);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue