Fix Unicode name mangling
`{` and `}` aren’t valid characters on ARM. This also fixes a small bug where `)` (**r**ight **p**arenthesis) and `*` (**r**aw **p**ointer) would both mangle to `$RP$`, making `)` show up as `*` in backtraces.
This commit is contained in:
parent
7858cb432d
commit
cfe18fb836
3 changed files with 24 additions and 21 deletions
|
@ -227,9 +227,8 @@ pub fn sanitize(s: &str) -> String {
|
||||||
match c {
|
match c {
|
||||||
// Escape these with $ sequences
|
// Escape these with $ sequences
|
||||||
'@' => result.push_str("$SP$"),
|
'@' => result.push_str("$SP$"),
|
||||||
'~' => result.push_str("$UP$"),
|
'*' => result.push_str("$BP$"),
|
||||||
'*' => result.push_str("$RP$"),
|
'&' => result.push_str("$RF$"),
|
||||||
'&' => result.push_str("$BP$"),
|
|
||||||
'<' => result.push_str("$LT$"),
|
'<' => result.push_str("$LT$"),
|
||||||
'>' => result.push_str("$GT$"),
|
'>' => result.push_str("$GT$"),
|
||||||
'(' => result.push_str("$LP$"),
|
'(' => result.push_str("$LP$"),
|
||||||
|
@ -247,10 +246,14 @@ pub fn sanitize(s: &str) -> String {
|
||||||
| '_' | '.' | '$' => result.push(c),
|
| '_' | '.' | '$' => result.push(c),
|
||||||
|
|
||||||
_ => {
|
_ => {
|
||||||
let mut tstr = String::new();
|
|
||||||
for c in c.escape_unicode() { tstr.push(c) }
|
|
||||||
result.push('$');
|
result.push('$');
|
||||||
result.push_str(&tstr[1..]);
|
for c in c.escape_unicode().skip(1) {
|
||||||
|
match c {
|
||||||
|
'{' => {},
|
||||||
|
'}' => result.push('$'),
|
||||||
|
c => result.push(c),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,22 +57,22 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn demangle_dollars() {
|
fn demangle_dollars() {
|
||||||
t!("_ZN4$UP$E", "Box");
|
t!("_ZN4$RP$E", ")");
|
||||||
t!("_ZN8$UP$testE", "Boxtest");
|
t!("_ZN8$RF$testE", "&test");
|
||||||
t!("_ZN8$UP$test4foobE", "Boxtest::foob");
|
t!("_ZN8$BP$test4foobE", "*test::foob");
|
||||||
t!("_ZN10$u{20}test4foobE", " test::foob");
|
t!("_ZN9$u20$test4foobE", " test::foob");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn demangle_many_dollars() {
|
fn demangle_many_dollars() {
|
||||||
t!("_ZN14test$u{20}test4foobE", "test test::foob");
|
t!("_ZN13test$u20$test4foobE", "test test::foob");
|
||||||
t!("_ZN12test$UP$test4foobE", "testBoxtest::foob");
|
t!("_ZN12test$BP$test4foobE", "test*test::foob");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn demangle_windows() {
|
fn demangle_windows() {
|
||||||
t!("ZN4testE", "test");
|
t!("ZN4testE", "test");
|
||||||
t!("ZN14test$u{20}test4foobE", "test test::foob");
|
t!("ZN13test$u20$test4foobE", "test test::foob");
|
||||||
t!("ZN12test$UP$test4foobE", "testBoxtest::foob");
|
t!("ZN12test$RF$test4foobE", "test&test::foob");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,9 +107,8 @@ pub fn demangle(writer: &mut Writer, s: &str) -> IoResult<()> {
|
||||||
// see src/librustc/back/link.rs for these mappings
|
// see src/librustc/back/link.rs for these mappings
|
||||||
demangle! (
|
demangle! (
|
||||||
"$SP$", => "@",
|
"$SP$", => "@",
|
||||||
"$UP$", => "Box",
|
"$BP$", => "*",
|
||||||
"$RP$", => "*",
|
"$RF$", => "&",
|
||||||
"$BP$", => "&",
|
|
||||||
"$LT$", => "<",
|
"$LT$", => "<",
|
||||||
"$GT$", => ">",
|
"$GT$", => ">",
|
||||||
"$LP$", => "(",
|
"$LP$", => "(",
|
||||||
|
@ -118,10 +117,11 @@ pub fn demangle(writer: &mut Writer, s: &str) -> IoResult<()> {
|
||||||
|
|
||||||
// in theory we can demangle any Unicode code point, but
|
// in theory we can demangle any Unicode code point, but
|
||||||
// for simplicity we just catch the common ones.
|
// for simplicity we just catch the common ones.
|
||||||
"$u{20}", => " ",
|
"$u7e$", => "~",
|
||||||
"$u{27}", => "'",
|
"$u20$", => " ",
|
||||||
"$u{5b}", => "[",
|
"$u27$", => "'",
|
||||||
"$u{5d}", => "]"
|
"$u5b$", => "[",
|
||||||
|
"$u5d$", => "]"
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
let idx = match rest.find('$') {
|
let idx = match rest.find('$') {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue