-
Notifications
You must be signed in to change notification settings - Fork 44
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
06053ff
[MIPS] Use gnuv2_demangle for better demangling
AngheloAlf 7620f53
Add gnuv2_demangle to x86
AngheloAlf 213a9a0
Arch independent demanglers
AngheloAlf cf61d2e
Use new demangling logic on the "Demangle..." popup
AngheloAlf 680fe94
Fixes
AngheloAlf 1941373
Rename to itanium
AngheloAlf 7e3619e
Allow selecting the demangler on the "Demangle" popup
AngheloAlf 6c9f241
Address review
AngheloAlf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
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::Itanium => Self::demangle_itanium(name), | ||
Demangler::GnuLegacy => Self::demangle_gnu_legacy(name), | ||
Demangler::Auto => { | ||
// Try to guess | ||
if name.starts_with('?') { | ||
Self::demangle_msvc(name) | ||
} else { | ||
Self::demangle_codewarrior(name) | ||
.or_else(|| Self::demangle_gnu_legacy(name)) | ||
.or_else(|| Self::demangle_itanium(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_itanium(name: &str) -> Option<String> { | ||
let name = name.trim_start_matches('.'); | ||
cpp_demangle::Symbol::new(name) | ||
.ok() | ||
.and_then(|s| s.demangle(&cpp_demangle::DemangleOptions::default()).ok()) | ||
} | ||
|
||
fn demangle_gnu_legacy(name: &str) -> Option<String> { | ||
let name = name.trim_start_matches('.'); | ||
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 } | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep this
.
trimming logicThere was a problem hiding this comment.
Choose a reason for hiding this comment
The 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
.
when the demangler is not msvc? Or should it be only be applied to specific demanglers (cpp_demangle, cwdemangle, etc) ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can just add it for itanium/gnuv2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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.
It is okay if you don't have any, don't worry much about it.