Can i issue GDB commands post flash while starting a debugging session automatically?
Hi
I am trying to overcome the limitation that M0 cores cant detect if they are running in a debugging session or not.
For an M3/M4, I would have written something like:
bool InDebugMode(void) {
bool ret_val = false;
if ( ((CoreDebug->DHCSR) & 1u) == 1u) {
ret_val = true;
}
return ret_val;
}One way that seems to work is to this instead
First set up a global variable that may not op optimized and then check on that variable
static volatile uint32_t i_n_Debug_Mode = 0u;
bool InDebugMode(void) {
bool ret_val = false;
if (i_n_Debug_Mode == 0xDEADBEAFu) {
ret_val = true;
}
return ret_val;
}Then, after the program has been flashed, I switch to the "Debugger console" tab and enter
set variable i_n_Debug_Mode = 0xDEADBEAFAnd after that I hit run.
Now I get the desired result.
However it would be nice if I could automate this.
I have tried to enter this command in various places in the Run => Debug configurations of my ST-link GDB server configurations, but so far I have come up empty handed.
Does anyone have a solution to this or know of a better approach?
Best regards
Martin
