enhance: 打印崩溃堆栈

This commit is contained in:
2023-09-16 20:26:58 +08:00
parent 735e99d891
commit a6cd981a51
5 changed files with 47 additions and 24 deletions

View File

@@ -2,6 +2,10 @@
#include "mainwindow-dtk.h" #include "mainwindow-dtk.h"
#include "utils/utils.h" #include "utils/utils.h"
#include <signal.h>
#include <execinfo.h>
#include <unistd.h>
#include <DSysInfo> #include <DSysInfo>
#include <DApplicationSettings> #include <DApplicationSettings>
#include <DWidgetUtil> #include <DWidgetUtil>
@@ -16,8 +20,27 @@
DCORE_USE_NAMESPACE DCORE_USE_NAMESPACE
DWIDGET_USE_NAMESPACE DWIDGET_USE_NAMESPACE
void crashHandler(int sig) {
void *array[50];
size_t size;
// 获取所有活动的函数指针
size = backtrace(array, 50);
// 打印函数调用堆栈
fprintf(stderr, "Error: signal %d:\n", sig);
backtrace_symbols_fd(array, size, STDERR_FILENO);
exit(1);
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
// 崩溃处理
signal(SIGSEGV, crashHandler); // 注册SIGSEGV处理函数
// Get build time // Get build time
static const QDate buildDate = QLocale(QLocale::English).toDate(QString(__DATE__).replace(" ", " 0"), "MMM dd yyyy"); static const QDate buildDate = QLocale(QLocale::English).toDate(QString(__DATE__).replace(" ", " 0"), "MMM dd yyyy");
static const QTime buildTime = QTime::fromString(__TIME__, "hh:mm:ss"); static const QTime buildTime = QTime::fromString(__TIME__, "hh:mm:ss");

View File

@@ -268,12 +268,12 @@
<context> <context>
<name>DAboutDialog</name> <name>DAboutDialog</name>
<message> <message>
<location filename="../src/application.cpp" line="139"/> <location filename="../src/application.cpp" line="141"/>
<source>Version: %1</source> <source>Version: %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../src/application.cpp" line="149"/> <location filename="../src/application.cpp" line="151"/>
<source>%1 is released under %2</source> <source>%1 is released under %2</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@@ -514,19 +514,19 @@
<context> <context>
<name>QObject</name> <name>QObject</name>
<message> <message>
<location filename="../src/application.cpp" line="33"/> <location filename="../src/application.cpp" line="35"/>
<location filename="../src/application.cpp" line="34"/> <location filename="../src/application.cpp" line="36"/>
<location filename="../src/mainwindow-dtk.cpp" line="126"/> <location filename="../src/mainwindow-dtk.cpp" line="126"/>
<source>Spark Store</source> <source>Spark Store</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../src/application.cpp" line="38"/> <location filename="../src/application.cpp" line="40"/>
<source>&lt;span style=&apos; font-size:10pt;font-weight:60;&apos;&gt;An appstore powered by community&lt;/span&gt;&lt;br/&gt;&lt;a href=&apos;https://www.spark-app.store/&apos;&gt;https://www.spark-app.store&lt;/a&gt;&lt;br/&gt;&lt;span style=&apos; font-size:12pt;&apos;&gt;Spark developers&lt;/span&gt;</source> <source>&lt;span style=&apos; font-size:10pt;font-weight:60;&apos;&gt;An appstore powered by community&lt;/span&gt;&lt;br/&gt;&lt;a href=&apos;https://www.spark-app.store/&apos;&gt;https://www.spark-app.store&lt;/a&gt;&lt;br/&gt;&lt;span style=&apos; font-size:12pt;&apos;&gt;Spark developers&lt;/span&gt;</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../src/application.cpp" line="146"/> <location filename="../src/application.cpp" line="148"/>
<source>Spark Project</source> <source>Spark Project</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>

View File

@@ -268,12 +268,12 @@
<context> <context>
<name>DAboutDialog</name> <name>DAboutDialog</name>
<message> <message>
<location filename="../src/application.cpp" line="139"/> <location filename="../src/application.cpp" line="141"/>
<source>Version: %1</source> <source>Version: %1</source>
<translation>Version: %1</translation> <translation>Version: %1</translation>
</message> </message>
<message> <message>
<location filename="../src/application.cpp" line="149"/> <location filename="../src/application.cpp" line="151"/>
<source>%1 is released under %2</source> <source>%1 is released under %2</source>
<translation>%1 publié sous %2</translation> <translation>%1 publié sous %2</translation>
</message> </message>
@@ -514,19 +514,19 @@
<context> <context>
<name>QObject</name> <name>QObject</name>
<message> <message>
<location filename="../src/application.cpp" line="33"/> <location filename="../src/application.cpp" line="35"/>
<location filename="../src/application.cpp" line="34"/> <location filename="../src/application.cpp" line="36"/>
<location filename="../src/mainwindow-dtk.cpp" line="126"/> <location filename="../src/mainwindow-dtk.cpp" line="126"/>
<source>Spark Store</source> <source>Spark Store</source>
<translation>Le Spark store</translation> <translation>Le Spark store</translation>
</message> </message>
<message> <message>
<location filename="../src/application.cpp" line="38"/> <location filename="../src/application.cpp" line="40"/>
<source>&lt;span style=&apos; font-size:10pt;font-weight:60;&apos;&gt;An appstore powered by community&lt;/span&gt;&lt;br/&gt;&lt;a href=&apos;https://www.spark-app.store/&apos;&gt;https://www.spark-app.store&lt;/a&gt;&lt;br/&gt;&lt;span style=&apos; font-size:12pt;&apos;&gt;Spark developers&lt;/span&gt;</source> <source>&lt;span style=&apos; font-size:10pt;font-weight:60;&apos;&gt;An appstore powered by community&lt;/span&gt;&lt;br/&gt;&lt;a href=&apos;https://www.spark-app.store/&apos;&gt;https://www.spark-app.store&lt;/a&gt;&lt;br/&gt;&lt;span style=&apos; font-size:12pt;&apos;&gt;Spark developers&lt;/span&gt;</source>
<translation>&lt;span style=&apos; font-size:10pt;font-weight:60;&apos;&gt;An appstore powered by community&lt;/span&gt;&lt;br/&gt;&lt;a href=&apos;https://www.spark-app.store/&apos;&gt;https://www.spark-app.store&lt;/a&gt;&lt;br/&gt;&lt;span style=&apos; font-size:12pt;&apos;&gt;Spark developers&lt;/span&gt;</translation> <translation>&lt;span style=&apos; font-size:10pt;font-weight:60;&apos;&gt;An appstore powered by community&lt;/span&gt;&lt;br/&gt;&lt;a href=&apos;https://www.spark-app.store/&apos;&gt;https://www.spark-app.store&lt;/a&gt;&lt;br/&gt;&lt;span style=&apos; font-size:12pt;&apos;&gt;Spark developers&lt;/span&gt;</translation>
</message> </message>
<message> <message>
<location filename="../src/application.cpp" line="146"/> <location filename="../src/application.cpp" line="148"/>
<source>Spark Project</source> <source>Spark Project</source>
<translation>Le projet Spark</translation> <translation>Le projet Spark</translation>
</message> </message>

View File

@@ -268,12 +268,12 @@
<context> <context>
<name>DAboutDialog</name> <name>DAboutDialog</name>
<message> <message>
<location filename="../src/application.cpp" line="139"/> <location filename="../src/application.cpp" line="141"/>
<source>Version: %1</source> <source>Version: %1</source>
<translation>%1</translation> <translation>%1</translation>
</message> </message>
<message> <message>
<location filename="../src/application.cpp" line="149"/> <location filename="../src/application.cpp" line="151"/>
<source>%1 is released under %2</source> <source>%1 is released under %2</source>
<translation>%1%2</translation> <translation>%1%2</translation>
</message> </message>
@@ -514,19 +514,19 @@
<context> <context>
<name>QObject</name> <name>QObject</name>
<message> <message>
<location filename="../src/application.cpp" line="33"/> <location filename="../src/application.cpp" line="35"/>
<location filename="../src/application.cpp" line="34"/> <location filename="../src/application.cpp" line="36"/>
<location filename="../src/mainwindow-dtk.cpp" line="126"/> <location filename="../src/mainwindow-dtk.cpp" line="126"/>
<source>Spark Store</source> <source>Spark Store</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../src/application.cpp" line="38"/> <location filename="../src/application.cpp" line="40"/>
<source>&lt;span style=&apos; font-size:10pt;font-weight:60;&apos;&gt;An appstore powered by community&lt;/span&gt;&lt;br/&gt;&lt;a href=&apos;https://www.spark-app.store/&apos;&gt;https://www.spark-app.store&lt;/a&gt;&lt;br/&gt;&lt;span style=&apos; font-size:12pt;&apos;&gt;Spark developers&lt;/span&gt;</source> <source>&lt;span style=&apos; font-size:10pt;font-weight:60;&apos;&gt;An appstore powered by community&lt;/span&gt;&lt;br/&gt;&lt;a href=&apos;https://www.spark-app.store/&apos;&gt;https://www.spark-app.store&lt;/a&gt;&lt;br/&gt;&lt;span style=&apos; font-size:12pt;&apos;&gt;Spark developers&lt;/span&gt;</source>
<translation>&lt;span style=&apos; font-size:10pt;font-weight:60;&apos;&gt;&lt;/span&gt;&lt;br/&gt;&lt;a href=&apos;https://www.spark-app.store/&apos;&gt;https://www.spark-app.store&lt;/a&gt;&lt;br/&gt;&lt;span style=&apos; font-size:12pt;&apos;&gt;星火计划开发者&lt;/span&gt;</translation> <translation>&lt;span style=&apos; font-size:10pt;font-weight:60;&apos;&gt;&lt;/span&gt;&lt;br/&gt;&lt;a href=&apos;https://www.spark-app.store/&apos;&gt;https://www.spark-app.store&lt;/a&gt;&lt;br/&gt;&lt;span style=&apos; font-size:12pt;&apos;&gt;星火计划开发者&lt;/span&gt;</translation>
</message> </message>
<message> <message>
<location filename="../src/application.cpp" line="146"/> <location filename="../src/application.cpp" line="148"/>
<source>Spark Project</source> <source>Spark Project</source>
<translation></translation> <translation></translation>
</message> </message>

View File

@@ -268,12 +268,12 @@
<context> <context>
<name>DAboutDialog</name> <name>DAboutDialog</name>
<message> <message>
<location filename="../src/application.cpp" line="139"/> <location filename="../src/application.cpp" line="141"/>
<source>Version: %1</source> <source>Version: %1</source>
<translation>%1</translation> <translation>%1</translation>
</message> </message>
<message> <message>
<location filename="../src/application.cpp" line="149"/> <location filename="../src/application.cpp" line="151"/>
<source>%1 is released under %2</source> <source>%1 is released under %2</source>
<translation>%1%2</translation> <translation>%1%2</translation>
</message> </message>
@@ -514,19 +514,19 @@
<context> <context>
<name>QObject</name> <name>QObject</name>
<message> <message>
<location filename="../src/application.cpp" line="33"/> <location filename="../src/application.cpp" line="35"/>
<location filename="../src/application.cpp" line="34"/> <location filename="../src/application.cpp" line="36"/>
<location filename="../src/mainwindow-dtk.cpp" line="126"/> <location filename="../src/mainwindow-dtk.cpp" line="126"/>
<source>Spark Store</source> <source>Spark Store</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../src/application.cpp" line="38"/> <location filename="../src/application.cpp" line="40"/>
<source>&lt;span style=&apos; font-size:10pt;font-weight:60;&apos;&gt;An appstore powered by community&lt;/span&gt;&lt;br/&gt;&lt;a href=&apos;https://www.spark-app.store/&apos;&gt;https://www.spark-app.store&lt;/a&gt;&lt;br/&gt;&lt;span style=&apos; font-size:12pt;&apos;&gt;Spark developers&lt;/span&gt;</source> <source>&lt;span style=&apos; font-size:10pt;font-weight:60;&apos;&gt;An appstore powered by community&lt;/span&gt;&lt;br/&gt;&lt;a href=&apos;https://www.spark-app.store/&apos;&gt;https://www.spark-app.store&lt;/a&gt;&lt;br/&gt;&lt;span style=&apos; font-size:12pt;&apos;&gt;Spark developers&lt;/span&gt;</source>
<translation>&lt;span style=&apos; font-size:10pt;font-weight:60;&apos;&gt;&lt;/span&gt;&lt;br/&gt;&lt;a href=&apos;https://www.spark-app.store/&apos;&gt;https://www.spark-app.store&lt;/a&gt;&lt;br/&gt;&lt;span style=&apos; font-size:12pt;&apos;&gt;星火计划开发者&lt;/span&gt;</translation> <translation>&lt;span style=&apos; font-size:10pt;font-weight:60;&apos;&gt;&lt;/span&gt;&lt;br/&gt;&lt;a href=&apos;https://www.spark-app.store/&apos;&gt;https://www.spark-app.store&lt;/a&gt;&lt;br/&gt;&lt;span style=&apos; font-size:12pt;&apos;&gt;星火计划开发者&lt;/span&gt;</translation>
</message> </message>
<message> <message>
<location filename="../src/application.cpp" line="146"/> <location filename="../src/application.cpp" line="148"/>
<source>Spark Project</source> <source>Spark Project</source>
<translation></translation> <translation></translation>
</message> </message>