Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

GDB Pretty Printers

stdgba ships Python pretty-printers under gdb/ so common library types are shown in a readable form while debugging.

Instead of raw storage fields, GDB can show decoded values such as fixed-point numbers, angles in degrees, key masks, timer configuration, and music tokens.

Quick start

Load the aggregate script once per GDB session:

source D:/CLionProjects/stdgba/gdb/stdgba.py

To load them automatically, add the same source ... line to your .gdbinit.

When loaded successfully, GDB prints status lines including:

  • Loading stdgba pretty printers...
  • stdgba pretty printers loaded successfully

Available printers

The aggregate loader gdb/stdgba.py imports and registers these printer modules:

ModuleExample types
gdb/fixed_point.pygba::fixed<Rep, FracBits>
gdb/angle.pygba::angle, gba::packed_angle<Bits>
gdb/format.pygba::format::compiled_format, arg_binder, bound_arg, format_generator
gdb/music.pygba::music::note, bpm_value, token_type, ast_type, token, pattern types
gdb/log.pygba::log::level
gdb/video.pygba::color, gba::object
gdb/keyinput.pygba::keypad
gdb/key.pygba::key
gdb/registral.pygba::registral<T>
gdb/memory.pygba::plex<...>, gba::unique<T>, gba::bitpool
gdb/benchmark.pygba::benchmark::cycle_counter
gdb/interrupt.pygba::irq, gba::irq_handler
gdb/timer.pygba::timer::compiled_timer

You can also source any individual module directly if you only want one printer.

Practical workflow

tests/debug/test_pretty_printers.cpp constructs representative values for all supported printer categories and includes a dedicated breakpoint marker comment.

Build the manual test target:

cmake --build build --target test_pretty_printers - -j 8

Start GDB with the produced ELF:

arm-none-eabi-gdb build/tests/test_pretty_printers.elf

Inside GDB:

source D:/CLionProjects/stdgba/gdb/stdgba.py
break main
run
# Step/next until the BREAKPOINT HERE marker in test_pretty_printers.cpp
print fix8_val
print angle_90
print key_combo
print test_pool

Expected output is human-readable (for example fixed-point decimal form and decoded key masks), rather than only raw integer fields.

Notes

  • test_pretty_printers is listed in tests/CMakeLists.txt under MANUAL_TESTS, so it is intentionally excluded from CTest automation.
  • Pretty-printers are a debugger convenience only; they do not affect generated ROM code or runtime behaviour.
  • If GDB warns about auto-load restrictions, allow the script path in your local GDB security settings before sourcing the file.