Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit e6aec82

Browse files
committed
Add Rust support to Mangled
This adds Rust support to Mangled. I am not completely certain that this is needed (or alternatively that it does enough, maybe Mangled::GuessLanguage needs a Rust case). This should be checked before attempting to upstream.
1 parent 6ac9939 commit e6aec82

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

source/Core/Mangled.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,35 @@ get_demangled_name_without_arguments(ConstString mangled,
135135
return g_last_mangled;
136136
}
137137

138+
static void remove_rust_hash(char *str) {
139+
char *iter = str + strlen(str) - 1;
140+
size_t hashcount = 0;
141+
while (true) {
142+
if (iter == str) {
143+
// Hit the start of the string too early.
144+
return;
145+
}
146+
if ((*iter >= '0' && *iter <= '9') ||
147+
(*iter >= 'a' && *iter <= 'f')) {
148+
++hashcount;
149+
--iter;
150+
if (hashcount > 16) {
151+
// Too many hash chars.
152+
return;
153+
}
154+
} else {
155+
// Not a hash char.
156+
break;
157+
}
158+
}
159+
if (*iter != 'h' || hashcount < 5 || str + 2 >= iter ||
160+
iter[-1] != ':' || iter[-2] != ':') {
161+
return;
162+
}
163+
iter[-2] = '\0';
164+
}
165+
166+
138167
#pragma mark Mangled
139168
//----------------------------------------------------------------------
140169
// Default constructor
@@ -320,6 +349,11 @@ Mangled::GetDemangledName(lldb::LanguageType language) const {
320349
log->Printf("demangled itanium: %s -> error: failed to demangle",
321350
mangled_name);
322351
}
352+
353+
if (language == lldb::eLanguageTypeRust) {
354+
remove_rust_hash(demangled_name);
355+
}
356+
323357
break;
324358
}
325359
case eManglingSchemeNone:

0 commit comments

Comments
 (0)