]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Propagate the error number in x86 signal contexts to the client.
authorTom Hughes <tom@compton.nu>
Fri, 13 Jun 2008 08:37:49 +0000 (08:37 +0000)
committerTom Hughes <tom@compton.nu>
Fri, 13 Jun 2008 08:37:49 +0000 (08:37 +0000)
Fixes bug #163933.

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

coregrind/m_sigframe/sigframe-amd64-linux.c
coregrind/m_sigframe/sigframe-x86-linux.c
coregrind/m_signals.c

index f042a8dfd733be08a8abd2f617a886090649047a..0aed329f122a8ad477306ea1ce71f58a87ce9f8f 100644 (file)
@@ -321,8 +321,8 @@ struct rt_sigframe
    bits of sigcontext at the moment.
 */
 static 
-void synth_ucontext(ThreadId tid, const vki_siginfo_t *si, Int trapno,
-                    const vki_sigset_t *set, 
+void synth_ucontext(ThreadId tid, const vki_siginfo_t *si,
+                    UWord trapno, UWord err, const vki_sigset_t *set, 
                     struct vki_ucontext *uc, struct _vki_fpstate *fpstate)
 {
    ThreadState *tst = VG_(get_ThreadState)(tid);
@@ -361,8 +361,8 @@ void synth_ucontext(ThreadId tid, const vki_siginfo_t *si, Int trapno,
    // FIXME: SC2(cs,CS);
    // FIXME: SC2(gs,GS);
    // FIXME: SC2(fs,FS);
-   /* XXX err */
    sc->trapno = trapno;
+   sc->err = err;
 #  undef SC2
 
    sc->cr2 = (UWord)si->_sifields._sigfault._addr;
@@ -445,7 +445,8 @@ static Addr build_rt_sigframe(ThreadState *tst,
    struct rt_sigframe *frame;
    Addr rsp = rsp_top_of_frame;
    Int sigNo = siginfo->si_signo;
-   Int trapno;
+   UWord trapno;
+   UWord err;
 
    rsp -= sizeof(*frame);
    rsp = VG_ROUNDDN(rsp, 16);
@@ -463,10 +464,13 @@ static Addr build_rt_sigframe(ThreadState *tst,
    else
       frame->retaddr = (Addr)&VG_(amd64_linux_SUBST_FOR_rt_sigreturn);
 
-   if (siguc)
+   if (siguc) {
       trapno = siguc->uc_mcontext.trapno;
-   else
+      err = siguc->uc_mcontext.err;
+   } else {
       trapno = 0;
+      err = 0;
+   }
 
    VG_(memcpy)(&frame->sigInfo, siginfo, sizeof(vki_siginfo_t));
 
@@ -475,7 +479,8 @@ static Addr build_rt_sigframe(ThreadState *tst,
       frame->sigInfo._sifields._sigfault._addr 
          = (void*)tst->arch.vex.guest_RIP;
 
-   synth_ucontext(tst->tid, siginfo, trapno, mask, &frame->uContext, &frame->fpstate);
+   synth_ucontext(tst->tid, siginfo, trapno, err, mask,
+                  &frame->uContext, &frame->fpstate);
 
    VG_TRACK( post_mem_write,  Vg_CoreSignal, tst->tid, 
              rsp, offsetof(struct rt_sigframe, vg) );
index 0f3e57ded35c9e7ca9b61cb29a60aa4df6ad6daa..1fa345c41da9966557b9153d53a7ae490e02a599 100644 (file)
@@ -345,8 +345,8 @@ struct rt_sigframe
    bits of sigcontext at the moment.
 */
 static 
-void synth_ucontext(ThreadId tid, const vki_siginfo_t *si, Int trapno,
-                    const vki_sigset_t *set, 
+void synth_ucontext(ThreadId tid, const vki_siginfo_t *si,
+                    UWord trapno, UWord err, const vki_sigset_t *set, 
                     struct vki_ucontext *uc, struct _vki_fpstate *fpstate)
 {
    ThreadState *tst = VG_(get_ThreadState)(tid);
@@ -383,7 +383,7 @@ void synth_ucontext(ThreadId tid, const vki_siginfo_t *si, Int trapno,
    SC2(ss,SS);
    /* XXX esp_at_signal */
    sc->trapno = trapno;
-   /* XXX err */
+   sc->err = err;
 #  undef SC2
 
    sc->cr2 = (UInt)si->_sifields._sigfault._addr;
@@ -466,7 +466,8 @@ static Addr build_sigframe(ThreadState *tst,
    struct sigframe *frame;
    Addr esp = esp_top_of_frame;
    Int sigNo = siginfo->si_signo;
-   Int trapno;
+   UWord trapno;
+   UWord err;
    struct vki_ucontext uc;
 
    vg_assert((flags & VKI_SA_SIGINFO) == 0);
@@ -489,12 +490,15 @@ static Addr build_sigframe(ThreadState *tst,
    else
       frame->retaddr = (Addr)&VG_(x86_linux_SUBST_FOR_sigreturn);
 
-   if (siguc)
+   if (siguc) {
       trapno = siguc->uc_mcontext.trapno;
-   else
+      err = siguc->uc_mcontext.err;
+   } else {
       trapno = 0;
+      err = 0;
+   }
 
-   synth_ucontext(tst->tid, siginfo, trapno, mask, &uc, &frame->fpstate);
+   synth_ucontext(tst->tid, siginfo, trapno, err, mask, &uc, &frame->fpstate);
 
    VG_(memcpy)(&frame->sigContext, &uc.uc_mcontext, 
               sizeof(struct vki_sigcontext));
@@ -520,7 +524,8 @@ static Addr build_rt_sigframe(ThreadState *tst,
    struct rt_sigframe *frame;
    Addr esp = esp_top_of_frame;
    Int sigNo = siginfo->si_signo;
-   Int trapno;
+   UWord trapno;
+   UWord err;
 
    vg_assert((flags & VKI_SA_SIGINFO) != 0);
 
@@ -542,10 +547,13 @@ static Addr build_rt_sigframe(ThreadState *tst,
    else
       frame->retaddr = (Addr)&VG_(x86_linux_SUBST_FOR_rt_sigreturn);
 
-   if (siguc)
+   if (siguc) {
       trapno = siguc->uc_mcontext.trapno;
-   else
+      err = siguc->uc_mcontext.err;
+   } else {
       trapno = 0;
+      err = 0;
+   }
 
    frame->psigInfo = (Addr)&frame->sigInfo;
    frame->puContext = (Addr)&frame->uContext;
@@ -556,7 +564,8 @@ static Addr build_rt_sigframe(ThreadState *tst,
       frame->sigInfo._sifields._sigfault._addr 
          = (void*)tst->arch.vex.guest_EIP;
 
-   synth_ucontext(tst->tid, siginfo, trapno, mask, &frame->uContext, &frame->fpstate);
+   synth_ucontext(tst->tid, siginfo, trapno, err, mask,
+                  &frame->uContext, &frame->fpstate);
 
    VG_TRACK( post_mem_write,  Vg_CoreSignal, tst->tid, 
              esp, offsetof(struct rt_sigframe, vg) );
index 8057c8884827fb3877e6e79182d99dddbe9a6ddd..dd9cd84de3611a3355e9b3dad64988260b41d5f5 100644 (file)
@@ -1498,6 +1498,8 @@ void VG_(synth_sigtrap)(ThreadId tid)
 #if defined(VGA_x86) || defined(VGA_amd64)
    uc.uc_mcontext.trapno = 3;     /* tjh: this is the x86 trap number
                                           for a breakpoint trap... */
+   uc.uc_mcontext.err = 0;        /* tjh: no error code for x86
+                                          breakpoint trap... */
 #endif
 
    resume_scheduler(tid);