Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 2 Nov 2008 21:33:54 GMT
From:      Peter Wemm <peter@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 152379 for review
Message-ID:  <200811022133.mA2LXsKF039051@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=152379

Change 152379 by peter@peter_overcee on 2008/11/02 21:33:04

	Initial pass at getting signals delivered to userland and back again.

Affected files ...

.. //depot/projects/valgrind/coregrind/m_sigframe/sigframe-amd64-freebsd.c#4 edit

Differences ...

==== //depot/projects/valgrind/coregrind/m_sigframe/sigframe-amd64-freebsd.c#4 (text+ko) ====

@@ -114,10 +114,10 @@
    /* Sig handler's return address */
    Addr retaddr;
 
-   Int sigNo;
+   Int  sigNo;
    Addr psigInfo;	/* code or pointer to sigContext */
    Addr puContext;	/* points to uContext */
-   Addr addr;		/* secret 4th argument */
+   Addr addr;		/* "secret" 4th argument */
    Addr phandler;	/* "action" or "handler" */
 
    /* pointed to by puContext */
@@ -126,8 +126,6 @@
    /* pointed to by psiginfo */
    vki_siginfo_t sigInfo;
 
-   /* AAA:QQQ: struct _vki_fpstate fpstate; */
-
    struct vg_sigframe vg;
 };
 
@@ -347,33 +345,35 @@
    // FIXME: save_i387(&tst->arch, fpstate);
 
 #  define SC2(reg,REG)  sc->reg = tst->arch.vex.guest_##REG
+   SC2(rdi,RDI);
+   SC2(rsi,RSI);
+   SC2(rdx,RDX);
+   SC2(rcx,RCX);
    SC2(r8,R8);
    SC2(r9,R9);
+   SC2(rax,RAX);
+   SC2(rbx,RBX);
+   SC2(rbp,RBP);
    SC2(r10,R10);
    SC2(r11,R11);
    SC2(r12,R12);
    SC2(r13,R13);
    SC2(r14,R14);
    SC2(r15,R15);
-   SC2(rdi,RDI);
-   SC2(rsi,RSI);
-   SC2(rbp,RBP);
-   SC2(rbx,RBX);
-   SC2(rdx,RDX);
-   SC2(rax,RAX);
-   SC2(rcx,RCX);
-   SC2(rsp,RSP);
-
+   /* XXX trapno */
+   sc->addr = (UWord)si->si_addr;
+   /* XXX flags */
+   /* XXX err */
    SC2(rip,RIP);
+   // FIXME: SC2(cs,CS);
    sc->rflags = LibVEX_GuestAMD64_get_rflags(&tst->arch.vex);
-   // FIXME: SC2(cs,CS);
-   // FIXME: SC2(gs,GS);
-   // FIXME: SC2(fs,FS);
-   /* XXX err */
-   /* XXX trapno */
+   SC2(rsp,RSP);
+   /* XXX ss */
+   sc->len = sizeof(*sc);
+   sc->fpformat = VKI_FPFMT_NODEV;
+   sc->ownedfp = VKI_FPOWNED_NONE;
 #  undef SC2
 
-   /* sc->cr2 = (UWord)si->_sifields._sigfault._addr; */
 }
 
 
@@ -461,9 +461,10 @@
       return rsp_top_of_frame;
 
    /* retaddr, siginfo, uContext fields are to be written */
-   VG_TRACK( pre_mem_write, Vg_CoreSignal, tst->tid, "rt signal handler frame", 
+   VG_TRACK( pre_mem_write, Vg_CoreSignal, tst->tid, "signal handler frame", 
 	     rsp, offsetof(struct sigframe, vg) );
 
+   frame->sigNo = sigNo;
    frame->retaddr = (Addr)&VG_(amd64_freebsd_SUBST_FOR_sigreturn);
    if ((flags & VKI_SA_SIGINFO) == 0)
       frame->psigInfo = (Addr)siginfo->si_code;
@@ -472,13 +473,15 @@
    frame->puContext = (Addr)&frame->uContext;
    VG_(memcpy)(&frame->sigInfo, siginfo, sizeof(vki_siginfo_t));
 
+#if 0 /* QQQ */
    /* SIGILL defines addr to be the faulting address */
    if (sigNo == VKI_SIGILL && siginfo->si_code > 0)
       frame->sigInfo.si_addr = (void*)tst->arch.vex.guest_RIP;
+#endif
 
    synth_ucontext(tst->tid, siginfo, mask, &frame->uContext /*, &frame->fpstate*/);
 
-   frame->uContext.__spare__[0] = ((unsigned long)&frame->vg) >> 32;
+   frame->uContext.__spare__[0] = ((unsigned long)&frame->vg) >> 32ul;
    frame->uContext.__spare__[1] = 0x31415926;
    frame->uContext.__spare__[2] = (unsigned long)&frame->vg;
    frame->uContext.__spare__[3] = 0x53589793;
@@ -611,7 +614,7 @@
       return 0;
    }
 
-   addr = uc->__spare__[2] | (((unsigned long)uc->__spare__[0]) << 32);
+   addr = (unsigned long)uc->__spare__[2] | (((unsigned long)uc->__spare__[0]) << 32ul);
    if (restore_vg_sigframe(tst, (struct vg_sigframe *)addr, sigNo))
       restore_sigcontext(tst, uc /*, &frame->fpstate*/ );
 
@@ -626,8 +629,6 @@
    SizeT	 size;
    Int		 sigNo;
 
-   vg_assert(isRT);
-
    tst = VG_(get_ThreadState)(tid);
 
    /* Correctly reestablish the frame base address. */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200811022133.mA2LXsKF039051>