platformio-vscode-ide icon indicating copy to clipboard operation
platformio-vscode-ide copied to clipboard

Global variables are not shown for AVR + avr-stub

Open maxgerhardt opened this issue 4 years ago • 6 comments

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.

maxgerhardt avatar Jan 29 '21 16:01 maxgerhardt

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.

vtmarvin avatar Jan 30 '21 16:01 vtmarvin

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

nelsonov avatar Nov 16 '21 07:11 nelsonov

1+

Fr33man85 avatar Dec 12 '21 15:12 Fr33man85

same problem

jacksontong avatar Dec 27 '21 16:12 jacksontong

Same problem here!

jfdzar avatar Feb 09 '22 16:02 jfdzar

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

smwoodward avatar Sep 28 '22 19:09 smwoodward