Is there a step-through debugger for Arduino?

I'm trying to get a better idea of how the Parola library works.

Is there an IDE/debugger that will let me step through C/C++ code as an arduino sketch uses them? (For example, if in an arduino sketch I call a function defined by a C++ library, I would like to see the call tree by steeping through execution, variable values, etc,...)

If this isn't possible, what are some other ways to debug code written in a library (or to learn the structure of it?)

Is there an IDE/debugger that will let me step through C/C++ code as an arduino sketch uses them?

No. The Arduino code is not capable of running a debugger, or accepting commands from a remote computer to step through the code, or of sending any kind of information back to the remote computer.

PaulS:
No. The Arduino code is not capable of running a debugger, or accepting commands from a remote computer to step through the code, or of sending any kind of information back to the remote computer.

Ok does that mean that any code written for arduino can't be debugged using a debugger?

Ok does that mean that any code written for arduino can't be debugged using a debugger?

How would you debug code running on my computer, using a debugger running on your computer?

Substitute "the Arduino" for "my computer", and you can see why it is impossible to debug Arduino code. The Arduino can not run a debugger, for several reasons. Not the least of which is that it has no place to display the code, no way to interact with the user, and no way to display the state of the debugging process.

ElusivePi:
Ok does that mean that any code written for arduino can't be debugged using a debugger?

A human is a debugger. If you add "debugging prints" you can often see what is happening.

If it helps, I have a small library that displays to MAX7219 displays:

It's not particularly complex.

what about Atmel Studio and something like the the AVR Dragon?

PaulS:
How would you debug code running on my computer, using a debugger running on your computer?

Substitute "the Arduino" for "my computer", and you can see why it is impossible to debug Arduino code. The Arduino can not run a debugger, for several reasons. Not the least of which is that it has no place to display the code, no way to interact with the user, and no way to display the state of the debugging process.

Remote debuggers are very common. They are not so popular now that computers have the display real estate and gui horsepower - not to mention that it is now harder to crash the OS - to make it easier to debug on the same machine.

Thes best tool currently available for debugging Arduino applications is VisualMicro (www.visualmicro.com) which is a plug-in for VisualStudio and AtmelStudio that gives some debugging capabilities. It allows breakpoints, and "Trace-points" and viewing Arduino data, but does not provide full debugger capabilities like stepping line-by-line through the code. It is, however, adequate for most debugging needs, the price is very reasonable, and support is first-rate.

Regards,
Ray L.

PaulS:
How would you debug code running on my computer, using a debugger running on your computer?

Substitute "the Arduino" for "my computer", and you can see why it is impossible to debug Arduino code. The Arduino can not run a debugger, for several reasons. Not the least of which is that it has no place to display the code, no way to interact with the user, and no way to display the state of the debugging process.

Seriously??? You've never heard of remote debugging? Your experience seems to be remarkably limited in some areas. It's been VERY commonly used for decades in development of PC applications. And true debugging of embedded applications has been common place since the days of the 8080, using nothing but software to perform single-stepping, breakpoints, etc. There is nothing about the Arduino that inherently limits what can be done in the way of debugging, other than nobody has gone to the trouble to apply the methods that have been in common use in the embedded world since at least the '70s. Hardware debugging support helps, but it not essential.

Regards,
Ray L.

1 Like

With Atmel's tools, it's possible. It supports something called DebugWire - but I don't think I've seen a single discussion of using it on these forums; I don't think anyone's using that with Arduino. You have to disable reset to use it.

You've never heard of remote debugging?

Yes, I have, and yes, I've done it. My point was that the remote computer is what needs to be running the debugger. The Arduino can't run a debugger.

PaulS:
Yes, I have, and yes, I've done it. My point was that the remote computer is what needs to be running the debugger. The Arduino can't run a debugger.

I suppose that depends on what you call "the debugger". The remote computer runs the GUI, but, in the absense of hardware debugging support built into the MCU, there has to be a debugging "kernel" running on the target that does the actual stepping/breakpointing/memory access, etc. But this is a small piece of code that could absolutely be implemented on any Arduino, just as was done back in the days of the 8080/Z80/6502/6800/1802, etc. The typical connection between the two is a simple RS232 port.

Regards,
Ray L.