From: Tristan Gingold <gingold@adacore.com>
To: Joel Brobecker <brobecker@adacore.com>
Cc: gdb@sourceware.org
Subject: Re: Help: address vs pointer
Date: Mon, 02 Nov 2009 16:04:00 -0000 [thread overview]
Message-ID: <6B38A90C-7D7C-40C8-94DC-C4564F4A22AE@adacore.com> (raw)
In-Reply-To: <20091102154836.GG4573@adacore.com>
On Nov 2, 2009, at 4:48 PM, Joel Brobecker wrote:
>> So what should be the type of the pc register ? If it is a pointer
>> to
>> instructions, 'print $pc' would be wrong as it would be multiplied
>> by
>> 4 (once by read_pc and once during evaluation).
>
> My not-so-educated feeling on this issue is that PC should be a
> pointer
> to instruction. What seems strange is that the PC value gets doubled
> twice. I understand why during the read, but not why during the eval.
> Perhaps there is something we can do there?
I was able to work-around this issue by creating a pseudo-register
named 'pc'. This pseudo register
is a pointer to instruction whose value is really the program counter
(not multiplied by 2).
Using this pseudo-register, everything work well. So I think this is
the simplest solution!
However it is still difficult to set a breakpoint to a 'random' address:
break *0x1234 doesn't work because 0x1234 is interpreted as an integer
which is converted to a pointer
in the data space.
Unfortunately, break *(void (*)())0x1234 works only when addresses are
in the lower 64KW instruction
address space (because a pointer is 16 bits). But some AVR have 128KW/
256KB of instructions...
But we can still use 'break *(&func + 0x1234)' !
Tristan.
prev parent reply other threads:[~2009-11-02 16:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-02 9:17 Tristan Gingold
2009-11-02 15:48 ` Joel Brobecker
2009-11-02 16:04 ` Tristan Gingold [this message]
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=6B38A90C-7D7C-40C8-94DC-C4564F4A22AE@adacore.com \
--to=gingold@adacore.com \
--cc=brobecker@adacore.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