We have indeed not checked this functionality with STM32L071, so it is possible that this MCU simply does not implement the “debugger attached” bit. Please try checking the DEBUGEN bit in the DHCR register either via the Hardware Registers window, or manually. Please also check the STM32 documentation for details on this. If this particular MCU does not implement a ‘debugger attached’ bit, the automatic enabling/disabling of semihosting based on it will indeed not work.
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.