From 7bd6dca85571fbc85767022943109e662d0252ed Mon Sep 17 00:00:00 2001 From: Alessandra Loro Date: Thu, 1 Sep 2022 10:33:35 +0000 Subject: [PATCH] Resolve ro.debuggable at build time Test: n/a Bug: 243645021 Change-Id: I42c4b1e81383d83c73a565c5e74ac22f17389faf --- debuggerd/Android.bp | 6 ++++++ debuggerd/include/debuggerd/handler.h | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/debuggerd/Android.bp b/debuggerd/Android.bp index c15146b09..1c89472b8 100644 --- a/debuggerd/Android.bp +++ b/debuggerd/Android.bp @@ -14,9 +14,15 @@ cc_defaults { "-Wno-nullability-completeness", "-Os", "-fno-finite-loops", + "-DANDROID_DEBUGGABLE=0", ], local_include_dirs: ["include"], + product_variables: { + debuggable: { + cflags: ["-UANDROID_DEBUGGABLE", "-DANDROID_DEBUGGABLE=1"], + } + }, } cc_library_headers { diff --git a/debuggerd/include/debuggerd/handler.h b/debuggerd/include/debuggerd/handler.h index bc08327a1..68b2e678b 100644 --- a/debuggerd/include/debuggerd/handler.h +++ b/debuggerd/include/debuggerd/handler.h @@ -62,10 +62,11 @@ void debuggerd_init(debuggerd_callbacks_t* callbacks); #define DEBUGGER_SIGNAL BIONIC_SIGNAL_DEBUGGER static void __attribute__((__unused__)) debuggerd_register_handlers(struct sigaction* action) { + bool enabled = true; +#if ANDROID_DEBUGGABLE 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")); + enabled = !(__system_property_get("debug.debuggerd.disable", value) > 0 && !strcmp(value, "1")); +#endif if (enabled) { sigaction(SIGABRT, action, nullptr); sigaction(SIGBUS, action, nullptr);