How to debug a Qt-sample application with Digi ESP, and how to analyze core dump on device

Digi Embedded Linux 5.x provided Qt-sample application like tetrix_qt. The application uses qmake to build a .pro project file, as well as qmake to create a generated.mk which is used to build the final "tetrix" application. Using the ESP remote debugging will not work, since the application is always compiled without debug symbols or symbols are stripped off when rootfs is created.

In order to get debug symbols permanently compiled into the tetrix_qt sample application, modify its Makefile to add CONFIG+=debug to all qmake calls:
35:$(BINARY).pro:
36:          qmake –project CONFIG+=debug –o $@
.. and
38:generated.mk: $(BINARY).pro

39:          qmake –makefile CONFIG+=debug –o generated.mk $<
.. and


After rebuilding and copying the binary to your device, now you should be able to remotely debug the tetrix application using a device configuration and a debug configuration passing "-qws" as argument.
Note that for your own applications, the binary file including symbols might be quite big and might not fit to the /tmp or FTP timeout might occur during transfer to the device. In this case try to transfer the binary from the build/apps/tetrix_qt/ directory manually to your device.

Note when you build the root file system with the ESP, debug symbols are stripped off again, so using an application with debug symbols in field, needs to manually add it later to the root file system, or to disable stripping of symbols for all applications via CONFIG_DEL_ROOTFS_STRIP=n in the projects .config file (can create a reasonable bigger rootfs!).

In case you want to debug an application on the target device (e.g. because of rare occuring crash in the field) you need to run it with:
# ulimit -c unlimited
# tetrix
Segmentation fault
# gdb tetrix core
...
(gdb) backtrace
crash in main.cc: line 46
(gbd) list
..main.cc:46     *((int *)0) = 7;
(gdb) bt full
..
For this you need to copy /usr/local/DigiEL-5.9/x-tools/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/debug-root/usr/bin/gdb into /usr/bin on your target. If you want to see the source code while analyzing a core dump on the device, you need to copy the sources into the directory from where gdb is launched (in above example main.cc is needed).

To debug a core dump, you can also retrieve the core from the device and store it on your development PC build directory. As gdb you have to use then:
   /usr/local/DigiEL-5.9/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-gdb ./tetrix core
With this method you also have the full sources already in the local directory.
Last updated: Jan 01, 2024

Filed Under

Embedded

Recently Viewed

No recently viewed articles

Did you find this article helpful?