]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Arch-abstraction:
authorNicholas Nethercote <n.nethercote@gmail.com>
Wed, 13 Oct 2004 14:42:57 +0000 (14:42 +0000)
committerNicholas Nethercote <n.nethercote@gmail.com>
Wed, 13 Oct 2004 14:42:57 +0000 (14:42 +0000)
- factor out differences in ucontext types across different archs.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2751

coregrind/core.h
coregrind/vg_proxylwp.c
coregrind/vg_signals.c
coregrind/x86-linux/core_platform.h

index 01808080957352b560788675bcc3bd4930a09440..197fe887d4c99083ba4499a601061ce5ca486f79 100644 (file)
@@ -1361,7 +1361,7 @@ void VG_(sanity_check_proxy)(void);
    back into the proxy's main loop, so it doesn't return. */
 __attribute__ ((__noreturn__))
 extern void VG_(proxy_handlesig)( const vki_ksiginfo_t *siginfo, 
-                                 const struct vki_sigcontext *sigcontext );
+                                 Addr ip, Int sysnum );
 
 /* ---------------------------------------------------------------------
    Exports of vg_syscalls.c
index 8c57639c552ab828b8b66d4ea312e7b1cd328637..885644411632f2d5b351adf0f48e8a9fd925279b 100644 (file)
@@ -402,13 +402,10 @@ void VG_(proxy_shutdown)(void)
    handler is being run with all signals blocked; the longjmp is
    there to make sure they stay masked until the application thread is
    ready to run its signal handler. */
-void VG_(proxy_handlesig)(const vki_ksiginfo_t *siginfo, 
-                         const struct vki_sigcontext *sigcontext)
+void VG_(proxy_handlesig)(const vki_ksiginfo_t *siginfo, Addr ip, Int sysnum)
 {
    UChar local;
    ProxyLWP *px = LWP_TSD(&local);
-   Addr eip = sigcontext->eip;
-   Int eax = sigcontext->eax;
 
    vg_assert(siginfo->si_signo != 0);
    if (px->siginfo.si_signo != 0) {
@@ -423,7 +420,7 @@ void VG_(proxy_handlesig)(const vki_ksiginfo_t *siginfo,
 
    /* First look to see if the EIP is within our interesting ranges
       near a syscall to work out what should happen. */
-   if (sys_before <= eip && eip <= sys_restarted) {
+   if (sys_before <= ip && ip <= sys_restarted) {
       /* We are before the syscall actually ran, or it did run and
         wants to be restarted.  Either way, set the return code to
         indicate a restart.  This is not really any different from
@@ -431,15 +428,15 @@ void VG_(proxy_handlesig)(const vki_ksiginfo_t *siginfo,
         the proxy and machine state here. */
       vg_assert(px->state == PXS_RunSyscall);
       vg_assert(PLATFORM_SYSCALL_RET(px->tst->arch) == -VKI_ERESTARTSYS);
-   } else if (sys_after <= eip && eip <= sys_done) {
+   } else if (sys_after <= ip && ip <= sys_done) {
       /* We're after the syscall.  Either it was interrupted by the
         signal, or the syscall completed normally.  In either case
-        eax contains the correct syscall return value, and the new
-        state is effectively PXS_SysDone. */
+         the usual register contains the correct syscall return value, and
+         the new state is effectively PXS_SysDone. */
       vg_assert(px->state == PXS_RunSyscall ||
                px->state == PXS_SysDone);
       px->state = PXS_SysDone;
-      PLATFORM_SYSCALL_RET(px->tst->arch) = eax;
+      PLATFORM_SYSCALL_RET(px->tst->arch) = sysnum;
    }
    px_printf("  signalled in state %s\n", pxs_name(px->state));
 
index 9bd8406fee4b2a24bd6551fa7f2aeced66bc0991..80cc82a158f9bd6521296c5d9ba77a830b80e7d5 100644 (file)
@@ -1652,7 +1652,8 @@ void vg_async_signalhandler ( Int sigNo, vki_ksiginfo_t *info, struct vki_uconte
 
    vg_assert(VG_(gettid)() != VG_(main_pid));
 
-   VG_(proxy_handlesig)(info, &uc->uc_mcontext);
+   VG_(proxy_handlesig)(info, UCONTEXT_INSTR_PTR(uc),
+                              UCONTEXT_SYSCALL_NUM(uc));
 }
 
 /* 
@@ -1679,7 +1680,8 @@ void vg_sync_signalhandler ( Int sigNo, vki_ksiginfo_t *info, struct vki_ucontex
         proxy LWP code has a bug) */
       vg_assert(info->si_code <= VKI_SI_USER);
 
-      VG_(proxy_handlesig)(info, &uc->uc_mcontext);
+      VG_(proxy_handlesig)(info, UCONTEXT_INSTR_PTR(uc),
+                                 UCONTEXT_SYSCALL_NUM(uc));
       return;
    }
 
@@ -1852,9 +1854,9 @@ void vg_sync_signalhandler ( Int sigNo, vki_ksiginfo_t *info, struct vki_ucontex
       if (0)
         VG_(kill_self)(sigNo);         /* generate a core dump */
       VG_(core_panic_at)("Killed by fatal signal",
-                         VG_(get_ExeContext2)(uc->uc_mcontext.eip,
-                                              uc->uc_mcontext.ebp,
-                                              uc->uc_mcontext.esp,
+                         VG_(get_ExeContext2)(UCONTEXT_INSTR_PTR(uc),
+                                              UCONTEXT_FRAME_PTR(uc),
+                                              UCONTEXT_STACK_PTR(uc),
                                               VG_(valgrind_last)));
    }
 }
@@ -1876,7 +1878,8 @@ static void proxy_sigvg_handler(int signo, vki_ksiginfo_t *si, struct vki_uconte
       vg_assert(si->si_code == VKI_SI_TKILL);
       vg_assert(si->_sifields._kill._pid == VG_(main_pid));
    
-      VG_(proxy_handlesig)(si, &uc->uc_mcontext);
+      VG_(proxy_handlesig)(si, UCONTEXT_INSTR_PTR(uc),
+                               UCONTEXT_SYSCALL_NUM(uc));
    }
 }
 
index 6ffe040c6b04036d525b7c0d8408a89cd241dd77..d599811d6185df24935bc3613634702ba55d3a5f 100644 (file)
@@ -84,7 +84,14 @@ extern Int VG_(sys_get_thread_area) ( ThreadId tid,
    address, return a linear address, and do limit checks too. */
 extern Addr VG_(do_useseg) ( UInt seg_selector, Addr virtual_addr );
 
+/* ---------------------------------------------------------------------
+   ucontext stuff
+   ------------------------------------------------------------------ */
 
+#define UCONTEXT_INSTR_PTR(uc)   ((uc)->uc_mcontext.eip)
+#define UCONTEXT_STACK_PTR(uc)   ((uc)->uc_mcontext.esp)
+#define UCONTEXT_FRAME_PTR(uc)   ((uc)->uc_mcontext.ebp)
+#define UCONTEXT_SYSCALL_NUM(uc) ((uc)->uc_mcontext.eax)
 
 /*--------------------------------------------------------------------*/
 /*--- end                                                          ---*/