From 76eb935bd42a8fb162b2b1df261a7483ed01ac79 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Mon, 24 Feb 2020 16:17:19 -0800 Subject: [PATCH] debuggerd: add an opt-out for OEMs that would rather collect core dumps. On userdebug/eng devices, check a system property to see whether we should create tombstones or not. OEMs that would rather have core dumps can set this property and configure /proc/sys/kernel/core_pattern appropriately. Bug: https://issuetracker.google.com/149663286 Test: set the property, cause a crash Change-Id: If894b4582a1820b64bdae819cec593b7710cb6e3 (cherry picked from commit 530ab81e4215c86832294434f032306656c8f3b7) --- debuggerd/include/debuggerd/handler.h | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/debuggerd/include/debuggerd/handler.h b/debuggerd/include/debuggerd/handler.h index 4f24360dc..665d24a7f 100644 --- a/debuggerd/include/debuggerd/handler.h +++ b/debuggerd/include/debuggerd/handler.h @@ -19,7 +19,9 @@ #include #include #include +#include #include +#include #include __BEGIN_DECLS @@ -50,16 +52,21 @@ void debuggerd_init(debuggerd_callbacks_t* callbacks); #define DEBUGGER_SIGNAL BIONIC_SIGNAL_DEBUGGER static void __attribute__((__unused__)) debuggerd_register_handlers(struct sigaction* action) { - sigaction(SIGABRT, action, nullptr); - sigaction(SIGBUS, action, nullptr); - sigaction(SIGFPE, action, nullptr); - sigaction(SIGILL, action, nullptr); - sigaction(SIGSEGV, action, nullptr); -#if defined(SIGSTKFLT) - sigaction(SIGSTKFLT, action, nullptr); -#endif - sigaction(SIGSYS, action, nullptr); - sigaction(SIGTRAP, action, nullptr); + char value[PROP_VALUE_MAX] = ""; + bool enabled = + !(__system_property_get("ro.debuggable", value) > 0 && !strcmp(value, "1") && + __system_property_get("debug.debuggerd.disable", value) > 0 && !strcmp(value, "1")); + if (enabled) { + sigaction(SIGABRT, action, nullptr); + sigaction(SIGBUS, action, nullptr); + sigaction(SIGFPE, action, nullptr); + sigaction(SIGILL, action, nullptr); + sigaction(SIGSEGV, action, nullptr); + sigaction(SIGSTKFLT, action, nullptr); + sigaction(SIGSYS, action, nullptr); + sigaction(SIGTRAP, action, nullptr); + } + sigaction(BIONIC_SIGNAL_DEBUGGER, action, nullptr); }