Skip to content
Advertisement

Integrating Crashpad with Qt on Linux

I am trying to integrate Crashpad into Qt application on Linux. I am using Bugsplat database for testing and I followed this tutorial and managed to build this “dummy” application, which should serve as an example of using Qt with Crashpad.

I have made minor adjustments of files to fix build for my Linux platform, primarily making change of version easier and fixed creating directory & crashpad files next to application binaries.

All of the changes are listed below as a diff file:

diff --git a/Crashpad/Tools/Linux/symbols.sh b/Crashpad/Tools/Linux/symbols.sh
index 095f295..b065438 100644
--- a/Crashpad/Tools/Linux/symbols.sh
+++ b/Crashpad/Tools/Linux/symbols.sh
@@ -3,6 +3,6 @@ symupload="${1}/Crashpad/Tools/Linux/symupload"
 app="${2}/${4}.debug"
 sym="${4}.sym"
 url="https://${3}.bugsplat.com/post/bp/symbol/breakpadsymbols.php?appName=${4}&appVer=${5}"
-
+echo ${url}
 eval "${dump_syms} ${app} > ${sym}"
 eval $"${symupload} "${sym}" "${url}""
diff --git a/main.cpp b/main.cpp
index db97dd4..b721dc5 100644
--- a/main.cpp
+++ b/main.cpp
@@ -26,7 +26,7 @@ int main(int argc, char *argv[])
 {
     QString dbName = "Fred";
     QString appName = "myQtCrasher";
-    QString appVersion = "1.0";
+    QString appVersion = QString::number(MAJOR_VERSION) + "." + QString::number(MINOR_VERSION);
 
     initializeCrashpad(dbName, appName, appVersion);
 
diff --git a/myQtCrasher.pro b/myQtCrasher.pro
index 3005e41..3bf7a3e 100644
--- a/myQtCrasher.pro
+++ b/myQtCrasher.pro
@@ -15,6 +15,12 @@ DEFINES += QT_DEPRECATED_WARNINGS
 # You can also select to disable deprecated APIs only up to a certain version of Qt.
 #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
 
+MAJOR_VERSION = 4
+MINOR_VERSION = 9
+
+DEFINES += MAJOR_VERSION=$$MAJOR_VERSION
+DEFINES += MINOR_VERSION=$$MINOR_VERSION
+
 SOURCES += 
     main.cpp 
     mainwindow.cpp 
@@ -94,7 +100,8 @@ linux {
     LIBS += -L$$PWD/Crashpad/Libraries/Linux/ -lbase
 
     # Copy crashpad_handler to build directory and run dump_syms and symupload
-    QMAKE_POST_LINK += "cp $$PWD/Crashpad/Bin/Linux/crashpad_handler $$OUT_PWD/crashpad"
-    QMAKE_POST_LINK += "&& bash $$PWD/Crashpad/Tools/Linux/symbols.sh $$PWD $$OUT_PWD fred myQtCrasher 1.0 > $$PWD/Crashpad/Tools/Linux/symbols.out 2>&1"
-    QMAKE_POST_LINK += "&& cp $$PWD/Crashpad/attachment.txt $$OUT_PWD/attachment.txt"
+    QMAKE_POST_LINK += "mkdir $$OUT_PWD/crashpad"
+    QMAKE_POST_LINK += "&& cp $$PWD/Crashpad/Bin/Linux/crashpad_handler $$OUT_PWD/crashpad"
+    QMAKE_POST_LINK += "&& bash $$PWD/Crashpad/Tools/Linux/symbols.sh $$PWD $$OUT_PWD fred myQtCrasher $$MAJOR_VERSION"."$$MINOR_VERSION > $$PWD/Crashpad/Tools/Linux/symbols.out 2>&1"
+#    QMAKE_POST_LINK += "&& cp $$PWD/Crashpad/attachment.txt $$OUT_PWD/attachment.txt" #if any attachment is needed
 }

Build generates both myQtCrasher.debug, and externaly generated myQtCrasher.sym symbols file.

Using their dummy database (the creditals are fred@bugsplat.com and Flintstone as a password), I have managed to report crash, but I for some reason, the bug do not contain uploaded symbols. I have tried to manualy upload them using dump_syms and then symupload applications by sending request onto https://fred.bugsplat.com/post/bp/symbol/breakpadsymbols.php?appName=myQtCrasher&appVer=4.9, but without success.

The symupload application output is

Failed to open curl lib from binary, use libcurl.so instead
Successfully sent the symbol file.

How can I properly upload *.sym and view stack trace on crash?

Thanks for your help!

Advertisement

Answer

We were able to get the symbols to resolve for this crash report. Right after the symupload warning Failed to open curl lib from binary, use libcurl.so instead it says successfully sent the symbol file. I confirmed the symbol file was uploaded correctly.

I found 2 issues with the symbol file. When minidump_stackwalk was looking for the corresponding symbols it was looking for:

/myQtCrasher-4.9/myQtCrasher/C03D64A46AB29A093459A592482836E50/myQtCrasher.sym

The file that was uploaded to BugSplat was myQtCrasher.debug.sym and the module on the first line of the sym file was myQtCrasher.debug. I changed the file name to myQtCrasher.sym and the module name to myQtCrasher and the symbols for the myQtCrasher stack frames displayed function names and line numbers.

I’m not sure if these issues with mismatched symbols were due to your script changes but it seems like our script attempts to set the following variables:

app="${2}/${4}.debug"
sym="${4}.sym"

Therefore the script expects the user to generate sym files from the .debug file, but name them based on the corresponding executable.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement