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]

[RFA] Make the prec support signal better[3/4] -- i386-linux


This patch make i386-linux support signal record.
When signal happen, i386_linux_record_signal will record the change.
When the signal handler want return, new code in
"i386_linux_intx80_sysenter_record" will record the change.

2009-09-09  Michael Snyder  <msnyder@vmware.com>
	    Hui Zhu  <teawater@gmail.com>

	* i386-linux-tdep.c (i386_all_but_ip_registers_record): New
	function.
	(i386_linux_intx80_sysenter_record): Call
	i386_all_but_ip_registers_record if syscall is sys_sigreturn
	or sys_rt_sigreturn.
	(i386_linux_signal_stack): New enum.
	(i386_linux_record_signal): New function.
	(i386_linux_init_abi): Call set_gdbarch_process_record_signal.

---
 i386-linux-tdep.c |   71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 71 insertions(+)

--- a/i386-linux-tdep.c
+++ b/i386-linux-tdep.c
@@ -354,6 +354,33 @@ i386_linux_write_pc (struct regcache *re
   regcache_cooked_write_unsigned (regcache, I386_LINUX_ORIG_EAX_REGNUM, -1);
 }

+/* Record all registers for process-record.  */
+
+static int
+i386_all_but_ip_registers_record (struct regcache *regcache)
+{
+  if (record_arch_list_add_reg (regcache, I386_EAX_REGNUM))
+    return -1;
+  if (record_arch_list_add_reg (regcache, I386_ECX_REGNUM))
+    return -1;
+  if (record_arch_list_add_reg (regcache, I386_EDX_REGNUM))
+    return -1;
+  if (record_arch_list_add_reg (regcache, I386_EBX_REGNUM))
+    return -1;
+  if (record_arch_list_add_reg (regcache, I386_ESP_REGNUM))
+    return -1;
+  if (record_arch_list_add_reg (regcache, I386_EBP_REGNUM))
+    return -1;
+  if (record_arch_list_add_reg (regcache, I386_ESI_REGNUM))
+    return -1;
+  if (record_arch_list_add_reg (regcache, I386_EDI_REGNUM))
+    return -1;
+  if (record_arch_list_add_reg (regcache, I386_EFLAGS_REGNUM))
+    return -1;
+
+  return 0;
+}
+
 static struct linux_record_tdep i386_linux_record_tdep;

 /* i386_canonicalize_syscall maps from the native i386 Linux set
@@ -388,6 +415,14 @@ i386_linux_intx80_sysenter_record (struc

   regcache_raw_read_signed (regcache, I386_EAX_REGNUM, &syscall_native);

+  if (syscall_native == 119 || syscall_native == 173)
+   {
+     /* sys_sigreturn sys_rt_sigreturn */
+     if (i386_all_but_ip_registers_record (regcache))
+       return -1;
+     return 0;
+   }
+
   syscall_gdb = i386_canonicalize_syscall (syscall_native);

   if (syscall_gdb < 0)
@@ -409,6 +444,41 @@ i386_linux_intx80_sysenter_record (struc

   return 0;
 }
+
+enum i386_linux_signal_stack {
+  xstate = 270,
+  frame_size = 732,
+};
+
+int
+i386_linux_record_signal (struct gdbarch *gdbarch,
+                          struct regcache *regcache,
+                          enum target_signal signal)
+{
+  ULONGEST esp;
+
+  if (i386_all_but_ip_registers_record (regcache))
+    return -1;
+
+  if (record_arch_list_add_reg (regcache, I386_EIP_REGNUM))
+    return -1;
+
+  /* Record the change in the stack.  */
+  regcache_raw_read_unsigned (regcache, I386_ESP_REGNUM, &esp);
+  /* This is for xstate.
+     sp -= sizeof (struct _fpstate);  */
+  esp -= xstate;
+  /* This is for frame_size.
+     sp -= sizeof (struct rt_sigframe);  */
+  esp -= frame_size;
+  if (record_arch_list_add_mem (esp, xstate + frame_size))
+    return -1;
+
+  if (record_arch_list_add_end ())
+    return -1;
+
+  return 0;
+}


 /* The register sets used in GNU/Linux ELF core-dumps are identical to
@@ -504,6 +574,7 @@ i386_linux_init_abi (struct gdbarch_info
   tdep->sc_num_regs = ARRAY_SIZE (i386_linux_sc_reg_offset);

   set_gdbarch_process_record (gdbarch, i386_process_record);
+  set_gdbarch_process_record_signal (gdbarch, i386_linux_record_signal);

   /* Initialize the i386_linux_record_tdep.  */
   /* These values are the size of the type that will be used in a system

Attachment: prec-support-signal-i386-linux.txt
Description: Text document


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