Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic User friendly debug shutdown (Read 87 times)
Steven Bennett
Junior Member
**
Offline


Posts: 75
Location: High Bentham
Joined: Nov 2nd, 2022
User friendly debug shutdown
Oct 26th, 2026 at 2:30pm
Print Post  
Would it be possible to issue a command like "Debug.MIDebugExec monitor reset run" when the RED stop debug button is pressed and before the VM debug session is terminated.  This would put the target MCU back in it's free running state and allow a new debug session to start without having to press the MCU reset button first?
  
Back to top
 
IP Logged
 
Steven Bennett
Junior Member
**
Offline


Posts: 75
Location: High Bentham
Joined: Nov 2nd, 2022
Re: User friendly debug shutdown
Reply #1 - Oct 26th, 2026 at 4:07pm
Print Post  
There is a DETACH ALL item in Visual Studio DEBUG menu which does a friendly debug end process.  According to AI this option and the direct chip command in a Command Window are similar but with subtle variations:

In the DEBUG menu of Visual Studio their is an item called "Detach all" which seems to stop the debug session and release the target MCU to freely run.  Debug START or RE-ATACH then both seem to work, is this doing the same thing as the command:  Debug.MIDebugExec monitor reset run

Comparing how detach and disconnect differ in mechanism.
Not quite the same thing, but it reaches a similar end state by a different route, and it’s arguably the tidier fix.

Detach is a GDB command that works at the debugger level:

GDB removes all the breakpoints it had set in the target.
It resumes the CPU if it was halted.
It then closes the connection to OpenOCD.
The chip is not reset. Your program carries on running from wherever it was, with its variables and state intact.

monitor reset run works at the chip level:

OpenOCD resets the CPU, so your program restarts from the beginning.
The reset also wipes the breakpoint registers as a side effect, but GDB isn’t told, so it’s a blunt way of cleaning up.
Your original problem was a chip left halted or holding stale breakpoints after the red stop button. Detach fixes that cause directly, because it clears the breakpoints and resumes the target before disconnecting. The reset command fixes it indirectly by wiping everything. So if Detach All followed by Start or Re-attach works reliably for you, it’s a perfectly good replacement for the Command Window step, and it avoids restarting your program.

My guess is that the red stop button does a GDB kill or terminates the debugger more abruptly, without the clean-up, which would explain the stuck state. I can’t confirm that from the outside, though.

Two things to be aware of:

If the CPU is halted at a breakpoint when you detach, it resumes from that point, which is usually what you want.
Choose reset instead if you specifically want the program to start over, for example when testing boot behaviour or a clean power-up state.
« Last Edit: Oct 26th, 2026 at 4:09pm by Steven Bennett »  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint