Description
Including long functions appears to cause rustc to create invalid DWARF debug files. This leaves debugging and break-pointing unavailable. Debugging fails throughout the program, not just in the long functions.
Originally uncovered while porting (someone else's!) C code, which included a function of about 5k LOC. Also reproduced with macro-generated long methods. A minimal example is available here:
https://github.com/dan-fritchman/DwDemo
Previously reported this to LLDB, whose maintainers helped point out that the DWARF files appear invalid. Building from a fresh clone of that demo repo -
DwDemo $ cargo build
Compiling dwdemo v0.0.1 (/Users/dan/dev/HW21/DwDemo)
Finished dev [unoptimized + debuginfo] target(s) in 8.50s
DwDemo $ dwarfdump --debug-line target/debug/dwdemo.dSYM
error: target/debug/dwdemo.dSYM/Contents/Resources/DWARF/dwdemo: The file was not recognized as a valid object file
The demo's macros expand to a few similar-length functions, about 5-6k LOC. Shortening them (via shortening the structure/ schema files) causes dwarfdump
and lldb
to be happy with rustc's output -
DwDemo $ cargo build
Compiling dwdemo v0.0.1 (/Users/dan/dev/HW21/DwDemo)
Finished dev [unoptimized + debuginfo] target(s) in 4.11s
DwDemo $ dwarfdump --debug-line target/debug/dwdemo.dSYM | head -n 30
target/debug/dwdemo.dSYM/Contents/Resources/DWARF/dwdemo: file format Mach-O 64-bit x86-64
.debug_line contents:
debug_line[0x00000000]
Line table prologue:
total_length: 0x000000ca
version: 2
prologue_length: 0x00000075
min_inst_length: 1
default_is_stmt: 1
line_base: -5
line_range: 14
opcode_base: 13
standard_opcode_lengths[DW_LNS_copy] = 0
standard_opcode_lengths[DW_LNS_advance_pc] = 1
standard_opcode_lengths[DW_LNS_advance_line] = 1
standard_opcode_lengths[DW_LNS_set_file] = 1
standard_opcode_lengths[DW_LNS_set_column] = 1
standard_opcode_lengths[DW_LNS_negate_stmt] = 0
standard_opcode_lengths[DW_LNS_set_basic_block] = 0
standard_opcode_lengths[DW_LNS_const_add_pc] = 0
standard_opcode_lengths[DW_LNS_fixed_advance_pc] = 1
standard_opcode_lengths[DW_LNS_set_prologue_end] = 0
standard_opcode_lengths[DW_LNS_set_epilogue_begin] = 0
standard_opcode_lengths[DW_LNS_set_isa] = 1
include_directories[ 1] = "/Users/dan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd"
file_names[ 1]:
name: "rt.rs"
dir_index: 1
mod_time: 0x00000000
All of that was run on MacOS with the stable rust toolchain.
DwDemo $ rustup show
Default host: x86_64-apple-darwin
rustup home: /Users/dan/.rustup
installed toolchains
--------------------
stable-x86_64-apple-darwin (default)
nightly-x86_64-apple-darwin
active toolchain
----------------
stable-x86_64-apple-darwin (default)
rustc 1.46.0 (04488afe3 2020-08-24)
Thanks for all of the team's work on this project.
Please let me know if there's any further info I can provide.