Using GDB with Avrora

New in Beta 1.4.0 is a feature that allows Avrora to be used to debug programs with gdb, the GNU debugger. A remote serial protocol allows Avrora to communicate with gdb over a socket and service requests. If you are already familiar with gdb, you can use its convenient interface and the flexibility of Avrora's profiling and monitoring to unlock even more powerful debugging techniques.

Currently, debugging with gdb and Avrora only works with a single node simulation.


Step 1 - Start Avrora's GDBServer

The first step is to start Avrora with a special monitor that creates a server socket which listens for a connection from GDB. By default, Avrora will listen for a connection on port 10001. To change this port, specify the -port option. Avrora will start up as normal, but the GDB server monitor will listen for a connection before starting the program.

% avrora  -monitors=gdb simple.od 
Avrora [Beta 1.4.0] - (c) 2003-2005 UCLA Compilers Group

This simulator and analysis tool is provided with absolutely no warranty,
either expressed or implied. It is provided to you with the hope that it be
useful for evaluation of and experimentation with microcontroller and sensor
network programs. For more information about the license that this software is
provided to you under, specify the "license" option.

=={ Simulation events }=======================================================
Node       Time   Event
------------------------------------------------------------------------------
GDBServer listening on port 10001...


Step 2 - Start GDB and Connect

The next step is to start avr-gdb and load the same program. To connect to Avrora, you can use the target gdb command.

%  avr-gcc -mmcu=atmega128 -ggdb -o simple.elf simple.c
%  avr-gdb simple.elf
GNU gdb cvs-pre6.0-tinyos
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "--host=i686-pc-linux-gnu --target=avr"...
(gdb) target remote :10001
Remote debugging using :10001
0x00000000 in __vectors ()

% _


Step 3 - Use GDB as Normal

Now that you are connected, you should be able to use gdb as normal, inserting breakpoints, stepping, and inspecting variables. The support for GDB in Avrora is not well developed yet. If you have trouble, try passing the -verbose=monitor.gdb to Avrora to see the communication. Report problems to the mailing list.





[ Home | Download | Get Started | Online CVS | JavaDoc API ]


Copyright (c) 2004-2005, UCLA Compilers Group
The Avrora logo background is Copyright (c) 1996 Jan Curtis, used with permission.