|
From: <sv...@va...> - 2008-06-13 08:37:43
|
Author: tom
Date: 2008-06-13 09:37:49 +0100 (Fri, 13 Jun 2008)
New Revision: 8229
Log:
Propagate the error number in x86 signal contexts to the client.
Fixes bug #163933.
Modified:
trunk/coregrind/m_sigframe/sigframe-amd64-linux.c
trunk/coregrind/m_sigframe/sigframe-x86-linux.c
trunk/coregrind/m_signals.c
Modified: trunk/coregrind/m_sigframe/sigframe-amd64-linux.c
===================================================================
--- trunk/coregrind/m_sigframe/sigframe-amd64-linux.c 2008-06-13 07:44:02 UTC (rev 8228)
+++ trunk/coregrind/m_sigframe/sigframe-amd64-linux.c 2008-06-13 08:37:49 UTC (rev 8229)
@@ -321,8 +321,8 @@
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 @@
// 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 @@
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 @@
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 @@
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) );
Modified: trunk/coregrind/m_sigframe/sigframe-x86-linux.c
===================================================================
--- trunk/coregrind/m_sigframe/sigframe-x86-linux.c 2008-06-13 07:44:02 UTC (rev 8228)
+++ trunk/coregrind/m_sigframe/sigframe-x86-linux.c 2008-06-13 08:37:49 UTC (rev 8229)
@@ -345,8 +345,8 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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) );
Modified: trunk/coregrind/m_signals.c
===================================================================
--- trunk/coregrind/m_signals.c 2008-06-13 07:44:02 UTC (rev 8228)
+++ trunk/coregrind/m_signals.c 2008-06-13 08:37:49 UTC (rev 8229)
@@ -1498,6 +1498,8 @@
#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);
|