-
Notifications
You must be signed in to change notification settings - Fork 49
Arch-independent demangling and add gnuv2_demangle for old g++ projects
#262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
06053ff
7620f53
213a9a0
cf61d2e
680fe94
1941373
7e3619e
6c9f241
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -308,18 +308,6 @@ impl Arch for ArchPpc { | |
| } | ||
| } | ||
|
|
||
| fn demangle(&self, mut name: &str) -> Option<String> { | ||
| if name.starts_with('?') { | ||
| msvc_demangler::demangle(name, msvc_demangler::DemangleFlags::llvm()).ok() | ||
| } else { | ||
| name = name.trim_start_matches('.'); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's keep this
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From what I can see only ppc has this trimming logic. Do you want to always trim
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can just add it for itanium/gnuv2
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gotcha. btw, I'm a bit curious, do you have an example a mangled symbol like this? I would like to take an small look at it. |
||
| cpp_demangle::Symbol::new(name) | ||
| .ok() | ||
| .and_then(|s| s.demangle(&cpp_demangle::DemangleOptions::default()).ok()) | ||
| .or_else(|| cwdemangle::demangle(name, &cwdemangle::DemangleOptions::default())) | ||
| } | ||
| } | ||
|
|
||
| fn reloc_name(&self, flags: RelocationFlags) -> Option<&'static str> { | ||
| match flags { | ||
| RelocationFlags::Elf(r_type) => match r_type { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| use alloc::string::String; | ||
|
|
||
| use crate::diff::Demangler; | ||
|
|
||
| #[cfg(feature = "demangler")] | ||
| impl Demangler { | ||
| pub fn demangle(&self, name: &str) -> Option<String> { | ||
| match self { | ||
| Demangler::Codewarrior => Self::demangle_codewarrior(name), | ||
| Demangler::Msvc => Self::demangle_msvc(name), | ||
| Demangler::GnuModern => Self::demangle_gnu_modern(name), | ||
| Demangler::GnuV2 => Self::demangle_gnu_v2(name), | ||
| Demangler::Auto => { | ||
| // Try to guess | ||
| if name.starts_with('?') { | ||
| Self::demangle_msvc(name) | ||
| } else { | ||
| Self::demangle_codewarrior(name) | ||
| .or_else(|| Self::demangle_gnu_v2(name)) | ||
| .or_else(|| Self::demangle_gnu_modern(name)) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| fn demangle_codewarrior(name: &str) -> Option<String> { | ||
| cwdemangle::demangle(name, &cwdemangle::DemangleOptions::default()) | ||
| } | ||
|
|
||
| fn demangle_msvc(name: &str) -> Option<String> { | ||
| msvc_demangler::demangle(name, msvc_demangler::DemangleFlags::llvm()).ok() | ||
| } | ||
|
|
||
| fn demangle_gnu_modern(name: &str) -> Option<String> { | ||
| cpp_demangle::Symbol::new(name) | ||
| .ok() | ||
| .and_then(|s| s.demangle(&cpp_demangle::DemangleOptions::default()).ok()) | ||
| } | ||
|
|
||
| fn demangle_gnu_v2(name: &str) -> Option<String> { | ||
| gnuv2_demangle::demangle(name, &gnuv2_demangle::DemangleConfig::new_no_cfilt_mimics()).ok() | ||
| } | ||
| } | ||
|
|
||
| #[cfg(not(feature = "demangler"))] | ||
| impl Demangler { | ||
| pub fn demangle(&self, _name: &str) -> Option<String> { None } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.