AVR32 Embedded Development/GDB

From AVRFreaks Wiki

Jump to: navigation, search

Contents

Introduction

The application can be debugged on target using GNU Project Debugger (GDB) and JTAGICE mkII. This requires that a GDB proxy server is used. The proxy will translate standard GDB requests such as read memory, read registers and set breakpoints into JTAGICE mkII operations.

GDB is an open standard and any debugger supporting GDB may be connected to the GDB proxy server using socket communication.

Image:avr32_embedded_debugging.png

For more information about the GNU Project Debugger, please visit the Official GDB web site.


Setting up proxyserver - avr32gdbproxy

The AVR32 GDB proxy server must be started before using a GDB-client. Use the following command to start avr32gdbproxy and connect it to a host called 'remote' with port number '4242' :

avr32gdbproxy –a remote:4242

For the AP7, specify flash address and size:

avr32gdbproxy -f0,8Mb –a remote:4242

The -f parameter tells the GDB proxy server where the flash memory is located. For information about additional parameters use:

avr32gdbproxy --help

Starting a GBD session - avr32-gdb

Once the GDB proxy server is up an running, the user can communicate with it using any debugger with GDB support. This is done by using the same host name and port number as when avr32gdbproxy was invoked.

Start the GDB-client with the following command:

avr32-gdb myProgram.elf

Remember to keep the avr32gdbproxy running during the entire debug session. If a command line based GDB-client like avr32-gdb is used, it must be called from a new terminal. If Cygwin is used, one can easily do this by starting Cygwin one more time, so that there are two Cygwin windows: one with the GDB proxy and one with the GDB-client.

Once the GDB-client is startet, use the following GDB commands to initiate a debug session:

(gdb) target remote:4242

This connects the gdb-client to the avr32gdbproxy server (assuming host name 'remote' and port number '4242').


GDB reference

This section gives a brief introduction to the command based GDB-client avr32-gdb and its command set.

Getting general help in gdb:

(gdb) help

Set the program counter to the start address

(gdb) set $pc = _start

Start execution on target

(gdb) cont

Stop execution:

Use standard keys for interruption: ctrl-c

Getting general help on a specific topic:

(gdb) help 'topic'

It is also useful to know that by pressing the 'tab' key, for instance after having typet 'help', GDB will display all possible symbols that will be accepted. The 'tab' key works both alone, and after a keyword (such as 'help').

End GDB session and quit:

(gdb) quit

Getting an overview:

(gdb) where full

Display source code:

(gdb) list

Display disassembly:

(gdb) disassemble

Display variables:

(gdb) print 'symbol name'

Setting a variable:

(gdb) set 'symbol name' = 'value'

Single step:

(gdb) s

Instruction step:

(gdb) si

Next:

(gdb) n

Setting a breakpoint:

(gdb) break 'line number', 'function name' or 'address'

Clearing a breakpoint:

(gdb) clear 'line number' , 'function name', 'address' or breakpoint number

Setting a data breakpoint (at address 0xffff):

(gdb) watch *0x0000ffff

Clearing a data breakpoint:

(gdb) delete 'data breakpoint number'

Show general registers

(gdb) regs

Set general register:

(gdb) set $r1=0x0

Show system registers

(gdb) show sysreg 4

Set system register:

(gdb) set sysreg 4=0x0
Static version created: 2007-03-07
Copyright (c) 2007 Atmel Corporation