From: Nicholas Nethercote Date: Sun, 1 Aug 2004 23:06:22 +0000 (+0000) Subject: Factor out commonality between VG_(synth_fault*)(). X-Git-Tag: svn/VALGRIND_2_2_0~93 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=35ea93fb9e271175aef82ff41bbce744cd2ec1b3;p=thirdparty%2Fvalgrind.git Factor out commonality between VG_(synth_fault*)(). git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2543 --- diff --git a/coregrind/vg_signals.c b/coregrind/vg_signals.c index d2f88d0c9a..a4eb3d7c2d 100644 --- a/coregrind/vg_signals.c +++ b/coregrind/vg_signals.c @@ -1820,51 +1820,37 @@ static void vg_default_action(const vki_ksiginfo_t *info, ThreadId tid) vg_assert(!terminate); } -/* Synthesize a fault where the address is OK, but the page - permissions are bad */ -void VG_(synth_fault_perms)(ThreadId tid, Addr addr) +static void synth_fault_common(ThreadId tid, Addr addr, Int si_code) { vki_ksiginfo_t info; vg_assert(VG_(threads)[tid].status == VgTs_Runnable); info.si_signo = VKI_SIGSEGV; - info.si_code = 2; + info.si_code = si_code; info._sifields._sigfault._addr = (void*)addr; VG_(resume_scheduler)(VKI_SIGSEGV, &info); VG_(deliver_signal)(tid, &info, False); } -/* Synthesize a fault where the address there's nothing mapped at the - address */ -void VG_(synth_fault_mapping)(ThreadId tid, Addr addr) +// Synthesize a fault where the address is OK, but the page +// permissions are bad. +void VG_(synth_fault_perms)(ThreadId tid, Addr addr) { - vki_ksiginfo_t info; - - vg_assert(VG_(threads)[tid].status == VgTs_Runnable); - - info.si_signo = VKI_SIGSEGV; - info.si_code = 1; - info._sifields._sigfault._addr = (void*)addr; + synth_fault_common(tid, addr, 2); +} - VG_(resume_scheduler)(VKI_SIGSEGV, &info); - VG_(deliver_signal)(tid, &info, False); +// Synthesize a fault where the address there's nothing mapped at the address. +void VG_(synth_fault_mapping)(ThreadId tid, Addr addr) +{ + synth_fault_common(tid, addr, 1); } -/* Synthesize a misc memory fault */ +// Synthesize a misc memory fault. void VG_(synth_fault)(ThreadId tid) { - vki_ksiginfo_t info; - - vg_assert(VG_(threads)[tid].status == VgTs_Runnable); - - info.si_signo = VKI_SIGSEGV; - info.si_code = 0x80; - info._sifields._sigfault._addr = (void*)0; - - VG_(resume_scheduler)(VKI_SIGSEGV, &info); - VG_(deliver_signal)(tid, &info, False); + synth_fault_common(tid, 0, 0x80); } void VG_(deliver_signal) ( ThreadId tid, const vki_ksiginfo_t *info, Bool async )