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:

rocessButtons (this=<optimized out>) at C:\Users\jimfr\OneDrive\JF_Documents\Jim\home
293 if (SWreg[x].SWcurState == BIstate::T) SWreg[x].SWevalState = BtnState:

ressed; // Unk, T --> pressed
Natvis: [Error] Natvis failed to parse typename: unsigned long