Debugging: Trigger runtime gdbstub from during execution
Posted: Mon Apr 28, 2025 7:30 am
I had an idea to trigger a runtime gdbstub `CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME` during application execution. The idea came about when I implemented a quick panic stub assertion:
This works, but this will cause a hardfault and I cannot continue my application from here, I essentially have to restart.
It would go something like this:
I think this idea will help everyone have a faster and smoother dev debug cycle.
Code: Select all
#if CONFIG_ESP_SYSTEM_PANIC_STUB
#define ASSERT_GDB(expr) \
do { \
if (!(expr)) { \
__builtin_trap(); \
} \
} while (0)
It would go something like this:
Code: Select all
#if CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME
#define ASSERT_GDB(expr) \
do { \
if (!(expr)) { \
esp_gdbstub_handle_command("S", 2); \
} \
} while (0)
#elif CONFIG_ESP_SYSTEM_PANIC_STUB
#define ASSERT_GDB(expr) \
do { \
if (!(expr)) { \
__builtin_trap(); \
} \
} while (0)
#else
#define ASSERT_GDB(expr)
#endif