From: Paul Eggert Date: Mon, 7 Apr 2014 17:52:38 +0000 (-0700) Subject: * alloc.c: Simplify by removing use of HAVE_EXECINFO_H. X-Git-Tag: emacs-25.0.90~2640^2~258 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=608a4502b9fa8f5681368657fba5d5fd0fa46817;p=emacs.git * alloc.c: Simplify by removing use of HAVE_EXECINFO_H. We have a substitute execinfo.h on hosts that lack it. (suspicious_free_history): Make it EXTERNALLY_VISIBLE so it isn't optimized away. --- diff --git a/src/ChangeLog b/src/ChangeLog index de97b990735..b4722839fe3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2014-04-07 Paul Eggert + + * alloc.c: Simplify by removing use of HAVE_EXECINFO_H. + We have a substitute execinfo.h on hosts that lack it. + (suspicious_free_history): Make it EXTERNALLY_VISIBLE so it + isn't optimized away. + 2014-04-05 Paul Eggert Prefer 'ARRAYELTS (x)' to 'sizeof x / sizeof *x'. diff --git a/src/alloc.c b/src/alloc.c index 2919c21dfe5..dbd1ece5d49 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -47,10 +47,7 @@ along with GNU Emacs. If not, see . */ #endif /* HAVE_WINDOW_SYSTEM */ #include - -#ifdef HAVE_EXECINFO_H -#include /* For backtrace */ -#endif +#include /* For backtrace. */ #if (defined ENABLE_CHECKING \ && defined HAVE_VALGRIND_VALGRIND_H \ @@ -207,23 +204,22 @@ const char *pending_malloc_warning; #define SUSPICIOUS_OBJECT_CHECKING 1 #ifdef SUSPICIOUS_OBJECT_CHECKING -struct suspicious_free_record { +struct suspicious_free_record +{ void *suspicious_object; -#ifdef HAVE_EXECINFO_H void *backtrace[128]; -#endif }; static void *suspicious_objects[32]; static int suspicious_object_index; -struct suspicious_free_record suspicious_free_history[64]; +struct suspicious_free_record suspicious_free_history[64] EXTERNALLY_VISIBLE; static int suspicious_free_history_index; /* Find the first currently-monitored suspicious pointer in range [begin,end) or NULL if no such pointer exists. */ static void *find_suspicious_object_in_range (void *begin, void *end); static void detect_suspicious_free (void *ptr); #else -#define find_suspicious_object_in_range(begin, end) NULL -#define detect_suspicious_free(ptr) (void) +# define find_suspicious_object_in_range(begin, end) NULL +# define detect_suspicious_free(ptr) (void) #endif /* Maximum amount of C stack to save when a GC happens. */ @@ -6827,7 +6823,7 @@ which_symbols (Lisp_Object obj, EMACS_INT find_max) #ifdef SUSPICIOUS_OBJECT_CHECKING -static void* +static void * find_suspicious_object_in_range (void *begin, void *end) { char *begin_a = begin; @@ -6848,14 +6844,14 @@ static void detect_suspicious_free (void *ptr) { int i; - struct suspicious_free_record* rec; eassert (ptr != NULL); for (i = 0; i < ARRAYELTS (suspicious_objects); ++i) if (suspicious_objects[i] == ptr) { - rec = &suspicious_free_history[suspicious_free_history_index++]; + struct suspicious_free_record *rec + = &suspicious_free_history[suspicious_free_history_index++]; if (suspicious_free_history_index == ARRAYELTS (suspicious_free_history)) { @@ -6864,9 +6860,7 @@ detect_suspicious_free (void *ptr) memset (rec, 0, sizeof (*rec)); rec->suspicious_object = ptr; -#ifdef HAVE_EXECINFO_H - backtrace (&rec->backtrace[0], ARRAYELTS (rec->backtrace)); -#endif + backtrace (rec->backtrace, ARRAYELTS (rec->backtrace)); suspicious_objects[i] = NULL; } }