Debugging disabled after adding dependency

I'm doing AoC, and I'm using the opportunity to learn Rust. I have noticed that every day that I've added the dependency 'regex':

[dependencies]
regex = "1.3.9"

gdb can't see any debugging information in the binary. (This is on Linux, a Debian variety.)

I've tried:

export RUSTFLAGS=-g

Hopefully this is an easy fix and not some weird bug?

thx

That shouldn't happen. Can you show the output of gdb both before and after the change that breaks debuginfo?

I don't see any difference in the gdb start-up text. "list main" doesn't work in either binary. 'cgdb' is able to display main() in the non-regex binary, but not in the regex binary.

hmm, in the good binary, simply asking "list" lists the main file. In the bad binary, "list' says:

1 /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/core/src/iter/traits/collect.rs: No such file or directory.

If you are inside the standard library, to show it's sources you need to tell gdb where to find the standard library sources or use the rust-gdb wrapper that ships with gdb to do this for you. You also need to install the standard library sources using rustup component add rust-src.

Thanks for that rustup command. And using rust-gdb does let 'list' work, but it still doesn't get me to the main file and I prefer cgdb.

The work-around that I've settled on is to 'list <main_module>::main'.

I guess the remaining question for me is, Why does the version without regex work? What changed in the linker step, and could it be fixed?

Anyways, thanks again.

If list shows /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/core/src/iter/traits/collect.rs as location, that means that you are currently inside a function defined by the standard library. You can use up to change focus to the caller. (call as many times as you need to get back to your own code)

RUST_GDB=cgdb rust-gdb may work if cgdb accepts the same arguments as gdb. The RUST_GDB env var defines which command to invoke in the place of gdb.

1 Like