diff options
author | Josh Gao <jmgao@google.com> | 2018-02-27 16:10:29 -0800 |
---|---|---|
committer | Josh Gao <jmgao@google.com> | 2018-02-28 14:16:14 -0800 |
commit | e2176118f4e7a9e2470310f978a40dbdcc904fb3 (patch) | |
tree | bb6c73abb2573c730d63d4e611fa740063686f36 /adb | |
parent | c8a22bc1afa858af2e7319df41ee05d6dd1a2d4d (diff) | |
download | core-e2176118f4e7a9e2470310f978a40dbdcc904fb3.tar.gz core-e2176118f4e7a9e2470310f978a40dbdcc904fb3.tar.bz2 core-e2176118f4e7a9e2470310f978a40dbdcc904fb3.zip |
adb: add a way to make the server intentionally leak.
Add a way to test LeakSanitizer with the server by adding an
environment variable that intentionally leaks.
Test: ASAN_OPTIONS=detect_leaks=1:leak_check_at_exit=1 ADB_LEAK=1 adb server nodaemon
Change-Id: I7255d45335fa009dc9e5de99dff67af52bd70e06
Diffstat (limited to 'adb')
-rw-r--r-- | adb/client/main.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/adb/client/main.cpp b/adb/client/main.cpp index f28302b61..e5666bc8d 100644 --- a/adb/client/main.cpp +++ b/adb/client/main.cpp @@ -75,6 +75,11 @@ void adb_server_cleanup() { usb_cleanup(); } +static void intentionally_leak() { + void* p = ::operator new(1); + LOG(INFO) << "leaking pointer " << p; +} + int adb_server_main(int is_daemon, const std::string& socket_spec, int ack_reply_fd) { #if defined(_WIN32) // adb start-server starts us up with stdout and stderr hooked up to @@ -98,6 +103,11 @@ int adb_server_main(int is_daemon, const std::string& socket_spec, int ack_reply }); #endif + char* leak = getenv("ADB_LEAK"); + if (leak && strcmp(leak, "1") == 0) { + intentionally_leak(); + } + if (is_daemon) { close_stdin(); setup_daemon_logging(); |