]> git.eshelyaron.com Git - emacs.git/commitdiff
On assertion failure, print backtrace if available.
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 25 Aug 2012 04:04:08 +0000 (21:04 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 25 Aug 2012 04:04:08 +0000 (21:04 -0700)
Merge from gnulib, incorporating:
2012-08-24 execinfo: port to FreeBSD
2012-08-22 execinfo: new module
* admin/merge-gnulib (GNULIB_MODULES): Add execinfo.
* lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
* lib/execinfo.c, lib/execinfo.in.h, m4/execinfo.m4: New files.
* src/alloc.c [ENABLE_CHECKING]: Include <execinfo.h>.
(die) [ENABLE_CHECKING]: Print a backtrace if available.
* src/Makefile.in (LIB_EXECINFO): New macro.
(LIBES): Use it.

ChangeLog
admin/ChangeLog
admin/merge-gnulib
lib/gnulib.mk
m4/gnulib-comp.m4
src/ChangeLog
src/Makefile.in
src/alloc.c

index 5657f8bb3aa9976b6dafd3f0a6e6758e955f4aa4..8ffa630c16d916cca5a4cae98ade034816a9138b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2012-08-24  Paul Eggert  <eggert@cs.ucla.edu>
+
+       On assertion failure, print backtrace if available.
+       Merge from gnulib, incorporating:
+       2012-08-24 execinfo: port to FreeBSD
+       2012-08-22 execinfo: new module
+       * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
+       * lib/execinfo.c, lib/execinfo.in.h, m4/execinfo.m4: New files.
+
 2012-08-22  Glenn Morris  <rgm@gnu.org>
 
        * Makefile.in (install-arch-dep): If NO_BIN_LINK is non-null,
index ea977e80cfadaa17a73bd04cc1a402337395fcb0..0c674b91ea4ffbaa832e97cb7fd990bf5dd9fcf7 100644 (file)
@@ -1,3 +1,8 @@
+2012-08-24  Paul Eggert  <eggert@cs.ucla.edu>
+
+       On assertion failure, print backtrace if available.
+       * merge-gnulib (GNULIB_MODULES): Add execinfo.
+
 2012-08-16  Paul Eggert  <eggert@cs.ucla.edu>
 
        Use ASCII tests for character types.
index 63865edf3ceca45a8fc0a7a3499d96751c93cda4..775d43e68d393c0d039ae22dbbd6f1b87101c2aa 100755 (executable)
@@ -28,7 +28,7 @@ GNULIB_URL=git://git.savannah.gnu.org/gnulib.git
 GNULIB_MODULES='
   alloca-opt c-ctype c-strcase
   careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512
-  dtoastr dtotimespec dup2 environ
+  dtoastr dtotimespec dup2 environ execinfo
   filemode getloadavg getopt-gnu gettime gettimeofday
   ignore-value intprops largefile lstat
   manywarnings mktime pselect pthread_sigmask readlink
index a90cc59bbde5ce60ad377c517295b0dd6b37d33a..d49eb4fdf7ab1096a51ecc473c188153c173b167 100644 (file)
@@ -21,7 +21,7 @@
 # the same distribution terms as the rest of that program.
 #
 # Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=errno --avoid=fcntl --avoid=fcntl-h --avoid=fstat --avoid=msvc-inval --avoid=msvc-nothrow --avoid=raise --avoid=select --avoid=sigprocmask --avoid=sys_types --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt c-ctype c-strcase careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ filemode getloadavg getopt-gnu gettime gettimeofday ignore-value intprops largefile lstat manywarnings mktime pselect pthread_sigmask readlink socklen stat-time stdalign stdarg stdbool stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timespec-add timespec-sub utimens warnings
+# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=errno --avoid=fcntl --avoid=fcntl-h --avoid=fstat --avoid=msvc-inval --avoid=msvc-nothrow --avoid=raise --avoid=select --avoid=sigprocmask --avoid=sys_types --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt c-ctype c-strcase careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo filemode getloadavg getopt-gnu gettime gettimeofday ignore-value intprops largefile lstat manywarnings mktime pselect pthread_sigmask readlink socklen stat-time stdalign stdarg stdbool stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timespec-add timespec-sub utimens warnings
 
 
 MOSTLYCLEANFILES += core *.stackdump
@@ -150,6 +150,31 @@ EXTRA_libgnu_a_SOURCES += dup2.c
 
 ## end   gnulib module dup2
 
+## begin gnulib module execinfo
+
+BUILT_SOURCES += $(EXECINFO_H)
+
+# We need the following in order to create <execinfo.h> when the system
+# doesn't have one that works.
+if GL_GENERATE_EXECINFO_H
+execinfo.h: execinfo.in.h $(top_builddir)/config.status
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         cat $(srcdir)/execinfo.in.h; \
+       } > $@-t && \
+       mv $@-t $@
+else
+execinfo.h: $(top_builddir)/config.status
+       rm -f $@
+endif
+MOSTLYCLEANFILES += execinfo.h execinfo.h-t
+
+EXTRA_DIST += execinfo.c execinfo.in.h
+
+EXTRA_libgnu_a_SOURCES += execinfo.c
+
+## end   gnulib module execinfo
+
 ## begin gnulib module filemode
 
 libgnu_a_SOURCES += filemode.c
index 12c8ca8734b9fb70eb8e931aab29e041313e7863..0d73faee8d143cc76cb447f5dbe3f32133849f78 100644 (file)
@@ -53,6 +53,7 @@ AC_DEFUN([gl_EARLY],
   # Code from module dtotimespec:
   # Code from module dup2:
   # Code from module environ:
+  # Code from module execinfo:
   # Code from module extensions:
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
   # Code from module extern-inline:
@@ -152,6 +153,7 @@ AC_DEFUN([gl_INIT],
   gl_UNISTD_MODULE_INDICATOR([dup2])
   gl_ENVIRON
   gl_UNISTD_MODULE_INDICATOR([environ])
+  gl_EXECINFO_H
   AC_REQUIRE([gl_EXTERN_INLINE])
   gl_FILEMODE
   gl_GETLOADAVG
@@ -534,6 +536,8 @@ AC_DEFUN([gl_FILE_LIST], [
   lib/dtoastr.c
   lib/dtotimespec.c
   lib/dup2.c
+  lib/execinfo.c
+  lib/execinfo.in.h
   lib/filemode.c
   lib/filemode.h
   lib/ftoastr.c
@@ -605,6 +609,7 @@ AC_DEFUN([gl_FILE_LIST], [
   m4/clock_time.m4
   m4/dup2.m4
   m4/environ.m4
+  m4/execinfo.m4
   m4/extensions.m4
   m4/extern-inline.m4
   m4/filemode.m4
index 95b9a57f24b7c9cad1163c57023aeabbb6c48532..fbaf555f8b285562f2cf6fc0fbf48d676062c628 100644 (file)
@@ -1,5 +1,11 @@
 2012-08-25  Paul Eggert  <eggert@cs.ucla.edu>
 
+       On assertion failure, print backtrace if available.
+       * alloc.c [ENABLE_CHECKING]: Include <execinfo.h>.
+       (die) [ENABLE_CHECKING]: Print a backtrace if available.
+       * Makefile.in (LIB_EXECINFO): New macro.
+       (LIBES): Use it.
+
        * bytecode.c, callint.c, callproc.c: Use bool for boolean.
        * bytecode.c (exec_byte_code):
        * callint.c (check_mark, Fcall_interactively):
index 1d89af314015ef0183150dc8891a5ccaccb9f7e8..856452220524eca2a64e0479d683a10bd8ce4f2a 100644 (file)
@@ -159,6 +159,8 @@ DBUS_LIBS = @DBUS_LIBS@
 ## dbusbind.o if HAVE_DBUS, else empty.
 DBUS_OBJ = @DBUS_OBJ@
 
+LIB_EXECINFO=@LIB_EXECINFO@
+
 SETTINGS_CFLAGS = @SETTINGS_CFLAGS@
 SETTINGS_LIBS = @SETTINGS_LIBS@
 
@@ -383,6 +385,7 @@ otherobj= $(TERMCAP_OBJ) $(PRE_ALLOC_OBJ) $(GMALLOC_OBJ) $(RALLOC_OBJ) \
 ## with GCC, we might need LIB_GCC again after them.
 LIBES = $(LIBS) $(LIBX_BASE) $(LIBX_OTHER) $(LIBSOUND) \
    $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_CLOCK_GETTIME) $(DBUS_LIBS) \
+   $(LIB_EXECINFO) \
    $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \
    $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \
    $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \
index f0da9416eceafa3d7fc01c77a202361455f5ac67..961febb6dfffca96f4a79418534d21d14e0afe23 100644 (file)
@@ -6681,13 +6681,21 @@ which_symbols (Lisp_Object obj, EMACS_INT find_max)
 }
 
 #ifdef ENABLE_CHECKING
+
+# include <execinfo.h>
+
 bool suppress_checking;
 
 void
 die (const char *msg, const char *file, int line)
 {
+  enum { NPOINTERS_MAX = 500 };
+  void *buffer[NPOINTERS_MAX];
+  int npointers;
   fprintf (stderr, "\r\n%s:%d: Emacs fatal error: %s\r\n",
           file, line, msg);
+  npointers = backtrace (buffer, NPOINTERS_MAX);
+  backtrace_symbols_fd (buffer, npointers, STDERR_FILENO);
   abort ();
 }
 #endif