Avr-debugger include files not found

I’m trying to get debugging on the UNO working using the avr-debugger. (Linux desktop)
I’ve installed the library, and as per the documentation I’ve added the
#include “avr8-stub.h”
#include “app_api.h”
includes as well as the debug_init(); in the setup.
I’ve also set my platformio.ini to have the extra variables
debug_tool = avr-stub
debug_port = /dev/ttyUSB1
lib_deps = jdolinay/avr-debugger@^1.5

When I compile it says that it can’t open the include files. What am I missing?

Full platformio.ini please.

Did you already refresh your intellisense by doing Ctrl+Shift+P → Rebuild Intellisense Index?

Thanks for replying. My platformio.ini is as follows:

[env:uno]
platform = atmelavr
board = uno
framework = arduino
monitor_speed = 115200
debug_tool = avr-stub
debug_port = /dev/ttyUSB1
lib_deps = jdolinay/avr-debugger@^1.5

I’ve found that adding
#include <app_api.h>

to main.cpp seems to find the other include files, so now onto the next error:

 *  The terminal process "platformio 'debug'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

 *  Executing task in folder blinkpin: platformio debug 

Processing uno (platform: atmelavr; board: uno; framework: arduino)
-------------------------------------------------------------------------------------------------------
Removing unused dependencies...
Error: Traceback (most recent call last):
  File "/home/chris/.platformio/penv/lib/python3.10/site-packages/platformio/__main__.py", line 102, in main
    cli()  # pylint: disable=no-value-for-parameter
  File "/home/chris/.platformio/penv/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/chris/.platformio/penv/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/chris/.platformio/penv/lib/python3.10/site-packages/platformio/cli.py", line 71, in invoke
    return super().invoke(ctx)
  File "/home/chris/.platformio/penv/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/chris/.platformio/penv/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/chris/.platformio/penv/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/chris/.platformio/penv/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/chris/.platformio/penv/lib/python3.10/site-packages/platformio/debug/cli.py", line 84, in cli
    return _debug_in_project_dir(
  File "/home/chris/.platformio/penv/lib/python3.10/site-packages/platformio/debug/cli.py", line 111, in _debug_in_project_dir
    return helpers.predebug_project(
  File "/home/chris/.platformio/penv/lib/python3.10/site-packages/platformio/debug/helpers.py", line 103, in predebug_project
    ctx.invoke(
  File "/home/chris/.platformio/penv/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/chris/.platformio/penv/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/chris/.platformio/penv/lib/python3.10/site-packages/platformio/run/cli.py", line 144, in cli
    process_env(
  File "/home/chris/.platformio/penv/lib/python3.10/site-packages/platformio/run/cli.py", line 201, in process_env
    result = {"env": name, "duration": time(), "succeeded": ep.process()}
  File "/home/chris/.platformio/penv/lib/python3.10/site-packages/platformio/run/processor.py", line 83, in process
    install_project_env_dependencies(
  File "/home/chris/.platformio/penv/lib/python3.10/site-packages/platformio/package/commands/install.py", line 132, in install_project_env_dependencies
    _install_project_env_libraries(project_env, options),
  File "/home/chris/.platformio/penv/lib/python3.10/site-packages/platformio/package/commands/install.py", line 204, in _install_project_env_libraries
    _uninstall_project_unused_libdeps(project_env, options)
  File "/home/chris/.platformio/penv/lib/python3.10/site-packages/platformio/package/commands/install.py", line 280, in _uninstall_project_unused_libdeps
    lm.uninstall(spec)
  File "/home/chris/.platformio/penv/lib/python3.10/site-packages/platformio/package/manager/_uninstall.py", line 29, in uninstall
    return self._uninstall(spec, skip_dependencies)
  File "/home/chris/.platformio/penv/lib/python3.10/site-packages/platformio/package/manager/_uninstall.py", line 34, in _uninstall
    pkg = self.get_package(spec)
  File "/home/chris/.platformio/penv/lib/python3.10/site-packages/platformio/package/manager/base.py", line 263, in get_package
    spec = self.ensure_spec(spec)
  File "/home/chris/.platformio/penv/lib/python3.10/site-packages/platformio/package/manager/base.py", line 133, in ensure_spec
    return spec if isinstance(spec, PackageSpec) else PackageSpec(spec)
  File "/home/chris/.platformio/penv/lib/python3.10/site-packages/platformio/package/meta.py", line 184, in __init__
    self._parse(self.raw)
  File "/home/chris/.platformio/penv/lib/python3.10/site-packages/platformio/package/meta.py", line 291, in _parse
    raw = parser(raw)
  File "/home/chris/.platformio/penv/lib/python3.10/site-packages/platformio/package/meta.py", line 316, in _parse_requirements
    self.requirements = tokens[1].strip()
  File "/home/chris/.platformio/penv/lib/python3.10/site-packages/platformio/package/meta.py", line 231, in requirements
    else semantic_version.SimpleSpec(str(value))
  File "/home/chris/.platformio/penv/lib/python3.10/site-packages/semantic_version/base.py", line 647, in __init__
    self.clause = self._parse_to_clause(expression)
  File "/home/chris/.platformio/penv/lib/python3.10/site-packages/semantic_version/base.py", line 1043, in _parse_to_clause
    return cls.Parser.parse(expression)
  File "/home/chris/.platformio/penv/lib/python3.10/site-packages/semantic_version/base.py", line 1063, in parse
    raise ValueError("Invalid simple block %r" % block)
ValueError: Invalid simple block '~'

============================================================

An unexpected error occurred. Further steps:

* Verify that you have the latest version of PlatformIO using
  `pip install -U platformio` command

* Try to find answer in FAQ Troubleshooting section
  https://docs.platformio.org/page/faq/index.html

* Report this problem to the developers
  https://github.com/platformio/platformio-core/issues

============================================================


 *  The terminal process "platformio 'debug'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it.

That usually appears if you have an invalid lib_deps expression in your platformio.ini.

Can you take a screenshot of VSCode with the platformio.ini open and post it here?

That should not happen.

Can you, in the terminal in VSCode, execute

rm -rf .pio
rm -rf ~/.platformio/lib

to make sure there aren’t any zombie libraries causing this issue.

So it rebuilt the libraries but failed on linking.


Compiling .pio/build/uno/FrameworkArduino/wiring_digital.c.o
Compiling .pio/build/uno/FrameworkArduino/wiring_pulse.S.o
Compiling .pio/build/uno/FrameworkArduino/wiring_pulse.c.o
Compiling .pio/build/uno/FrameworkArduino/wiring_shift.c.o
Archiving .pio/build/uno/libFrameworkArduino.a
Indexing .pio/build/uno/libFrameworkArduino.a
Linking .pio/build/uno/firmware.elf
HardwareSerial0.cpp.o (symbol from plugin): In function Serial': (.text+0x0): multiple definition of __vector_18’
avr8-stub.c.o (symbol from plugin):(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
*** [.pio/build/uno/firmware.elf] Error 1
===================================== [FAILED] Took 3.59 seconds =====================================

You cannot use the Serial object in your code because the serial is used by avr-stub to exactly communicate with the GDB client. Please exactly use the example code in

https://docs.platformio.org/en/latest/plus/debug-tools/avr-stub.html

as your first test program and double-read the documented limitations section.

Ah, that explains it. Thanks for your time.