Add aliases for backtrace related options.

Using the long option names might not fit in the malloc debug option
property since properties have a 92 character limit.

This patch creates new aliases for the original options.

Bug: 264504531
Test: set new options pass
Test: Config unit tests pass.
Change-Id: Id985720f36a2bf0da7b35ff444c2c80eb1fb4363
This commit is contained in:
Junjie Hu 2023-01-10 18:30:45 +08:00 committed by Christopher Ferris
parent 42f97f5288
commit 8655d1741f
3 changed files with 104 additions and 2 deletions

View file

@ -86,36 +86,66 @@ const std::unordered_map<std::string, Config::OptionInfo> Config::kOptions = {
"backtrace_size",
{BACKTRACE_SPECIFIC_SIZES, &Config::SetBacktraceSize},
},
{
"bt_sz",
{BACKTRACE_SPECIFIC_SIZES, &Config::SetBacktraceSize},
},
{
"backtrace_min_size",
{BACKTRACE_SPECIFIC_SIZES, &Config::SetBacktraceMinSize},
},
{
"bt_min_sz",
{BACKTRACE_SPECIFIC_SIZES, &Config::SetBacktraceMinSize},
},
{
"backtrace_max_size",
{BACKTRACE_SPECIFIC_SIZES, &Config::SetBacktraceMaxSize},
},
{
"bt_max_sz",
{BACKTRACE_SPECIFIC_SIZES, &Config::SetBacktraceMaxSize},
},
{
"backtrace",
{BACKTRACE | TRACK_ALLOCS, &Config::SetBacktrace},
},
{
"bt",
{BACKTRACE | TRACK_ALLOCS, &Config::SetBacktrace},
},
{
"backtrace_enable_on_signal",
{BACKTRACE | TRACK_ALLOCS, &Config::SetBacktraceEnableOnSignal},
},
{
"bt_en_on_sig",
{BACKTRACE | TRACK_ALLOCS, &Config::SetBacktraceEnableOnSignal},
},
{
"backtrace_dump_on_exit",
{0, &Config::SetBacktraceDumpOnExit},
},
{
"bt_dmp_on_ex",
{0, &Config::SetBacktraceDumpOnExit},
},
{
"backtrace_dump_prefix",
{0, &Config::SetBacktraceDumpPrefix},
},
{
"bt_dmp_pre",
{0, &Config::SetBacktraceDumpPrefix},
},
{
"backtrace_full",
{BACKTRACE_FULL, &Config::VerifyValueEmpty},
},
{
"bt_full",
{BACKTRACE_FULL, &Config::VerifyValueEmpty},
},
{
"fill",

View file

@ -200,6 +200,20 @@ As of Q, any time that a backtrace is gathered, a different algorithm is used
that is extra thorough and can unwind through Java frames. This will run
slower than the normal backtracing function.
### bt, bt\_dmp\_on\_ex, bt\_dmp\_pre, bt\_en\_on\_sig, bt\_full, bt\_max\_sz, bt\_min\_sz, bt\_sz
As of U, add shorter aliases for backtrace related options to avoid property length restrictions.
| Alias | Option |
|:----------------|:------------------------------|
| bt | backtrace |
| bt\_dmp\_on\_ex | backtrace\_dump\_on\_exit |
| bt\_dmp\_pre | backtrace\_dump\_prefix |
| bt\_en\_on\_sig | backtrace\_enable\_on\_signal |
| bt\_full | backtrace\_full |
| bt\_max\_sz | backtrace\_max\_size |
| bt\_min\_sz | backtrace\_min\_size |
| bt\_sz | backtrace\_size |
### check\_unreachable\_on\_signal
As of Android U, this option will trigger a check for unreachable memory
in a process. Specifically, if the signal SIGRTMAX - 16 (which is 48 on

View file

@ -215,6 +215,13 @@ TEST_F(MallocDebugConfigTest, backtrace) {
ASSERT_FALSE(config->backtrace_enable_on_signal());
ASSERT_FALSE(config->backtrace_dump_on_exit());
ASSERT_TRUE(InitConfig("bt=23")) << getFakeLogPrint();
ASSERT_EQ(BACKTRACE | TRACK_ALLOCS, config->options());
ASSERT_EQ(23U, config->backtrace_frames());
ASSERT_TRUE(config->backtrace_enabled());
ASSERT_FALSE(config->backtrace_enable_on_signal());
ASSERT_FALSE(config->backtrace_dump_on_exit());
ASSERT_TRUE(InitConfig("backtrace")) << getFakeLogPrint();
ASSERT_EQ(BACKTRACE | TRACK_ALLOCS, config->options());
ASSERT_EQ(16U, config->backtrace_frames());
@ -222,6 +229,13 @@ TEST_F(MallocDebugConfigTest, backtrace) {
ASSERT_FALSE(config->backtrace_enable_on_signal());
ASSERT_FALSE(config->backtrace_dump_on_exit());
ASSERT_TRUE(InitConfig("bt")) << getFakeLogPrint();
ASSERT_EQ(BACKTRACE | TRACK_ALLOCS, config->options());
ASSERT_EQ(16U, config->backtrace_frames());
ASSERT_TRUE(config->backtrace_enabled());
ASSERT_FALSE(config->backtrace_enable_on_signal());
ASSERT_FALSE(config->backtrace_dump_on_exit());
ASSERT_STREQ("", getFakeLogBuf().c_str());
ASSERT_STREQ("", getFakeLogPrint().c_str());
}
@ -234,6 +248,13 @@ TEST_F(MallocDebugConfigTest, backtrace_enable_on_signal) {
ASSERT_TRUE(config->backtrace_enable_on_signal());
ASSERT_FALSE(config->backtrace_dump_on_exit());
ASSERT_TRUE(InitConfig("bt_en_on_sig=64")) << getFakeLogPrint();
ASSERT_EQ(BACKTRACE | TRACK_ALLOCS, config->options());
ASSERT_EQ(64U, config->backtrace_frames());
ASSERT_FALSE(config->backtrace_enabled());
ASSERT_TRUE(config->backtrace_enable_on_signal());
ASSERT_FALSE(config->backtrace_dump_on_exit());
ASSERT_TRUE(InitConfig("backtrace_enable_on_signal")) << getFakeLogPrint();
ASSERT_EQ(BACKTRACE | TRACK_ALLOCS, config->options());
ASSERT_EQ(16U, config->backtrace_frames());
@ -241,6 +262,13 @@ TEST_F(MallocDebugConfigTest, backtrace_enable_on_signal) {
ASSERT_TRUE(config->backtrace_enable_on_signal());
ASSERT_FALSE(config->backtrace_dump_on_exit());
ASSERT_TRUE(InitConfig("bt_en_on_sig")) << getFakeLogPrint();
ASSERT_EQ(BACKTRACE | TRACK_ALLOCS, config->options());
ASSERT_EQ(16U, config->backtrace_frames());
ASSERT_FALSE(config->backtrace_enabled());
ASSERT_TRUE(config->backtrace_enable_on_signal());
ASSERT_FALSE(config->backtrace_dump_on_exit());
ASSERT_STREQ("", getFakeLogBuf().c_str());
ASSERT_STREQ("", getFakeLogPrint().c_str());
}
@ -288,6 +316,10 @@ TEST_F(MallocDebugConfigTest, backtrace_dump_on_exit) {
ASSERT_EQ(0U, config->options());
ASSERT_TRUE(config->backtrace_dump_on_exit());
ASSERT_TRUE(InitConfig("bt_dmp_on_ex")) << getFakeLogPrint();
ASSERT_EQ(0U, config->options());
ASSERT_TRUE(config->backtrace_dump_on_exit());
ASSERT_STREQ("", getFakeLogBuf().c_str());
ASSERT_STREQ("", getFakeLogPrint().c_str());
}
@ -307,10 +339,18 @@ TEST_F(MallocDebugConfigTest, backtrace_dump_prefix) {
ASSERT_EQ(0U, config->options());
ASSERT_EQ("/data/local/tmp/backtrace_heap", config->backtrace_dump_prefix());
ASSERT_TRUE(InitConfig("bt_dmp_pre")) << getFakeLogPrint();
ASSERT_EQ(0U, config->options());
ASSERT_EQ("/data/local/tmp/backtrace_heap", config->backtrace_dump_prefix());
ASSERT_TRUE(InitConfig("backtrace_dump_prefix=/fake/location")) << getFakeLogPrint();
ASSERT_EQ(0U, config->options());
ASSERT_EQ("/fake/location", config->backtrace_dump_prefix());
ASSERT_TRUE(InitConfig("bt_dmp_pre=/fake/location")) << getFakeLogPrint();
ASSERT_EQ(0U, config->options());
ASSERT_EQ("/fake/location", config->backtrace_dump_prefix());
ASSERT_STREQ("", getFakeLogBuf().c_str());
ASSERT_STREQ("", getFakeLogPrint().c_str());
}
@ -319,6 +359,9 @@ TEST_F(MallocDebugConfigTest, backtrace_full) {
ASSERT_TRUE(InitConfig("backtrace_full")) << getFakeLogPrint();
ASSERT_EQ(BACKTRACE_FULL, config->options());
ASSERT_TRUE(InitConfig("bt_full")) << getFakeLogPrint();
ASSERT_EQ(BACKTRACE_FULL, config->options());
ASSERT_STREQ("", getFakeLogBuf().c_str());
ASSERT_STREQ("", getFakeLogPrint().c_str());
}
@ -786,6 +829,11 @@ TEST_F(MallocDebugConfigTest, size) {
ASSERT_EQ(37U, config->backtrace_min_size_bytes());
ASSERT_EQ(37U, config->backtrace_max_size_bytes());
ASSERT_TRUE(InitConfig("bt_sz=39")) << getFakeLogPrint();
ASSERT_EQ(BACKTRACE_SPECIFIC_SIZES, config->options());
ASSERT_EQ(39U, config->backtrace_min_size_bytes());
ASSERT_EQ(39U, config->backtrace_max_size_bytes());
ASSERT_FALSE(InitConfig("backtrace_size")) << getFakeLogPrint();
ASSERT_FALSE(InitConfig("backtrace_size=0")) << getFakeLogPrint();
ASSERT_FALSE(InitConfig("backtrace_size=-1")) << getFakeLogPrint();
@ -808,6 +856,11 @@ TEST_F(MallocDebugConfigTest, min_size) {
ASSERT_EQ(9U, config->backtrace_min_size_bytes());
ASSERT_EQ(SIZE_MAX, config->backtrace_max_size_bytes());
ASSERT_TRUE(InitConfig("bt_min_sz=11")) << getFakeLogPrint();
ASSERT_EQ(BACKTRACE_SPECIFIC_SIZES, config->options());
ASSERT_EQ(11U, config->backtrace_min_size_bytes());
ASSERT_EQ(SIZE_MAX, config->backtrace_max_size_bytes());
ASSERT_FALSE(InitConfig("backtrace_min_size")) << getFakeLogPrint();
ASSERT_FALSE(InitConfig("backtrace_min_size=0")) << getFakeLogPrint();
ASSERT_FALSE(InitConfig("backtrace_min_size=-1")) << getFakeLogPrint();
@ -830,6 +883,11 @@ TEST_F(MallocDebugConfigTest, max_size) {
ASSERT_EQ(0U, config->backtrace_min_size_bytes());
ASSERT_EQ(13U, config->backtrace_max_size_bytes());
ASSERT_TRUE(InitConfig("bt_max_sz=15")) << getFakeLogPrint();
ASSERT_EQ(BACKTRACE_SPECIFIC_SIZES, config->options());
ASSERT_EQ(0U, config->backtrace_min_size_bytes());
ASSERT_EQ(15U, config->backtrace_max_size_bytes());
ASSERT_FALSE(InitConfig("backtrace_max_size")) << getFakeLogPrint();
ASSERT_FALSE(InitConfig("backtrace_max_size=0")) << getFakeLogPrint();
ASSERT_FALSE(InitConfig("backtrace_max_size=-1")) << getFakeLogPrint();