Fix a few demangler issues.

Specifically:

  * rvalue references.

  * St does not require N...E delimiters (explicit special case in the spec).

  * ".cfi" suffixes.

Bug: http://b/67678053
Test: ran tests
Change-Id: If8cabad448b46b165eefc6c5487996428c9c6975
This commit is contained in:
Elliott Hughes 2018-02-09 17:30:14 -08:00
parent 9d6b55928c
commit d7bb826a9c
2 changed files with 40 additions and 0 deletions

View file

@ -509,6 +509,29 @@ TEST(DemangleTest, non_virtual_thunk) {
ASSERT_EQ("_ZTH_N3oneE", demangler.Parse("_ZTH_N3oneE"));
}
TEST(DemangleTest, r_value_reference) {
Demangler demangler;
ASSERT_EQ(
"android::SurfaceComposerClient::Transaction::merge(android::SurfaceComposerClient::"
"Transaction&&)",
demangler.Parse("_ZN7android21SurfaceComposerClient11Transaction5mergeEOS1_"));
}
TEST(DemangleTest, initial_St) {
Demangler demangler;
EXPECT_EQ("std::state", demangler.Parse("_ZSt5state"));
EXPECT_EQ("std::_In::ward", demangler.Parse("_ZNSt3_In4wardE"));
EXPECT_EQ("std::__terminate(void (*)())", demangler.Parse("_ZSt11__terminatePFvvE"));
}
TEST(DemangleTest, cfi) {
Demangler demangler;
EXPECT_EQ("nfa_sys_ptim_timer_update(tPTIM_CB*)",
demangler.Parse("_Z25nfa_sys_ptim_timer_updateP8tPTIM_CB"));
EXPECT_EQ("nfa_sys_ptim_timer_update(tPTIM_CB*) [clone .cfi]",
demangler.Parse("_Z25nfa_sys_ptim_timer_updateP8tPTIM_CB.cfi"));
}
TEST(DemangleTest, demangle) {
std::string str;

View file

@ -580,6 +580,10 @@ const char* Demangler::ParseArguments(const char* name) {
}
return name + 1;
case 'O':
cur_state_.suffixes.push_back("&&");
return name + 1;
case 'K':
case 'V': {
const char* suffix;
@ -701,6 +705,9 @@ const char* Demangler::ParseArguments(const char* name) {
cur_state_.str.clear();
}
return name;
} else if (strcmp(name, ".cfi") == 0) {
function_suffix_ += " [clone .cfi]";
return name + 4;
}
}
return nullptr;
@ -816,6 +823,16 @@ const char* Demangler::FindFunctionName(const char* name) {
return name + 1;
}
if (*name == 'S') {
name++;
if (*name == 't') {
function_name_ = "std::";
name++;
} else {
return nullptr;
}
}
if (std::isdigit(*name)) {
name = GetStringFromLength(name, &function_name_);
} else if (*name == 'L' && std::isdigit(name[1])) {