mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 15:27:54 +00:00
Merge pull request #7667 from Chocobo1/stackdump
Include & print caught signal in stackdump
This commit is contained in:
commit
04cec39277
@ -84,10 +84,17 @@ void sigNormalHandler(int signum);
|
|||||||
void sigAbnormalHandler(int signum);
|
void sigAbnormalHandler(int signum);
|
||||||
// sys_signame[] is only defined in BSD
|
// sys_signame[] is only defined in BSD
|
||||||
const char *sysSigName[] = {
|
const char *sysSigName[] = {
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
|
"", "", "SIGINT", "", "SIGILL", "", "SIGABRT_COMPAT", "", "SIGFPE", "",
|
||||||
|
"", "SIGSEGV", "", "", "", "SIGTERM", "", "", "", "",
|
||||||
|
"", "SIGBREAK", "SIGABRT", "", "", "", "", "", "", "",
|
||||||
|
"", ""
|
||||||
|
#else
|
||||||
"", "SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", "SIGTRAP", "SIGABRT", "SIGBUS", "SIGFPE", "SIGKILL",
|
"", "SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", "SIGTRAP", "SIGABRT", "SIGBUS", "SIGFPE", "SIGKILL",
|
||||||
"SIGUSR1", "SIGSEGV", "SIGUSR2", "SIGPIPE", "SIGALRM", "SIGTERM", "SIGSTKFLT", "SIGCHLD", "SIGCONT", "SIGSTOP",
|
"SIGUSR1", "SIGSEGV", "SIGUSR2", "SIGPIPE", "SIGALRM", "SIGTERM", "SIGSTKFLT", "SIGCHLD", "SIGCONT", "SIGSTOP",
|
||||||
"SIGTSTP", "SIGTTIN", "SIGTTOU", "SIGURG", "SIGXCPU", "SIGXFSZ", "SIGVTALRM", "SIGPROF", "SIGWINCH", "SIGIO",
|
"SIGTSTP", "SIGTTIN", "SIGTTOU", "SIGURG", "SIGXCPU", "SIGXFSZ", "SIGVTALRM", "SIGPROF", "SIGWINCH", "SIGIO",
|
||||||
"SIGPWR", "SIGUNUSED"
|
"SIGPWR", "SIGUNUSED"
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -214,7 +221,7 @@ int main(int argc, char *argv[])
|
|||||||
QByteArray path = "/usr/local/bin:";
|
QByteArray path = "/usr/local/bin:";
|
||||||
path += qgetenv("PATH");
|
path += qgetenv("PATH");
|
||||||
qputenv("PATH", path.constData());
|
qputenv("PATH", path.constData());
|
||||||
|
|
||||||
// On OS X the standard is to not show icons in the menus
|
// On OS X the standard is to not show icons in the menus
|
||||||
app->setAttribute(Qt::AA_DontShowIconsInMenus);
|
app->setAttribute(Qt::AA_DontShowIconsInMenus);
|
||||||
#endif
|
#endif
|
||||||
@ -276,12 +283,11 @@ void reportToUser(const char* str)
|
|||||||
void sigNormalHandler(int signum)
|
void sigNormalHandler(int signum)
|
||||||
{
|
{
|
||||||
#if !defined Q_OS_WIN && !defined Q_OS_HAIKU
|
#if !defined Q_OS_WIN && !defined Q_OS_HAIKU
|
||||||
const char str1[] = "Catching signal: ";
|
const char msg1[] = "Catching signal: ";
|
||||||
const char *sigName = sysSigName[signum];
|
const char msg2[] = "\nExiting cleanly\n";
|
||||||
const char str2[] = "\nExiting cleanly\n";
|
reportToUser(msg1);
|
||||||
reportToUser(str1);
|
reportToUser(sysSigName[signum]);
|
||||||
reportToUser(sigName);
|
reportToUser(msg2);
|
||||||
reportToUser(str2);
|
|
||||||
#endif // !defined Q_OS_WIN && !defined Q_OS_HAIKU
|
#endif // !defined Q_OS_WIN && !defined Q_OS_HAIKU
|
||||||
signal(signum, SIG_DFL);
|
signal(signum, SIG_DFL);
|
||||||
qApp->exit(); // unsafe, but exit anyway
|
qApp->exit(); // unsafe, but exit anyway
|
||||||
@ -289,19 +295,20 @@ void sigNormalHandler(int signum)
|
|||||||
|
|
||||||
void sigAbnormalHandler(int signum)
|
void sigAbnormalHandler(int signum)
|
||||||
{
|
{
|
||||||
#if !defined Q_OS_WIN && !defined Q_OS_HAIKU
|
|
||||||
const char str1[] = "\n\n*************************************************************\nCatching signal: ";
|
|
||||||
const char *sigName = sysSigName[signum];
|
const char *sigName = sysSigName[signum];
|
||||||
const char str2[] = "\nPlease file a bug report at http://bug.qbittorrent.org and provide the following information:\n\n"
|
#if !defined Q_OS_WIN && !defined Q_OS_HAIKU
|
||||||
"qBittorrent version: " QBT_VERSION "\n";
|
const char msg[] = "\n\n*************************************************************\n"
|
||||||
reportToUser(str1);
|
"Please file a bug report at http://bug.qbittorrent.org and provide the following information:\n\n"
|
||||||
|
"qBittorrent version: " QBT_VERSION "\n\n"
|
||||||
|
"Caught signal: ";
|
||||||
|
reportToUser(msg);
|
||||||
reportToUser(sigName);
|
reportToUser(sigName);
|
||||||
reportToUser(str2);
|
reportToUser("\n");
|
||||||
print_stacktrace(); // unsafe
|
print_stacktrace(); // unsafe
|
||||||
#endif // !defined Q_OS_WIN && !defined Q_OS_HAIKU
|
#endif // !defined Q_OS_WIN && !defined Q_OS_HAIKU
|
||||||
#ifdef STACKTRACE_WIN
|
#ifdef STACKTRACE_WIN
|
||||||
StraceDlg dlg; // unsafe
|
StraceDlg dlg; // unsafe
|
||||||
dlg.setStacktraceString(straceWin::getBacktrace());
|
dlg.setStacktraceString(QLatin1String(sigName), straceWin::getBacktrace());
|
||||||
dlg.exec();
|
dlg.exec();
|
||||||
#endif // STACKTRACE_WIN
|
#endif // STACKTRACE_WIN
|
||||||
signal(signum, SIG_DFL);
|
signal(signum, SIG_DFL);
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
/** Print a demangled stack backtrace of the caller function to FILE* out. */
|
/** Print a demangled stack backtrace of the caller function to FILE* out. */
|
||||||
static inline void print_stacktrace(FILE *out = stderr, unsigned int max_frames = 63)
|
static inline void print_stacktrace(FILE *out = stderr, unsigned int max_frames = 63)
|
||||||
{
|
{
|
||||||
fprintf(out, "stack trace:\n");
|
fprintf(out, "Stack trace:\n");
|
||||||
|
|
||||||
// storage array for stack trace address data
|
// storage array for stack trace address data
|
||||||
std::vector<void *> addrlist(max_frames + 1);
|
std::vector<void *> addrlist(max_frames + 1);
|
||||||
|
@ -40,13 +40,13 @@ class StraceDlg : public QDialog, private Ui::errorDialog
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StraceDlg(QWidget* parent = 0)
|
StraceDlg(QWidget *parent = nullptr)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setStacktraceString(const QString& trace)
|
void setStacktraceString(const QString &sigName, const QString &trace)
|
||||||
{
|
{
|
||||||
// try to call Qt function as less as possible
|
// try to call Qt function as less as possible
|
||||||
QString htmlStr = QString(
|
QString htmlStr = QString(
|
||||||
@ -68,14 +68,16 @@ public:
|
|||||||
"Libtorrent version: %1<br/>"
|
"Libtorrent version: %1<br/>"
|
||||||
"Qt version: " QT_VERSION_STR "<br/>"
|
"Qt version: " QT_VERSION_STR "<br/>"
|
||||||
"Boost version: %2<br/>"
|
"Boost version: %2<br/>"
|
||||||
"OS version: %3"
|
"OS version: %3<br/><br/>"
|
||||||
"</font></p><br/>"
|
"Caught signal: %4"
|
||||||
"<pre><code>%4</code></pre>"
|
"</font></p>"
|
||||||
|
"<pre><code>%5</code></pre>"
|
||||||
"<br/><hr><br/><br/>")
|
"<br/><hr><br/><br/>")
|
||||||
.arg(Utils::Misc::libtorrentVersionString())
|
.arg(Utils::Misc::libtorrentVersionString())
|
||||||
.arg(Utils::Misc::boostVersionString())
|
.arg(Utils::Misc::boostVersionString())
|
||||||
.arg(Utils::Misc::osName())
|
.arg(Utils::Misc::osName())
|
||||||
.arg(trace);
|
.arg(sigName)
|
||||||
|
.arg(trace);
|
||||||
|
|
||||||
errorText->setHtml(htmlStr);
|
errorText->setHtml(htmlStr);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user