This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[rfa] Use better types for ARM registers
- From: Daniel Jacobowitz <drow at false dot org>
- To: gdb-patches at sourceware dot org, Richard Earnshaw <Richard dot Earnshaw at arm dot com>
- Date: Tue, 20 Jun 2006 15:45:45 -0400
- Subject: [rfa] Use better types for ARM registers
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)