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 GDB ESP8266 Variable Problem (Read 1351 times)
Sylvain
Junior Member
**
Offline


Posts: 67
Location: Montreal, Canada
Joined: Nov 13th, 2014
GDB ESP8266 Variable Problem
Feb 22nd, 2021 at 10:16pm
Print Post  
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: 2145
Joined: Feb 13th, 2019
Re: GDB ESP8266 Variable Problem
Reply #1 - Feb 23rd, 2021 at 11:57am
Print Post  
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: 67
Location: Montreal, Canada
Joined: Nov 13th, 2014
Re: GDB ESP8266 Variable Problem
Reply #2 - Feb 23rd, 2021 at 4:01pm
Print Post  
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: 2145
Joined: Feb 13th, 2019
Re: GDB ESP8266 Variable Problem
Reply #3 - Feb 23rd, 2021 at 4:04pm
Print Post  
Are you using Debug > Start, or Debug > Attach to Process?
  
Back to top
 
IP Logged
 
Sylvain
Junior Member
**
Offline


Posts: 67
Location: Montreal, Canada
Joined: Nov 13th, 2014
Re: GDB ESP8266 Variable Problem
Reply #4 - Feb 23rd, 2021 at 4:24pm
Print Post  
I use the green arrow Start
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2145
Joined: Feb 13th, 2019
Re: GDB ESP8266 Variable Problem
Reply #5 - Feb 23rd, 2021 at 4:38pm
Print Post  
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: 67
Location: Montreal, Canada
Joined: Nov 13th, 2014
Re: GDB ESP8266 Variable Problem
Reply #6 - Feb 23rd, 2021 at 4:57pm
Print Post  
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: 2145
Joined: Feb 13th, 2019
Re: GDB ESP8266 Variable Problem
Reply #7 - Feb 23rd, 2021 at 5:07pm
Print Post  
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 TopicPrint