This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: Problem with breakpoint addresses
- From: Michael Snyder <Michael dot Snyder at palmsource dot com>
- To: Andrew STUBBS <andrew dot stubbs at st dot com>
- Cc: GDB List <gdb at sourceware dot org>
- Date: Thu, 12 Oct 2006 12:50:11 -0700
- Subject: Re: Problem with breakpoint addresses
- References: <452E8150.5090209@st.com>
On Thu, 2006-10-12 at 18:54 +0100, Andrew STUBBS wrote:
> Hi,
>
> I have a problem setting breakpoints from addresses stored in registers.
>
> Here's an example:
>
> (gdb) set $r1 = 0x80000000
> (gdb) b *$r1
> Breakpoint 2 at 0x80000000
>
> The breakpoint looks like it is set correctly, but actually, if it is to
> work, I have to set it like this:
>
> (gdb) b *($r1 & ~0U)
> Breakpoint 3 at 0x80000000
>
> This shows the difference:
>
> (gdb) info breakpoints
> Num Type Disp Enb Address What
> 2 breakpoint keep y 0xffffffff80000000
> 3 breakpoint keep y 0x80000000
>
> The address has been sign extended. Note that there is no problem with
> registers of unsigned type. This is with an sh-elf target hosted on
> i686-pc-linux-gnu and using 'target sim'.
What's the size of $r1, and what's the size of an address?
By converting $r1 to an address, you're applying an implied cast.
If that doesn't give the expected result (eg. because $r1 is signed),
then you need to use an explicit cast.