diff --git a/src/RecordSession.cc b/src/RecordSession.cc index 56aa273a147..690056cf10d 100644 --- a/src/RecordSession.cc +++ b/src/RecordSession.cc @@ -1609,15 +1609,42 @@ static ssize_t get_sigframe_size(SupportedArch arch) { } } -static remote_code_ptr get_sigframe_ip(RecordTask *t, remote_ptr frame_ptr) +template +static remote_ptr get_sigframe_ip_ptr(remote_ptr frame_ptr); + +template <> +remote_ptr get_sigframe_ip_ptr(remote_ptr frame_ptr) { + return REMOTE_PTR_FIELD(REMOTE_PTR_FIELD(REMOTE_PTR_FIELD(REMOTE_PTR_FIELD(frame_ptr, uc), uc_mcontext), regs), pc); +} + +template <> +remote_ptr get_sigframe_ip_ptr(remote_ptr frame_ptr) { + return REMOTE_PTR_FIELD(REMOTE_PTR_FIELD(REMOTE_PTR_FIELD(frame_ptr, uc), uc_mcontext), ip); +} + +template <> +remote_ptr get_sigframe_ip_ptr(remote_ptr frame_ptr) { + return REMOTE_PTR_FIELD(REMOTE_PTR_FIELD(REMOTE_PTR_FIELD(frame_ptr, uc), uc_mcontext), ip); +} + +template +static remote_code_ptr get_sigframe_ip_arch(RecordTask *t, remote_ptr frame_ptr) { - return t->read_mem(REMOTE_PTR_FIELD(REMOTE_PTR_FIELD(REMOTE_PTR_FIELD(REMOTE_PTR_FIELD(frame_ptr, uc), uc_mcontext), regs), pc)); + return t->read_mem(get_sigframe_ip_ptr(frame_ptr)); +} + +static remote_code_ptr get_sigframe_ip(RecordTask *t, remote_ptr frame_ptr) { + RR_ARCH_FUNCTION(get_sigframe_ip_arch, t->arch(), t, frame_ptr.as_int()); } -static void set_sigframe_ip(RecordTask *t, remote_ptr frame_ptr, remote_code_ptr ip) +template +static void set_sigframe_ip_arch(RecordTask *t, remote_ptr frame_ptr, remote_code_ptr ip) { - t->write_mem(REMOTE_PTR_FIELD(REMOTE_PTR_FIELD(REMOTE_PTR_FIELD(REMOTE_PTR_FIELD(frame_ptr, uc), uc_mcontext), regs), pc), - ip.register_value()); + t->write_mem(get_sigframe_ip_ptr(frame_ptr), (typename Arch::unsigned_long)ip.register_value()); +} + +static void set_sigframe_ip(RecordTask *t, remote_ptr frame_ptr, remote_code_ptr ip) { + RR_ARCH_FUNCTION(set_sigframe_ip_arch, t->arch(), t, frame_ptr.as_int(), ip); } /** diff --git a/src/kernel_abi.h b/src/kernel_abi.h index 0a6f4b3d633..3aa3180c5ac 100644 --- a/src/kernel_abi.h +++ b/src/kernel_abi.h @@ -2051,6 +2051,21 @@ struct X64Arch : public BaseArch { }; RR_VERIFY_TYPE_ARCH(SupportedArch::x86_64, ::sigcontext, sigcontext); + struct ucontext { + unsigned_long uc_flags; + ptr uc_link; + stack_t uc_stack; + struct sigcontext uc_mcontext; + kernel_sigset_t uc_sigmask; + }; + + struct rt_sigframe { + ptr pretcode; + struct ucontext uc; + siginfo_t info; + // Extended ISA state follows + }; + struct user_fpregs_struct { uint16_t cwd; uint16_t swd; @@ -2274,6 +2289,21 @@ struct X86Arch : public BaseArch { }; RR_VERIFY_TYPE_ARCH(SupportedArch::x86, ::sigcontext, sigcontext); + struct ucontext { + unsigned int uc_flags; + unsigned int uc_link; + stack_t uc_stack; + struct sigcontext uc_mcontext; + kernel_sigset_t uc_sigmask; + }; + + struct rt_sigframe { + ptr pretcode; + struct ucontext uc; + siginfo_t info; + // Extended ISA state follows + }; + struct user { user_regs_struct regs; int u_fpvalid;