Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: Christo <christo.crause@gmail.com>
Cc: gdb@sourceware.org
Subject: Re: AVR - invalid address used when evaluating a variable
Date: Tue, 26 Jun 2018 01:02:00 -0000	[thread overview]
Message-ID: <9371449a502b565344361885fd86c980@polymtl.ca> (raw)
In-Reply-To: <1529868512.24104.26.camel@gmail.com>

On 2018-06-24 15:28, Christo wrote:
> 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?

Hi Christo,

I am not proficient in Pascal.  Can you provide a test program, with all 
the command lines needed to reproduce?

Thanks,

Simon


  reply	other threads:[~2018-06-26  1:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-24 19:28 Christo
2018-06-26  1:02 ` Simon Marchi [this message]
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=9371449a502b565344361885fd86c980@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=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