Skip to main content
CTapp.1
Senior III
Mar 20, 2025 11:45 AM UTC
Question

"Python scripting is not supported in this copy of GDB"

Split from https://community.st.com/t5/stm32-mcus-boards-and-hardware/st-link-contolled-by-python/td-p/677553


Could you please give an update on this?

I just ran "help python" within arm-none-eabi-gdb (IDE version 1.17.0) and got:

(gdb) help python
python, py
Evaluate a Python command.

Python scripting is not supported in this copy of GDB.
This command is only a placeholder.

It would be nice to know if this will be implemented at some point.

My use case is similar to the OP - collection of target execution history within a unit test environment. I current have a Python script that controls the GDB server and runs the client with a command file, but it would be easier to use Python directly.

Edited to correct IDE version.

This topic has been closed for replies.

7 replies

Andrew Neil
Super User
Mar 20, 2025 11:52 AM UTC

@CTapp.1 wrote:

I just ran "help python" within arm-none-eabi-gdb (IDE version 1.18.0) .


Is that specific to just what ST ships with CubeIDE, or is it general for any arm-none-eabi-gdb ?

Or, in fact, for any GDB?

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Tesla DeLorean
Guru
Mar 20, 2025 12:30 PM UTC

Or external Python resources it can call or access. 

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Pavel A.
Mar 20, 2025 9:53 PM UTC
...\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.12.3.rel1.win32_1.0.100.202403111256\tools\bin>"arm-none-eabi-gdb.exe" --configuration
This GDB was configured as follows:
.........................
 --without-python
 --without-python-libdir
..... etc.

 

> It would be nice to know if this will be implemented at some point.

This is non-trivial amount of work. Just because it 'would be nice'? Users that really need python in gdb, can bring their own arm-non-eabi-gdb  (or ask someone else to build it).

Associate II
Oct 26, 2025 10:53 AM UTC

Hello @CTapp.1 , I found this thread while searching how to export variables from CubeIDE's "Expressions" window. Something I've been taking for granted in IDE's for a very long time. Never occurred to me you can't just right-click on a variable and export to a CSV or something. But anyway.

I can resort to the "Debugger Console" to dump the variables I need, but this is cumbersome when you have to do it often, tracking an Heisenbug. Eventually I found out, as you have, that there's no Python support in CubeIDE's GDB setup. So the next question I had was: can I connect to CubeIDE's GDB server using a Python script (or other programming language) to automate dumping variables, parsing and displaying them, etc...

Can you share the Python script you wrote to control the GDB server ? That would be huge help. My Google kung-fu must be too weak, I can't see to find how to do it.

@Pavel A. maybe adding Python support requires work, but maybe also that's something ST should work on instead of adding unwanted features like a mandatory login or opt-out telemetry, don't you think ? Also, not to be rude, but CTapp said it would be "nice to know", he didn't say "nice to have".

Pavel A.
Oct 26, 2025 12:38 PM UTC

@JDoe.2 Point taken, thanks. Python is not needed if you want just execute some canned gdb commands. To execute the commands, put them it a text file (say, script.gdb) and  type: source script.gdb.

Also you can define custom commands (macros) and put them to .gdbinit file.

Associate II
Oct 26, 2025 2:54 PM UTC

Very interesting @Pavel A. I'll need to look into that.

Is this .gdbinit file part of CubeIDE, or can it be part of a project ?

It seems like it could be one way to create a script that's part of a project and that executes custom actions every time I start a debug section. I would definitely want to use that to dump a log from my target to a file for plotting, for example.