Site logo
Stories around the Genode Operating System RSS feed
Christian Helmuth avatar

On-target debugging with GDB on Sculpt OS 24.04


With the recent Sculpt release, we introduced initial on-target debugging support to get the best from the ported GNU debugger (GDB) and our custom debug monitor that fuels the Sculpt runtime. This little hands-on introduction is completed by a live demo.

Live debugging of Sculpt runtime components is a built-in feature since version 24.04. Just give it a trial with a downloaded image (or Sculpt installation if you already have one) and an internet connection with the following steps.

Preparation

  1. If you're not running a window-manager desktop, enable Networking, select Use in the ram_fs node, and startup the window manager preset from the System menu in the Leitzentrale.

  2. Select download debug info in + Options to enable automatic download of missing debug-information files from the online depot.

  3. Run a graphical terminal in Tools: terminal from the genodelabs index.

  4. Run GDB from Tools: gdb x86.

Now, you should be presented with a terminal windows containing initial output from GDB and a prompt. You may try first commands like follows.

info inferiors
info threads

Debugging nano3d

  1. Run Demos: nano3d with options Debug and Allow code patching enabled.

  2. Restart gdb x86 node in Leitzentrale to pick up new debug inferior.

  3. Load debug information into GDB via the following commands.

cd /debug/nano3d
file nano3d

We are ready to inspect the debug target now, but first have to stop its execution by interrupt -a (which stops all threads of the inferior). The component threads may be resumed later by continue -a &. Please mind the & is significant to execute the inferior in background and keep the GDB prompt intact as we currently do not support arbitrary break-in interruption via CTRL-C. You may try the following commands in interrupted state.

info sharedlibrary
info inferiors
info threads
thread 2
backtrace
up
info locals
set print pretty on

Using a breakpoint

Static inspection is nice but hunting bugs often requires to break into the debugger at certain code points. Our GDB port supports ordinary breakpoints you may try out and step through the nano3d rendering frame-by-frame using the following command sequence. Note, the last GDB command can be repeated by just hitting the Return key.

thread 2
break render
backtrace
info locals
info registers
continue &
continue &
continue &
...

Live Demo

For illustration I recorded the following screencast and commentary with a live debugging session of the nano3d demo tool.

I hope you enjoyed this little howto. See you around!