This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

AVR - invalid address used when evaluating a variable


I am testing the debugging of AVR microcontrollers over debugWIRE with gdb. When evaluating the
value of a variable I noticed an incorrect value. On closer inspection I realized that gdb (8.1
compiled for AVR support) was reading flash memory, not SRAM.  When I evaluate the pointer to
the variable, gdb correctly reports the SRAM address. When reading the memory pointed to by this
pointer the correct value is returned.  This leads me to postulate that there is a
mistake/omission when gdb evaluates/prints a variable, resolve its address and then reads it
from flash rather than SRAM.

Below a short excerpt of debugging a simple program with a variable "i" which the compiler
located at address 0 in SRAM (which should be mapped to 0x800060, right after the io registers).
The program was compiled with Freepascal and debugged using a debugWIRE server.  I've called
"set debug remote 1" so that the rsp requests can be seen:

(gdb) print i
Sending packet: $m60,1#30...Ack
Packet received: 20
$7 = 32 ' '
(gdb) print &i
$8 = (Byte *) 0x800060 <TC_sPsBLINK_ss_I> Sending packet: $m800060,8#ff...Ack
Packet received: 020003B8F6777DD2
"\002"
(gdb) print *&i
Sending packet: $m800060,1#f8...Ack
Packet received: 02
$9 = 2 '\002'

Can anyone confirm this behaviour is indeed wrong/unexpected?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]