Welcome, Guest. Please Login or Register
Arduino IDE for Visual Studio
 
 
When Logging a Support Issue in the Forum, please ensure you have also:-
  • Enabled vMicro > Compiler > Show Build Properties and Verbose
  • 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
 
  HomeSearch Tutorials & Wiki visualmicro.com LoginHelpRegister  
 
Page Index Toggle Pages: 1
Send Topic Print
GDB ESP8266 Variable Problem (Read 74 times)
Sylvain
Junior Member
**
Offline



Posts: 33
Montreal, Canada
GDB ESP8266 Variable Problem
Feb 22nd, 2021 at 10:16pm
 
Hi,

     I face a strange problem,  I had install GDB Stub in a ESP8266, it was really simple, I can step through my code, but all my variable initialization value fail,  When my code hit the breakpoint it's stop and the locals window show the locals variable but with the wrong value, the initialization don't work example if I wrote "i=0" the variable will not show with the value "0" but something like "854433" and if in my code I make "i++" the value report will be "854434"...  The increment work but on the wrong value...

VS2017 with the last version of VM plugin
ESP Core 2.7.4

Any help will be welcome
Sylvain Bissonnette

Here is my small test program

#include <GDBStub.h>

//--------------------------------------------------------------

void setup()
{
     int i,j;

     Serial.begin(115200);
     gdbstub_init();

     i = 0;
     j = 0;

     while (true)
     {
           i++;
           j++;
     }
}

//--------------------------------------------------------------

void loop()
{
}
Back to top
 
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline



Posts: 698
Re: GDB ESP8266 Variable Problem
Reply #1 - Feb 23rd, 2021 at 11:57am
 
Thanks for the report.

Can you confirm if you put a break above the infinite loop, and step over line by line, this works as expected?

If I put a break on i=0, and step then the uninitialized values change to 0 and increment as expected.
Back to top
 
 
IP Logged
 
Sylvain
Junior Member
**
Offline



Posts: 33
Montreal, Canada
Re: GDB ESP8266 Variable Problem
Reply #2 - Feb 23rd, 2021 at 4:01pm
 
Thanks for your reply,

    I just find that if I put the breakpoint on the first line "i=0" and step by step all the code everything work fine,  but if I put the first break point on the first line in the while() " i++;"  it's don't work. Did you have any clue?

Sylvain Bissonnette
Back to top
 
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline



Posts: 698
Re: GDB ESP8266 Variable Problem
Reply #3 - Feb 23rd, 2021 at 4:04pm
 
Are you using Debug > Start, or Debug > Attach to Process?
Back to top
 
 
IP Logged
 
Sylvain
Junior Member
**
Offline



Posts: 33
Montreal, Canada
Re: GDB ESP8266 Variable Problem
Reply #4 - Feb 23rd, 2021 at 4:24pm
 
I use the green arrow Start
Back to top
 
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline



Posts: 698
Re: GDB ESP8266 Variable Problem
Reply #5 - Feb 23rd, 2021 at 4:38pm
 
Thanks for confirming.

I can only think at present that the code is running while the debugger is connecting.

With the full speed infinite loop running even for a fraction of a second would iterate very rapidly and give a very large (and seemingly random value).

We will see if there is anything else that can be done to avoid this, however setting the break above the loop helps avoid it in the mean time.
Back to top
 
 
IP Logged
 
Sylvain
Junior Member
**
Offline



Posts: 33
Montreal, Canada
Re: GDB ESP8266 Variable Problem
Reply #6 - Feb 23rd, 2021 at 4:57pm
 
You are right on,  I just add "delay(3000)" after the "i=0" with a breakpoint at "i++" and it's work just fine. 

Thanks for your time
Sylvain Bissonnette
Back to top
 
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline



Posts: 698
Re: GDB ESP8266 Variable Problem
Reply #7 - Feb 23rd, 2021 at 5:07pm
 
Thanks for confirming, we have added a tip to the documentation page for the ESP8266 GDB Stub to cover this.
Back to top
 
 
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print