GDBStub not Working

WanderingEmbeddor
Posts: 1
Joined: Fri Apr 24, 2026 4:26 pm

GDBStub not Working

Postby WanderingEmbeddor » Fri May 01, 2026 4:58 pm

Hey I am having issues with the gbdstub but only on certain projects… I have posted this around online in desperate hope of some guidance and I am kinda stuck without any input so far... To be clear I have posted this on the platformIO forums.

I have set up an example project (blinky) to try and get the esp gdbstub working. To do this I set the ESP_SYSTEM_GDBSTUB_RUNTIME in the menuconfig for the project, then flashed and ran idf.py with monitor and did the Ctrl C trick documented. It opened up gdb and I was able to debug just fine which was very exciting! everything worked as expected, it was AWESOME!

I then went back to an old project using platformIO over the top of esp, copied over its builds to the expected places (since it needs - unfortunately - to be built with platformIO’s wrapping build system).

I ran:

Code: Select all

cp .\.pio\build\dev\firmware.elf .\build\<PROJECT_NAME>.elf
so that it is as if it were build idf.py build.

When I do this and use the same trick with Ctrl - C and the serial monitor, it halts the processor and allows me to set breakpoints, but these breakpoints are never ever hit. I know for a fact that these lines of code are being run frequently- they are toggling LED over an MCP once per second which is visible. It also seems kinda glitchy using the gdb prompt. For example, when continuing, the prompt hangs at “continuing” in gdb. You cannot enter any further commands until the prompt returns when you hit Ctrl C again.

I thought that perhaps there might be issues with code inlining and optimisation but in my ini file:

Code: Select all

[build_type_flags] 
debug_flags = -D${compile_option_flags.debug} -O0 ; Turn off 
optimisations -g3 ; All debug information 
... 
[env:dev] 
build_type = debug 
build_flags = ${common.build_flags} ${build_type_flags.debug_flags}
so I can’t imagine that there is inlining etc going on since we are working in an extension of debug without any optimisations.

later, reading the pio documentation on pio debug I ran the following:

Code: Select all

  (penv) PS C:<MY_PATH_TO_MY_PROJECT>> pio debug --interface=gdb
C:\Users\<MY_USER>\.platformio\packages\toolchain-xtensa-esp32\bin\xtensa-esp32-elf-gdb.exe: warning: Couldn't determine a path for the index cache directory.
Reading symbols from C:<MY_PATH_TO_MY_PROJECT>\.pio\build\dev\firmware.elf...
(gdb) target remote COM3
Remote debugging using COM3
0x4019480e in esp_pm_impl_waiti ()
    at C:\Users\<MY_USER>\.platformio\packages\framework-espidf\components\hal\esp32\include/hal/cpu_ll.h:183
183         asm volatile ("waiti 0\n");
(gdb) continue
Continuing.
When I do this and set a breakpoint I get the same behaviour, the breakpoint is never hit at all.


Any advice to get this working? I'd really appreciate any and all guidance since I have been stuck for a few days now trying to get this set up working. In some of our projects JTAG isn't always feasible and this would be a dream come true to be able to do some debugging over serial even if I can only set one breakpoint at a time!

PETERESP
Posts: 9
Joined: Mon May 25, 2026 7:45 am

Re: GDBStub not Working

Postby PETERESP » Sat Jul 11, 2026 1:32 pm

Looking forward to our good friends' reply!

Who is online

Users browsing this forum: Applebot and 1 guest