Skip to content

Commit a9e9acb

Browse files
authored
Use --no-show-raw-insn to make disassemble parser simple. (#948)
1 parent 1e7bbbb commit a9e9acb

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

crates/stdarch-test/src/disassembly.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ pub(crate) fn disassemble_myself() -> HashSet<Function> {
8585
let objdump = env::var("OBJDUMP").unwrap_or_else(|_| "objdump".to_string());
8686
let output = Command::new(objdump.clone())
8787
.arg("--disassemble")
88+
.arg("--no-show-raw-insn")
8889
.arg(&me)
8990
.output()
9091
.unwrap_or_else(|_| panic!("failed to execute objdump. OBJDUMP={}", objdump));
@@ -156,20 +157,13 @@ fn parse(output: &str) -> HashSet<Function> {
156157
.skip_while(|s| *s == "lock") // skip x86-specific prefix
157158
.collect::<Vec<String>>()
158159
} else {
159-
// objdump
160+
// objdump with --no-show-raw-insn
160161
// Each line of instructions should look like:
161162
//
162-
// $rel_offset: ab cd ef 00 $instruction...
163-
let expected_len = if cfg!(target_arch = "arm") || cfg!(target_arch = "aarch64") {
164-
8
165-
} else {
166-
2
167-
};
168-
163+
// $rel_offset: $instruction...
169164
instruction
170165
.split_whitespace()
171166
.skip(1)
172-
.skip_while(|s| s.len() == expected_len && usize::from_str_radix(s, 16).is_ok())
173167
.skip_while(|s| *s == "lock") // skip x86-specific prefix
174168
.map(std::string::ToString::to_string)
175169
.collect::<Vec<String>>()

0 commit comments

Comments
 (0)