Skip to content

Debugging

Karas Lukáš edited this page Feb 5, 2019 · 2 revisions

Debugging

What to do when application is crashing?

When you are ordinary user

First, try to reproduce the crash. Second, create issue on GitHub and try to describe what happen before the crash and when possible, how to reproduce it. It is possible that author of the application will not be able to reproduce it (there may be something specific to your device, used map database...). I will guide you what information may be useful then.

When you are developer

Start with article Howto build for Sailfish OS to be familiar with crosscompilation. Edit rpm/harbour-osmscout.spec:

  • configure "debug" type of CMake build (-DCMAKE_BUILD_TYPE=DEBUG)
  • remove stripping of debug symbols from binary (just comment line with strip command)

Build rpm package with unstripped binary and install it on device.

Local analyse of core-dump

Connect to device via ssh (using nemo user), enable creation of coredumps and run process:

ulimit -c unlimited
harbour-osmscout

Reproduce crash, process should generate core.$PID in home directory. Mount phone filesystem via sshfs and open coredump in gdb-multiarch:

mkdir -p sysroot-dir
# replace "jolla" by address of your device
sshfs nemo@jolla:/ sysroot-dir
gdb-multiarch ./sysroot-dir/usr/bin/harbour-osmscout ./sysroot-dir/home/nemo/core.XXXXX

Then setup sysroot for gdb and inspect stack trace, variables...

set debug-file-directory sysroot-dir/usr/lib/debug/
set sysroot sysroot-dir
info threads
bt full

Remote debugging

Run gdbserver on phone:

gdbserver :12345 /usr/bin/harbour-osmscout

Mount device filesystem via sshfs and open debugger

mkdir -p sysroot-dir
# replace "jolla" by address of your device
sshfs nemo@jolla:/ sysroot-dir
gdb-multiarch ./sysroot-dir/usr/bin/harbour-osmscout

Setup debugger, breakpoints (...) and continue with executing

set debug-file-directory sysroot-dir/usr/lib/debug/
set sysroot sysroot-dir
# setup path to source code
set substitute-path /home/mersdk/share/SailfishOS/projects/ $(HOME)/SailfishOS/projects/
target remote jolla:12345
continue