-
Notifications
You must be signed in to change notification settings - Fork 38
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
base: main
Are you sure you want to change the base?
Changes from all commits
06053ff
7620f53
213a9a0
cf61d2e
680fe94
1941373
7e3619e
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 |
---|---|---|
|
@@ -25,6 +25,37 @@ | |
} | ||
] | ||
}, | ||
{ | ||
"id": "demangler", | ||
"type": "choice", | ||
"default": "auto", | ||
"name": "Demangler", | ||
"description": "Which demangler should be used to demangle each symbol.", | ||
"items": [ | ||
{ | ||
"value": "auto", | ||
"name": "Auto", | ||
"description": "Try to automatically guess the mangling format." | ||
}, | ||
{ | ||
"value": "codewarrior", | ||
"name": "CodeWarrior" | ||
}, | ||
{ | ||
"value": "msvc", | ||
"name": "MSVC" | ||
}, | ||
{ | ||
"value": "itanium", | ||
"name": "Itanium" | ||
}, | ||
{ | ||
"value": "gnu_v2", | ||
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. Thoughts on |
||
"name": "GNU g++ (V2)", | ||
"description": "Use the old GNU mangling ABI. Used up to g++ 2.9.x" | ||
} | ||
] | ||
}, | ||
{ | ||
"id": "analyzeDataFlow", | ||
"type": "boolean", | ||
|
@@ -259,6 +290,7 @@ | |
"name": "General", | ||
"properties": [ | ||
"functionRelocDiffs", | ||
"demangler", | ||
"spaceBetweenArgs", | ||
"combineDataSections", | ||
"combineTextSections" | ||
|
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('.'); | ||
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 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 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 |
||
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::Itanium => Self::demangle_itanium(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_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> { | ||
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 } | ||
} |
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.