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/alloc.c | |
| 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/alloc.c')
| -rw-r--r-- | src/alloc.c | 8 |
1 files changed, 8 insertions, 0 deletions
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 |