Only observed on x86_32, see https://github.com/rust-lang/rust/pull/40367#issuecomment-293623287 and relevant code in GDB source.
LLVM appears to generate the .loc` for the first LLVM IR instruction in a function just before the last instruction of the prologue, resulting in GDB refusing to break on that location (by file and line number).
Not sure if this is solvable in GDB - perhaps by using the location information from the prologue after the prologue? Or maybe the intention is to actually never do that? It's really not clear from the GDB source.
Before #40367, we used to have a branch from the LLVM IR entry block to the MIR start block, which triggered the problem, but not in an user-visible way. Subsequent instructions were and still are unaffected.
As a workaround, I changed producer
from rustc version _
to clang LLVM (rustc version _)
.
cc @michaelwoerister @Manishearth
Why not future-proof this sucker and go with Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (LLVM, like Clang) Rust/1.18.0 Safari/537.36
?
The original gdb thread starts here: https://sourceware.org/ml/gdb-patches/2012-11/msg00492.html
It seems that the idea was to use producer sniffing to decide when the DWARF prologue information can be trusted; but it was done in a way that is specific to clang. LLVM doesn't seem to mention its own presence generically in the producer; that is, for clang I see just "clang version 3.8.1 (tags/RELEASE_381/final)".
I filed a gdb bug for this here: https://sourceware.org/bugzilla/show_bug.cgi?id=21470
IMO gdb should check for the presence of "clang" or for "LLVM". Then all languages like Rust that use llvm can put "LLVM" into their producer string when encountering the bug. We can then kindly ask clang to include "LLVM" into its producer string as well, and long term the "clang" check in gdb can be removed some day.
Yeah, that would be an improvement. I wonder though if gdb can just blacklist producers instead though. I plan to try that.
Most helpful comment
Why not future-proof this sucker and go with
Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (LLVM, like Clang) Rust/1.18.0 Safari/537.36
?