]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Create new module m_libcsetjmp, which wraps up uses of
authorJulian Seward <jseward@acm.org>
Mon, 11 Apr 2011 16:17:51 +0000 (16:17 +0000)
committerJulian Seward <jseward@acm.org>
Mon, 11 Apr 2011 16:17:51 +0000 (16:17 +0000)
__builtin_setjmp and __builtin_longjmp so that they can be selectively
replaced, on a platform by platform basis.  Does not change any
functionality.  Related to #259977.

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

41 files changed:
coregrind/Makefile.am
coregrind/m_coredump/coredump-elf.c
coregrind/m_debugger.c
coregrind/m_debuginfo/debuginfo.c
coregrind/m_debuginfo/readdwarf3.c
coregrind/m_errormgr.c
coregrind/m_execontext.c
coregrind/m_initimg/initimg-linux.c
coregrind/m_initimg/initimg-pathscan.c
coregrind/m_libcassert.c
coregrind/m_libcsetjmp.c [new file with mode: 0644]
coregrind/m_machine.c
coregrind/m_main.c
coregrind/m_mallocfree.c
coregrind/m_scheduler/scheduler.c
coregrind/m_sigframe/sigframe-amd64-linux.c
coregrind/m_sigframe/sigframe-arm-linux.c
coregrind/m_sigframe/sigframe-ppc32-linux.c
coregrind/m_sigframe/sigframe-ppc64-linux.c
coregrind/m_sigframe/sigframe-s390x-linux.c
coregrind/m_sigframe/sigframe-x86-linux.c
coregrind/m_signals.c
coregrind/m_stacktrace.c
coregrind/m_syswrap/syswrap-amd64-linux.c
coregrind/m_syswrap/syswrap-arm-linux.c
coregrind/m_syswrap/syswrap-generic.c
coregrind/m_syswrap/syswrap-linux-variants.c
coregrind/m_syswrap/syswrap-linux.c
coregrind/m_syswrap/syswrap-main.c
coregrind/m_syswrap/syswrap-ppc32-linux.c
coregrind/m_syswrap/syswrap-ppc64-linux.c
coregrind/m_syswrap/syswrap-s390x-linux.c
coregrind/m_syswrap/syswrap-x86-linux.c
coregrind/m_threadstate.c
coregrind/m_translate.c
coregrind/pub_core_basics.h
coregrind/pub_core_libcsetjmp.h [new file with mode: 0644]
coregrind/pub_core_threadstate.h
include/Makefile.am
include/pub_tool_libcsetjmp.h [new file with mode: 0644]
memcheck/mc_leakcheck.c

index e34999b767cec21f5e7ac21aa2c2db09a4876c6f..57fa59358311a962aa74602963834cb9a047752b 100644 (file)
@@ -154,6 +154,7 @@ noinst_HEADERS = \
        pub_core_libcfile.h     \
        pub_core_libcprint.h    \
        pub_core_libcproc.h     \
+       pub_core_libcsetjmp.h   \
        pub_core_libcsignal.h   \
        pub_core_mach.h         \
        pub_core_machine.h      \
@@ -239,6 +240,7 @@ COREGRIND_SOURCES_COMMON = \
        m_libcfile.c \
        m_libcprint.c \
        m_libcproc.c \
+       m_libcsetjmp.c \
        m_libcsignal.c \
        m_machine.c \
        m_main.c \
index ef27bb5a9331c63be830fdfb14a4516e47ad4a84..fe04c5b6f2452eef8407f2961ec82904933f8967 100644 (file)
@@ -42,6 +42,7 @@
 #include "pub_core_libcproc.h"    // VG_(geteuid), VG_(getegid)
 #include "pub_core_libcassert.h"  // VG_(exit), vg_assert
 #include "pub_core_mallocfree.h"  // VG_(malloc), VG_(free)
+#include "pub_core_libcsetjmp.h"  // to keep _threadstate.h happy
 #include "pub_core_threadstate.h"
 #include "pub_core_xarray.h"
 #include "pub_core_clientstate.h"
index 0638755c219d8b6f986690530685c69d1a5102cd..fe2c7f29c0d436174381e6b9eeb253a8876f1abb 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "pub_core_basics.h"
 #include "pub_core_vki.h"
+#include "pub_core_libcsetjmp.h"
 #include "pub_core_threadstate.h"
 #include "pub_core_xarray.h"
 #include "pub_core_clientstate.h"
index 9e67d553b5416e01a9f2f3f59088396e2f538284..8e431ade61bf08f36d115dffcaa2b3917d8e6f65 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "pub_core_basics.h"
 #include "pub_core_vki.h"
+#include "pub_core_libcsetjmp.h" // to keep _threadstate.h happy
 #include "pub_core_threadstate.h"
 #include "pub_core_debuginfo.h"  /* self */
 #include "pub_core_demangle.h"
index 4d75afbcf24f979dd99600170ce1563be23e89c8..918c425f008258c0f5506e351293d55fc8ef4d38 100644 (file)
 #include "pub_core_libcbase.h"
 #include "pub_core_libcassert.h"
 #include "pub_core_libcprint.h"
+#include "pub_core_libcsetjmp.h"   // setjmp facilities
 #include "pub_core_options.h"
 #include "pub_core_tooliface.h"    /* VG_(needs) */
 #include "pub_core_xarray.h"
@@ -3952,18 +3953,14 @@ void new_dwarf3_reader_wrk (
 /*---                                                      ---*/
 /*------------------------------------------------------------*/
 
-/* --- !!! --- EXTERNAL HEADERS start --- !!! --- */
-#include <setjmp.h>   /* For jmp_buf */
-/* --- !!! --- EXTERNAL HEADERS end --- !!! --- */
-
-static Bool    d3rd_jmpbuf_valid  = False;
-static HChar*  d3rd_jmpbuf_reason = NULL;
-static jmp_buf d3rd_jmpbuf;
+static Bool               d3rd_jmpbuf_valid  = False;
+static HChar*             d3rd_jmpbuf_reason = NULL;
+static VG_MINIMAL_JMP_BUF d3rd_jmpbuf;
 
 static __attribute__((noreturn)) void barf ( HChar* reason ) {
    vg_assert(d3rd_jmpbuf_valid);
    d3rd_jmpbuf_reason = reason;
-   __builtin_longjmp(&d3rd_jmpbuf, 1);
+   VG_MINIMAL_LONGJMP(d3rd_jmpbuf);
    /*NOTREACHED*/
    vg_assert(0);
 }
@@ -3991,7 +3988,7 @@ ML_(new_dwarf3_reader) (
    vg_assert(d3rd_jmpbuf_reason == NULL);
 
    d3rd_jmpbuf_valid = True;
-   jumped = __builtin_setjmp(&d3rd_jmpbuf);
+   jumped = VG_MINIMAL_SETJMP(d3rd_jmpbuf);
    if (jumped == 0) {
       /* try this ... */
       new_dwarf3_reader_wrk( di, barf,
index d04374766751e4f1919497b61f3b366a4895c96a..bb3247a85048746944eb5dc88a17130a17c8aef6 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "pub_core_basics.h"
 #include "pub_core_vki.h"
+#include "pub_core_libcsetjmp.h"
 #include "pub_core_threadstate.h"      // For VG_N_THREADS
 #include "pub_core_debugger.h"
 #include "pub_core_debuginfo.h"
index fcb45d7a5a1900675bc4b8288e172d39c1ab8dab..80574feb01fb1c6b8bde23b18b39b4436b316cbf 100644 (file)
@@ -37,6 +37,7 @@
 #include "pub_core_stacktrace.h"
 #include "pub_core_machine.h"       // VG_(get_IP)
 #include "pub_core_vki.h"           // To keep pub_core_threadstate.h happy
+#include "pub_core_libcsetjmp.h"    // Ditto
 #include "pub_core_threadstate.h"   // VG_(is_valid_tid)
 #include "pub_core_execontext.h"    // self
 
index 097699840eb7770c95d1ca76b81757ec43241fd3..4b9f0dd7a016c586e1b3d29bb80121e6dd2964af 100644 (file)
@@ -48,6 +48,7 @@
 #include "pub_core_options.h"
 #include "pub_core_syscall.h"
 #include "pub_core_tooliface.h"       /* VG_TRACK */
+#include "pub_core_libcsetjmp.h"      // to keep _threadstate.h happy
 #include "pub_core_threadstate.h"     /* ThreadArchState */
 #include "priv_initimg_pathscan.h"
 #include "pub_core_initimg.h"         /* self */
index df47316bdf167e88ce9109fee8b23fb0c13ad03a..cca58170c8755d0fef023e490043d36bd091a2b6 100644 (file)
@@ -44,7 +44,6 @@
 #include "pub_core_ume.h"
 #include "pub_core_options.h"
 #include "pub_core_tooliface.h"       /* VG_TRACK */
-#include "pub_core_threadstate.h"     /* ThreadArchState */
 #include "pub_core_initimg.h"         /* self */
 
 #include "priv_initimg_pathscan.h"
index 63e3f1cd7d86c74b009459b46000da315f80e5e1..49c5ad634314e466ea423c730dffcf1342ffee67 100644 (file)
@@ -31,6 +31,7 @@
 #include "pub_core_basics.h"
 #include "pub_core_vki.h"
 #include "pub_core_vkiscnums.h"
+#include "pub_core_libcsetjmp.h"    // to keep threadstate.h happy
 #include "pub_core_threadstate.h"
 #include "pub_core_libcbase.h"
 #include "pub_core_libcassert.h"
diff --git a/coregrind/m_libcsetjmp.c b/coregrind/m_libcsetjmp.c
new file mode 100644 (file)
index 0000000..8d1c2c2
--- /dev/null
@@ -0,0 +1,44 @@
+
+/*--------------------------------------------------------------------*/
+/*--- A minimal setjmp/longjmp implementation.      m_libcsetjmp.c ---*/
+/*--------------------------------------------------------------------*/
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2010-2010 Mozilla Inc
+
+   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.
+*/
+
+/* Contributed by Julian Seward <jseward@acm.org> */
+
+
+#include "pub_core_basics.h"
+#include "pub_core_libcsetjmp.h"    /* self */
+
+
+/* See include/pub_tool_libcsetjmp.h for background and rationale. */
+
+/* No alternative implementations at present. */
+
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
index 042d98513afff0a3a86f1597d1d4f118b3ddbbe4..521569d5f5a7a14acc11c0d11a85d433fce3f165 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "pub_core_basics.h"
 #include "pub_core_vki.h"
+#include "pub_core_libcsetjmp.h"   // setjmp facilities
 #include "pub_core_threadstate.h"
 #include "pub_core_libcassert.h"
 #include "pub_core_libcbase.h"
@@ -418,11 +419,14 @@ Int VG_(machine_arm_archlevel) = 4;
 /* fixs390: anything for s390x here ? */
 
 /* For hwcaps detection on ppc32/64 and arm we'll need to do SIGILL
-   testing, so we need a jmp_buf. */
-#if defined(VGA_ppc32) || defined(VGA_ppc64) || defined(VGA_arm) || defined(VGA_s390x)
-#include <setjmp.h> // For jmp_buf
-static jmp_buf env_unsup_insn;
-static void handler_unsup_insn ( Int x ) { __builtin_longjmp(env_unsup_insn,1); }
+   testing, so we need a VG_MINIMAL_JMP_BUF. */
+#if defined(VGA_ppc32) || defined(VGA_ppc64) \
+    || defined(VGA_arm) || defined(VGA_s390x)
+#include "pub_tool_libcsetjmp.h"
+static VG_MINIMAL_JMP_BUF env_unsup_insn;
+static void handler_unsup_insn ( Int x ) {
+   VG_MINIMAL_LONGJMP(env_unsup_insn);
+}
 #endif
 
 
@@ -462,7 +466,7 @@ static void find_ppc_dcbz_sz(VexArchInfo *arch_info)
    vg_assert(dcbz_szB == 32 || dcbz_szB == 64 || dcbz_szB == 128);
 
    /* dcbzl clears 128B on G5/PPC970, and usually 32B on other platforms */
-   if (__builtin_setjmp(env_unsup_insn)) {
+   if (VG_MINIMAL_SETJMP(env_unsup_insn)) {
       dcbzl_szB = 0; /* indicates unsupported */
    }
    else {
@@ -689,7 +693,7 @@ Bool VG_(machine_get_hwcaps)( void )
 
      /* standard FP insns */
      have_F = True;
-     if (__builtin_setjmp(env_unsup_insn)) {
+     if (VG_MINIMAL_SETJMP(env_unsup_insn)) {
         have_F = False;
      } else {
         __asm__ __volatile__(".long 0xFC000090"); /*fmr 0,0 */
@@ -697,7 +701,7 @@ Bool VG_(machine_get_hwcaps)( void )
 
      /* Altivec insns */
      have_V = True;
-     if (__builtin_setjmp(env_unsup_insn)) {
+     if (VG_MINIMAL_SETJMP(env_unsup_insn)) {
         have_V = False;
      } else {
         /* Unfortunately some older assemblers don't speak Altivec (or
@@ -710,7 +714,7 @@ Bool VG_(machine_get_hwcaps)( void )
 
      /* General-Purpose optional (fsqrt, fsqrts) */
      have_FX = True;
-     if (__builtin_setjmp(env_unsup_insn)) {
+     if (VG_MINIMAL_SETJMP(env_unsup_insn)) {
         have_FX = False;
      } else {
         __asm__ __volatile__(".long 0xFC00002C"); /*fsqrt 0,0 */
@@ -718,7 +722,7 @@ Bool VG_(machine_get_hwcaps)( void )
 
      /* Graphics optional (stfiwx, fres, frsqrte, fsel) */
      have_GX = True;
-     if (__builtin_setjmp(env_unsup_insn)) {
+     if (VG_MINIMAL_SETJMP(env_unsup_insn)) {
         have_GX = False;
      } else {
         __asm__ __volatile__(".long 0xFC000034"); /* frsqrte 0,0 */
@@ -808,7 +812,7 @@ Bool VG_(machine_get_hwcaps)( void )
 
      /* standard FP insns */
      have_F = True;
-     if (__builtin_setjmp(env_unsup_insn)) {
+     if (VG_MINIMAL_SETJMP(env_unsup_insn)) {
         have_F = False;
      } else {
         __asm__ __volatile__("fmr 0,0");
@@ -816,7 +820,7 @@ Bool VG_(machine_get_hwcaps)( void )
 
      /* Altivec insns */
      have_V = True;
-     if (__builtin_setjmp(env_unsup_insn)) {
+     if (VG_MINIMAL_SETJMP(env_unsup_insn)) {
         have_V = False;
      } else {
         __asm__ __volatile__(".long 0x10000484"); /*vor 0,0,0*/
@@ -824,7 +828,7 @@ Bool VG_(machine_get_hwcaps)( void )
 
      /* General-Purpose optional (fsqrt, fsqrts) */
      have_FX = True;
-     if (__builtin_setjmp(env_unsup_insn)) {
+     if (VG_MINIMAL_SETJMP(env_unsup_insn)) {
         have_FX = False;
      } else {
         __asm__ __volatile__(".long 0xFC00002C"); /*fsqrt 0,0*/
@@ -832,7 +836,7 @@ Bool VG_(machine_get_hwcaps)( void )
 
      /* Graphics optional (stfiwx, fres, frsqrte, fsel) */
      have_GX = True;
-     if (__builtin_setjmp(env_unsup_insn)) {
+     if (VG_MINIMAL_SETJMP(env_unsup_insn)) {
         have_GX = False;
      } else {
         __asm__ __volatile__(".long 0xFC000034"); /*frsqrte 0,0*/
@@ -899,7 +903,7 @@ Bool VG_(machine_get_hwcaps)( void )
         is not supported on z900. */
 
      have_LDISP = True;
-     if (__builtin_setjmp(env_unsup_insn)) {
+     if (VG_MINIMAL_SETJMP(env_unsup_insn)) {
         have_LDISP = False;
      } else {
        /* BASR loads the address of the next insn into r1. Needed to avoid
@@ -910,7 +914,7 @@ Bool VG_(machine_get_hwcaps)( void )
      }
 
      have_EIMM = True;
-     if (__builtin_setjmp(env_unsup_insn)) {
+     if (VG_MINIMAL_SETJMP(env_unsup_insn)) {
         have_EIMM = False;
      } else {
         __asm__ __volatile__(".long  0xc0090000\n\t"  /* iilf r0,0 */
@@ -918,7 +922,7 @@ Bool VG_(machine_get_hwcaps)( void )
      }
 
      have_GIE = True;
-     if (__builtin_setjmp(env_unsup_insn)) {
+     if (VG_MINIMAL_SETJMP(env_unsup_insn)) {
         have_GIE = False;
      } else {
         __asm__ __volatile__(".long  0xc2010000\n\t"  /* msfi r0,0 */
@@ -926,7 +930,7 @@ Bool VG_(machine_get_hwcaps)( void )
      }
 
      have_DFP = True;
-     if (__builtin_setjmp(env_unsup_insn)) {
+     if (VG_MINIMAL_SETJMP(env_unsup_insn)) {
         have_DFP = False;
      } else {
         __asm__ __volatile__(".long 0xb3d20000"
@@ -1004,7 +1008,7 @@ Bool VG_(machine_get_hwcaps)( void )
 
      /* VFP insns */
      have_VFP = True;
-     if (__builtin_setjmp(env_unsup_insn)) {
+     if (VG_MINIMAL_SETJMP(env_unsup_insn)) {
         have_VFP = False;
      } else {
         __asm__ __volatile__(".word 0xEEB02B42"); /* VMOV.F64 d2, d2 */
@@ -1016,7 +1020,7 @@ Bool VG_(machine_get_hwcaps)( void )
 
      /* NEON insns */
      have_NEON = True;
-     if (__builtin_setjmp(env_unsup_insn)) {
+     if (VG_MINIMAL_SETJMP(env_unsup_insn)) {
         have_NEON = False;
      } else {
         __asm__ __volatile__(".word 0xF2244154"); /* VMOV q2, q2 */
@@ -1026,7 +1030,7 @@ Bool VG_(machine_get_hwcaps)( void )
      archlevel = 5; /* v5 will be base level */
      if (archlevel < 7) {
         archlevel = 7;
-        if (__builtin_setjmp(env_unsup_insn)) {
+        if (VG_MINIMAL_SETJMP(env_unsup_insn)) {
            archlevel = 5;
         } else {
            __asm__ __volatile__(".word 0xF45FF000"); /* PLI [PC,#-0] */
@@ -1034,7 +1038,7 @@ Bool VG_(machine_get_hwcaps)( void )
      }
      if (archlevel < 6) {
         archlevel = 6;
-        if (__builtin_setjmp(env_unsup_insn)) {
+        if (VG_MINIMAL_SETJMP(env_unsup_insn)) {
            archlevel = 5;
         } else {
            __asm__ __volatile__(".word 0xE6822012"); /* PKHBT r2, r2, r2 */
index e9bfe20906da5410bdce22e3918f2f645c64067d..05984242b55152ce1eb4233b8376634de3fed267 100644 (file)
@@ -31,6 +31,7 @@
 #include "pub_core_basics.h"
 #include "pub_core_vki.h"
 #include "pub_core_vkiscnums.h"
+#include "pub_core_libcsetjmp.h"    // to keep _threadstate.h happy
 #include "pub_core_threadstate.h"
 #include "pub_core_xarray.h"
 #include "pub_core_clientstate.h"
index 4054c965fa59a52556898a7ca82ad81fa910578e..6199f16e3d8cf0d97b28364c309c3690e972e1ad 100644 (file)
@@ -38,6 +38,7 @@
 #include "pub_core_libcprint.h"
 #include "pub_core_mallocfree.h"
 #include "pub_core_options.h"
+#include "pub_core_libcsetjmp.h"    // to keep _threadstate.h happy
 #include "pub_core_threadstate.h"   // For VG_INVALID_THREADID
 #include "pub_core_tooliface.h"
 #include "valgrind.h"
index 200adaef1b45f6a1b7beed9a63e97dcd720ef0e3..f49a4cf3790a128e6177f77781fe364ced64ec1f 100644 (file)
@@ -61,6 +61,7 @@
 #include "pub_core_debuglog.h"
 #include "pub_core_vki.h"
 #include "pub_core_vkiscnums.h"    // __NR_sched_yield
+#include "pub_core_libcsetjmp.h"   // to keep _threadstate.h happy
 #include "pub_core_threadstate.h"
 #include "pub_core_aspacemgr.h"
 #include "pub_core_clreq.h"         // for VG_USERREQ__*
@@ -581,7 +582,7 @@ void VG_(scheduler_init_phase2) ( ThreadId tid_main,
    do {                                                                        \
       ThreadState * volatile _qq_tst = VG_(get_ThreadState)(tid);      \
                                                                        \
-      (jumped) = __builtin_setjmp(_qq_tst->sched_jmpbuf);               \
+      (jumped) = VG_MINIMAL_SETJMP(_qq_tst->sched_jmpbuf);              \
       if ((jumped) == 0) {                                             \
         vg_assert(!_qq_tst->sched_jmpbuf_valid);                       \
         _qq_tst->sched_jmpbuf_valid = True;                            \
index b234e3a95d6ba6f6ac1e580abe8873d762ca28a4..710a34bcf78f3c950538208e0fe1e7a385020f78 100644 (file)
@@ -33,6 +33,7 @@
 
 #include "pub_core_basics.h"
 #include "pub_core_vki.h"
+#include "pub_core_libcsetjmp.h"    // to keep _threadstate.h happy
 #include "pub_core_threadstate.h"
 #include "pub_core_aspacemgr.h"
 #include "pub_core_libcbase.h"
index 01c1c058c48b913313ef86ae02020fde899d0668..47677005a482c08695944487a035802cdac83e1e 100644 (file)
@@ -38,6 +38,7 @@
 #include "pub_core_basics.h"
 #include "pub_core_vki.h"
 #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_libcbase.h"
index 9710b3726b9346a56b7b90341a6fab7936b3158b..f19f71fe199ecdf1fdd11a19b79a2c4945ba3b9e 100644 (file)
@@ -36,6 +36,7 @@
 #include "pub_core_basics.h"
 #include "pub_core_vki.h"
 #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_libcbase.h"
index 5c6198baed9892a95aa56fdfb99fbf0399dd80d8..2e6dc0fdfa936e761c9cf1d2936efcd9261f5dc4 100644 (file)
@@ -36,6 +36,7 @@
 #include "pub_core_basics.h"
 #include "pub_core_vki.h"
 #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_libcbase.h"
index e5e380161a273465056cdb38fc6b5653f661cb09..9d3afca1eec18ce61539d539ac1e9ee2cc9ee874 100644 (file)
@@ -33,6 +33,7 @@
 #include "pub_core_basics.h"
 #include "pub_core_vki.h"
 #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_libcbase.h"
index 6b61055866dcd3ae8e75750074091f4d7fa74d96..079fc710a44c28972ac12de6ab9cde7a39ea75d6 100644 (file)
@@ -33,6 +33,7 @@
 
 #include "pub_core_basics.h"
 #include "pub_core_vki.h"
+#include "pub_core_libcsetjmp.h"    // to keep _threadstate.h happy
 #include "pub_core_threadstate.h"
 #include "pub_core_aspacemgr.h" /* find_segment */
 #include "pub_core_libcbase.h"
index 65fc40a051aa73f5bffdb309fbd51f5029e4d4df..105c02a3fd56b6a9cff04ef44a218a7ee1bff51a 100644 (file)
 #include "pub_core_vki.h"
 #include "pub_core_vkiscnums.h"
 #include "pub_core_debuglog.h"
+#include "pub_core_libcsetjmp.h"    // to keep _threadstate.h happy
 #include "pub_core_threadstate.h"
 #include "pub_core_xarray.h"
 #include "pub_core_clientstate.h"
@@ -1779,7 +1780,7 @@ static void resume_scheduler(ThreadId tid)
    if (tst->sched_jmpbuf_valid) {
       /* Can't continue; must longjmp back to the scheduler and thus
          enter the sighandler immediately. */
-      __builtin_longjmp(tst->sched_jmpbuf, True);
+      VG_MINIMAL_LONGJMP(tst->sched_jmpbuf);
    }
 }
 
index 707b470d6076d6c784f928c2b6f190e4bdc9dab4..7984de32c9541278e6a207db791c255f8cef9847 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "pub_core_basics.h"
 #include "pub_core_vki.h"
+#include "pub_core_libcsetjmp.h"    // to keep _threadstate.h happy
 #include "pub_core_threadstate.h"
 #include "pub_core_debuginfo.h"     // XXX: circular dependency
 #include "pub_core_aspacemgr.h"     // For VG_(is_addressable)()
index ecb3d002329439d47eafe49becd45c341be8d156..ece1a73b4448f10be8db15faa01c7e252ef33fa9 100644 (file)
@@ -33,6 +33,7 @@
 #include "pub_core_basics.h"
 #include "pub_core_vki.h"
 #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_debuglog.h"
index 65b3923760a959f6c343886dd23a98e3e1987c40..076508908fea474ec26024af1842a61b8ce38d9a 100644 (file)
@@ -35,6 +35,7 @@
 #include "pub_core_basics.h"
 #include "pub_core_vki.h"
 #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_debuglog.h"
index 9f4025c4eeb4833d941d424c4edfe3a13b81c3b0..436214093385c1bd87e9eaff6f8e2c756b71c4e8 100644 (file)
@@ -34,6 +34,7 @@
 #include "pub_core_basics.h"
 #include "pub_core_vki.h"
 #include "pub_core_vkiscnums.h"
+#include "pub_core_libcsetjmp.h"    // to keep _threadstate.h happy
 #include "pub_core_threadstate.h"
 #include "pub_core_debuginfo.h"     // VG_(di_notify_*)
 #include "pub_core_aspacemgr.h"
index 27463edef4a2309197f3ceab8fc12b371f207ea7..dc433ec3a6c46ddc193ce81fab2aae0a02eaed7d 100644 (file)
@@ -48,6 +48,7 @@
 
 #include "pub_core_basics.h"
 #include "pub_core_vki.h"
+#include "pub_core_libcsetjmp.h"   // to keep _threadstate.h happy
 #include "pub_core_threadstate.h"
 #include "pub_core_aspacemgr.h"
 #include "pub_core_debuginfo.h"    // VG_(di_notify_*)
index 35f8ee63780dc99975fbd0fb5e9e0f2540846d94..df5654a0245027c6916716aa33443bf03c03107a 100644 (file)
@@ -33,6 +33,7 @@
 #include "pub_core_basics.h"
 #include "pub_core_vki.h"
 #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_debuginfo.h"    // VG_(di_notify_*)
index 4d33eb8d6dee684470b60b3d5d00dfa7198d06ec..cff054333d2a3b612ad287e24e538430d5d0e687 100644 (file)
@@ -34,6 +34,7 @@
 #include "pub_core_aspacemgr.h"
 #include "pub_core_vki.h"
 #include "pub_core_vkiscnums.h"
+#include "pub_core_libcsetjmp.h"    // to keep _threadstate.h happy
 #include "pub_core_threadstate.h"
 #include "pub_core_libcbase.h"
 #include "pub_core_libcassert.h"
@@ -2266,7 +2267,7 @@ void ML_(wqthread_continue_NORETURN)(ThreadId tid)
    sci->status.what = SsIdle;
 
    vg_assert(tst->sched_jmpbuf_valid);
-   __builtin_longjmp(tst->sched_jmpbuf, True);
+   VG_MINIMAL_LONGJMP(tst->sched_jmpbuf, True);
 
    /* NOTREACHED */
    vg_assert(0);
index ca37a5afc0efc9224d6b90b94c3468e7cd1c1375..9baf8d8e06740bdaeb1fd9cb93e6a4840d9a6c76 100644 (file)
@@ -33,6 +33,7 @@
 #include "pub_core_basics.h"
 #include "pub_core_vki.h"
 #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_debuglog.h"
index 9e9456a4e205813d0d305c311b16e6b839f77b6b..1e9e96c929857c90aa3012182111bfde6d36bc70 100644 (file)
@@ -33,6 +33,7 @@
 #include "pub_core_basics.h"
 #include "pub_core_vki.h"
 #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_debuglog.h"
index eb2f290484292bb1aabff48f53804fea9e52c15b..02acbf4ac013b569c26ba1f1207553240bb4fbe3 100644 (file)
@@ -34,6 +34,7 @@
 #include "pub_core_basics.h"
 #include "pub_core_vki.h"
 #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_debuglog.h"
index c0a8b2b36c872c33d2351e49fc07fb3cfff5aa41..4b526563bcf986ba31f3d2603b386193d850f385 100644 (file)
@@ -38,6 +38,7 @@
 #include "pub_core_basics.h"
 #include "pub_core_vki.h"
 #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_debuglog.h"
index d047110de2ca364573fe29eccd9a3ef3b40e863c..c45ce214b5bc464438f24ab27433f6aaf37924a5 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "pub_core_basics.h"
 #include "pub_core_vki.h"
+#include "pub_core_libcsetjmp.h"    // to keep _threadstate.h happy
 #include "pub_core_threadstate.h"
 #include "pub_core_libcassert.h"
 
index fae4854fbee2ec7edb4382ba5ecbdee884d381d7..5fa2dd1bc72450afe5895a2c993d988deafd16ca 100644 (file)
@@ -53,6 +53,7 @@
 #include "pub_core_dispatch.h" // VG_(run_innerloop__dispatch_{un}profiled)
                                // VG_(run_a_noredir_translation__return_point)
 
+#include "pub_core_libcsetjmp.h"   // to keep _threadstate.h happy
 #include "pub_core_threadstate.h"  // VexGuestArchState
 #include "pub_core_trampoline.h"   // VG_(ppctoc_magic_redirect_return_stub)
 
index 0718c82c7fd2728087ed8a9754da9d53ba7b47bb..760cccd34f57875f442f3d0693bd124cf3c1aa6b 100644 (file)
@@ -64,9 +64,6 @@
 #  error Unknown arch
 #endif
 
-// For jmp_buf
-#include <setjmp.h>
-
 
 /* ---------------------------------------------------------------------
    A struct to hold starting values for stack unwinding.
diff --git a/coregrind/pub_core_libcsetjmp.h b/coregrind/pub_core_libcsetjmp.h
new file mode 100644 (file)
index 0000000..215eacc
--- /dev/null
@@ -0,0 +1,49 @@
+
+/*--------------------------------------------------------------------*/
+/*--- A minimal setjmp/longjmp facility.     pub_core_libcsetjmp.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2010-2010 Mozilla Inc
+
+   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.
+*/
+
+/* Contributed by Julian Seward <jseward@acm.org> */
+
+#ifndef __PUB_CORE_LIBCSETJMP_H
+#define __PUB_CORE_LIBCSETJMP_H
+
+//--------------------------------------------------------------------
+// PURPOSE: Provides a minimal setjmp/longjmp facility, that saves/
+// restores integer registers, but not necessarily anything more.
+//--------------------------------------------------------------------
+
+// No core-only exports; everything in this module is visible to both
+// the core and tools.
+
+#include "pub_tool_libcsetjmp.h"
+
+#endif   // __PUB_CORE_LIBCSETJMP_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                    pub_core_libcsetjmp.h ---*/
+/*--------------------------------------------------------------------*/
index a784d0e18877aef9e4db877d9a55d9a8fe76a8dc..639ef73afcf4649f9456e20938269e007cc18ee7 100644 (file)
@@ -355,8 +355,8 @@ typedef struct {
    ThreadOSstate os_state;
 
    /* Per-thread jmp_buf to resume scheduler after a signal */
-   Bool    sched_jmpbuf_valid;
-   jmp_buf sched_jmpbuf;
+   Bool               sched_jmpbuf_valid;
+   VG_MINIMAL_JMP_BUF sched_jmpbuf;
 }
 ThreadState;
 
index 3a1adc06faaecabd92f0e142d6f6b87e97f36498..ae1f0cae9a6ed42ce9587d22f1c660eaa9935748 100644 (file)
@@ -18,6 +18,7 @@ nobase_pkginclude_HEADERS = \
        pub_tool_libcfile.h             \
        pub_tool_libcprint.h            \
        pub_tool_libcproc.h             \
+       pub_tool_libcsetjmp.h           \
        pub_tool_libcsignal.h           \
        pub_tool_machine.h              \
        pub_tool_mallocfree.h           \
diff --git a/include/pub_tool_libcsetjmp.h b/include/pub_tool_libcsetjmp.h
new file mode 100644 (file)
index 0000000..faf8d37
--- /dev/null
@@ -0,0 +1,76 @@
+
+/*--------------------------------------------------------------------*/
+/*--- A minimal setjmp/longjmp facility.     pub_tool_libcsetjmp.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2010-2010 Mozilla Inc
+
+   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.
+*/
+
+/* Contributed by Julian Seward <jseward@acm.org> */
+
+#ifndef __PUB_TOOL_LIBCSETJMP_H
+#define __PUB_TOOL_LIBCSETJMP_H
+
+//--------------------------------------------------------------------
+// PURPOSE: Provides a minimal setjmp/longjmp facility, that saves/
+// restores integer registers, but not necessarily anything more.
+//--------------------------------------------------------------------
+
+
+/* This provides an extremely minimal setjmp/longjmp facility, in
+   which only the host's integer registers are saved/restored.  Or at
+   least, that is the minimal guaranteed functionality.
+
+   Until Apr 2011 we used __builtin_setjmp and __builtin_longjmp, but
+   it appears that that is not always correctly implemented.  See
+   https://bugs.kde.org/show_bug.cgi?id=259977.  So this module wraps
+   those functions up and facilitates replacing them with our own
+   implementations where necessary.
+*/
+
+/* --- !!! --- EXTERNAL HEADERS start --- !!! --- */
+#include <setjmp.h>
+/* --- !!! --- EXTERNAL HEADERS end --- !!! --- */
+
+
+/* Don't use jmp_buf, __builtin_setjmp or __builtin_longjmp directly.
+   They don't always work reliably.  Instead use these macros, which
+   provide the opportunity to supply alternative implementations as
+   necessary.
+
+   Note that the abstraction is done with macros (ick) rather than
+   functions and typedefs, since wrapping __builtin_setjmp up in a
+   second function (eg, VG_(minimal_setjmp)) doesn't seem to work for
+   whatever reason -- returns via a VG_(minimal_longjmp) go wrong.
+*/
+#define VG_MINIMAL_JMP_BUF        jmp_buf
+#define VG_MINIMAL_SETJMP(_env)   __builtin_setjmp((_env))
+#define VG_MINIMAL_LONGJMP(_env)  __builtin_longjmp((_env),1)
+
+
+#endif   // __PUB_TOOL_LIBCSETJMP_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                    pub_tool_libcsetjmp.h ---*/
+/*--------------------------------------------------------------------*/
index 13b8de398f412d75b5c4f863422c7966a7a7cd61..bdf0fc667ec736e644cd5e04d42a99d29c114a20 100644 (file)
 #include "pub_tool_options.h"
 #include "pub_tool_oset.h"
 #include "pub_tool_signals.h"
+#include "pub_tool_libcsetjmp.h"    // setjmp facilities
 #include "pub_tool_tooliface.h"     // Needed for mc_include.h
 
 #include "mc_include.h"
 
-#include <setjmp.h>                 // For jmp_buf
-
 /*------------------------------------------------------------*/
 /*--- An overview of leak checking.                        ---*/
 /*------------------------------------------------------------*/
@@ -636,7 +635,7 @@ lc_push_if_a_chunk_ptr(Addr ptr, Int clique, Bool is_prior_definite)
 }
 
 
-static jmp_buf memscan_jmpbuf;
+static VG_MINIMAL_JMP_BUF memscan_jmpbuf;
 
 static
 void scan_all_valid_memory_catcher ( Int sigNo, Addr addr )
@@ -644,7 +643,7 @@ void scan_all_valid_memory_catcher ( Int sigNo, Addr addr )
    if (0)
       VG_(printf)("OUCH! sig=%d addr=%#lx\n", sigNo, addr);
    if (sigNo == VKI_SIGSEGV || sigNo == VKI_SIGBUS)
-      __builtin_longjmp(memscan_jmpbuf, 1);
+      VG_MINIMAL_LONGJMP(memscan_jmpbuf);
 }
 
 // Scan a block of memory between [start, start+len).  This range may
@@ -686,7 +685,7 @@ lc_scan_memory(Addr start, SizeT len, Bool is_prior_definite, Int clique)
          }
       }
 
-      if (__builtin_setjmp(memscan_jmpbuf) == 0) {
+      if (VG_MINIMAL_SETJMP(memscan_jmpbuf) == 0) {
          if ( MC_(is_valid_aligned_word)(ptr) ) {
             lc_scanned_szB += sizeof(Addr);
             addr = *(Addr *)ptr;