This is the mail archive of the
mailing list for the GDB project.
AVR - invalid address used when evaluating a variable
- From: Christo <christo dot crause at gmail dot com>
- To: gdb at sourceware dot org
- Cc: christo dot crause at gmail dot com
- Date: Sun, 24 Jun 2018 21:28:32 +0200
- Subject: 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
(gdb) print *&i
Sending packet: $m800060,1#f8...Ack
Packet received: 02
$9 = 2 '\002'
Can anyone confirm this behaviour is indeed wrong/unexpected?