[RFA 2/5] Prec: x86 segment register support: i386-linux-tdep

Hui Zhu teawater@gmail.com
Tue Mar 16 16:57:00 GMT 2010


This patch add the function for the interface.  It will call the
interface to_get_segment_base in  current_target.

Thanks,
Hui

2010-03-16  Hui Zhu  <teawater@gmail.com>

	* i386-linux-tdep.c (i386_linux_segment_base): New function.
	(i386_linux_init_abi): Set i386_linux_segment_base to
	tdep->i386_segment_base.
-------------- next part --------------
---
 i386-linux-tdep.c |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

--- a/i386-linux-tdep.c
+++ b/i386-linux-tdep.c
@@ -439,6 +439,25 @@ i386_linux_intx80_sysenter_record (struc
   return 0;
 }
 
+static int
+i386_linux_segment_base (struct regcache *regcache, int regnum,
+                         ULONGEST *base)
+{
+  ULONGEST value;
+
+  /* Check if the target  */
+  if (current_target.to_get_segment_base == NULL)
+    return -1;
+
+  /* Get the regnum reg's value.  */
+  regcache_raw_read_unsigned (regcache, regnum, &value);
+
+  if (current_target.to_get_segment_base (value >> 3 ,base) != 0)
+    return -1;
+
+  return 0;
+}
+
 #define I386_LINUX_xstate	270
 #define I386_LINUX_frame_size	732
 
@@ -787,6 +806,7 @@ i386_linux_init_abi (struct gdbarch_info
 
   tdep->i386_intx80_record = i386_linux_intx80_sysenter_record;
   tdep->i386_sysenter_record = i386_linux_intx80_sysenter_record;
+  tdep->i386_segment_base = i386_linux_segment_base;
 
   /* N_FUN symbols in shared libaries have 0 for their values and need
      to be relocated. */


More information about the Gdb-patches mailing list