Debugging with gdb, setting a breakpoint in main()


So I’m trying to do some debugging with gdb and noticed that setting my breakpoint at main() seems to be ignored by the debugger, it just goes ahead and executes the whole program when I give gdb the run command.

I did some research and apparently this is caused by Rust having a different main() function that actually executes the main() of your program. But based on the thread I was reading on this forum, that issue has already been fixed?

I’ve just upgraded gdb to 8.1, which supposedly has Rust support, and I’m still running into this problem. Setting the breakpoint at program_name::main is a quick workaround though.


I’m using gdb with Rust like this:

$ cargo test
$ rust-gdb ./target/debug/examples/some_exe
(gdb) b

Which would set a breakpoint in line 372 of the Rust code example called I hope this helps …