diff options
author | Tamas Berghammer <tberghammer@google.com> | 2016-08-26 15:54:59 +0100 |
---|---|---|
committer | Christopher Ferris <cferris@google.com> | 2016-11-17 13:13:27 -0800 |
commit | ac81fe8657119c265edcc2f05b3e5b7c5b17ae9f (patch) | |
tree | 99a6e825926829bb7c8d955cbc96ae1777691ef9 /libc/malloc_debug/Config.cpp | |
parent | 8945d5e43a25737f3f888a90742cc918b1124a05 (diff) |
Enable malloc debug using environment variables
Previously malloc debug can be enabled only using global settings
accessible to the root user only. This CL adds a new option to enable
it using environment variables making it possible to use it with pure
native (shell) applications on production builds (from shell user) and
prepares it for using it from logwrapper on production devices.
Remove the old environment variable and property since they are not
necessary.
Test: Enable malloc debug using environment variable and verify
Test: that it only affects the commands launched from the shell.
Test: Enable malloc debug using the property variable and verify
Test: that it affects all commands.
Test: Run all unit tests in 32 bit and 64 bit.
Change-Id: Iecb75a3471552f619f196ad550c5f41fcd9ce8e5
Diffstat (limited to 'libc/malloc_debug/Config.cpp')
-rw-r--r-- | libc/malloc_debug/Config.cpp | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/libc/malloc_debug/Config.cpp b/libc/malloc_debug/Config.cpp index c9fb850d8..cb75bd603 100644 --- a/libc/malloc_debug/Config.cpp +++ b/libc/malloc_debug/Config.cpp @@ -37,8 +37,6 @@ #include <string> #include <vector> -#include <sys/system_properties.h> - #include <private/bionic_macros.h> #include "Config.h" @@ -329,13 +327,7 @@ void PropertyParser::LogUsage() { // This function is designed to be called once. A second call will not // reset all variables. -bool Config::SetFromProperties() { - char property_str[PROP_VALUE_MAX]; - memset(property_str, 0, sizeof(property_str)); - if (!__system_property_get("libc.debug.malloc.options", property_str)) { - return false; - } - +bool Config::Set(const char* options_str) { // Initialize a few default values. fill_alloc_value = DEFAULT_FILL_ALLOC_VALUE; fill_free_value = DEFAULT_FILL_FREE_VALUE; @@ -426,7 +418,7 @@ bool Config::SetFromProperties() { } // Process each property name we can find. - PropertyParser parser(property_str); + PropertyParser parser(options_str); bool valid = true; std::string property; std::string value; |