2025-03-20 4:45 AM - edited 2025-03-20 11:29 AM
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.
2025-03-20 4:52 AM
@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?
2025-03-20 5:30 AM
Or external Python resources it can call or access.
2025-03-20 10:56 AM
That was for the GDB shipped with CubeIDE 1.17.0 (incorrectly reported as 1.18.0 in my original post).
I do not have any others to try.
2025-03-20 2:53 PM - edited 2025-03-20 3:54 PM
...\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).
2025-10-26 3:53 AM
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".
2025-10-26 5:38 AM
@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.
2025-10-26 7:54 AM
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.