platformio / platformio-vscode-ide

PlatformIO IDE for VSCode: The next generation integrated development environment for IoT
https://marketplace.visualstudio.com/items?itemName=platformio.platformio-ide
Apache License 2.0
1.2k stars 192 forks source link

Global variables are not shown for AVR + avr-stub #2334

Open maxgerhardt opened 3 years ago

maxgerhardt commented 3 years ago

For the given platformio.ini

[env:uno]
platform = atmelavr
board = uno
framework = arduino
debug_tool = avr-stub
debug_port = \\.\COM14
debug_build_flags = -O0 -ggdb3 -g3
lib_deps =
    jdolinay/avr-debugger @ ~1.1

and creating a simple sketch

#include "Arduino.h"
#include "avr8-stub.h"

volatile int lastAnalogRead = 0;

void setup()
{
  // initialize GDB stub
  debug_init();
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop()
{
  lastAnalogRead = analogRead(A0);
  if(lastAnalogRead > 128) 
      digitalWrite(LED_BUILTIN, HIGH);
  delay(1000);
  digitalWrite(LED_BUILTIN, LOW);
  delay(1000);
}

the global variable lastAnalogRead is not shown

grafik

Although it shows up when doing a info variables command in the GDB console, as also see in the output above.

The error does not change when the debug_build_flags are removed.

The debugger still shows local variables as normal.

grafik

Using latest PlatformIO home and core version.

vtmarvin commented 3 years ago

Had the same problem (cpp development for Arduino UNO), watch tooltip stated that it is "unable to create variable object" and I was not able to see any watched variables in UI. I tried to add some debug flags and to change port from COM3 to \.\COM3 but with no success. After playing with platformio.ini a while I gave it up and returned to original configuration I started with and ... it started working at least partially. image

Now I see variable in watches but not in global/local variables. Variable was and is still present while using list variables in debug console

My platformio.ini

[env:uno]
platform = atmelavr
board = uno
framework = arduino
debug_tool = avr-stub
debug_port = COM3

; GDB stub implementation
lib_deps =
    jdolinay/avr-debugger @ ~1.1

It still works after restarting VSC/PIO.

nelsonov commented 2 years ago

I am having exactly the same problem with both an Uno and a Mega2560. Is there a workaround for this?

Fr33man85 commented 2 years ago

1+

jacksontong commented 2 years ago

same problem

jfdzar commented 2 years ago

Same problem here!

smwoodward commented 1 year ago

I'm also having the same issue. I can see it under watch and in terminal when I print the variable.