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 GDBstub not working as expected on Nano using VS 2026 with VM. (Read 687 times)
jimf
Junior Member
**
Offline


Posts: 30
Joined: May 30th, 2015
GDBstub not working as expected on Nano using VS 2026 with VM.
Jan 22nd, 2026 at 6:40pm
Print Post  
I'm having a heck of a time getting GDB stub working with VS2026 and VM.  This is the first time I'm using GDBstub.  Below are three examples of how I set up for GDBstub in setup().  My VS project has one .ino file and several .h and .cpp files.  I've attached the build.  target board in Nano 328p. My IDE is set as on the VM tutorials. building a release version, hardware debug with GDBstub. Optimization No project + library optimization.  Any help is much appreciated!  Thanks....jim

Example 1: configured as below, with breakpoints set at lines 82 and 100 (both showing in breakpoints window as "break always".
After starting debugger (attaching to process) the debugger breaks at line 82.  If I press continue (F5) the breakpoint at line 100 is ignored and the program is running.   
When I press pause (break all ctl+alt+break) the debugger breaks within the code for Loop()....clearly not what is expected.


     //#define UseVMserialDebug            // uncomment out if using VM native serial debugger.  Leave in place if using GDBstub
     
14      #ifndef UseVMserialDebug
15      #define DISABLE_HWSERIAL
16      #define SkipMoreBreakpointCalls
17      #include <app_api.h>
18      #include <avr8-stub.h>
19      #include <Arduino.h>
20      #endif // !UseVMserialDebug



67      void setup() {
68      #ifndef UseVMserialDebug
69      // using GDBstub to debug
70      debug_init();      // Initialize GDB suub for debugging
71      #ifdef SkipMoreBreakpointCalls
72            static bool firstBreakpointFncCall = true;
73            if (firstBreakpointFncCall)
74            {
75                  firstBreakpointFncCall = false;
76                  breakpoint();   // debugger on-ramp
77            }
78      #endif
79      #endif
80
81
82      pinMode(s1, INPUT_PULLUP);      // when pressed, pin is pulled low--> active low

Here is the debug output for this:
=cmd-param-changed,param="pagination",value="off"
0x0000224a in setup () at C:\Users\jimfr\OneDrive\JF_Documents\Jim\home stuff\Repos\jimfrankfort\Generic-button-handler\PB_Example1/PB_Example1.ino:76
76                  breakpoint();   // debugger on-ramp
Warning: Exceptions are not supported in this scenario.

Breakpoint 6, setup () at C:\Users\jimfr\OneDrive\JF_Documents\Jim\home stuff\Repos\jimfrankfort\Generic-button-handler\PB_Example1/PB_Example1.ino:82
82            pinMode(s1, INPUT_PULLUP);      // when pressed, pin is pulled low--> active low

Example 2: If I change how Breakpoint() is invoked to that which is below, I get the same behavior, only stopping at the first breakpoint.   
Pressing continue ends up with the program running, stopping in loop() on break-all.


#ifndef UseVMserialDebug
     // using GDBstub to debug
     debug_init();      // Initialize GDB suub for debugging
     breakpoint();   // debugger on-ramp
#endif

here is the debug output for this configuration:
=cmd-param-changed,param="pagination",value="off"
setup () at C:\Users\jimfr\OneDrive\JF_Documents\Jim\home stuff\Repos\jimfrankfort\Generic-button-handler\PB_Example1/PB_Example1.ino:76
76            pinMode(s1, INPUT_PULLUP);      // when pressed, pin is pulled low--> active low
Warning: Exceptions are not supported in this scenario.

Breakpoint 6, setup () at C:\Users\jimfr\OneDrive\JF_Documents\Jim\home stuff\Repos\jimfrankfort\Generic-button-handler\PB_Example1/PB_Example1.ino:76
76            pinMode(s1, INPUT_PULLUP);      // when pressed, pin is pulled low--> active low

Example3: If I move the first breakpoint to the next executable line, it doesn't even break there, just runs the program.  Break-all stops in loop(). Below is the debug output for  this example.
=cmd-param-changed,param="pagination",value="off"
setup () at C:\Users\jimfr\OneDrive\JF_Documents\Jim\home stuff\Repos\jimfrankfort\Generic-button-handler\PB_Example1/PB_Example1.ino:76
76            pinMode(s1, INPUT_PULLUP);      // when pressed, pin is pulled low--> active low
Warning: Exceptions are not supported in this scenario.

Program received signal SIGINT, Interrupt.
0x00000c86 in BI:TonguerocessButtons (this=<optimized out>) at C:\Users\jimfr\OneDrive\JF_Documents\Jim\home 
293                              if (SWreg[x].SWcurState == BIstate::T) SWreg[x].SWevalState = BtnState:Tongueressed;            // Unk, T --> pressed
Natvis: [Error] Natvis failed to parse typename: unsigned long

  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
jimf
Junior Member
**
Offline


Posts: 30
Joined: May 30th, 2015
Re: GDBstub not working as expected on Nano using VS 2026 with VM.
Reply #1 - Jan 23rd, 2026 at 2:45am
Print Post  
One thing I forgot to mention, if I single step from the first breakpoint, it does what is expected, advances one line with debugger auto's as expected. 
Not sure if it is related or not, I needed to add to my .h file the following:
     #if defined(VM_DEBUG) || defined(VM_DEBUG_BANDWIDTH)
     #include <VM_DBG.h>
     #endif
Absent that, I was getting compile errors when compiling for debug (using the vMicro debugger).
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2962
Joined: Feb 13th, 2019
Re: GDBstub not working as expected on Nano using VS 2026 with VM.
Reply #2 - Jan 23rd, 2026 at 10:35am
Print Post  
Thanks for the report and detail, can you attach your complete project as a ZIP file (or email it to us) so we can work through these steps?

There are limitations on the number of breakpoints set however 2 should always work....
« Last Edit: Jan 23rd, 2026 at 10:46am by Simon@Visual Micro »  
Back to top
IP Logged
 
jimf
Junior Member
**
Offline


Posts: 30
Joined: May 30th, 2015
Re: GDBstub not working as expected on Nano using VS 2026 with VM.
Reply #3 - Jan 25th, 2026 at 1:31am
Print Post  
Thanks for the quick response!  I think I figured out that the issue was caused by my use of D2 for input. In setup I configured it as INPUT_PULLUP.  I read through the header file for avr8-stub and found that default interrupt used for traps in breakpoints is INT0 which is D2 on the 328p.  When I left D2 unused, the debugger behaved more as expected.  I found a lot of useful information in the header file and realize that there is a lot more to using avr_debugger than I initially thought.  I'm currently having trouble shifting between the vMicro debugger and avr8-stub debugging which I'll post to a separate thread.  Thanks again....jim
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2962
Joined: Feb 13th, 2019
Re: GDBstub not working as expected on Nano using VS 2026 with VM.
Reply #4 - Jan 27th, 2026 at 10:07am
Print Post  
Thanks for the detail around this, and from a quick read of the GitHub page for this project, there seem to be additional options for which interrupt to use:

https://github.com/jdolinay/avr_debug
Quote:
Added code to use TIMER0 as an alternative to using the watchdog timer (AVR8_USE_TIMER0_INSTEAD_OF_WDT = 1).
Added a new possibility for generating a software interrupt, which does not use any external pin (AVR8_SWINT_SOURCE = -1).


We haven't tested these, but we will look into them and try to improve our documentation to make it smoother to use in vMicro.
  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint