Release build generates ~30% fewer debug symbol entries than debug build
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 61.4k
- Forks
- 5.4k
- Avg merge
- 3h 33m
- Merged PRs (30d)
- 4
Description
Description
When comparing debug symbols generated with -g in debug vs release mode, the release build produces significantly fewer symbol entries (~30% less). Both builds include all DWARF debug sections, but release mode maps fewer positions in the source code.
Expected Behaviour
If -g is specified, debug symbols should be complete in both debug and release builds, or the difference in coverage should be documented.
Steps to Reproduce
- Create a simple Sway program:
script;
use std::logging::log;
fn factorial(n: u64) -> u64 {
let mut result = 1;
let mut counter = 0;
while counter < n {
counter = counter + 1;
result = result * counter;
}
return result;
}
fn main() {
log::<u64>(factorial(5)); // 120
}
- Build with debug symbols in debug mode:
forc build -g symbols_debug.json
- Build with debug symbols in release mode:
forc build --release -g symbols_release.json
- Compare the resulting JSON files
Observations
Debug map has 39 entries, release map has 28 entries
Debug has 33 entries mapping to main.sw, release has 23
We can also notive a difference if we generate the dwarf files and inspect them using llvm-dwarfdump
DWARF line table differences:
- Debug build has 38 address-to-line mappings
- Release build has 29 address-to-line mappings
Full DWARF dump comparison provided below:
# Debug build
❯ llvm-dwarfdump --debug-line out/debug/debug_symbols.obj
out/debug/debug_symbls.obj: file format elf64-x86-64
.debug_line contents:
debug_line[0x00000000]
Line table prologue:
total_length: 0x0000000000000188
format: DWARF64
version: 5
address_size: 8
seg_select_size: 0
prologue_length: 0x0000000000000124
min_inst_length: 1
max_ops_per_inst: 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[ 0] = "/Users/josh/Documents/rust/fuel/test_projects/dbg_example"
include_directories[ 1] = "/Users/josh/.forc/git/checkouts/std-77214b14e13f9b04/986aee2c1e34c9cd958c81e7fd6b84638b26619b/sway-lib-core/src"
include_directories[ 2] = "/Users/josh/Documents/rust/fuel/test_projects/dbg_example/src"
file_names[ 0]:
name: "src/main.sw"
dir_index: 0
file_names[ 1]:
name: "codec.sw"
dir_index: 1
file_names[ 2]:
name: "main.sw"
dir_index: 2
Address Line Column File ISA Discriminator Flags
------------------ ------ ------ ------ --- ------------- -------------
0x0000000000000000 1 0 1 0 0 is_stmt
0x0000000000000019 2507 5 1 0 0 is_stmt
0x000000000000002d 15 1 2 0 0 is_stmt
0x000000000000002e 15 1 2 0 0 is_stmt
0x0000000000000032 16 16 2 0 0 is_stmt
0x0000000000000033 16 16 2 0 0 is_stmt
0x0000000000000034 16 16 2 0 0 is_stmt
0x0000000000000036 16 16 2 0 0 is_stmt
0x0000000000000038 16 16 2 0 0 is_stmt
0x0000000000000045 16 5 2 0 0 is_stmt
0x0000000000000047 16 5 2 0 0 is_stmt
0x0000000000000048 16 5 2 0 0 is_stmt
0x0000000000000049 16 5 2 0 0 is_stmt
0x000000000000004b 16 5 2 0 0 is_stmt
0x000000000000004c 16 5 2 0 0 is_stmt
0x0000000000000050 16 5 2 0 0 is_stmt
0x0000000000000052 16 5 2 0 0 is_stmt
0x0000000000000055 16 5 2 0 0 is_stmt
0x0000000000000056 16 5 2 0 0 is_stmt
0x0000000000000057 16 5 2 0 0 is_stmt
0x0000000000000059 16 5 2 0 0 is_stmt
0x000000000000005a 16 5 2 0 0 is_stmt
0x000000000000005b 16 5 2 0 0 is_stmt
0x000000000000005c 16 5 2 0 0 is_stmt
0x000000000000005d 16 5 2 0 0 is_stmt
0x0000000000000060 16 5 2 0 0 is_stmt
0x0000000000000064 16 5 2 0 0 is_stmt
0x0000000000000066 16 5 2 0 0 is_stmt
0x000000000000007d 16 16 2 0 0 is_stmt
0x000000000000007e 16 16 2 0 0 is_stmt
0x000000000000007f 16 16 2 0 0 is_stmt
0x0000000000000080 16 16 2 0 0 is_stmt
0x0000000000000081 16 16 2 0 0 is_stmt
0x0000000000000082 16 16 2 0 0 is_stmt
0x0000000000000083 16 16 2 0 0 is_stmt
0x000000000000008a 10 5 1 0 0 is_stmt
0x000000000000008b 10 5 1 0 0 is_stmt
0x0000000000000099 11 9 1 0 0 is_stmt
0x00000000000000a2 29 5 1 0 0 is_stmt
0x00000000000000a4 29 5 1 0 0 is_stmt end_sequence
# Release build
❯ llvm-dwarfdump --debug-line out/release/debug_symbols.obj
out/release/debug_symbls.obj: file format elf64-x86-64
.debug_line contents:
debug_line[0x00000000]
Line table prologue:
total_length: 0x0000000000000175
format: DWARF64
version: 5
address_size: 8
seg_select_size: 0
prologue_length: 0x0000000000000124
min_inst_length: 1
max_ops_per_inst: 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[ 0] = "/Users/josh/Documents/rust/fuel/test_projects/dbg_example"
include_directories[ 1] = "/Users/josh/Documents/rust/fuel/test_projects/dbg_example/src"
include_directories[ 2] = "/Users/josh/.forc/git/checkouts/std-77214b14e13f9b04/986aee2c1e34c9cd958c81e7fd6b84638b26619b/sway-lib-core/src"
file_names[ 0]:
name: "src/main.sw"
dir_index: 0
file_names[ 1]:
name: "main.sw"
dir_index: 1
file_names[ 2]:
name: "codec.sw"
dir_index: 2
Address Line Column File ISA Discriminator Flags
------------------ ------ ------ ------ --- ------------- -------------
0x0000000000000000 1 0 1 0 0 is_stmt
0x0000000000000029 15 1 1 0 0 is_stmt
0x000000000000002a 15 1 1 0 0 is_stmt
0x0000000000000031 16 16 1 0 0 is_stmt
0x000000000000003f 16 5 1 0 0 is_stmt
0x0000000000000041 16 5 1 0 0 is_stmt
0x0000000000000042 16 5 1 0 0 is_stmt
0x0000000000000043 16 5 1 0 0 is_stmt
0x0000000000000045 16 5 1 0 0 is_stmt
0x0000000000000046 16 5 1 0 0 is_stmt
0x000000000000004a 16 5 1 0 0 is_stmt
0x000000000000004c 16 5 1 0 0 is_stmt
0x000000000000004f 16 5 1 0 0 is_stmt
0x0000000000000050 16 5 1 0 0 is_stmt
0x0000000000000051 16 5 1 0 0 is_stmt
0x0000000000000052 16 5 1 0 0 is_stmt
0x0000000000000053 16 5 1 0 0 is_stmt
0x0000000000000054 16 5 1 0 0 is_stmt
0x0000000000000055 16 5 1 0 0 is_stmt
0x0000000000000058 16 5 1 0 0 is_stmt
0x000000000000005a 16 5 1 0 0 is_stmt
0x000000000000005c 16 5 1 0 0 is_stmt
0x0000000000000071 16 16 1 0 0 is_stmt
0x0000000000000072 16 16 1 0 0 is_stmt
0x0000000000000079 10 5 2 0 0 is_stmt
0x000000000000007a 10 5 2 0 0 is_stmt
0x0000000000000088 11 9 2 0 0 is_stmt
0x0000000000000091 29 5 2 0 0 is_stmt
0x0000000000000093 29 5 2 0 0 is_stmt end_sequence
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the provided forc build -g and forc build --release -g commands, then compare the generated JSON files and inspect both objects with llvm-dwarfdump --debug-line. Trace where release and debug builds produce their DWARF line mappings. Done means the difference is corrected or its intended coverage is documented and verified against the reported counts.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100