This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Implement $sp/$eip and $pc/$eip for x32


Hi,

This patch on top of

http://sourceware.org/ml/gdb-patches/2012-04/msg00191.html

implements $sp/$eip and $pc/$eip for x32.  OK to install?

Thanks.


H.J.
---
	* amd64-tdep.c (amd64_dword_names): Add "eip".
	(amd64_pseudo_register_type): New function.
	(amd64_init_abi): Set num_dword_regs to 17.  Call
	set_tdesc_pseudo_register_type with amd64_pseudo_register_type.

	* i386-tdep.c (i386_pseudo_register_type): Make it global.
	* i386-tdep.h (i386_pseudo_register_type): New prototype.

diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index d2bcd17..e2fbf33 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -256,9 +258,34 @@ static const char *amd64_word_names[] =
 static const char *amd64_dword_names[] =
 {
   "eax", "ebx", "ecx", "edx", "esi", "edi", "ebp", "esp", 
-  "r8d", "r9d", "r10d", "r11d", "r12d", "r13d", "r14d", "r15d"
+  "r8d", "r9d", "r10d", "r11d", "r12d", "r13d", "r14d", "r15d", "eip"
 };
 
+/* Return the GDB type object for the "standard" data type of data in
+   register REGNUM.  */
+
+static struct type *
+amd64_pseudo_register_type (struct gdbarch *gdbarch, int regnum)
+{
+  /* Use pointer types for ebp, esp and eip registers in x32.  */
+  if (gdbarch_ptr_bit (gdbarch) == 32)
+    {
+      struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+      switch (regnum - tdep->eax_regnum)
+	{
+	default:
+	  break;
+	case AMD64_RBP_REGNUM:	/* ebp  */
+	case AMD64_RSP_REGNUM:	/* esp	*/
+	  return builtin_type (gdbarch)->builtin_data_ptr;
+	case AMD64_RIP_REGNUM:	/* eip */
+	  return builtin_type (gdbarch)->builtin_func_ptr;
+	}
+    }
+
+  return i386_pseudo_register_type (gdbarch, regnum);
+}
+
 /* Return the name of register REGNUM.  */
 
 static const char *
@@ -2670,7 +2697,7 @@ amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 
   tdep->num_byte_regs = 20;
   tdep->num_word_regs = 16;
-  tdep->num_dword_regs = 16;
+  tdep->num_dword_regs = 17;
   /* Avoid wiring in the MMX registers for now.  */
   tdep->num_mmx_regs = 0;
 
@@ -2679,6 +2706,7 @@ amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   set_gdbarch_pseudo_register_write (gdbarch,
 				     amd64_pseudo_register_write);
 
+  set_tdesc_pseudo_register_type (gdbarch, amd64_pseudo_register_type);
   set_tdesc_pseudo_register_name (gdbarch, amd64_pseudo_register_name);
 
   /* AMD64 has an FPU and 16 SSE registers.  */
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 0106eae..639ba97 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -2781,7 +2781,7 @@ i386_mmx_type (struct gdbarch *gdbarch)
 /* Return the GDB type object for the "standard" data type of data in
    register REGNUM.  */
 
-static struct type *
+struct type *
 i386_pseudo_register_type (struct gdbarch *gdbarch, int regnum)
 {
   if (i386_mmx_regnum_p (gdbarch, regnum))
diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h
index 0eec1fb..e1f7c44 100644
--- a/gdb/i386-tdep.h
+++ b/gdb/i386-tdep.h
@@ -315,6 +315,7 @@ extern int i386_dword_regnum_p (struct gdbarch *gdbarch, int regnum);
 extern int i386_xmm_regnum_p (struct gdbarch *gdbarch, int regnum);
 extern int i386_ymm_regnum_p (struct gdbarch *gdbarch, int regnum);
 
+extern struct type *i386_pseudo_register_type (struct gdbarch *, int);
 extern const char *i386_pseudo_register_name (struct gdbarch *gdbarch,
 					      int regnum);
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]