diff options
| author | Paul Eggert | 2014-04-07 10:52:38 -0700 |
|---|---|---|
| committer | Paul Eggert | 2014-04-07 10:52:38 -0700 |
| commit | 608a4502b9fa8f5681368657fba5d5fd0fa46817 (patch) | |
| tree | 88737a27e165aa144b96e0aa1e72308f3020a51e /src/alloc.c | |
| parent | 5da21a7f8a39354008b010305d8d4e8b4a0b3967 (diff) | |
| download | emacs-608a4502b9fa8f5681368657fba5d5fd0fa46817.tar.gz emacs-608a4502b9fa8f5681368657fba5d5fd0fa46817.zip | |
* 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.
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 26 |
1 files changed, 10 insertions, 16 deletions
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 <http://www.gnu.org/licenses/>. */ | |||
| 47 | #endif /* HAVE_WINDOW_SYSTEM */ | 47 | #endif /* HAVE_WINDOW_SYSTEM */ |
| 48 | 48 | ||
| 49 | #include <verify.h> | 49 | #include <verify.h> |
| 50 | 50 | #include <execinfo.h> /* For backtrace. */ | |
| 51 | #ifdef HAVE_EXECINFO_H | ||
| 52 | #include <execinfo.h> /* For backtrace */ | ||
| 53 | #endif | ||
| 54 | 51 | ||
| 55 | #if (defined ENABLE_CHECKING \ | 52 | #if (defined ENABLE_CHECKING \ |
| 56 | && defined HAVE_VALGRIND_VALGRIND_H \ | 53 | && defined HAVE_VALGRIND_VALGRIND_H \ |
| @@ -207,23 +204,22 @@ const char *pending_malloc_warning; | |||
| 207 | #define SUSPICIOUS_OBJECT_CHECKING 1 | 204 | #define SUSPICIOUS_OBJECT_CHECKING 1 |
| 208 | 205 | ||
| 209 | #ifdef SUSPICIOUS_OBJECT_CHECKING | 206 | #ifdef SUSPICIOUS_OBJECT_CHECKING |
| 210 | struct suspicious_free_record { | 207 | struct suspicious_free_record |
| 208 | { | ||
| 211 | void *suspicious_object; | 209 | void *suspicious_object; |
| 212 | #ifdef HAVE_EXECINFO_H | ||
| 213 | void *backtrace[128]; | 210 | void *backtrace[128]; |
| 214 | #endif | ||
| 215 | }; | 211 | }; |
| 216 | static void *suspicious_objects[32]; | 212 | static void *suspicious_objects[32]; |
| 217 | static int suspicious_object_index; | 213 | static int suspicious_object_index; |
| 218 | struct suspicious_free_record suspicious_free_history[64]; | 214 | struct suspicious_free_record suspicious_free_history[64] EXTERNALLY_VISIBLE; |
| 219 | static int suspicious_free_history_index; | 215 | static int suspicious_free_history_index; |
| 220 | /* Find the first currently-monitored suspicious pointer in range | 216 | /* Find the first currently-monitored suspicious pointer in range |
| 221 | [begin,end) or NULL if no such pointer exists. */ | 217 | [begin,end) or NULL if no such pointer exists. */ |
| 222 | static void *find_suspicious_object_in_range (void *begin, void *end); | 218 | static void *find_suspicious_object_in_range (void *begin, void *end); |
| 223 | static void detect_suspicious_free (void *ptr); | 219 | static void detect_suspicious_free (void *ptr); |
| 224 | #else | 220 | #else |
| 225 | #define find_suspicious_object_in_range(begin, end) NULL | 221 | # define find_suspicious_object_in_range(begin, end) NULL |
| 226 | #define detect_suspicious_free(ptr) (void) | 222 | # define detect_suspicious_free(ptr) (void) |
| 227 | #endif | 223 | #endif |
| 228 | 224 | ||
| 229 | /* Maximum amount of C stack to save when a GC happens. */ | 225 | /* Maximum amount of C stack to save when a GC happens. */ |
| @@ -6827,7 +6823,7 @@ which_symbols (Lisp_Object obj, EMACS_INT find_max) | |||
| 6827 | 6823 | ||
| 6828 | #ifdef SUSPICIOUS_OBJECT_CHECKING | 6824 | #ifdef SUSPICIOUS_OBJECT_CHECKING |
| 6829 | 6825 | ||
| 6830 | static void* | 6826 | static void * |
| 6831 | find_suspicious_object_in_range (void *begin, void *end) | 6827 | find_suspicious_object_in_range (void *begin, void *end) |
| 6832 | { | 6828 | { |
| 6833 | char *begin_a = begin; | 6829 | char *begin_a = begin; |
| @@ -6848,14 +6844,14 @@ static void | |||
| 6848 | detect_suspicious_free (void *ptr) | 6844 | detect_suspicious_free (void *ptr) |
| 6849 | { | 6845 | { |
| 6850 | int i; | 6846 | int i; |
| 6851 | struct suspicious_free_record* rec; | ||
| 6852 | 6847 | ||
| 6853 | eassert (ptr != NULL); | 6848 | eassert (ptr != NULL); |
| 6854 | 6849 | ||
| 6855 | for (i = 0; i < ARRAYELTS (suspicious_objects); ++i) | 6850 | for (i = 0; i < ARRAYELTS (suspicious_objects); ++i) |
| 6856 | if (suspicious_objects[i] == ptr) | 6851 | if (suspicious_objects[i] == ptr) |
| 6857 | { | 6852 | { |
| 6858 | rec = &suspicious_free_history[suspicious_free_history_index++]; | 6853 | struct suspicious_free_record *rec |
| 6854 | = &suspicious_free_history[suspicious_free_history_index++]; | ||
| 6859 | if (suspicious_free_history_index == | 6855 | if (suspicious_free_history_index == |
| 6860 | ARRAYELTS (suspicious_free_history)) | 6856 | ARRAYELTS (suspicious_free_history)) |
| 6861 | { | 6857 | { |
| @@ -6864,9 +6860,7 @@ detect_suspicious_free (void *ptr) | |||
| 6864 | 6860 | ||
| 6865 | memset (rec, 0, sizeof (*rec)); | 6861 | memset (rec, 0, sizeof (*rec)); |
| 6866 | rec->suspicious_object = ptr; | 6862 | rec->suspicious_object = ptr; |
| 6867 | #ifdef HAVE_EXECINFO_H | 6863 | backtrace (rec->backtrace, ARRAYELTS (rec->backtrace)); |
| 6868 | backtrace (&rec->backtrace[0], ARRAYELTS (rec->backtrace)); | ||
| 6869 | #endif | ||
| 6870 | suspicious_objects[i] = NULL; | 6864 | suspicious_objects[i] = NULL; |
| 6871 | } | 6865 | } |
| 6872 | } | 6866 | } |