Skip to content

Commit 2a0cc57

Browse files
committed
Merge pull request #227 from osiewicz/optional-demangle-in-asm-listings
feat: Optionally leave function names in asm listings unmangled. Output of `cargo run -- --keep-mangled --lib -C symbol-mangling-version=v0 --asm 4` (shortened for brevity): Without `--keep-mangled`: ``` mov w0, #8 mov w1, #24 bl alloc::alloc::handle_alloc_error ``` With `--keep-mangled`: ``` mov w0, #8 mov w1, #24 bl __ZN5alloc5alloc18handle_alloc_error17h04014ba8bc4ecf83E ``` With `--full-name`: ``` mov w0, #8 mov w1, #24 bl alloc::alloc::handle_alloc_error::h04014ba8bc4ecf83 ```
2 parents 6d6d890 + 823c21c commit 2a0cc57

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/asm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,10 @@ pub fn dump_range(
274274
}
275275

276276
empty_line = false;
277-
#[allow(clippy::match_bool)]
278277
match fmt.name_display {
279278
crate::opts::NameDisplay::Full => safeprintln!("{line:#}"),
280-
_ => safeprintln!("{line}"),
279+
crate::opts::NameDisplay::Short => safeprintln!("{line}"),
280+
crate::opts::NameDisplay::Mangled => safeprintln!("{line:-}"),
281281
}
282282
}
283283
}

src/asm/statements.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,12 @@ impl std::fmt::Display for Instruction<'_> {
5757
write!(f, "{}", color!(self.op, OwoColorize::bright_blue))?;
5858
}
5959
if let Some(args) = self.args {
60-
let args = demangle::contents(args, f.alternate());
60+
let args = if f.sign_minus() {
61+
// Do not demangle
62+
Cow::from(args)
63+
} else {
64+
demangle::contents(args, f.alternate())
65+
};
6166
let w_label = demangle::color_local_labels(&args);
6267
let w_comment = demangle::color_comment(&w_label);
6368
write!(f, " {w_comment}")?;
@@ -78,7 +83,9 @@ impl std::fmt::Display for Statement<'_> {
7883
}
7984
}
8085
Statement::Instruction(i) => {
81-
if f.alternate() {
86+
if f.sign_minus() {
87+
write!(f, "\t{i:-#}")
88+
} else if f.alternate() {
8289
write!(f, "\t{i:#}")
8390
} else {
8491
write!(f, "\t{i}")

0 commit comments

Comments
 (0)