From: Po Lu Date: Fri, 13 Oct 2023 03:57:46 +0000 (+0800) Subject: Try harder to generate tombstones upon emacs_abort X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=29095d0b1cc5e5b0e4ee089deb59f44f950872ff;p=emacs.git Try harder to generate tombstones upon emacs_abort * src/android.c (HAS_BUILTIN_TRAP): New macro definition. (emacs_abort) [HAS_BUILTIN_TRAP]: Call __builtin_trap to abort, in place of dereferencing NULL. * src/androidterm.c (android_draw_fringe_bitmap): Correct comment transplanted from X code. --- diff --git a/src/android.c b/src/android.c index 98ace1156d7..fa7bfe6c0f0 100644 --- a/src/android.c +++ b/src/android.c @@ -5542,22 +5542,40 @@ android_toggle_on_screen_keyboard (android_window window, bool show) +#if defined __clang_major__ && __clang_major__ < 5 +# define HAS_BUILTIN_TRAP 0 +#elif 3 < __GNUC__ + (3 < __GNUC_MINOR__ + (4 <= __GNUC_PATCHLEVEL__)) +# define HAS_BUILTIN_TRAP 1 +#elif defined __has_builtin +# define HAS_BUILTIN_TRAP __has_builtin (__builtin_trap) +#else /* !__has_builtin */ +# define HAS_BUILTIN_TRAP 0 +#endif /* defined __clang_major__ && __clang_major__ < 5 */ + /* emacs_abort implementation for Android. This logs a stack trace. */ void emacs_abort (void) { +#ifndef HAS_BUILTIN_TRAP volatile char *foo; +#endif /* !HAS_BUILTIN_TRAP */ __android_log_print (ANDROID_LOG_FATAL, __func__, - "emacs_abort called, please review the ensuing" + "emacs_abort called, please review the following" " stack trace"); - /* Cause a NULL pointer dereference to make debuggerd generate a +#ifndef HAS_BUILTIN_TRAP + /* Induce a NULL pointer dereference to make debuggerd generate a tombstone. */ foo = NULL; *foo = '\0'; +#else /* HAS_BUILTIN_TRAP */ + /* Crash through __builtin_trap instead. This appears to more + uniformly elicit crash reports from debuggerd. */ + __builtin_trap (); +#endif /* !HAS_BUILTIN_TRAP */ abort (); } diff --git a/src/androidterm.c b/src/androidterm.c index 9b00ad85642..ef3c20f4e0f 100644 --- a/src/androidterm.c +++ b/src/androidterm.c @@ -2529,7 +2529,8 @@ android_draw_fringe_bitmap (struct window *w, struct glyph_row *row, /* Intersect the destination rectangle with that of the row. Setting a clip mask overrides the clip rectangles provided by - x_clip_to_row, so clipping must be performed by hand. */ + android_clip_to_row, so clipping must be performed by + hand. */ image_rect.x = p->x; image_rect.y = p->y;