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

example crashes #5

Closed matthiaskrgr closed 6 years ago

matthiaskrgr commented 6 years ago

what I did:

git clone https://github.com/gnzlbg/cargo-asm
cd cargo-asm
cargo build
RUST_BACKTRACE=1 ./target/debug/cargo-asm asm  lib_crate::bar::double_n --rust

=>

thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `"cargo_asm0-4ce2645c1a13a92e69757cfe527b30cb.rs"`,
 right: `".file"`', src/asm/parse.rs:248:17
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::_print
             at libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at libstd/sys_common/backtrace.rs:59
             at libstd/panicking.rs:206
   3: std::panicking::default_hook
             at libstd/panicking.rs:222
   4: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:400
   5: std::panicking::begin_panic_fmt
             at libstd/panicking.rs:347
   6: cargo_asm::asm::parse::function
             at src/asm/parse.rs:248
   7: cargo_asm::parse_files
             at src/main.rs:53
   8: cargo_asm::main
             at src/main.rs:108
   9: std::rt::lang_start::{{closure}}
             at /checkout/src/libstd/rt.rs:74
  10: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:305
  11: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:102
  12: std::rt::lang_start_internal
             at libstd/panicking.rs:284
             at libstd/panic.rs:361
             at libstd/rt.rs:58
  13: std::rt::lang_start
             at /checkout/src/libstd/rt.rs:74
  14: main
  15: __libc_start_main
  16: _start
matthiaskrgr commented 6 years ago

meta:

rustc 1.25.0-nightly (27a046e93 2018-02-18)
binary: rustc
commit-hash: 27a046e9338fb0455c33b13e8fe28da78212dedc
commit-date: 2018-02-18
host: x86_64-unknown-linux-gnu
release: 1.25.0-nightly
LLVM version: 6.0
gnzlbg commented 6 years ago

Can reproduce :)

gnzlbg commented 6 years ago

Will publish a new version once build bots run, but that commit should have fixed this. Thanks for the report :)

matthiaskrgr commented 6 years ago

Hmm :/

./target/debug/cargo-asm asm  lib_crate::bar::double_n --rust 
[ERROR]: could not find function at path "lib_crate::bar::double_n" in the generated assembly.
Maybe you meant one of the following functions?

  <alloc::raw_vec::RawVec<T, A>>::double
  syn::lit::parsing::boolean

Otherwise make sure that the function is present in the final binary (e.g. if it's a generic function, make sure that it is actually monomorphized) or try to do a --clean build (sometimes changes are not picked up).
gnzlbg commented 6 years ago

That's correct. You are calling cargo-asm on the cargo-asm crate, which does not contain a double_n function. You might want to try that in the cargo-asm/cargo-asm-test/lib_crate.

gnzlbg commented 6 years ago

I am going to word the readme a bit differently.

gnzlbg commented 6 years ago

So i've worded the readme differently. Let me know if it's more clear now :) And thanks for trying this out! You are the first non-me user :D

matthiaskrgr commented 6 years ago

I got it working now, thanks you! :)