2026-01-19 3:34 AM
Is it possible to get pretty-print support for data-structures and custom types? It seems that not even STL types (e.g. std::vector) can be inspected easily by default:
std::_Vector_base<int, std::allocator<int> > = {...}
std::_Vector_base<int, std::allocator<int> > = Variable object not found> python print(True)
Python scripting is not supported in this copy of GDB.So: Is there any current support for something like this? Or is it at least planned?
2026-02-11 6:12 AM
hi @LukasLang
there is no task planned for the moment to enable python scripting in GDB build, I'll share with dev and marketing but don't think it will be available soon if accepted
2026-04-13 4:43 AM
Any updates?
2026-05-01 9:01 AM
strongly supporting this request
2026-05-01 4:11 PM - edited 2026-05-01 4:14 PM
I did a bit of investigation and came up with a solution.
It seems that upstream python support in arm-none-eabi-gdb is pretty recent. I am not sure exactly when it was added, but it's not there in the macos build of 14.2-rel1, but it's there in the macos build of 15.2-rel1. I downloaded that release's .tar.xz package for macos arm64 from the ARM release pages. ThereIt includes a dedicated binary with python support arm-none-eabi-gdb-py (which by thw way crashes if you don't have the correct python version installed in your system, so make sure you install it if it crashes; it seems to use 3.9 which is pretty old as I understand).
The most recent toolchain I can install from within STM32CubeIDE is 14.3.rel1, which has gdb 15.2:
GNU gdb (GNU Tools for STM32 14.3.rel1.20251027-0700) 15.2.90.20241229-git
With that installed and enabled in the IDE, I can start debugging from within the IDE with Debug -> [Projectname] Debug, which is an STM32 C/C++ Application run/debug launcher. While that session is up, I can start the downloaded arm-none-eabi-gdb-py in a terminal. In there I connected to the STLINK gdbserver started by the IDE (default port 61234):
(gdb) target remote localhost:61234and now I can control the running program, e.g.:
(gdb) break main
(gdb) monitor reset
(gdb) continuewill break in `main()`. Python is enabled:
(gdb) python print("Hello") Hello
Good, now on to making it work inside the IDE. I don't think there's a way of overriding which gdb the STM32 C/C++ Application run/debug launcher uses, so I simply found out which one it uses (for me it lives in /Applications/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.14.3.rel1.macos64_1.0.100.202602081740/tools/bin/arm-none-eabi-gdb ) and replaced it with a symlink to the arm-none-eabi-gdb-py I have downloaded.
Now if I run a debugging session within the IDE, I get the upstream gdb-py which has working python support. Nice.
Next, pretty printers: in this gdb if I run info pretty-printer I get an empty result.
I load the pretty printers that ship with the upstream arm-none-eabi toolchain (which live in /path/to/arm-gnu-toolchain-15.2.rel1-darwin-arm64-arm-none-eabi//share/gcc-15.2.1/python) by running the following interactively in gdb (it may fail and require further work if placed in gdbinit due to auto load safe paths):
(gdb) python
>import sys
>sys.path.insert(0, '/path/to/arm-gnu-toolchain-15.2.rel1-darwin-arm64-arm-none-eabi//share/gcc-15.2.1/python')
>from libstdcxx.v6.printers import register_libstdcxx_printers >register_libstdcxx_printers (None)
>end
(gdb) info pretty-printers
global pretty-printers:
builtin
libstdc++-v6Finally, enable them:
(gdb) set print pretty onNow you can pretty print within the IDE:
(gdb) p order
$1 = std::vector of length 15, capacity 15 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}Done!
The next step is to load the pretty printers automatically via gdbinit or some other configuration file, in a way that's compliant with gdb's auto load safe paths.
For users: the above should work for you.
For ST: now that the upstraem arm-none-eabi-gdb has python support, it should be much easier for you to include it in the toolchain-provided gdb.