Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* AVR - invalid address used when evaluating a variable
@ 2018-06-24 19:28 Christo
  2018-06-26  1:02 ` Simon Marchi
  0 siblings, 1 reply; 5+ messages in thread
From: Christo @ 2018-06-24 19:28 UTC (permalink / raw)
  To: gdb; +Cc: christo.crause

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?


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-06-27  5:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-24 19:28 AVR - invalid address used when evaluating a variable Christo
2018-06-26  1:02 ` Simon Marchi
2018-06-26 20:32   ` Christo
2018-06-27  2:01     ` Simon Marchi
2018-06-27  5:33       ` Christo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox