1 year ago

#77144

test-img

at54321

Difference between debug=1 and debug=2

As I was testing this, I ran a test program with the Cargo setting:

[profile.release]
debug = 1

I got exactly the same stacktrace as if with debug = 2:

$ RUST_BACKTRACE=1 cargo run --release
    Finished release [optimized + debuginfo] target(s) in 0.02s
     Running `target/release/an`
Error: param not big enough!

Stack backtrace:
   0: an::bb
             at ./src/main.rs:18:5
      an::aa
             at ./src/main.rs:13:2
      an::main
             at ./src/main.rs:6:2
   1: core::ops::function::FnOnce::call_once
             at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/core/src/ops/function.rs:227:5
      std::sys_common::backtrace::__rust_begin_short_backtrace
             at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/std/src/sys_common/backtrace.rs:123:18
   2: std::rt::lang_start::{{closure}}
             at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/std/src/rt.rs:145:18
   3: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
             at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/core/src/ops/function.rs:259:13
      std::panicking::try::do_call
             at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/std/src/panicking.rs:406:40
      std::panicking::try
             at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/std/src/panicking.rs:370:19
      std::panic::catch_unwind
             at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/std/src/panic.rs:133:14
      std::rt::lang_start_internal::{{closure}}
             at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/std/src/rt.rs:128:48
      std::panicking::try::do_call
             at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/std/src/panicking.rs:406:40
      std::panicking::try
             at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/std/src/panicking.rs:370:19
      std::panic::catch_unwind
             at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/std/src/panic.rs:133:14
      std::rt::lang_start_internal
             at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/std/src/rt.rs:128:20
   4: main
   5: __libc_start_main
   6: _start

Why?

The doc says:

The valid options are:

  • 0 or false: no debug info at all
  • 1: line tables only
  • 2 or true: full debug info

So I expected only line numbers would be present in the stack trace with debug = 1.

(BTW the binary file size with debug = 2 was considerably bigger than with debug = 1, so obviously there is some difference somewhere...)

rust

rust-cargo

0 Answers

Your Answer

Accepted video resources