diff options
| author | Paul Eggert | 2012-08-24 21:04:08 -0700 |
|---|---|---|
| committer | Paul Eggert | 2012-08-24 21:04:08 -0700 |
| commit | f4a681b077a4af9f1eb36e0a109003262e2dafd1 (patch) | |
| tree | f08a7aea4f14c0581b848931007ab892bda3b7b7 /src | |
| parent | 2f221583cf4a4b412c16260d148b59931b12455a (diff) | |
| download | emacs-f4a681b077a4af9f1eb36e0a109003262e2dafd1.tar.gz emacs-f4a681b077a4af9f1eb36e0a109003262e2dafd1.zip | |
On assertion failure, print backtrace if available.
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/Makefile.in | 3 | ||||
| -rw-r--r-- | src/alloc.c | 8 |
3 files changed, 17 insertions, 0 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 95b9a57f24b..fbaf555f8b2 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,11 @@ | |||
| 1 | 2012-08-25 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2012-08-25 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | On assertion failure, print backtrace if available. | ||
| 4 | * alloc.c [ENABLE_CHECKING]: Include <execinfo.h>. | ||
| 5 | (die) [ENABLE_CHECKING]: Print a backtrace if available. | ||
| 6 | * Makefile.in (LIB_EXECINFO): New macro. | ||
| 7 | (LIBES): Use it. | ||
| 8 | |||
| 3 | * bytecode.c, callint.c, callproc.c: Use bool for boolean. | 9 | * bytecode.c, callint.c, callproc.c: Use bool for boolean. |
| 4 | * bytecode.c (exec_byte_code): | 10 | * bytecode.c (exec_byte_code): |
| 5 | * callint.c (check_mark, Fcall_interactively): | 11 | * callint.c (check_mark, Fcall_interactively): |
diff --git a/src/Makefile.in b/src/Makefile.in index 1d89af31401..85645222052 100644 --- a/src/Makefile.in +++ b/src/Makefile.in | |||
| @@ -159,6 +159,8 @@ DBUS_LIBS = @DBUS_LIBS@ | |||
| 159 | ## dbusbind.o if HAVE_DBUS, else empty. | 159 | ## dbusbind.o if HAVE_DBUS, else empty. |
| 160 | DBUS_OBJ = @DBUS_OBJ@ | 160 | DBUS_OBJ = @DBUS_OBJ@ |
| 161 | 161 | ||
| 162 | LIB_EXECINFO=@LIB_EXECINFO@ | ||
| 163 | |||
| 162 | SETTINGS_CFLAGS = @SETTINGS_CFLAGS@ | 164 | SETTINGS_CFLAGS = @SETTINGS_CFLAGS@ |
| 163 | SETTINGS_LIBS = @SETTINGS_LIBS@ | 165 | SETTINGS_LIBS = @SETTINGS_LIBS@ |
| 164 | 166 | ||
| @@ -383,6 +385,7 @@ otherobj= $(TERMCAP_OBJ) $(PRE_ALLOC_OBJ) $(GMALLOC_OBJ) $(RALLOC_OBJ) \ | |||
| 383 | ## with GCC, we might need LIB_GCC again after them. | 385 | ## with GCC, we might need LIB_GCC again after them. |
| 384 | LIBES = $(LIBS) $(LIBX_BASE) $(LIBX_OTHER) $(LIBSOUND) \ | 386 | LIBES = $(LIBS) $(LIBX_BASE) $(LIBX_OTHER) $(LIBSOUND) \ |
| 385 | $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_CLOCK_GETTIME) $(DBUS_LIBS) \ | 387 | $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_CLOCK_GETTIME) $(DBUS_LIBS) \ |
| 388 | $(LIB_EXECINFO) \ | ||
| 386 | $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \ | 389 | $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \ |
| 387 | $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \ | 390 | $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \ |
| 388 | $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \ | 391 | $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \ |
diff --git a/src/alloc.c b/src/alloc.c index f0da9416ece..961febb6dff 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -6681,13 +6681,21 @@ which_symbols (Lisp_Object obj, EMACS_INT find_max) | |||
| 6681 | } | 6681 | } |
| 6682 | 6682 | ||
| 6683 | #ifdef ENABLE_CHECKING | 6683 | #ifdef ENABLE_CHECKING |
| 6684 | |||
| 6685 | # include <execinfo.h> | ||
| 6686 | |||
| 6684 | bool suppress_checking; | 6687 | bool suppress_checking; |
| 6685 | 6688 | ||
| 6686 | void | 6689 | void |
| 6687 | die (const char *msg, const char *file, int line) | 6690 | die (const char *msg, const char *file, int line) |
| 6688 | { | 6691 | { |
| 6692 | enum { NPOINTERS_MAX = 500 }; | ||
| 6693 | void *buffer[NPOINTERS_MAX]; | ||
| 6694 | int npointers; | ||
| 6689 | fprintf (stderr, "\r\n%s:%d: Emacs fatal error: %s\r\n", | 6695 | fprintf (stderr, "\r\n%s:%d: Emacs fatal error: %s\r\n", |
| 6690 | file, line, msg); | 6696 | file, line, msg); |
| 6697 | npointers = backtrace (buffer, NPOINTERS_MAX); | ||
| 6698 | backtrace_symbols_fd (buffer, npointers, STDERR_FILENO); | ||
| 6691 | abort (); | 6699 | abort (); |
| 6692 | } | 6700 | } |
| 6693 | #endif | 6701 | #endif |