From: Christo <christo.crause@gmail.com>
To: Simon Marchi <simon.marchi@polymtl.ca>
Cc: gdb@sourceware.org, christo.crause@gmail.com
Subject: Re: AVR - invalid address used when evaluating a variable
Date: Tue, 26 Jun 2018 20:32:00 -0000 [thread overview]
Message-ID: <1530045135.6272.16.camel@gmail.com> (raw)
In-Reply-To: <9371449a502b565344361885fd86c980@polymtl.ca>
On Mon, 2018-06-25 at 21:02 -0400, Simon Marchi wrote:
> I am not proficient in Pascal.  Can you provide a test program, with allÂ
> the command lines needed to reproduce?
Hi Simon,
I'm using the development version of the Freepascal compiler to get the latest AVR support, so
bootstrapping a compiler to compile my test program may be too much hassle. Anyway, the example
code can be seen here:Â https://github.com/ccrause/fpc-avr/blob/master/src/examples/blink2/blink.
pp
I've also uploaded the compiled elf file in case you rather want to use this instead of
compiling it:Â https://github.com/ccrause/fpc-avr/blob/master/src/examples/blink2/bin/blink.elf
Anyway the compiler command line:
fpc/3.1.1/compiler/ppcrossavr -Tembedded -Pavr -CpAVR25 -MObjFPC -Scghi -O4 -g -l -vewnhibq
-Filib/avr-embedded -Fu../../library -Fu. -FUlib/avr-embedded -FE. -oblink -Wpattiny45 -g -a
-XPavr- -al -Sm -Si -dF_CPU:=8000000
An example of a gdb session:
~/fpc/fpc-avr/src/examples/blink2 $ ~/gdb/gdb-8.1/gdb/avr-gdb-8.1.0-originalÂ
GNU gdb (GDB) 8.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-pc-linux-gnu --target=avr".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) file bin/blink.elfÂ
Reading symbols from bin/blink.elf...done.
(gdb) target remote :2345
Remote debugging using :2345
0x00000000 in _START ()
(gdb) load
Loading section .text, size 0xb2 lma 0x0
Loading section .data, size 0x2 lma 0xb2
Start address 0x0, load size 180
Transfer rate: 505 bytes/sec, 25 bytes/write.
(gdb) set language pascal
(gdb) set debug remote 1
(gdb) print i
Sending packet: $m60,1#30...Ack
Packet received: 20
$1 = 32
(gdb) print @i
$2 = (^Sending packet: $m800060,8#ff...Ack
Packet received: 04000A00F6777DD2
Byte) 0x800060 #4
(gdb) print (@i)^
Sending packet: $m800060,1#f8...Ack
Packet received: 04
$3 = 4
(gdb)
From the above "print i" instruction one can see that gdb requests the memory content of address
0x60 which is in flash. Â The "print @i" instruction should print the address of variable i,
which is correct, 0x800060.
I have also tested an equivalent C program compiled with avr-gcc, with gdb reading the correct
SRAM address for the value of i. Â This makes me wonder if the symbol information generated by
Freepascal is correct?
next prev parent reply other threads:[~2018-06-26 20:32 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
2018-06-26 20:32 ` Christo [this message]
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=1530045135.6272.16.camel@gmail.com \
--to=christo.crause@gmail.com \
--cc=gdb@sourceware.org \
--cc=simon.marchi@polymtl.ca \
/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