one for Darwin. Down from 11.
Carve out a new function 'track_frame_memory' that communicates to the
tool the allocation of a new stack frame. This was slightly different on
Linux and Darwin but should be the same on both platforms.
New files: priv_sigframe.h and sigframe-common.c
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15109
m_scheduler/priv_sema.h \
m_scheduler/priv_sched-lock.h \
m_scheduler/priv_sched-lock-impl.h \
+ m_sigframe/priv_sigframe.h \
m_syswrap/priv_types_n_macros.h \
m_syswrap/priv_syswrap-generic.h \
m_syswrap/priv_syswrap-linux.h \
m_scheduler/sema.c \
m_scheduler/sched-lock.c \
m_scheduler/sched-lock-generic.c \
+ m_sigframe/sigframe-common.c \
m_sigframe/sigframe-x86-linux.c \
m_sigframe/sigframe-amd64-linux.c \
m_sigframe/sigframe-ppc32-linux.c \
--- /dev/null
+/* -*- mode: C; c-basic-offset: 3; -*- */
+
+/*--------------------------------------------------------------------*/
+/*--- Module-local header file for m_sigframe. ---*/
+/*--- priv_sigframe.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+ This file is part of Valgrind, a dynamic binary instrumentation
+ framework.
+
+ Copyright (C) 2015-2015 Florian Krohm
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ The GNU General Public License is contained in the file COPYING.
+*/
+
+#ifndef __PRIV_SIGFRAME_H
+#define __PRIV_SIGFRAME_H
+
+#include "pub_core_basics.h" // types
+#include "pub_core_threadstate.h" // ThreadState
+
+/* --------------- Implemented in sigframe-common.c ---------------*/
+
+Bool ML_(sf_extend_stack)( const ThreadState *tst, Addr addr, SizeT size );
+
+#endif // __PRIV_SIGFRAME_H
+
+/*--------------------------------------------------------------------*/
+/*--- end ---*/
+/*--------------------------------------------------------------------*/
};
-/* Extend the stack segment downwards if needed so as to ensure the
- new signal frames are mapped to something. Return a Bool
- indicating whether or not the operation was successful.
-*/
-static Bool extend ( ThreadState *tst, Addr addr, SizeT size )
-{
- ThreadId tid = tst->tid;
- VG_TRACK( new_mem_stack_signal, addr - VG_STACK_REDZONE_SZB,
- size + VG_STACK_REDZONE_SZB, tid );
- return True;
-}
-
-
/* Create a signal frame for thread 'tid'. Make a 3-arg frame
regardless of whether the client originally requested a 1-arg
version (no SA_SIGINFO) or a 3-arg one (SA_SIGINFO) since in the
entry to a function. */
tst = VG_(get_ThreadState)(tid);
- if (!extend(tst, rsp, sp_top_of_frame - rsp))
+ if (! ML_(sf_extend_stack)(tst, rsp, sp_top_of_frame - rsp))
return;
vg_assert(VG_IS_16_ALIGNED(rsp+8));
#include "pub_core_tooliface.h"
#include "pub_core_trampoline.h"
#include "pub_core_sigframe.h" /* self */
+#include "priv_sigframe.h"
/* This module creates and removes signal frames for signal deliveries
on amd64-linux.
}
-/* Extend the stack segment downwards if needed so as to ensure the
- new signal frames are mapped to something. Return a Bool
- indicating whether or not the operation was successful.
-*/
-static Bool extend ( ThreadState *tst, Addr addr, SizeT size )
-{
- ThreadId tid = tst->tid;
- NSegment const* stackseg = NULL;
-
- if (VG_(extend_stack)(tid, addr)) {
- stackseg = VG_(am_find_nsegment)(addr);
- if (0 && stackseg)
- VG_(printf)("frame=%#lx seg=%#lx-%#lx\n",
- addr, stackseg->start, stackseg->end);
- }
-
- if (stackseg == NULL || !stackseg->hasR || !stackseg->hasW) {
- VG_(message)(
- Vg_UserMsg,
- "Can't extend stack to %#lx during signal delivery for thread %d:\n",
- addr, tid);
- if (stackseg == NULL)
- VG_(message)(Vg_UserMsg, " no stack segment\n");
- else
- VG_(message)(Vg_UserMsg, " too small or bad protection modes\n");
-
- /* set SIGSEGV to default handler */
- VG_(set_default_handler)(VKI_SIGSEGV);
- VG_(synth_fault_mapping)(tid, addr);
-
- /* The whole process should be about to die, since the default
- action of SIGSEGV to kill the whole process. */
- return False;
- }
-
- /* For tracking memory events, indicate the entire frame has been
- allocated. */
- VG_TRACK( new_mem_stack_signal, addr - VG_STACK_REDZONE_SZB,
- size + VG_STACK_REDZONE_SZB, tid );
-
- return True;
-}
-
-
/* Build the Valgrind-specific part of a signal frame. */
static void build_vg_sigframe(struct vg_sigframe *frame,
rsp = VG_ROUNDDN(rsp, 16) - 8;
frame = (struct rt_sigframe *)rsp;
- if (!extend(tst, rsp, sizeof(*frame)))
+ if (! ML_(sf_extend_stack)(tst, rsp, sizeof(*frame)))
return rsp_top_of_frame;
/* retaddr, siginfo, uContext fields are to be written */
#include "pub_core_signals.h"
#include "pub_core_tooliface.h"
#include "pub_core_trampoline.h"
-#include "pub_core_transtab.h" // VG_(discard_translations)
+#include "priv_sigframe.h"
/* This uses the hack of dumping the vex guest state along with both
struct sigframe sig;
};
-static Bool extend ( ThreadState *tst, Addr addr, SizeT size )
-{
- ThreadId tid = tst->tid;
- NSegment const* stackseg = NULL;
-
- if (VG_(extend_stack)(tid, addr)) {
- stackseg = VG_(am_find_nsegment)(addr);
- if (0 && stackseg)
- VG_(printf)("frame=%#lx seg=%#lx-%#lx\n",
- addr, stackseg->start, stackseg->end);
- }
-
- if (stackseg == NULL || !stackseg->hasR || !stackseg->hasW) {
- VG_(message)(
- Vg_UserMsg,
- "Can't extend stack to %#lx during signal delivery for thread %d:",
- addr, tid);
- if (stackseg == NULL)
- VG_(message)(Vg_UserMsg, " no stack segment");
- else
- VG_(message)(Vg_UserMsg, " too small or bad protection modes");
-
- /* set SIGSEGV to default handler */
- VG_(set_default_handler)(VKI_SIGSEGV);
- VG_(synth_fault_mapping)(tid, addr);
-
- /* The whole process should be about to die, since the default
- action of SIGSEGV to kill the whole process. */
- return False;
- }
-
- /* For tracking memory events, indicate the entire frame has been
- allocated. */
- VG_TRACK( new_mem_stack_signal, addr - VG_STACK_REDZONE_SZB,
- size + VG_STACK_REDZONE_SZB, tid );
-
- return True;
-}
static void synth_ucontext( ThreadId tid, const vki_siginfo_t *si,
UWord trapno, UWord err, const vki_sigset_t *set,
sp -= size;
sp = VG_ROUNDDN(sp, 16);
- if(!extend(tst, sp, size))
+ if(! ML_(sf_extend_stack)(tst, sp, size))
I_die_here; // XXX Incorrect behavior
#include "pub_core_basics.h"
#include "pub_core_vki.h"
-//ZZ #include "pub_core_vkiscnums.h"
#include "pub_core_libcsetjmp.h" // to keep _threadstate.h happy
#include "pub_core_threadstate.h"
#include "pub_core_aspacemgr.h"
#include "pub_core_signals.h"
#include "pub_core_tooliface.h"
#include "pub_core_trampoline.h"
-//ZZ #include "pub_core_transtab.h" // VG_(discard_translations)
+#include "priv_sigframe.h"
/* This uses the hack of dumping the vex guest state along with both
struct sigframe sig;
};
-static Bool extend ( ThreadState *tst, Addr addr, SizeT size )
-{
- ThreadId tid = tst->tid;
- NSegment const* stackseg = NULL;
-
- if (VG_(extend_stack)(tid, addr)) {
- stackseg = VG_(am_find_nsegment)(addr);
- if (0 && stackseg)
- VG_(printf)("frame=%#lx seg=%#lx-%#lx\n",
- addr, stackseg->start, stackseg->end);
- }
-
- if (stackseg == NULL || !stackseg->hasR || !stackseg->hasW) {
- VG_(message)(
- Vg_UserMsg,
- "Can't extend stack to %#lx during signal delivery for thread %d:",
- addr, tid);
- if (stackseg == NULL)
- VG_(message)(Vg_UserMsg, " no stack segment");
- else
- VG_(message)(Vg_UserMsg, " too small or bad protection modes");
-
- /* set SIGSEGV to default handler */
- VG_(set_default_handler)(VKI_SIGSEGV);
- VG_(synth_fault_mapping)(tid, addr);
-
- /* The whole process should be about to die, since the default
- action of SIGSEGV to kill the whole process. */
- return False;
- }
-
- /* For tracking memory events, indicate the entire frame has been
- allocated. */
- VG_TRACK( new_mem_stack_signal, addr - VG_STACK_REDZONE_SZB,
- size + VG_STACK_REDZONE_SZB, tid );
-
- return True;
-}
static void synth_ucontext( ThreadId tid, const vki_siginfo_t *si,
UWord trapno, UWord err, const vki_sigset_t *set,
sp -= size;
sp = VG_ROUNDDN(sp, 16);
- if (!extend(tst, sp, size))
+ if (! ML_(sf_extend_stack)(tst, sp, size))
return; // Give up. No idea if this is correct
struct rt_sigframe *rsf = (struct rt_sigframe *)sp;
--- /dev/null
+/* -*- mode: C; c-basic-offset: 3; -*- */
+
+/*--------------------------------------------------------------------*/
+/*--- Signal frames handling: stuff common to most/all platforms ---*/
+/*--- ---*/
+/*--- sigframe-common.c ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+ This file is part of Valgrind, a dynamic binary instrumentation
+ framework.
+
+ Copyright (C) 2000-2013 Nicholas Nethercote
+ njn@valgrind.org
+ Copyright (C) 2006-2013 OpenWorks Ltd
+ info@open-works.co.uk
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ The GNU General Public License is contained in the file COPYING.
+*/
+
+#include "pub_core_aspacemgr.h" // VG_(am_find_nsegment)
+#include "pub_core_signals.h" // VG_(extend_stack)
+#include "pub_core_libcprint.h" // VG_(umsg)
+#include "pub_core_tooliface.h" // VG_TRACK
+#include "pub_core_machine.h" // VG_STACK_REDZONE_SZB
+#include "priv_sigframe.h" // self
+
+
+/* For tracking memory events, indicate the entire frame has been
+ allocated. Except, don't mess with the area which
+ overlaps the previous frame's redzone. */
+static void track_frame_memory ( Addr addr, SizeT size, ThreadId tid )
+{
+ VG_TRACK( new_mem_stack_signal, addr - VG_STACK_REDZONE_SZB, size, tid );
+}
+
+#if defined(VGO_linux)
+
+/* Extend the stack segment downwards if needed so as to ensure the
+ new signal frames are mapped to something. Return a Bool
+ indicating whether or not the operation was successful. */
+Bool ML_(sf_extend_stack) ( const ThreadState *tst, Addr addr, SizeT size )
+{
+ ThreadId tid = tst->tid;
+ const NSegment *stackseg = NULL;
+
+ if (VG_(extend_stack)(tid, addr)) {
+ stackseg = VG_(am_find_nsegment)(addr);
+ if (0 && stackseg)
+ VG_(printf)("frame=%#lx seg=%#lx-%#lx\n",
+ addr, stackseg->start, stackseg->end);
+ }
+
+ if (stackseg == NULL || !stackseg->hasR || !stackseg->hasW) {
+ VG_(umsg)("Can't extend stack to %#lx during signal delivery for "
+ "thread %d:\n", addr, tid);
+ if (stackseg == NULL)
+ VG_(umsg)(" no stack segment\n");
+ else
+ VG_(umsg)(" too small or bad protection modes\n");
+
+ /* set SIGSEGV to default handler */
+ VG_(set_default_handler)(VKI_SIGSEGV);
+ VG_(synth_fault_mapping)(tid, addr);
+
+ /* The whole process should be about to die, since the default
+ action of SIGSEGV to kill the whole process. */
+ return False;
+ }
+
+ /* Tell the tool about the new memory */
+ track_frame_memory(addr, size, tid);
+
+ return True;
+}
+
+#elif defined(VGO_darwin)
+
+/* Extend the stack segment downwards if needed so as to ensure the
+ new signal frames are mapped to something. Return a Bool
+ indicating whether or not the operation was successful. */
+Bool ML_(sf_extend_stack) ( const ThreadState *tst, Addr addr, SizeT size )
+{
+ /* Tell the tool about the new memory */
+ track_frame_memory(addr, size, tst->tid);
+ return True;
+}
+
+#else
+#error unknown OS
+#endif
+
+/*--------------------------------------------------------------------*/
+/*--- end ---*/
+/*--------------------------------------------------------------------*/
#include "pub_core_signals.h"
#include "pub_core_tooliface.h"
#include "pub_core_trampoline.h"
-#include "pub_core_transtab.h" // VG_(discard_translations)
+#include "priv_sigframe.h"
struct vg_sig_private
{
struct vg_sig_private priv;
};
-/* Extend the stack segment downwards if needed so as to ensure the
- new signal frames are mapped to something. Return a Bool
- indicating whether or not the operation was successful.
-*/
-static Bool extend ( ThreadState *tst, Addr addr, SizeT size )
-{
- ThreadId tid = tst->tid;
- NSegment const* stackseg = NULL;
-
- if (VG_(extend_stack)(tid, addr)) {
- stackseg = VG_(am_find_nsegment)(addr);
- }
-
- if (stackseg == NULL || !stackseg->hasR || !stackseg->hasW)
- {
- VG_(message)(Vg_UserMsg,
- "Can't extend stack to %#lx during signal delivery for thread %d:\n",
- addr, tid );
- if (stackseg == NULL)
- VG_(message)( Vg_UserMsg, " no stack segment\n" );
- else
- VG_(message)( Vg_UserMsg, " too small or bad protection modes\n" );
-
- /* set SIGSEGV to default handler */
- VG_(set_default_handler)( VKI_SIGSEGV );
- VG_(synth_fault_mapping)( tid, addr );
-
- /* The whole process should be about to die, since the default
- action of SIGSEGV to kill the whole process. */
- return False;
- }
-
- /* For tracking memory events, indicate the entire frame has been
- allocated. */
- VG_TRACK( new_mem_stack_signal, addr - VG_STACK_REDZONE_SZB,
- size + VG_STACK_REDZONE_SZB, tid );
-
- return True;
-}
static
void setup_sigcontext2 ( ThreadState* tst, struct vki_sigcontext **sc1,
}
tst = VG_(get_ThreadState)(tid);
- if (!extend(tst, sp, sp_top_of_frame - sp))
+ if (! ML_(sf_extend_stack)(tst, sp, sp_top_of_frame - sp))
return;
vg_assert(VG_IS_8_ALIGNED(sp));
#include "pub_core_signals.h"
#include "pub_core_tooliface.h"
#include "pub_core_trampoline.h"
-#include "pub_core_transtab.h" /* VG_(discard_translations) */
+#include "priv_sigframe.h"
struct vg_sig_private {
UInt magicPI;
struct vg_sig_private priv;
};
-/* Extend the stack segment downwards if needed so as to ensure the new signal
- frames are mapped to something. Return a Bool indicating whether or not the
- operation was successful.
-*/
-static Bool extend ( ThreadState *tst, Addr addr, SizeT size )
-{
- ThreadId tid = tst->tid;
- NSegment const* stackseg = NULL;
-
- if (VG_(extend_stack)(tid, addr)) {
- stackseg = VG_(am_find_nsegment)(addr);
- }
-
- if (stackseg == NULL || !stackseg->hasR || !stackseg->hasW) {
- VG_(message)(Vg_UserMsg,
- "Can't extend stack to %#lx during signal delivery for thread %d:\n",
- addr, tid);
- if (stackseg == NULL)
- VG_(message)(Vg_UserMsg, " no stack segment\n");
- else
- VG_(message)(Vg_UserMsg, " too small or bad protection modes\n");
-
- /* set SIGSEGV to default handler */
- VG_(set_default_handler)(VKI_SIGSEGV);
- VG_(synth_fault_mapping)(tid, addr);
-
- /* The whole process should be about to die, since the default
- action of SIGSEGV to kill the whole process. */
- return False;
- }
-
- /* For tracking memory events, indicate the entire frame has been
- allocated. */
- VG_TRACK(new_mem_stack_signal, addr - VG_STACK_REDZONE_SZB,
- size + VG_STACK_REDZONE_SZB, tid);
-
- return True;
-}
static void setup_sigcontext ( ThreadState* tst, struct vki_sigcontext **sc1,
const vki_siginfo_t *si)
sp = sp_top_of_frame - sizeof(struct rt_sigframe);
tst = VG_(get_ThreadState)(tid);
- if (!extend(tst, sp, sp_top_of_frame - sp))
+ if (! ML_(sf_extend_stack)(tst, sp, sp_top_of_frame - sp))
return;
sp = VG_ROUNDDN(sp, 16);
#include "pub_core_tooliface.h"
#include "pub_core_trampoline.h"
#include "pub_core_transtab.h" // VG_(discard_translations)
-
+#include "priv_sigframe.h"
/* This module creates and removes signal frames for signal deliveries
on ppc32-linux.
//.. Vg_CoreSignal, zztid, VG_O_STACK_PTR, sizeof(Addr))
*/
-/* Extend the stack segment downwards if needed so as to ensure the
- new signal frames are mapped to something. Return a Bool
- indicating whether or not the operation was successful.
-*/
-static Bool extend ( ThreadState *tst, Addr addr, SizeT size )
-{
- ThreadId tid = tst->tid;
- NSegment const* stackseg = NULL;
-
- if (VG_(extend_stack)(tid, addr)) {
- stackseg = VG_(am_find_nsegment)(addr);
- if (0 && stackseg)
- VG_(printf)("frame=%#lx seg=%#lx-%#lx\n",
- addr, stackseg->start, stackseg->end);
- }
-
- if (stackseg == NULL || !stackseg->hasR || !stackseg->hasW) {
- VG_(message)(
- Vg_UserMsg,
- "Can't extend stack to %#lx during signal delivery for thread %d:\n",
- addr, tid);
- if (stackseg == NULL)
- VG_(message)(Vg_UserMsg, " no stack segment\n");
- else
- VG_(message)(Vg_UserMsg, " too small or bad protection modes\n");
-
- /* set SIGSEGV to default handler */
- VG_(set_default_handler)(VKI_SIGSEGV);
- VG_(synth_fault_mapping)(tid, addr);
-
- /* The whole process should be about to die, since the default
- action of SIGSEGV to kill the whole process. */
- return False;
- }
-
- /* For tracking memory events, indicate the entire frame has been
- allocated. */
- VG_TRACK( new_mem_stack_signal, addr - VG_STACK_REDZONE_SZB,
- size + VG_STACK_REDZONE_SZB, tid );
-
- return True;
-}
//.. /* Build the Valgrind-specific part of a signal frame. */
//..
tst = VG_(get_ThreadState)(tid);
- if (!extend(tst, sp, sp_top_of_frame - sp))
+ if (! ML_(sf_extend_stack)(tst, sp, sp_top_of_frame - sp))
return;
vg_assert(VG_IS_16_ALIGNED(sp));
#include "pub_core_tooliface.h"
#include "pub_core_trampoline.h"
#include "pub_core_transtab.h" // VG_(discard_translations)
-
+#include "priv_sigframe.h"
/* This module creates and removes signal frames for signal deliveries
on ppc64-linux.
} while (0)
-/* Extend the stack segment downwards if needed so as to ensure the
- new signal frames are mapped to something. Return a Bool
- indicating whether or not the operation was successful.
-*/
-static Bool extend ( ThreadState *tst, Addr addr, SizeT size )
-{
- ThreadId tid = tst->tid;
- NSegment const* stackseg = NULL;
-
- if (VG_(extend_stack)(tid, addr)) {
- stackseg = VG_(am_find_nsegment)(addr);
- if (0 && stackseg)
- VG_(printf)("frame=%#lx seg=%#lx-%#lx\n",
- addr, stackseg->start, stackseg->end);
- }
-
- if (stackseg == NULL || !stackseg->hasR || !stackseg->hasW) {
- VG_(message)(
- Vg_UserMsg,
- "Can't extend stack to %#lx during signal delivery for thread %d:\n",
- addr, tid);
- if (stackseg == NULL)
- VG_(message)(Vg_UserMsg, " no stack segment\n");
- else
- VG_(message)(Vg_UserMsg, " too small or bad protection modes\n");
-
- /* set SIGSEGV to default handler */
- VG_(set_default_handler)(VKI_SIGSEGV);
- VG_(synth_fault_mapping)(tid, addr);
-
- /* The whole process should be about to die, since the default
- action of SIGSEGV to kill the whole process. */
- return False;
- }
-
- /* For tracking memory events, indicate the entire frame has been
- allocated. */
- VG_TRACK( new_mem_stack_signal, addr - VG_STACK_REDZONE_SZB,
- size + VG_STACK_REDZONE_SZB, tid );
-
- return True;
-}
-
/* EXPORTED */
void VG_(sigframe_create)( ThreadId tid,
sp = sp_top_of_frame - sizeof(struct rt_sigframe);
tst = VG_(get_ThreadState)(tid);
- if (!extend(tst, sp, sp_top_of_frame - sp))
+ if (! ML_(sf_extend_stack)(tst, sp, sp_top_of_frame - sp))
return;
vg_assert(VG_IS_16_ALIGNED(sp));
#include "pub_core_signals.h"
#include "pub_core_tooliface.h"
#include "pub_core_trampoline.h"
+#include "priv_sigframe.h"
#if defined(VGA_s390x)
tst->arch.vex.guest_IA = sigregs->regs.psw.addr;
}
-/* Extend the stack segment downwards if needed so as to ensure the
- new signal frames are mapped to something. Return a Bool
- indicating whether or not the operation was successful.
-*/
-static Bool extend ( ThreadState *tst, Addr addr, SizeT size )
-{
- ThreadId tid = tst->tid;
- NSegment const* stackseg = NULL;
-
- if (VG_(extend_stack)(tid, addr)) {
- stackseg = VG_(am_find_nsegment)(addr);
- if (0 && stackseg)
- VG_(printf)("frame=%#lx seg=%#lx-%#lx\n",
- addr, stackseg->start, stackseg->end);
- }
-
- if (stackseg == NULL || !stackseg->hasR || !stackseg->hasW) {
- VG_(message)(
- Vg_UserMsg,
- "Can't extend stack to %#lx during signal delivery for thread %d:\n",
- addr, tid);
- if (stackseg == NULL)
- VG_(message)(Vg_UserMsg, " no stack segment\n");
- else
- VG_(message)(Vg_UserMsg, " too small or bad protection modes\n");
-
- /* set SIGSEGV to default handler */
- VG_(set_default_handler)(VKI_SIGSEGV);
- VG_(synth_fault_mapping)(tid, addr);
-
- /* The whole process should be about to die, since the default
- action of SIGSEGV to kill the whole process. */
- return False;
- }
-
- /* For tracking memory events, indicate the entire frame has been
- allocated. */
- VG_TRACK( new_mem_stack_signal, addr - VG_STACK_REDZONE_SZB,
- size + VG_STACK_REDZONE_SZB, tid );
-
- return True;
-}
-
/* Build the Valgrind-specific part of a signal frame. */
sp -= sizeof(*frame);
frame = (struct sigframe *)sp;
- if (!extend(tst, sp, sizeof(*frame)))
+ if (! ML_(sf_extend_stack)(tst, sp, sizeof(*frame)))
return sp_top_of_frame;
/* retcode, sigNo, sc, sregs fields are to be written */
sp -= sizeof(*frame);
frame = (struct rt_sigframe *)sp;
- if (!extend(tst, sp, sizeof(*frame)))
+ if (! ML_(sf_extend_stack)(tst, sp, sizeof(*frame)))
return sp_top_of_frame;
/* retcode, sigNo, sc, sregs fields are to be written */
#include "pub_core_signals.h"
#include "pub_core_tooliface.h"
#include "pub_core_trampoline.h"
-#include "pub_core_transtab.h" // VG_(discard_translations)
+#include "priv_sigframe.h"
struct vg_sig_private
{
struct vg_sig_private priv;
};
-/* Extend the stack segment downwards if needed so as to ensure the
- new signal frames are mapped to something. Return a Bool
- indicating whether or not the operation was successful.
-*/
-static Bool extend ( ThreadState *tst, Addr addr, SizeT size )
-{
- ThreadId tid = tst->tid;
- NSegment const* stackseg = NULL;
-
- if (VG_(extend_stack)(tid, addr))
- stackseg = VG_(am_find_nsegment)(addr);
-
- if (stackseg == NULL || !stackseg->hasR || !stackseg->hasW)
- {
- VG_(message)(Vg_UserMsg,
- "Can't extend stack to %#lx during signal delivery for thread %d:\n",
- addr, tid );
- if (stackseg == NULL)
- VG_(message)( Vg_UserMsg, " no stack segment\n" );
- else
- VG_(message)( Vg_UserMsg, " too small or bad protection modes\n" );
-
- /* set SIGSEGV to default handler */
- VG_(set_default_handler)( VKI_SIGSEGV );
- VG_(synth_fault_mapping)( tid, addr );
-
- /* The whole process should be about to die, since the default
- action of SIGSEGV to kill the whole process. */
- return False;
- }
-
- /* For tracking memory events, indicate the entire frame has been
- allocated. */
- VG_TRACK( new_mem_stack_signal, addr - VG_STACK_REDZONE_SZB,
- size + VG_STACK_REDZONE_SZB, tid );
-
- return True;
-}
static
void setup_sigcontext2 ( ThreadState* tst, struct vki_sigcontext **sc1,
sp = sp_top_of_frame - sizeof(struct rt_sigframe);
tst = VG_(get_ThreadState)(tid);
- if (!extend(tst, sp, sizeof(struct rt_sigframe)))
+ if (! ML_(sf_extend_stack)(tst, sp, sizeof(struct rt_sigframe)))
return;
vg_assert(VG_IS_8_ALIGNED(sp));
};
-/* Extend the stack segment downwards if needed so as to ensure the
- new signal frames are mapped to something. Return a Bool
- indicating whether or not the operation was successful.
-*/
-static Bool extend ( ThreadState *tst, Addr addr, SizeT size )
-{
- ThreadId tid = tst->tid;
- /* For tracking memory events, indicate the entire frame has been
- allocated. Except, don't mess with the area which
- overlaps the previous frame's redzone. */
- /* XXX is the following call really right? compared with the
- amd64-linux version, this doesn't appear to handle the redzone
- in the same way. */
- VG_TRACK( new_mem_stack_signal,
- addr - VG_STACK_REDZONE_SZB, size, tid );
- return True;
-}
-
-
/* Create a signal frame for thread 'tid'. Make a 3-arg frame
regardless of whether the client originally requested a 1-arg
version (no SA_SIGINFO) or a 3-arg one (SA_SIGINFO) since in the
entry to a function. */
tst = VG_(get_ThreadState)(tid);
- if (!extend(tst, esp, sp_top_of_frame - esp))
+ if (! ML_(sf_extend_stack)(tst, esp, sp_top_of_frame - esp))
return;
vg_assert(VG_IS_16_ALIGNED(esp+4));
#include "pub_core_tooliface.h"
#include "pub_core_trampoline.h"
#include "pub_core_sigframe.h" /* self */
-
+#include "priv_sigframe.h"
/* This module creates and removes signal frames for signal deliveries
on x86-linux.
}
-/* Extend the stack segment downwards if needed so as to ensure the
- new signal frames are mapped to something. Return a Bool
- indicating whether or not the operation was successful.
-*/
-static Bool extend ( ThreadState *tst, Addr addr, SizeT size )
-{
- ThreadId tid = tst->tid;
- NSegment const* stackseg = NULL;
-
- if (VG_(extend_stack)(tid, addr)) {
- stackseg = VG_(am_find_nsegment)(addr);
- if (0 && stackseg)
- VG_(printf)("frame=%#lx seg=%#lx-%#lx\n",
- addr, stackseg->start, stackseg->end);
- }
-
- if (stackseg == NULL || !stackseg->hasR || !stackseg->hasW) {
- VG_(message)(
- Vg_UserMsg,
- "Can't extend stack to %#lx during signal delivery for thread %d:\n",
- addr, tid);
- if (stackseg == NULL)
- VG_(message)(Vg_UserMsg, " no stack segment\n");
- else
- VG_(message)(Vg_UserMsg, " too small or bad protection modes\n");
-
- /* set SIGSEGV to default handler */
- VG_(set_default_handler)(VKI_SIGSEGV);
- VG_(synth_fault_mapping)(tid, addr);
-
- /* The whole process should be about to die, since the default
- action of SIGSEGV to kill the whole process. */
- return False;
- }
-
- /* For tracking memory events, indicate the entire frame has been
- allocated. */
- VG_TRACK( new_mem_stack_signal, addr - VG_STACK_REDZONE_SZB,
- size + VG_STACK_REDZONE_SZB, tid );
-
- return True;
-}
-
-
/* Build the Valgrind-specific part of a signal frame. */
static void build_vg_sigframe(struct vg_sigframe *frame,
esp = VG_ROUNDDN(esp, 16);
frame = (struct sigframe *)esp;
- if (!extend(tst, esp, sizeof(*frame)))
+ if (! ML_(sf_extend_stack)(tst, esp, sizeof(*frame)))
return esp_top_of_frame;
/* retaddr, sigNo, siguContext fields are to be written */
esp = VG_ROUNDDN(esp, 16);
frame = (struct rt_sigframe *)esp;
- if (!extend(tst, esp, sizeof(*frame)))
+ if (! ML_(sf_extend_stack)(tst, esp, sizeof(*frame)))
return esp_top_of_frame;
/* retaddr, sigNo, pSiginfo, puContext fields are to be written */