--- 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