summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernd Weimer <bernd.weimer@pelagicore.com>2018-09-19 09:28:58 +0200
committerBernd Weimer <bernd.weimer@pelagicore.com>2018-10-09 07:17:41 +0000
commit9e4614e1a4b73d88ad140431c424e14c8d954272 (patch)
treeb20f96d9f112c90fe17c155423ad3b53e55cec19
parentb6cd1a3560823e47674b62382f7d6a6ca71829b6 (diff)
downloadqtapplicationmanager-9e4614e1a4b73d88ad140431c424e14c8d954272.tar.gz
Add thread name in crash info
Also fixed tools-only build without Qt qml module. This is a backport of 856d232. Change-Id: Ieb32efabcd8574cc5e188a2e3bb093e8c3d121f5 Reviewed-by: Robert Griebl <robert.griebl@pelagicore.com>
-rw-r--r--application-manager.pro2
-rw-r--r--doc/installation.qdoc3
-rw-r--r--src/common-lib/crashhandler.cpp44
-rw-r--r--tests/qml/crash/apps/tld.test.crash/terminator2/qmlterminator2.cpp2
4 files changed, 38 insertions, 13 deletions
diff --git a/application-manager.pro b/application-manager.pro
index c63a48be..d38380ae 100644
--- a/application-manager.pro
+++ b/application-manager.pro
@@ -83,7 +83,7 @@ printConfigLine("Qt version", $$[QT_VERSION], white)
printConfigLine("Qt installation", $$[QT_HOST_BINS])
printConfigLine("Debug or release", $$check_debug, white)
printConfigLine("Installation prefix", $$INSTALL_PREFIX, auto)
-printConfigLine("Tools only build", $$yesNo(CONFIG(tools-only)), no)
+printConfigLine("Tools only build", $$yesNo(CONFIG(tools-only)), auto)
printConfigLine("Enable support for QtWidgets", $$yesNo(CONFIG(enable-widgets)), auto)
printConfigLine("Headless", $$yesNo(CONFIG(headless)), auto)
printConfigLine("Touch emulation", $$yesNo(CONFIG(config_touchemulation)), auto)
diff --git a/doc/installation.qdoc b/doc/installation.qdoc
index 532829b2..5f2ec407 100644
--- a/doc/installation.qdoc
+++ b/doc/installation.qdoc
@@ -128,6 +128,9 @@ There are various options that can be given to \c qmake to tailor the build to y
\li Completely disable the external D-Bus interfaces. The internal communication channel between the
applications and the application-manager will still be based on a peer-to-peer D-Bus though.
\row
+ \li \c{-config tools-only}
+ \li Build tools only: \l{Controller}{appman-controller} and \l{Packager}{appman-packager}.
+\row
\li \c{-config install-prefix=<path>}
\li Uses \c path as the base directory for \c{make install}.
If you are not specifying an \c install-prefix when running qmake, then the application-manager
diff --git a/src/common-lib/crashhandler.cpp b/src/common-lib/crashhandler.cpp
index d702814c..0939ce7b 100644
--- a/src/common-lib/crashhandler.cpp
+++ b/src/common-lib/crashhandler.cpp
@@ -60,15 +60,20 @@ QT_END_NAMESPACE_AM
#else
-#include <QQmlEngine>
-#include <QtQml/private/qv4engine_p.h>
-#include <QtQml/private/qv8engine_p.h>
+#if defined(QT_QML_LIB)
+# include <QQmlEngine>
+# include <QtQml/private/qv4engine_p.h>
+# include <QtQml/private/qv8engine_p.h>
+#endif
#include <cxxabi.h>
#include <execinfo.h>
#include <setjmp.h>
#include <signal.h>
#include <inttypes.h>
+#include <sys/syscall.h>
+#include <pthread.h>
+#include <stdio.h>
#if defined(AM_USE_LIBBACKTRACE)
# include <libbacktrace/backtrace.h>
@@ -93,8 +98,6 @@ static int waitForGdbAttach;
static char *demangleBuffer;
static size_t demangleBufferSize;
-static QQmlEngine *qmlEngine;
-
// this will make it run before all other static constructor functions
static void initBacktrace() __attribute__((constructor(101)));
@@ -108,11 +111,14 @@ void CrashHandler::setCrashActionConfiguration(const QVariantMap &config)
dumpCore = config.value(qSL("dumpCore"), dumpCore).toBool();
}
+#if defined(QT_QML_LIB)
+static QQmlEngine *qmlEngine;
void CrashHandler::setQmlEngine(QQmlEngine *engine)
{
qmlEngine = engine;
}
+#endif
static void initBacktrace()
{
@@ -204,16 +210,30 @@ static void printMsgToDlt(const char *format, ...)
static void printCrashInfo(PrintDestination dest, const char *why, int stackFramesToIgnore)
{
- char who[256];
- int whoLen = readlink("/proc/self/exe", who, sizeof(who) -1);
- who[qMax(0, whoLen)] = '\0';
- const char *title = ProcessTitle::title();
-
using printMsgType = void (*)(const char *format, ...);
static printMsgType printMsg;
printMsg = (dest == Dlt) ? printMsgToDlt : printMsgToConsole;
- printMsg("\n*** process %s (%d) crashed ***\n\n > why: %s", title ? title : who, getpid(), why);
+ const char *title = ProcessTitle::title();
+ char who[256];
+ if (!title) {
+ int whoLen = readlink("/proc/self/exe", who, sizeof(who) -1);
+ who[qMax(0, whoLen)] = '\0';
+ title = who;
+ }
+
+ pid_t pid = getpid();
+ long tid = syscall(SYS_gettid);
+ pthread_t pthreadId = pthread_self();
+ char threadName[16];
+ if (tid == pid)
+ strcpy(threadName, "main");
+ else if (pthread_getname_np(pthreadId, threadName, sizeof(threadName)))
+ strcpy(threadName, "unknown");
+
+ printMsg("\n*** process %s (%d) crashed ***", title, pid);
+ printMsg("\n > why: %s", why);
+ printMsg("\n > where: %s thread, TID: %d, pthread ID: %p", threadName, tid, pthreadId);
if (printBacktrace) {
#if defined(AM_USE_LIBBACKTRACE) && defined(BACKTRACE_SUPPORTED)
@@ -340,6 +360,7 @@ static void printCrashInfo(PrintDestination dest, const char *why, int stackFram
#endif // defined(AM_USE_LIBBACKTRACE) && defined(BACKTRACE_SUPPORTED)
}
+#if defined(QT_QML_LIB)
if (printQmlStack && qmlEngine) {
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
QV8Engine *v8engine = qmlEngine->handle();
@@ -364,6 +385,7 @@ static void printCrashInfo(PrintDestination dest, const char *why, int stackFram
}
}
}
+#endif
}
static void crashHandler(const char *why, int stackFramesToIgnore)
diff --git a/tests/qml/crash/apps/tld.test.crash/terminator2/qmlterminator2.cpp b/tests/qml/crash/apps/tld.test.crash/terminator2/qmlterminator2.cpp
index 69ab4c99..45842216 100644
--- a/tests/qml/crash/apps/tld.test.crash/terminator2/qmlterminator2.cpp
+++ b/tests/qml/crash/apps/tld.test.crash/terminator2/qmlterminator2.cpp
@@ -101,5 +101,5 @@ TerminatorThread::TerminatorThread(Terminator *parent)
void TerminatorThread::run()
{
- m_terminator->accessIllegalMemory();;
+ m_terminator->accessIllegalMemory();
}