* [rfa] Use better types for ARM registers
@ 2006-06-20 19:45 Daniel Jacobowitz
2006-06-21 10:59 ` Richard Earnshaw
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Jacobowitz @ 2006-06-20 19:45 UTC (permalink / raw)
To: gdb-patches, Richard Earnshaw
This patch switches pc and sp to pointer types, and other registers
from int32 to uint32. The pc switch follows in the footsteps of a
clever idea that I last remember seeing from Mark Kettenis:
(gdb) i reg pc
pc 0x83a4 0x83a4 <handler+20>
The uint32 change is both cosmetic (I think it's less messy) and
necessary. I recently committed this, after a bug report from Michael
and some discussion:
2006-05-17 Daniel Jacobowitz <dan@codesourcery.com>
* dwarf2-frame.c: Include "value.h".
(read_reg): Use unpack_long and register_type.
* Makefile.in (dwarf2-frame.o): Update.
An unexpected consequence is that if the CFA comes from a register with
a signed type, and the host is 64-bit (like my amd64 desktop), the CFA
will be extended in the dwarf2 frame ID. This causes "stack
corruption" messages because we think it's way outside of the previous
frame. So, fix and prettify, at the same time.
OK?
Independent of this patch, if you have ideas on avoiding the sign
extension without discarding that reasonable and otherwise correct
patch, I am interested; more targets than ARM are affected. Should we
manually construct a pointer type of the correct size in read_reg?
--
Daniel Jacobowitz
CodeSourcery
2006-06-20 Daniel Jacobowitz <dan@codesourcery.com>
* arm-tdep.c (arm_register_type): Use unsigned types for registers.
Add special types for sp and pc.
* Makefile.in (arm-tdep.o): Update.
Index: src/gdb/arm-tdep.c
===================================================================
--- src.orig/gdb/arm-tdep.c 2006-06-20 15:30:24.000000000 -0400
+++ src/gdb/arm-tdep.c 2006-06-20 15:35:12.000000000 -0400
@@ -40,6 +40,7 @@
#include "trad-frame.h"
#include "objfiles.h"
#include "dwarf2-frame.h"
+#include "gdbtypes.h"
#include "arm-tdep.h"
#include "gdb/sim-arm.h"
@@ -1356,8 +1357,12 @@ arm_register_type (struct gdbarch *gdbar
else
return builtin_type_arm_ext_littlebyte_bigword;
}
+ else if (regnum == ARM_SP_REGNUM)
+ return builtin_type_void_data_ptr;
+ else if (regnum == ARM_PC_REGNUM)
+ return builtin_type_void_func_ptr;
else
- return builtin_type_int32;
+ return builtin_type_uint32;
}
/* Index within `registers' of the first byte of the space for
Index: src/gdb/Makefile.in
===================================================================
--- src.orig/gdb/Makefile.in 2006-06-20 15:32:01.000000000 -0400
+++ src/gdb/Makefile.in 2006-06-20 15:32:20.000000000 -0400
@@ -1786,7 +1786,7 @@ arm-tdep.o: arm-tdep.c $(defs_h) $(frame
$(frame_unwind_h) $(frame_base_h) $(trad_frame_h) $(arm_tdep_h) \
$(gdb_sim_arm_h) $(elf_bfd_h) $(coff_internal_h) $(elf_arm_h) \
$(gdb_assert_h) $(bfd_in2_h) $(libcoff_h) $(objfiles_h) \
- $(dwarf2_frame_h)
+ $(dwarf2_frame_h) $(gdbtypes_h)
auxv.o: auxv.c $(defs_h) $(target_h) $(gdbtypes_h) $(command_h) \
$(inferior_h) $(valprint_h) $(gdb_assert_h) $(auxv_h) \
$(elf_common_h)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [rfa] Use better types for ARM registers
2006-06-20 19:45 [rfa] Use better types for ARM registers Daniel Jacobowitz
@ 2006-06-21 10:59 ` Richard Earnshaw
2006-06-23 13:01 ` Daniel Jacobowitz
0 siblings, 1 reply; 3+ messages in thread
From: Richard Earnshaw @ 2006-06-21 10:59 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
On Tue, 2006-06-20 at 20:45, Daniel Jacobowitz wrote:
> This patch switches pc and sp to pointer types, and other registers
> from int32 to uint32. The pc switch follows in the footsteps of a
> clever idea that I last remember seeing from Mark Kettenis:
>
> (gdb) i reg pc
> pc 0x83a4 0x83a4 <handler+20>
>
> The uint32 change is both cosmetic (I think it's less messy) and
> necessary. I recently committed this, after a bug report from Michael
> and some discussion:
>
> 2006-05-17 Daniel Jacobowitz <dan@codesourcery.com>
>
> * dwarf2-frame.c: Include "value.h".
> (read_reg): Use unpack_long and register_type.
> * Makefile.in (dwarf2-frame.o): Update.
>
> An unexpected consequence is that if the CFA comes from a register with
> a signed type, and the host is 64-bit (like my amd64 desktop), the CFA
> will be extended in the dwarf2 frame ID. This causes "stack
> corruption" messages because we think it's way outside of the previous
> frame. So, fix and prettify, at the same time.
>
> OK?
I can't see any problems with this. Abstractly, registers are just
buckets of bits, it's the use context that determines whether they are
signed or unsigned (or something else entirely). In some ways it might
be nice if we could enforce all interpretation of the bits to be
explicit, but I can see that might be an unnecessary overhead. I guess
interpreting the value by default as unsigned is closer to my ideal than
defaulting to signed.
R.
One of the things that has always frustrated me with GDB is to print out
the value of an integer register (or pair of such registers) as a
floating point value -- ie, there's no obvious way to do the equivalent
of *(double*)®num.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [rfa] Use better types for ARM registers
2006-06-21 10:59 ` Richard Earnshaw
@ 2006-06-23 13:01 ` Daniel Jacobowitz
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Jacobowitz @ 2006-06-23 13:01 UTC (permalink / raw)
To: Richard Earnshaw; +Cc: gdb-patches
On Wed, Jun 21, 2006 at 11:58:27AM +0100, Richard Earnshaw wrote:
> I can't see any problems with this. Abstractly, registers are just
> buckets of bits, it's the use context that determines whether they are
> signed or unsigned (or something else entirely). In some ways it might
> be nice if we could enforce all interpretation of the bits to be
> explicit, but I can see that might be an unnecessary overhead. I guess
> interpreting the value by default as unsigned is closer to my ideal than
> defaulting to signed.
Thanks, checked in. I agree it'd be nice, but I don't think it's
practical.
> One of the things that has always frustrated me with GDB is to print out
> the value of an integer register (or pair of such registers) as a
> floating point value -- ie, there's no obvious way to do the equivalent
> of *(double*)®num.
Hmm, I'll keep this message around... really the implementation would
be easy, we'd just need a syntax.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-06-23 13:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-20 19:45 [rfa] Use better types for ARM registers Daniel Jacobowitz
2006-06-21 10:59 ` Richard Earnshaw
2006-06-23 13:01 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox