From 4258f083331cc10348f971149389cefc378f4f51 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Mon, 10 Mar 2014 11:57:40 +0100 Subject: [PATCH] android: Fix enabling debug logs when running under Valgrind --- android/bluetoothd-wrapper.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/android/bluetoothd-wrapper.c b/android/bluetoothd-wrapper.c index 80c59c900..3df6954a9 100644 --- a/android/bluetoothd-wrapper.c +++ b/android/bluetoothd-wrapper.c @@ -32,15 +32,17 @@ #define BLUETOOTHD_BIN "/system/bin/bluetoothd-main" -static void run_valgrind(void) +static void run_valgrind(int debug, int mgmt_dbg) { - char *prg_argv[4]; + char *prg_argv[6]; char *prg_envp[3]; prg_argv[0] = VALGRIND_BIN; prg_argv[1] = "--leak-check=full"; prg_argv[2] = BLUETOOTHD_BIN; - prg_argv[3] = NULL; + prg_argv[3] = debug ? "-d" : NULL; + prg_argv[4] = mgmt_dbg ? "--mgmt-debug" : NULL; + prg_argv[5] = NULL; prg_envp[0] = "G_SLICE=always-malloc"; prg_envp[1] = "G_DEBUG=gc-friendly"; @@ -70,10 +72,6 @@ int main(int argc, char *argv[]) int debug = 0; int mgmt_dbg = 0; - if (property_get(PROPERTY_VALGRIND_NAME, value, "") > 0 && - (!strcasecmp(value, "true") || atoi(value) > 0)) - run_valgrind(); - if (property_get(PROPERTY_DEBUG_NAME, value, "") > 0 && (!strcasecmp(value, "true") || atoi(value) > 0)) debug = 1; @@ -84,6 +82,10 @@ int main(int argc, char *argv[]) mgmt_dbg = 1; } + if (property_get(PROPERTY_VALGRIND_NAME, value, "") > 0 && + (!strcasecmp(value, "true") || atoi(value) > 0)) + run_valgrind(debug, mgmt_dbg); + /* In case we failed to execute Valgrind, try to run bluetoothd * without it */ -- 2.47.3