Electronic – arduino – How to debug a Arduino Uno with gdb on a Linux pc

arduinoavrdebugginglinux

How do I debug (source code single step) a Arduino Uno with gdb on a Linux pc?
Please note that I do not like to use AVR Studio in wine or VirtualBox.

Question 1: Physical connection

How and what do I connect to the Uno board?
My guess is that since the Uno board is populated with a ATmega328, single step source code should be available?
I also guess that I can use either a AVR JTAGICE mkII or a AVR Dragon over the ICSP header?

Question 2: GDB server

Then I noticed that there is some projects like AVaRICE that seems to provide a jtag to gdb function, but there may be other projects?

Question 3: Where is the elf?

And if I get it up and running, where does the Arduino IDE hide the generated output like the elf file with debug symbols (there should be one)? Or do I need to generate a classic Makefile that just uses the Ardino libs?

I tried to find some info on what/how to use, but I have only found those clues that told me what I could do. Can someone push me in the right direction?

Best Answer

You can find the compiler artifacts by holding down the shift key when clicking the compile button in older version of the IDE (read < 1.0). In newer versions (read >= 1.0) there's an option under the preferences dialog for displaying verbose output during compilation (see screenshot). With verbose output the folder where all the compiler outputs end up is printed (repeatedly) in the console. That should get you started at least.

screenshot arduino show verbose output during compilation

On a side note, there was all sorts of chatter on this subject on Arduino developers list earlier in June 2012 and somebody posted an announcement to the Arduino developers list on an improved / integrated way of GDB debugging for Arduino, but I haven't investigated it much further. I guess the project is called VisualMicro (?). It looks like it's been built as a Visual Studio plugin so might not be helpful to you in a linux environment, and it's in beta on top of that, but I'll let you decide.