Problem with breakpoint addresses

Michael Snyder Michael.Snyder@palmsource.com
Thu Oct 12 19:50:00 GMT 2006


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.



More information about the Gdb mailing list