aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIliyan Malchev <malchev@google.com>2012-05-29 16:46:17 -0700
committerIliyan Malchev <malchev@google.com>2012-05-30 20:03:47 -0700
commit7d2e24eb167b6257f7935c7bd2023a708704ca1a (patch)
tree827446ee24c7175462c76278a56db005233bbcaf
parent03539a36b634bdfa61c06277cf25e0ca8e3105ba (diff)
downloadandroid_bionic-7d2e24eb167b6257f7935c7bd2023a708704ca1a.tar.gz
android_bionic-7d2e24eb167b6257f7935c7bd2023a708704ca1a.tar.bz2
android_bionic-7d2e24eb167b6257f7935c7bd2023a708704ca1a.zip
bionic: introduce libc.debug.malloc.program
libc.debug.malloc.program provides an additional level of control over which processes to enable libc.debug.malloc functionality for. The string value of libc.debug.malloc.program is matched against the program name; if the value of libc.debug.malloc.program is a substring of the program name, then malloc debug is applied to that program at whatever level libc.debug.malloc specifies. If lib.debug.malloc.program is not specified, then libc.debug.malloc has the same effect as before. For example, to enable libc.deubug.malloc = 10 only to the mediaserver, do the following: adb root # necessary for setprop adb setprop libc.debug.malloc.program mediaserver adb setprop libc.debug.malloc 10 adb kill -9 $(pid mediaserver) Change-Id: I6f01c12f033c8e2e015d73025369d7f1685ba200 Signed-off-by: Iliyan Malchev <malchev@google.com>
-rw-r--r--libc/bionic/malloc_debug_common.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/libc/bionic/malloc_debug_common.c b/libc/bionic/malloc_debug_common.c
index b9fcbc49b..6837e393d 100644
--- a/libc/bionic/malloc_debug_common.c
+++ b/libc/bionic/malloc_debug_common.c
@@ -298,6 +298,7 @@ static void malloc_init_impl(void)
unsigned int memcheck_enabled = 0;
char env[PROP_VALUE_MAX];
char memcheck_tracing[PROP_VALUE_MAX];
+ char debug_program[PROP_VALUE_MAX];
/* Get custom malloc debug level. Note that emulator started with
* memory checking option will have priority over debug level set in
@@ -325,6 +326,15 @@ static void malloc_init_impl(void)
return;
}
+ /* If libc.debug.malloc.program is set and is not a substring of progname,
+ * then exit.
+ */
+ if (__system_property_get("libc.debug.malloc.program", debug_program)) {
+ if (!strstr(__progname, debug_program)) {
+ return;
+ }
+ }
+
// Lets see which .so must be loaded for the requested debug level
switch (debug_level) {
case 1: