summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Holland <dominik.holland@qt.io>2020-02-05 16:45:18 +0100
committerDominik Holland <dominik.holland@qt.io>2020-02-05 16:06:26 +0000
commit51ef3d423b53299c04552ae7eff864dff4470d87 (patch)
treee63d20d9e3dc00b2a7c239dc7d3a8a04c440d8dc
parent9bc74981bdaa3c1b88cb9ef96c865030c5ad3f79 (diff)
Enable the crashhandler also on macos
Right now we cannot create a backtrace, but at least we can use the crashhandler to kill all child processes and also print a QML backtrace and other useful information Change-Id: I865e4d33dce5f6e032f550cd680176e1b3b54e19 Reviewed-by: Robert Griebl <robert.griebl@qt.io>
-rw-r--r--src/common-lib/crashhandler.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/common-lib/crashhandler.cpp b/src/common-lib/crashhandler.cpp
index 7f3ca903..1b24d3a4 100644
--- a/src/common-lib/crashhandler.cpp
+++ b/src/common-lib/crashhandler.cpp
@@ -43,7 +43,7 @@
#include "crashhandler.h"
#include "global.h"
-#if !defined(Q_OS_LINUX) || defined(Q_OS_ANDROID)
+#if !defined(Q_OS_UNIX) || defined(Q_OS_ANDROID)
QT_BEGIN_NAMESPACE_AM
@@ -226,10 +226,17 @@ static void printCrashInfo(PrintDestination dest, const char *why, int stackFram
}
pid_t pid = getpid();
+#if defined(Q_OS_LINUX)
long tid = syscall(SYS_gettid);
+ bool isMainThread = (tid == pid);
+#else
+ long tid = -1;
+ bool isMainThread = pthread_main_np();
+#endif
pthread_t pthreadId = pthread_self();
char threadName[16];
- if (tid == pid)
+
+ if (isMainThread)
strcpy(threadName, "main");
else if (pthread_getname_np(pthreadId, threadName, sizeof(threadName)))
strcpy(threadName, "unknown");