Skip to content

Debugging userspace apps

Leandro Zungri edited this page Apr 4, 2020 · 1 revision

laritOS comes with the tools/gdb/debug.py utility designed to help with the process of debugging an application running under laritOS (under QEMU).

There are two simple steps you need to follow in order to debug your app:

  1. Launch laritOS in debug mode
  2. Start the debugger

Launching OS in debug mode

Run the launch.py script with the -d option as in:

$LARITOS/tools/qemu/launch.py -d

You should immediately see the following message:

Launching laritOS in debugging mode (listening on :1234)

Then, the launcher will wait until the debugger is connected.

Launching the debugger

Open a new terminal and run:

$LARITOS/tools/gdb/debug.py

Let's say you want to debug the shell app (with pid=3). Once the debugger is running, do the following (in order):

In the debugger terminal In the OS terminal
Type continue then enter
. Type bd debugpid 3 and take note of the instructions
Interrupt debugger with ctrl-c
Type add-symbol-file <path_to_elf> <address>, e.g. add-symbol-file ~/dev/src/laritos-apps/shell/bin/arm/shell.elf 0x40027EF4
Setup breakpoints, watchpoints, etc, then type continue

Where:

  1. <path_to_elf>: Is the path to the ELF binary of the application you want to debug
  2. <address>: Is the memory address printed by the bd debugpid <pid> command