diff options
author | Chris Mihelich <cmihelic@google.com> | 2024-06-05 07:21:37 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2024-06-05 07:22:24 -0700 |
commit | cba68bb93b102416843d364348bc29ca665da1ce (patch) | |
tree | a7a36832d8cadc81c99cbaf59b8337b0be3e3fca /absl/debugging | |
parent | 29bd16cb925bd762ac7ca90e26ad044200ae0711 (diff) |
Demangle modern _ZGR..._ symbols.
PiperOrigin-RevId: 640517212
Change-Id: Ideaaf45d2104a3c82cc9b6807894554335e5b904
Diffstat (limited to 'absl/debugging')
-rw-r--r-- | absl/debugging/internal/demangle.cc | 19 | ||||
-rw-r--r-- | absl/debugging/internal/demangle_test.cc | 20 |
2 files changed, 36 insertions, 3 deletions
diff --git a/absl/debugging/internal/demangle.cc b/absl/debugging/internal/demangle.cc index 7ce14713..ab611f71 100644 --- a/absl/debugging/internal/demangle.cc +++ b/absl/debugging/internal/demangle.cc @@ -1080,12 +1080,13 @@ static bool ParseOperatorName(State *state, int *arity) { // ::= TH <name> # thread-local initialization // ::= Tc <call-offset> <call-offset> <(base) encoding> // ::= GV <(object) name> +// ::= GR <(object) name> [<seq-id>] _ // ::= T <call-offset> <(base) encoding> // G++ extensions: // ::= TC <type> <(offset) number> _ <(base) type> // ::= TF <type> // ::= TJ <type> -// ::= GR <name> +// ::= GR <name> # without final _, perhaps an earlier form? // ::= GA <encoding> // ::= Th <call-offset> <(base) encoding> // ::= Tv <call-offset> <(base) encoding> @@ -1152,10 +1153,22 @@ static bool ParseSpecialName(State *state) { } state->parse_state = copy; - if (ParseTwoCharToken(state, "GR") && ParseName(state)) { + // <special-name> ::= GR <(object) name> [<seq-id>] _ # modern standard + // ::= GR <(object) name> # also recognized + if (ParseTwoCharToken(state, "GR")) { + MaybeAppend(state, "reference temporary for "); + if (!ParseName(state)) { + state->parse_state = copy; + return false; + } + const bool has_seq_id = ParseSeqId(state); + const bool has_underscore = ParseOneCharToken(state, '_'); + if (has_seq_id && !has_underscore) { + state->parse_state = copy; + return false; + } return true; } - state->parse_state = copy; if (ParseTwoCharToken(state, "GA") && ParseEncoding(state)) { return true; diff --git a/absl/debugging/internal/demangle_test.cc b/absl/debugging/internal/demangle_test.cc index 052c66bb..c70cf660 100644 --- a/absl/debugging/internal/demangle_test.cc +++ b/absl/debugging/internal/demangle_test.cc @@ -612,6 +612,26 @@ TEST(Demangle, StringLiterals) { EXPECT_STREQ("f<>()", tmp); } +TEST(Demangle, GlobalInitializers) { + char tmp[80]; + + // old form without suffix + EXPECT_TRUE(Demangle("_ZGR1v", tmp, sizeof(tmp))); + EXPECT_STREQ("reference temporary for v", tmp); + + // modern form for the whole initializer + EXPECT_TRUE(Demangle("_ZGR1v_", tmp, sizeof(tmp))); + EXPECT_STREQ("reference temporary for v", tmp); + + // next subobject in depth-first preorder traversal + EXPECT_TRUE(Demangle("_ZGR1v0_", tmp, sizeof(tmp))); + EXPECT_STREQ("reference temporary for v", tmp); + + // subobject with a larger seq-id + EXPECT_TRUE(Demangle("_ZGR1v1Z_", tmp, sizeof(tmp))); + EXPECT_STREQ("reference temporary for v", tmp); +} + // Test the GNU abi_tag extension. TEST(Demangle, AbiTags) { char tmp[80]; |