summaryrefslogtreecommitdiff
path: root/libc/malloc_debug/tests/malloc_debug_config_tests.cpp
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2018-04-05 11:12:38 -0700
committerChristopher Ferris <cferris@google.com>2018-05-24 08:44:53 -0700
commit93bdd6ae3ad8322b7be2be0201c8db7227631d14 (patch)
tree42ee959b96c2c2db42f0569554680dbe22ce39ef /libc/malloc_debug/tests/malloc_debug_config_tests.cpp
parent4c5c45346fcc6f066a89bfc455f287fe2f4e3e41 (diff)
Add support for using the new unwinder.
This adds a new option backtrace_full, when it is set, then it will use libunwindstack. Modify the dump to file data to dump the extra information from libunwindstack. Along with the new dump file format, change the version to v1.1. Updated document for new format of file data. Add unit tests for the new functionality. Bug: 74361929 Test: Ran unit tests. Change-Id: I40fff795f5346bba7b9d7fde2e04f269ff4eb7f1
Diffstat (limited to 'libc/malloc_debug/tests/malloc_debug_config_tests.cpp')
-rw-r--r--libc/malloc_debug/tests/malloc_debug_config_tests.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/libc/malloc_debug/tests/malloc_debug_config_tests.cpp b/libc/malloc_debug/tests/malloc_debug_config_tests.cpp
index 460353583..2a6e39986 100644
--- a/libc/malloc_debug/tests/malloc_debug_config_tests.cpp
+++ b/libc/malloc_debug/tests/malloc_debug_config_tests.cpp
@@ -83,6 +83,11 @@ std::string usage_string(
"6 malloc_debug backtrace_dump_prefix.<PID>.final.txt.\n"
"6 malloc_debug The default is false.\n"
"6 malloc_debug \n"
+ "6 malloc_debug backtrace_full\n"
+ "6 malloc_debug Any time a backtrace is acquired, use an unwinder that can\n"
+ "6 malloc_debug display Java stack frames. This unwinder can run slower than\n"
+ "6 malloc_debug normal unwinder.\n"
+ "6 malloc_debug \n"
"6 malloc_debug fill_on_alloc[=XX]\n"
"6 malloc_debug On first allocation, fill with the value 0xeb.\n"
"6 malloc_debug If XX is set it will only fill up to XX bytes of the\n"
@@ -413,6 +418,24 @@ TEST_F(MallocDebugConfigTest, backtrace_dump_prefix) {
ASSERT_STREQ("", getFakeLogPrint().c_str());
}
+TEST_F(MallocDebugConfigTest, backtrace_full) {
+ ASSERT_TRUE(InitConfig("backtrace_full")) << getFakeLogPrint();
+ ASSERT_EQ(BACKTRACE_FULL, config->options());
+
+ ASSERT_STREQ("", getFakeLogBuf().c_str());
+ ASSERT_STREQ("", getFakeLogPrint().c_str());
+}
+
+TEST_F(MallocDebugConfigTest, backtrace_full_fail) {
+ ASSERT_FALSE(InitConfig("backtrace_full=200")) << getFakeLogPrint();
+
+ ASSERT_STREQ("", getFakeLogBuf().c_str());
+ std::string log_msg(
+ "6 malloc_debug malloc_testing: value set for option 'backtrace_full' "
+ "which does not take a value\n");
+ ASSERT_STREQ((log_msg + usage_string).c_str(), getFakeLogPrint().c_str());
+}
+
TEST_F(MallocDebugConfigTest, fill_on_alloc) {
ASSERT_TRUE(InitConfig("fill_on_alloc=64")) << getFakeLogPrint();
ASSERT_EQ(FILL_ON_ALLOC, config->options());