Introduce common/gdb_setjmp.h
authorGary Benson <gbenson@redhat.com>
Thu, 7 Aug 2014 14:53:21 +0000 (15:53 +0100)
committerGary Benson <gbenson@redhat.com>
Fri, 29 Aug 2014 09:53:36 +0000 (10:53 +0100)
This commit creates a new file, common/gdb_setjmp.h, to hold some
portability macros for setjmp/longjmp et al. that are used by the
exceptions subsystem and by the demangler crash catcher.

gdb/ChangeLog:

* common/gdb_setjmp.h: New file.
* Makefile.in (HFILES_NO_SRCDIR): Add common/gdb_setjmp.h.
* configure.ac: Move sigsetjmp check...
* common/common.m4: ...here.
* configure: Regenerate.
* cp-support.c (SIGJMP_BUF): Delete.
(SIGSETJMP): Likewise.
(SIGLONGJMP): Likewise.
* exceptions.h (gdb_setjmp.h): Include.
(setjmp.h): Do not include.
(EXCEPTIONS_SIGJMP_BUF): Delete.
(EXCEPTIONS_SIGSETJMP): Likewise.
(EXCEPTIONS_SIGLONGJMP): Likewise.
Replace all uses of EXCEPTIONS_SIG* macros with SIG* macros
from gdb_setjmp.h.
* exceptions.c: Likewise.

gdb/gdbserver/ChangeLog:

* config.in: Regenerate.
* configure: Likewise.

12 files changed:
gdb/ChangeLog
gdb/Makefile.in
gdb/common/common.m4
gdb/common/gdb_setjmp.h [new file with mode: 0644]
gdb/configure
gdb/configure.ac
gdb/cp-support.c
gdb/exceptions.c
gdb/exceptions.h
gdb/gdbserver/ChangeLog
gdb/gdbserver/config.in
gdb/gdbserver/configure

index 6bacb45102b00a14369845ae169028a3a9e4c7d3..fbe8e87a41f49182665834aeb056b9b317b34a25 100644 (file)
@@ -1,3 +1,22 @@
+2014-08-29  Gary Benson  <gbenson@redhat.com>
+
+       * common/gdb_setjmp.h: New file.
+       * Makefile.in (HFILES_NO_SRCDIR): Add common/gdb_setjmp.h.
+       * configure.ac: Move sigsetjmp check...
+       * common/common.m4: ...here.
+       * configure: Regenerate.
+       * cp-support.c (SIGJMP_BUF): Delete.
+       (SIGSETJMP): Likewise.
+       (SIGLONGJMP): Likewise.
+       * exceptions.h (gdb_setjmp.h): Include.
+       (setjmp.h): Do not include.
+       (EXCEPTIONS_SIGJMP_BUF): Delete.
+       (EXCEPTIONS_SIGSETJMP): Likewise.
+       (EXCEPTIONS_SIGLONGJMP): Likewise.
+       Replace all uses of EXCEPTIONS_SIG* macros with SIG* macros
+       from gdb_setjmp.h.
+       * exceptions.c: Likewise.
+
 2014-08-29  Gary Benson  <gbenson@redhat.com>
 
        * cleanups.h: Moved to...
index 8479324f577606572960eec7c73ecb9396a5a1e0..c886c5d0ba857989ecb5180bf470bf444a37aa11 100644 (file)
@@ -937,7 +937,7 @@ ctf.h nat/i386-cpuid.h nat/i386-gcc-cpuid.h target/resume.h \
 target/wait.h target/waitstatus.h nat/linux-nat.h nat/linux-waitpid.h \
 common/print-utils.h common/rsp-low.h nat/i386-dregs.h x86-linux-nat.h \
 i386-linux-nat.h common/common-defs.h common/errors.h common/common-types.h \
-common/common-debug.h common/cleanups.h
+common/common-debug.h common/cleanups.h common/gdb_setjmp.h
 
 # Header files that already have srcdir in them, or which are in objdir.
 
index 426df7938421512442e66289f9d23aaf4117c92a..7aabd07c43014861473e3ed5ef695d335e79a7b3 100644 (file)
@@ -33,4 +33,15 @@ AC_DEFUN([GDB_AC_COMMON], [
   AC_CHECK_FUNCS([fdwalk getrlimit pipe pipe2 socketpair])
 
   AC_CHECK_DECLS([strerror, strstr])
+
+  dnl Check if sigsetjmp is available.  Using AC_CHECK_FUNCS won't
+  dnl do since sigsetjmp might only be defined as a macro.
+AC_CACHE_CHECK([for sigsetjmp], gdb_cv_func_sigsetjmp,
+[AC_TRY_COMPILE([
+#include <setjmp.h>
+], [sigjmp_buf env; while (! sigsetjmp (env, 1)) siglongjmp (env, 1);],
+gdb_cv_func_sigsetjmp=yes, gdb_cv_func_sigsetjmp=no)])
+if test $gdb_cv_func_sigsetjmp = yes; then
+  AC_DEFINE(HAVE_SIGSETJMP, 1, [Define if sigsetjmp is available. ])
+fi
 ])
diff --git a/gdb/common/gdb_setjmp.h b/gdb/common/gdb_setjmp.h
new file mode 100644 (file)
index 0000000..aba50a4
--- /dev/null
@@ -0,0 +1,34 @@
+/* Portability wrappers for setjmp and longjmp.
+   Copyright (C) 1986-2014 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   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 3 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, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef GDB_SETJMP_H
+#define GDB_SETJMP_H
+
+#include <setjmp.h>
+
+#ifdef HAVE_SIGSETJMP
+#define SIGJMP_BUF             sigjmp_buf
+#define SIGSETJMP(buf)         sigsetjmp((buf), 1)
+#define SIGLONGJMP(buf,val)    siglongjmp((buf), (val))
+#else
+#define SIGJMP_BUF             jmp_buf
+#define SIGSETJMP(buf)         setjmp(buf)
+#define SIGLONGJMP(buf,val)    longjmp((buf), (val))
+#endif
+
+#endif /* GDB_SETJMP_H */
index 9253e28ee0b94e3af8c2691c0c5eba0f22598ea3..bf141f15d065fdb1b07faa654320452acfaea5ba 100755 (executable)
@@ -11143,6 +11143,39 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sigsetjmp" >&5
+$as_echo_n "checking for sigsetjmp... " >&6; }
+if test "${gdb_cv_func_sigsetjmp+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <setjmp.h>
+
+int
+main ()
+{
+sigjmp_buf env; while (! sigsetjmp (env, 1)) siglongjmp (env, 1);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gdb_cv_func_sigsetjmp=yes
+else
+  gdb_cv_func_sigsetjmp=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_func_sigsetjmp" >&5
+$as_echo "$gdb_cv_func_sigsetjmp" >&6; }
+if test $gdb_cv_func_sigsetjmp = yes; then
+
+$as_echo "#define HAVE_SIGSETJMP 1" >>confdefs.h
+
+fi
+
 
 # Check the return and argument types of ptrace.  No canned test for
 # this, so roll our own.
@@ -11405,41 +11438,6 @@ if test $ac_cv_func_setpgrp_void = yes; then
 fi
 fi
 
-# Check if sigsetjmp is available.  Using AC_CHECK_FUNCS won't do
-# since sigsetjmp might only be defined as a macro.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sigsetjmp" >&5
-$as_echo_n "checking for sigsetjmp... " >&6; }
-if test "${gdb_cv_func_sigsetjmp+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#include <setjmp.h>
-
-int
-main ()
-{
-sigjmp_buf env; while (! sigsetjmp (env, 1)) siglongjmp (env, 1);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  gdb_cv_func_sigsetjmp=yes
-else
-  gdb_cv_func_sigsetjmp=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_func_sigsetjmp" >&5
-$as_echo "$gdb_cv_func_sigsetjmp" >&6; }
-if test $gdb_cv_func_sigsetjmp = yes; then
-
-$as_echo "#define HAVE_SIGSETJMP 1" >>confdefs.h
-
-fi
-
 # Assume we'll default to using the included libiberty regex.
 gdb_use_included_regex=yes
 
index 61919b4462af770266b414d0022402ea4f078f8d..26c8ecfc954cfa1b0cc46152a04cdd05f32b6fb3 100644 (file)
@@ -1441,17 +1441,6 @@ if test $ac_cv_func_setpgrp_void = yes; then
 fi
 fi
 
-# Check if sigsetjmp is available.  Using AC_CHECK_FUNCS won't do
-# since sigsetjmp might only be defined as a macro.
-AC_CACHE_CHECK([for sigsetjmp], gdb_cv_func_sigsetjmp,
-[AC_TRY_COMPILE([
-#include <setjmp.h>
-], [sigjmp_buf env; while (! sigsetjmp (env, 1)) siglongjmp (env, 1);],
-gdb_cv_func_sigsetjmp=yes, gdb_cv_func_sigsetjmp=no)])
-if test $gdb_cv_func_sigsetjmp = yes; then
-  AC_DEFINE(HAVE_SIGSETJMP, 1, [Define if sigsetjmp is available. ])
-fi
-
 # Assume we'll default to using the included libiberty regex.
 gdb_use_included_regex=yes
 
index 20a4a073ead658d2891ce2c2a625964338f4ead7..14aaac8ad0d3f74dfdc509f7bc29dfebc5fe576e 100644 (file)
@@ -1488,18 +1488,6 @@ cp_lookup_rtti_type (const char *name, struct block *block)
 
 static int catch_demangler_crashes = 1;
 
-/* Wrap set/long jmp so that it's more portable.  */
-
-#if defined(HAVE_SIGSETJMP)
-#define SIGJMP_BUF             sigjmp_buf
-#define SIGSETJMP(buf)         sigsetjmp((buf), 1)
-#define SIGLONGJMP(buf,val)    siglongjmp((buf), (val))
-#else
-#define SIGJMP_BUF             jmp_buf
-#define SIGSETJMP(buf)         setjmp(buf)
-#define SIGLONGJMP(buf,val)    longjmp((buf), (val))
-#endif
-
 /* Stack context and environment for demangler crash recovery.  */
 
 static SIGJMP_BUF gdb_demangle_jmp_buf;
index 063d2b15664fee1b2d61a324317297df80448a5c..48843eae753a76c8f7e1111d45e5004b22d2e7ee 100644 (file)
@@ -51,7 +51,7 @@ struct catcher
 {
   enum catcher_state state;
   /* Jump buffer pointing back at the exception handler.  */
-  EXCEPTIONS_SIGJMP_BUF buf;
+  SIGJMP_BUF buf;
   /* Status buffer belonging to the exception handler.  */
   volatile struct gdb_exception *exception;
   /* Saved/current state.  */
@@ -80,7 +80,7 @@ catcher_list_size (void)
   return size;
 }
 
-EXCEPTIONS_SIGJMP_BUF *
+SIGJMP_BUF *
 exceptions_state_mc_init (volatile struct gdb_exception *exception,
                          return_mask mask)
 {
@@ -229,7 +229,7 @@ throw_exception (struct gdb_exception exception)
      be zero, by definition in defs.h.  */
   exceptions_state_mc (CATCH_THROWING);
   *current_catcher->exception = exception;
-  EXCEPTIONS_SIGLONGJMP (current_catcher->buf, exception.reason);
+  SIGLONGJMP (current_catcher->buf, exception.reason);
 }
 
 static void
index be74ad5b795884b457f2a5b38eea4da48e895fbd..e3ff672f264e4ff030fd4de4ec3eaede2fdc523f 100644 (file)
@@ -21,7 +21,7 @@
 #define EXCEPTIONS_H
 
 #include "ui-out.h"
-#include <setjmp.h>
+#include "gdb_setjmp.h"
 
 /* Reasons for calling throw_exceptions().  NOTE: all reason values
    must be less than zero.  enum value 0 is reserved for internal use
@@ -114,24 +114,11 @@ struct gdb_exception
 /* A pre-defined non-exception.  */
 extern const struct gdb_exception exception_none;
 
-/* Wrap set/long jmp so that it's more portable (internal to
-   exceptions).  */
-
-#if defined(HAVE_SIGSETJMP)
-#define EXCEPTIONS_SIGJMP_BUF          sigjmp_buf
-#define EXCEPTIONS_SIGSETJMP(buf)      sigsetjmp((buf), 1)
-#define EXCEPTIONS_SIGLONGJMP(buf,val) siglongjmp((buf), (val))
-#else
-#define EXCEPTIONS_SIGJMP_BUF          jmp_buf
-#define EXCEPTIONS_SIGSETJMP(buf)      setjmp(buf)
-#define EXCEPTIONS_SIGLONGJMP(buf,val) longjmp((buf), (val))
-#endif
-
 /* Functions to drive the exceptions state m/c (internal to
    exceptions).  */
-EXCEPTIONS_SIGJMP_BUF *exceptions_state_mc_init (volatile struct
-                                                gdb_exception *exception,
-                                                return_mask mask);
+SIGJMP_BUF *exceptions_state_mc_init (volatile struct
+                                     gdb_exception *exception,
+                                     return_mask mask);
 int exceptions_state_mc_action_iter (void);
 int exceptions_state_mc_action_iter_1 (void);
 
@@ -159,9 +146,9 @@ int exceptions_state_mc_action_iter_1 (void);
 
 #define TRY_CATCH(EXCEPTION,MASK) \
      { \
-       EXCEPTIONS_SIGJMP_BUF *buf = \
+       SIGJMP_BUF *buf = \
         exceptions_state_mc_init (&(EXCEPTION), (MASK)); \
-       EXCEPTIONS_SIGSETJMP (*buf); \
+       SIGSETJMP (*buf); \
      } \
      while (exceptions_state_mc_action_iter ()) \
        while (exceptions_state_mc_action_iter_1 ())
index 76afb0d5bc4e0c34c1278d6567157447dc1e01db..453854ef19aee7643c48868ae42da7a3aa89869e 100644 (file)
@@ -1,3 +1,8 @@
+2014-08-29  Gary Benson  <gbenson@redhat.com>
+
+       * config.in: Regenerate.
+       * configure: Likewise.
+
 2014-08-29  Gary Benson  <gbenson@redhat.com>
 
        * Makefile.in (SFILES): Add common/cleanups.c.
index 216c01d1f0693ada52dfa482000006b183264a3b..7828bf9ce0e5dac89b586d693ea4be97c4e30cd2 100644 (file)
 /* Define to 1 if you have the <signal.h> header file. */
 #undef HAVE_SIGNAL_H
 
+/* Define if sigsetjmp is available. */
+#undef HAVE_SIGSETJMP
+
 /* Define to 1 if you have the `socketpair' function. */
 #undef HAVE_SOCKETPAIR
 
index 9c1f9a830ffa1f77420fd5ae182e75705dce128f..9495905c666dfd4a126956eeed8f0c3db0e9347e 100755 (executable)
@@ -5322,6 +5322,39 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sigsetjmp" >&5
+$as_echo_n "checking for sigsetjmp... " >&6; }
+if test "${gdb_cv_func_sigsetjmp+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <setjmp.h>
+
+int
+main ()
+{
+sigjmp_buf env; while (! sigsetjmp (env, 1)) siglongjmp (env, 1);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gdb_cv_func_sigsetjmp=yes
+else
+  gdb_cv_func_sigsetjmp=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_func_sigsetjmp" >&5
+$as_echo "$gdb_cv_func_sigsetjmp" >&6; }
+if test $gdb_cv_func_sigsetjmp = yes; then
+
+$as_echo "#define HAVE_SIGSETJMP 1" >>confdefs.h
+
+fi
+
 
 # Check for UST
 ustlibs=""
This page took 0.044614 seconds and 4 git commands to generate.