From: Christo <christo.crause@gmail.com>
To: gdb@sourceware.org
Cc: christo.crause@gmail.com
Subject: AVR - invalid address used when evaluating a variable
Date: Sun, 24 Jun 2018 19:28:00 -0000 [thread overview]
Message-ID: <1529868512.24104.26.camel@gmail.com> (raw)
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?
next reply other threads:[~2018-06-24 19:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-24 19:28 Christo [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1529868512.24104.26.camel@gmail.com \
--to=christo.crause@gmail.com \
--cc=gdb@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox