Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. How to debug in a cross-compilation environment with Qt Creator using GCC?
QtWS25 Last Chance

How to debug in a cross-compilation environment with Qt Creator using GCC?

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
5 Posts 3 Posters 1.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    coldspark29
    wrote on 19 Sept 2021, 09:33 last edited by coldspark29
    #1

    I am struggling to create debug symbols for my application. I have set up a cross-compilation environment for the Raspberry Pi.

    163c8a27-ea51-41ad-b0b5-87df469af864-grafik.png

    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 to

    5aaf4c34-d450-43a2-b1c2-ddf6a025f91b-grafik.png

    I 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.

    c0e0903b-3cd0-47c1-9097-fd80e780e33d-grafik.png

    What am I missing?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      AxelVienna
      wrote on 20 Sept 2021, 11:40 last edited by
      #2

      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.

      C++ and Python walk into a bar. C++ reuses the first glass.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        JoeCFD
        wrote on 20 Sept 2021, 19:56 last edited by
        #3

        Check the Makefile in Qt/build-HealthPi**Debug which should have something like the following.

        CFLAGS = -pipe -g -Wall -Wextra -D_REENTRANT -fPIC $(DEFINES)
        CXXFLAGS = -pipe -g -Wall -Wextra -D_REENTRANT -fPIC $(DEFINES)

        1 Reply Last reply
        0
        • C Offline
          C Offline
          coldspark29
          wrote on 26 Sept 2021, 06:38 last edited by coldspark29
          #4

          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

          425cd9f5-74c5-4747-aedd-597a0ac154d5-grafik.png

          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:

          https://pastebin.com/ksHV5L0D


          @JoeCFD The -g flag is indeed missing

          Here 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...

          1 Reply Last reply
          0
          • C Offline
            C Offline
            coldspark29
            wrote on 26 Sept 2021, 11:05 last edited by coldspark29
            #5

            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 says Error 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...

            1 Reply Last reply
            0

            4/5

            26 Sept 2021, 06:38

            • Login

            • Login or register to search.
            4 out of 5
            • First post
              4/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved