Commit 44e077d6 by Chris Mihelich Committed by Copybara-Service

Demangle thread_local helper functions.

PiperOrigin-RevId: 638039514
Change-Id: I623d87e91ebe0a1166fee175151179b61ef54249
parent 3ef92c6f
...@@ -1049,7 +1049,8 @@ static bool ParseOperatorName(State *state, int *arity) { ...@@ -1049,7 +1049,8 @@ static bool ParseOperatorName(State *state, int *arity) {
// ::= TT <type> // ::= TT <type>
// ::= TI <type> // ::= TI <type>
// ::= TS <type> // ::= TS <type>
// ::= TH <type> # thread-local // ::= TW <name> # thread-local wrapper
// ::= TH <name> # thread-local initialization
// ::= Tc <call-offset> <call-offset> <(base) encoding> // ::= Tc <call-offset> <call-offset> <(base) encoding>
// ::= GV <(object) name> // ::= GV <(object) name>
// ::= T <call-offset> <(base) encoding> // ::= T <call-offset> <(base) encoding>
...@@ -1062,13 +1063,31 @@ static bool ParseOperatorName(State *state, int *arity) { ...@@ -1062,13 +1063,31 @@ static bool ParseOperatorName(State *state, int *arity) {
// ::= Th <call-offset> <(base) encoding> // ::= Th <call-offset> <(base) encoding>
// ::= Tv <call-offset> <(base) encoding> // ::= Tv <call-offset> <(base) encoding>
// //
// Note: we don't care much about them since they don't appear in // Note: Most of these are special data, not functions that occur in stack
// stack traces. The are special data. // traces. Exceptions are TW and TH, which denote functions supporting the
// thread_local feature. For these see:
//
// https://maskray.me/blog/2021-02-14-all-about-thread-local-storage
static bool ParseSpecialName(State *state) { static bool ParseSpecialName(State *state) {
ComplexityGuard guard(state); ComplexityGuard guard(state);
if (guard.IsTooComplex()) return false; if (guard.IsTooComplex()) return false;
ParseState copy = state->parse_state; ParseState copy = state->parse_state;
if (ParseOneCharToken(state, 'T') && ParseCharClass(state, "VTISH") &&
if (ParseTwoCharToken(state, "TW")) {
MaybeAppend(state, "thread-local wrapper routine for ");
if (ParseName(state)) return true;
state->parse_state = copy;
return false;
}
if (ParseTwoCharToken(state, "TH")) {
MaybeAppend(state, "thread-local initialization routine for ");
if (ParseName(state)) return true;
state->parse_state = copy;
return false;
}
if (ParseOneCharToken(state, 'T') && ParseCharClass(state, "VTIS") &&
ParseType(state)) { ParseType(state)) {
return true; return true;
} }
......
...@@ -631,6 +631,16 @@ TEST(Demangle, ReferenceQualifiedFunctionTypes) { ...@@ -631,6 +631,16 @@ TEST(Demangle, ReferenceQualifiedFunctionTypes) {
EXPECT_STREQ("f()", tmp); EXPECT_STREQ("f()", tmp);
} }
TEST(Demangle, ThreadLocalWrappers) {
char tmp[80];
EXPECT_TRUE(Demangle("_ZTWN2ns3varE", tmp, sizeof(tmp)));
EXPECT_STREQ("thread-local wrapper routine for ns::var", tmp);
EXPECT_TRUE(Demangle("_ZTHN2ns3varE", tmp, sizeof(tmp)));
EXPECT_STREQ("thread-local initialization routine for ns::var", tmp);
}
// Test one Rust symbol to exercise Demangle's delegation path. Rust demangling // Test one Rust symbol to exercise Demangle's delegation path. Rust demangling
// itself is more thoroughly tested in demangle_rust_test.cc. // itself is more thoroughly tested in demangle_rust_test.cc.
TEST(Demangle, DelegatesToDemangleRustSymbolEncoding) { TEST(Demangle, DelegatesToDemangleRustSymbolEncoding) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment