No problem and thanks for checking this.
Looks like the default implementation of CanInvokeSemihostingCalls() will indeed not work in this scenario, however you should be able to work around it using some advanced scripting:
- Define a global variable (e.g. int g_DebuggerAttached).
- Create an implementation of CanInvokeSemihostingCalls() that will check the global variable and set the “When running without debugger” setting to “Use a custom function to decide”.
- Create a noinline function with a “nop” statement and call it from main()
- Create a GDB script file that will add a breakpoint in the empty function and run the “set g_DebuggerAttached 1” command when the breakpoint is hit (see this page for details).
- Add “source <gdb script file>” to VisualGDB Project Properties -> GDB Commands -> Commands after selecting target.
This won’t be as flexible as using the ARM Cortex registers (e.g. it won’t detect when a debugger is detached after starting the program), however it should allow distinguishing between starting a new debug session and just resetting the device without a debugger.