How to debug in a cross-compilation environment with Qt Creator using GCC?
-
I am struggling to create debug symbols for my application. I have set up a cross-compilation environment for the Raspberry Pi.
I don't see a problem here. I was assuming that I would have to add the
-g
flag in the project settings, but when I add it toI get a warning about the
-g
being an invalid option.I have also tried adding
CONFIG += debug
to my .pro file, but I guess that is just for QML.
My problem is that when I click on Kit -> Build -> Debug and try to do an analysis with Valgrind, it tells me that it can't find debug symbols. Debugging with GDB also doesn't work of course. I realized this earlier but thought that there was an issue with my cross-compilation setup, because the shipped GDB from Linaro wasn't recognized by Qt. I chose the
gnueabihf-gdb
from my system then. Actually there shouldn't be a problem with it, because it is newer than the one fro Linaro and it should be backwards compatible I assume.What am I missing?
-
Can you post your HealthPi.pro file?
What exactly does Valgrind say?
Maybe you are linking to a non debug library, hence no symbols being found there. -
Sorry for the late reply. This is a personal project and I am currently very busy at work.
@AxelVienna Here is my file
QT += quick multimedia multimediawidgets CONFIG += c++17 CONFIG += debug # You can make your code fail to compile if it uses deprecated APIs. # In order to do so, uncomment the following line. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ DS1820.cpp \ Sensor.cpp \ gsrsensor.cpp \ main.cpp \ pulsesensor.cpp \ wiringPi.c RESOURCES += qml.qrc TRANSLATIONS += \ HealthPi_de_DE.ts CONFIG += lrelease CONFIG += lvlc CONFIG += embed_translations # Additional import path used to resolve QML modules in Qt Creator's code model QML_IMPORT_PATH = # Additional import path used to resolve QML modules just for Qt Quick Designer QML_DESIGNER_IMPORT_PATH = # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target DISTFILES += \ fonts/AreaKilometer50.otf \ fonts/AreaKilometer50.ttf \ fonts/IBMPlexMono-Bold.ttf \ fonts/IBMPlexMono-Regular.ttf \ images/dot.png \ images/heart.png \ HEADERS += \ DS1820.h \ EmojiControl.h \ Heartbeat.h \ Sensor.h \ ThermometerControl.h \ TimelineControl.h \ Updater.h \ gsrsensor.h \ main.h \ pulsesensor.h \ wiringPi.h INSTALLS = target target.files = HealthPi target.path = /home/pi/CC_folder arm-linux-gnueabihf-g++{ DEFINES+= RASPI }
When I try to launch debug mode, I get
and Valgrind says
Serious error reading debug info!
. I was assuming that it needs the debugs symbols to tell me at which line the error occur, which it currently doesn't.Full ouput is here:
@JoeCFD The
-g
flag is indeed missingHere is a snippet of the Makefile
####### Compile DS1820.o: ../HealthPi/DS1820.cpp ../HealthPi/DS1820.h \ ../HealthPi/Sensor.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o DS1820.o ../HealthPi/DS1820.cpp Sensor.o: ../HealthPi/Sensor.cpp ../HealthPi/Sensor.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o Sensor.o ../HealthPi/Sensor.cpp gsrsensor.o: ../HealthPi/gsrsensor.cpp ../HealthPi/gsrsensor.h \ ../HealthPi/Sensor.h \ ../HealthPi/wiringPi.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o gsrsensor.o ../HealthPi/gsrsensor.cpp
Whole thing https://pastebin.com/D1rD0LJD
Ah no, the flag is there when you look at
CXXFLAGS
. Weird... -
So I came a little closer. Seems like I had QML-Debugging enabled in Projects -> Build -> QML debugging and profiling, which I was actually not interested in. I disabled it and then installed
gdbserver
on the device. I can now launch debug mode, but Valgrind still saysError reading debug symbols
, plug I get a bunch of other error messages.Could not load shared library symbols for 10 libraries, e.g. /usr/local/qt5.15/lib/libQt5Quick.so.5. Use the "info sharedlibrary" command to see the complete listing. Do you need "set solib-search-path" or "set sysroot"?QML debugging is enabled. Only use this in a safe environment. Could not load shared library symbols for 3 libraries, e.g. /usr/local/qt5.15/plugins/platforms/libqxcb.so. Use the "info sharedlibrary" command to see the complete listing. Do you need "set solib-search-path" or "set sysroot"?QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-pi' Could not load shared library symbols for /usr/local/qt5.15/plugins/platforminputcontexts/libcomposeplatforminputcontextplugin.so. Do you need "set solib-search-path" or "set sysroot"?Could not load shared library symbols for 2 libraries, e.g. /usr/local/qt5.15/qml/QtQuick.2/libqtquick2plugin.so. Use the "info sharedlibrary" command to see the complete listing. Do you need "set solib-search-path" or "set sysroot"?Could not load shared library symbols for /usr/local/qt5.15/qml/QtQuick/Window.2/libwindowplugin.so. Do you need "set solib-search-path" or "set sysroot"?Could not load shared library symbols for /usr/local/qt5.15/qml/QtQuick/Timeline/libqtquicktimelineplugin.so. Do you need "set solib-search-path" or "set sysroot"?Could not load shared library symbols for 3 libraries, e.g. /usr/local/qt5.15/qml/QtQuick/Controls.2/libqtquickcontrols2plugin.so. Use the "info sharedlibrary" command to see the complete listing. Do you need "set solib-search-path" or "set sysroot"?Could not load shared library symbols for /usr/local/qt5.15/qml/QtQuick/Templates.2/libqtquicktemplates2plugin.so. Do you need "set solib-search-path" or "set sysroot"?Could not load shared library symbols for /usr/local/qt5.15/plugins/xcbglintegrations/libqxcb-egl-integration.so. Do you need "set solib-search-path" or "set sysroot"?Could not load shared library symbols for /usr/local/qt5.15/plugins/imageformats/libqgif.so. Do you need "set solib-search-path" or "set sysroot"?Could not load shared library symbols for /usr/local/qt5.15/plugins/imageformats/libqicns.so. Do you need "set solib-search-path" or "set sysroot"?Could not load shared library symbols for /usr/local/qt5.15/plugins/imageformats/libqico.so. Do you need "set solib-search-path" or "set sysroot"?Could not load shared library symbols for /usr/local/qt5.15/plugins/imageformats/libqjpeg.so. Do you need "set solib-search-path" or "set sysroot"?Could not load shared library symbols for 2 libraries, e.g. /usr/local/qt5.15/plugins/imageformats/libqsvg.so. Use the "info sharedlibrary" command to see the complete listing. Do you need "set solib-search-path" or "set sysroot"?Could not load shared library symbols for /usr/local/qt5.15/plugins/imageformats/libqtga.so. Do you need "set solib-search-path" or "set sysroot"?Could not load shared library symbols for /usr/local/qt5.15/plugins/imageformats/libqtiff.so. Do you need "set solib-search-path" or "set sysroot"?Could not load shared library symbols for /usr/local/qt5.15/plugins/imageformats/libqwbmp.so. Do you need "set solib-search-path" or "set sysroot"?Could not load shared library symbols for /usr/local/qt5.15/plugins/imageformats/libqwebp.so.
I guess that there is some environment variable missing on the device. I have
SHELL=/bin/bash LANGUAGE=de_DE.UTF-8 NO_AT_BRIDGE=1 PWD=/home/pi LOGNAME=pi XDG_SESSION_TYPE=tty MOTD_SHOWN=pam HOME=/home/pi LANG=de_DE.UTF-8 LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36: SSH_CONNECTION=xxxx:xxxx:xxxx:xxxx::xxxx:xxxx:xxxx:xxxx 22 XDG_SESSION_CLASS=user TERM=xterm-256color USER=pi SHLVL=1 XDG_SESSION_ID=5 XDG_RUNTIME_DIR=/run/user/1000 SSH_CLIENT=xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx 37756 22 LC_ALL=de_DE.UTF-8 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus SSH_TTY=/dev/pts/0 TEXTDOMAIN=Linux-PAM _=/usr/bin/printenv DISPLAY=:0 XDG_SESSION_TYPE=x11
I need to find a way to let Valgrind tell me the location of the errors. Else I will be searching forever...