gnzlbg / cargo-asm

cargo subcommand showing the assembly or llvm-ir generated for Rust code
https://github.com/gnzlbg/cargo-asm
Other
1.19k stars 37 forks source link

inherent method test breaks #30

Closed petr-tik closed 6 years ago

petr-tik commented 6 years ago

Problem description

Looks like a regression in tests - one of the lines from rust src is repeated.

Also, push, mov and pop instructions are missing where expected

Info on system

$$$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04 LTS
Release:    18.04
Codename:   bionic
$$$ rustc -V
rustc 1.29.0-nightly (12ed235ad 2018-07-18)
$$$ cargo -V
cargo 1.29.0-nightly (af9e40c26 2018-07-05)

Stacktrace

stdout after running the test command below

---- inherent_method stdout ----
thread 'inherent_method' panicked at 'CLI assertion failed: `cargo run --bin cargo-asm -- asm --manifest-path cargo-asm-test/lib_crate --no-color --debug-info lib_crate::baz::Foo::foo_add --rust` StdOut mismatch: diff:
 pub fn foo_add(&self) -> usize {
- push    rbp
 mov     rbp, rsp
  self.x + self.y
 mov     rax, qword, ptr, [rdi, +, 8]
+ self.x + self.y
  add     rax, qword, ptr, [rdi]
 }
- pop     rbp
  ret

Steps to reproduce

cargo test inherent

Desired outcome in tests/cli.rs

#[test]
fn inherent_method() {
    let expected = if cfg!(target_os = "macos") || cfg!(target_os = "linux") {
        r#" pub fn foo_add(&self) -> usize {
 self.x + self.y
 mov     rax, qword, ptr, [rdi, +, 8]
 add     rax, qword, ptr, [rdi]
 }
 ret
gnzlbg commented 6 years ago

This is probably because you are not using rustc 1.25.0 which is what the tests expect.

If this test fails with Rust 1.25.0 let me know and I'll reopen.