Hello everyone, this is my first time debugging an Arduino UNO. For some reason, after I start debugging, the debug console says everything works well. But I can’t use the Step In and Step Over function. And also, it will produce a wiring.c file, which I don’t know what is this too. Can anyone please help me?
This is the contents of my .ini file.
Place a breakpoint after the debug_init()
is called, e.g., at line 13. Stop and restart debugging again. Does it break there now?
oh yes it does. Thank you! May I know why a file called wiring.c always pops up each time I run the debugger?
The file isn’t created by PlatformIO, it’s part of the Arduino framework. When the debugger attaches or you pause in the middle of your code, it could e.g. be in the delay()
code or digitalWrite()
code. wiring.c
e.g. implements delay()
. (ArduinoCore-avr/wiring.c at master · arduino/ArduinoCore-avr · GitHub).
may i know it implements in what way?
Especially see
You can use the breakpoint()
function in order to definitely stop at a certain point instead of letting the code continue running.
I linked you to the documentation above. It uses a hardware timer on the ATMega328 chip.
Oh i see. I understand now. Thank you!
For some reason, I am having this issue again. But this time, it popped up a weird error that says i don’t have that source file in my folder, which I have.
Is s:\\
the correct drive name? Is that a shared network drive or a subst
'ed drive (for which there are known problems)?
The only problem here I saw is the “//” instead of the “/”. Will this affect anything? Other than that, it’s all correct.
When i try to use this code from the platformIO’s debugging page, it ran well without this error.
Did you move the project form its previous location?
No, I did not. However, I did copy the code from another file at another location into it and changed the name of the file.
I’m going to add some more details. I tried deleting and recreating the project. Apparently, it works fine, until when I create more projects, it starts to pop this error up and redirects the debugger to the breakpoint set in another project file where the debugger had previously run.
I created 2 additional projects to test this.
Let me describe this error in another way. Let’s say I have created projects P1, P2 and P3 (P1 first, P3 last).
The debugger ran well on P2 but shows the error when i tried to run on P1 and P3. While the debugger is active on either P1 and P3, when I proceed to add a breakpoint in P2, the debugger somehow break at that line in P2.
Did you use the project environment switcher to explicitly switch to the project you want to debug?
If yes, please open an issue at Issues · platformio/platformio-vscode-ide · GitHub with reproduction instructions for this bug.
The environment switches seemed to not affect anything whatever that I was debugging. Even though my environment is at P1, it can still run the debugger at P2.
This error pops up in both P1 and P2, but debugger works fine in P2 but not P1
This usally pops up when PlatofrmIO hasn’t yet re-generated the tasks file after switching an environment. Briefly waiting and trying it again might work. Does it consistently not work?
I clicked “Debug anyway” immediately, but yeah, it only works on P2. Which means consistently not work
Please notify the devs.
Funny though, my VSCode workspaces contains… a lot of projects and debuger environment always starts in the currently selected one (as selected with the project environment switcher).