Go to the documentation of this file.
20 #include "absl/debugging/internal/demangle.h"
28 namespace debugging_internal {
45 {
"da",
"delete[]", 1},
93 {
nullptr,
nullptr, 0},
104 {
"a",
"signed char", 0},
105 {
"h",
"unsigned char", 0},
107 {
"t",
"unsigned short", 0},
109 {
"j",
"unsigned int", 0},
111 {
"m",
"unsigned long", 0},
112 {
"x",
"long long", 0},
113 {
"y",
"unsigned long long", 0},
114 {
"n",
"__int128", 0},
115 {
"o",
"unsigned __int128", 0},
118 {
"e",
"long double", 0},
119 {
"g",
"__float128", 0},
120 {
"z",
"ellipsis", 0},
122 {
"De",
"decimal128", 0},
123 {
"Dd",
"decimal64", 0},
124 {
"Dc",
"decltype(auto)", 0},
126 {
"Dn",
"std::nullptr_t", 0},
127 {
"Df",
"decimal32", 0},
128 {
"Di",
"char32_t", 0},
129 {
"Du",
"char8_t", 0},
130 {
"Ds",
"char16_t", 0},
131 {
"Dh",
"float16", 0},
132 {
nullptr,
nullptr, 0},
138 {
"Sa",
"allocator", 0},
139 {
"Sb",
"basic_string", 0},
143 {
"Si",
"istream", 0},
145 {
"So",
"ostream", 0},
147 {
"Sd",
"iostream", 0},
148 {
nullptr,
nullptr, 0},
166 static_assert(
sizeof(
ParseState) == 4 *
sizeof(
int),
167 "unexpected size of ParseState");
187 class ComplexityGuard {
190 ++
state->recursion_depth;
193 ~ComplexityGuard() { --
state_->recursion_depth; }
216 bool IsTooComplex()
const {
230 while (*
str !=
'\0') {
239 for (
int i = 0;
i <
n; ++
i) {
240 if (
str[
i] ==
'\0') {
258 state->mangled_begin = mangled;
261 state->recursion_depth = 0;
264 state->parse_state.mangled_idx = 0;
265 state->parse_state.out_cur_idx = 0;
266 state->parse_state.prev_name_idx = 0;
267 state->parse_state.prev_name_length = -1;
268 state->parse_state.nest_level = -1;
269 state->parse_state.append =
true;
273 return &
state->mangled_begin[
state->parse_state.mangled_idx];
280 ComplexityGuard guard(
state);
281 if (guard.IsTooComplex())
return false;
283 ++
state->parse_state.mangled_idx;
293 ComplexityGuard guard(
state);
294 if (guard.IsTooComplex())
return false;
297 state->parse_state.mangled_idx += 2;
306 ComplexityGuard guard(
state);
307 if (guard.IsTooComplex())
return false;
311 const char *p = char_class;
312 for (; *p !=
'\0'; ++p) {
314 ++
state->parse_state.mangled_idx;
324 if (digit !=
nullptr) {
338 if (parse_func(
state)) {
339 while (parse_func(
state)) {
351 while (parse_func(
state)) {
361 if (
state->parse_state.out_cur_idx + 1 <
362 state->out_end_idx) {
366 state->parse_state.out_cur_idx =
state->out_end_idx + 1;
370 if (
state->parse_state.out_cur_idx <
state->out_end_idx) {
377 static bool IsLower(
char c) {
return c >=
'a' && c <=
'z'; }
380 return (c >=
'a' && c <=
'z') || (c >=
'A' && c <=
'Z');
383 static bool IsDigit(
char c) {
return c >=
'0' && c <=
'9'; }
392 while (
str[
i] !=
'\0') {
416 return state->parse_state.out_cur_idx > 0 &&
417 state->parse_state.out_cur_idx <
state->out_end_idx &&
432 if (
state->parse_state.out_cur_idx <
state->out_end_idx &&
434 state->parse_state.prev_name_idx =
state->parse_state.out_cur_idx;
444 constexpr
size_t kMaxLength = 20;
445 char buf[kMaxLength];
449 if (
state->parse_state.append) {
452 char *p = &
buf[kMaxLength];
454 *--p = (val % 10) +
'0';
456 }
while (p >
buf && val != 0);
468 if (
state->parse_state.append) {
477 state->parse_state.nest_level = 0;
483 state->parse_state.nest_level = prev_value;
489 state->parse_state.append =
false;
495 state->parse_state.append = prev_value;
501 if (
state->parse_state.nest_level > -1) {
502 ++
state->parse_state.nest_level;
508 if (
state->parse_state.nest_level >= 1) {
515 if (
state->parse_state.nest_level >= 1 &&
state->parse_state.append &&
516 state->parse_state.out_cur_idx >= 2) {
517 state->parse_state.out_cur_idx -= 2;
526 static const char anon_prefix[] =
"_GLOBAL__N_";
527 return (
length >
static_cast<int>(
sizeof(anon_prefix) - 1) &&
608 ComplexityGuard guard(
state);
609 if (guard.IsTooComplex())
return false;
617 ComplexityGuard guard(
state);
618 if (guard.IsTooComplex())
return false;
639 ComplexityGuard guard(
state);
640 if (guard.IsTooComplex())
return false;
669 ComplexityGuard guard(
state);
670 if (guard.IsTooComplex())
return false;
695 ComplexityGuard guard(
state);
696 if (guard.IsTooComplex())
return false;
721 ComplexityGuard guard(
state);
722 if (guard.IsTooComplex())
return false;
723 bool has_something =
false;
730 has_something =
true;
750 ComplexityGuard guard(
state);
751 if (guard.IsTooComplex())
return false;
759 ComplexityGuard guard(
state);
760 if (guard.IsTooComplex())
return false;
776 ComplexityGuard guard(
state);
777 if (guard.IsTooComplex())
return false;
792 ComplexityGuard guard(
state);
793 if (guard.IsTooComplex())
return false;
831 ComplexityGuard guard(
state);
832 if (guard.IsTooComplex())
return false;
839 for (; *p !=
'\0'; ++p) {
854 if (number_out !=
nullptr) {
866 ComplexityGuard guard(
state);
867 if (guard.IsTooComplex())
return false;
869 for (; *p !=
'\0'; ++p) {
870 if (!
IsDigit(*p) && !(*p >=
'a' && *p <=
'f')) {
884 ComplexityGuard guard(
state);
885 if (guard.IsTooComplex())
return false;
887 for (; *p !=
'\0'; ++p) {
888 if (!
IsDigit(*p) && !(*p >=
'A' && *p <=
'Z')) {
901 ComplexityGuard guard(
state);
902 if (guard.IsTooComplex())
return false;
919 ComplexityGuard guard(
state);
920 if (guard.IsTooComplex())
return false;
929 if (arity !=
nullptr) {
954 if (arity !=
nullptr) {
962 state->parse_state.mangled_idx += 2;
989 ComplexityGuard guard(
state);
990 if (guard.IsTooComplex())
return false;
1051 ComplexityGuard guard(
state);
1052 if (guard.IsTooComplex())
return false;
1071 ComplexityGuard guard(
state);
1072 if (guard.IsTooComplex())
return false;
1078 ComplexityGuard guard(
state);
1079 if (guard.IsTooComplex())
return false;
1097 ComplexityGuard guard(
state);
1098 if (guard.IsTooComplex())
return false;
1102 const char *
const prev_name =
1105 state->parse_state.prev_name_length);
1115 const char *
const prev_name =
state->
out +
state->parse_state.prev_name_idx;
1118 state->parse_state.prev_name_length);
1129 ComplexityGuard guard(
state);
1130 if (guard.IsTooComplex())
return false;
1162 ComplexityGuard guard(
state);
1163 if (guard.IsTooComplex())
return false;
1239 ComplexityGuard guard(
state);
1240 if (guard.IsTooComplex())
return false;
1241 int num_cv_qualifiers = 0;
1245 return num_cv_qualifiers > 0;
1256 ComplexityGuard guard(
state);
1257 if (guard.IsTooComplex())
return false;
1261 if (p->abbrev[1] ==
'\0') {
1288 ComplexityGuard guard(
state);
1289 if (guard.IsTooComplex())
return false;
1310 ComplexityGuard guard(
state);
1311 if (guard.IsTooComplex())
return false;
1325 ComplexityGuard guard(
state);
1326 if (guard.IsTooComplex())
return false;
1340 ComplexityGuard guard(
state);
1341 if (guard.IsTooComplex())
return false;
1348 ComplexityGuard guard(
state);
1349 if (guard.IsTooComplex())
return false;
1367 ComplexityGuard guard(
state);
1368 if (guard.IsTooComplex())
return false;
1380 ComplexityGuard guard(
state);
1381 if (guard.IsTooComplex())
return false;
1400 ComplexityGuard guard(
state);
1401 if (guard.IsTooComplex())
return false;
1409 ComplexityGuard guard(
state);
1410 if (guard.IsTooComplex())
return false;
1428 ComplexityGuard guard(
state);
1429 if (guard.IsTooComplex())
return false;
1551 ComplexityGuard guard(
state);
1552 if (guard.IsTooComplex())
return false;
1581 ComplexityGuard guard(
state);
1582 if (guard.IsTooComplex())
return false;
1637 ComplexityGuard guard(
state);
1638 if (guard.IsTooComplex())
return false;
1690 state->parse_state = copy2;
1770 ComplexityGuard guard(
state);
1771 if (guard.IsTooComplex())
return false;
1803 ComplexityGuard guard(
state);
1804 if (guard.IsTooComplex())
return false;
1832 ComplexityGuard guard(
state);
1833 if (guard.IsTooComplex())
return false;
1843 if (
state->parse_state.append) {
1851 ComplexityGuard guard(
state);
1852 if (guard.IsTooComplex())
return false;
1864 ComplexityGuard guard(
state);
1865 if (guard.IsTooComplex())
return false;
1886 ComplexityGuard guard(
state);
1887 if (guard.IsTooComplex())
return false;
1906 (accept_std || p->abbrev[1] !=
't')) {
1908 if (p->real_name[0] !=
'\0') {
1912 ++
state->parse_state.mangled_idx;
1924 ComplexityGuard guard(
state);
1925 if (guard.IsTooComplex())
return false;
1946 return state->parse_state.out_cur_idx >=
state->out_end_idx;
1954 state.parse_state.out_cur_idx > 0;
static bool ParseLocalSourceName(State *state)
static bool OneOrMore(ParseFunc parse_func, State *state)
static const AbbrevPair kSubstitutionList[]
static bool Optional(bool)
static bool IdentifierIsAnonymousNamespace(State *state, int length)
static bool MaybeAppend(State *state, const char *const str)
static bool ParseEncoding(State *state)
static void MaybeAppendSeparator(State *state)
static bool ParseDecltype(State *state)
static bool ParseIdentifier(State *state, int length)
static bool ParseLocalName(State *state)
static constexpr int kParseStepsLimit
static bool ParseOneCharToken(State *state, const char one_char_token)
static bool ParseArrayType(State *state)
static void MaybeIncreaseNestLevel(State *state)
static int copy(grpc_slice_buffer *input, grpc_slice_buffer *output)
signed int prev_name_length
static bool ParseTemplateParam(State *state)
static bool DisableAppend(State *state)
static bool ParseLocalNameSuffix(State *state)
static bool EnterNestedName(State *state)
static bool ParseSpecialName(State *state)
static void Append(State *state, const char *const str, const int length)
static void MaybeAppendWithLength(State *state, const char *const str, const int length)
static bool ParseCVQualifiers(State *state)
static bool ParseDiscriminator(State *state)
static bool RestoreAppend(State *state, bool prev_value)
bool(* ParseFunc)(State *)
static bool ParseUnresolvedType(State *state)
static bool ParseType(State *state)
#define ABSL_NAMESPACE_END
static bool ParseMangledName(State *state)
static bool ParseNestedName(State *state)
static bool ParsePointerToMemberType(State *state)
static bool ParseVOffset(State *state)
static bool ParseClassEnumType(State *state)
static bool ParseBareFunctionType(State *state)
static bool ParseBuiltinType(State *state)
static bool ParseSubstitution(State *state, bool accept_std)
static bool IsDigit(char c)
static bool ParseCharClass(State *state, const char *char_class)
static bool MaybeAppendDecimal(State *state, unsigned int val)
static bool ParseNVOffset(State *state)
#define ABSL_NAMESPACE_BEGIN
static bool ParseBaseUnresolvedName(State *state)
static constexpr int kRecursionDepthLimit
static bool Overflowed(const State *state)
static bool ParseTemplateTemplateParam(State *state)
static bool IsAlpha(char c)
unsigned char out[MAXWIN]
unsigned __int64 uint64_t
static bool IsLower(char c)
static uint8_t negative(signed char b)
static bool ParseFunctionType(State *state)
static bool ParseExceptionSpec(State *state)
static const char * RemainingInput(State *state)
static bool AtLeastNumCharsRemaining(const char *str, int n)
static bool ParseCtorDtorName(State *state)
static bool ParseTwoCharToken(State *state, const char *two_char_token)
static bool EndsWith(State *state, const char chr)
static bool ParsePrefix(State *state)
static bool ParseTemplateArgs(State *state)
static bool ParseFloatNumber(State *state)
static bool ParseExprPrimary(State *state)
static bool ParseOperatorName(State *state, int *arity)
static bool ParseSeqId(State *state)
static bool ZeroOrMore(ParseFunc parse_func, State *state)
static bool IsFunctionCloneSuffix(const char *str)
bool Demangle(const char *mangled, char *out, int out_size)
static bool ParseDigit(State *state, int *digit)
static bool ParseNumber(State *state, int *number_out)
static const char prefix[]
static bool ParseUnnamedTypeName(State *state)
static const AbbrevPair kBuiltinTypeList[]
static bool ParseUnqualifiedName(State *state)
static bool ParseUnresolvedName(State *state)
const char * mangled_begin
static bool ParseName(State *state)
static bool LeaveNestedName(State *state, int16_t prev_value)
static bool ParseTopLevelMangledName(State *state)
static void InitState(State *state, const char *mangled, char *out, int out_size)
static const AbbrevPair kOperatorList[]
static bool ParseCallOffset(State *state)
static size_t StrLen(const char *str)
static bool StrPrefix(const char *str, const char *prefix)
static bool ParseRefQualifier(State *state)
static bool ParseSourceName(State *state)
static bool ParseExpression(State *state)
static void MaybeCancelLastSeparator(State *state)
static bool ParseExprCastValue(State *state)
static bool ParseTemplateArg(State *state)
static struct rpc_state state
static bool ParseUnscopedName(State *state)
static bool ParseSimpleId(State *state)
grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:09