code wiki / (root) / nx_dwarf_aranges.nx

nx_dwarf_aranges.nx

buildroot/runtime/nx_dwarf_aranges.nx

6410 B184 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic dwarf
docsdependenciesstructsconstsfunctions

about

nx_dwarf_aranges.nx -- DWARF .debug_aranges builder. .debug_aranges is a fast PC-to-CU (Compilation Unit) lookup table. addr2line / gdb consult it FIRST when given a program counter: each entry maps a [start_addr, length) range to the file offset of a CU's DIE in .debug_info. Without aranges, the debugger has to scan every CU's DIE forest to find the one covering the PC -- O(n_CUs) per address lookup vs O(log n) here. Per-CU header layout (DWARF v5, section 6.1.2): length (u32 / u64 -- excludes itself) version (u16, =2 for DWARF v5) debug_info_off (u32 / u64 -- file offset of CU header in .debug_info) addr_size (u8, 8 for RV64) seg_size (u8, 0 -- we don't use segments) PADDING to 2*addr_size boundary tuples: (start_addr, length) pairs of `addr_size` bytes each final tuple: (0, 0) terminator We always use 32-bit DWARF (single .o files don't exceed 4 GB of debug info; if they do we'll switch to 64-bit DWARF). Pairs with nx_dwarf_info (the consumer of debug_info_off) + nx_dwarf_line / nx_dwarf_str / nx_dwarf_abbrev (cousins).

dependencies 1 imports · 0 importers

syscalls.nx nx_dwarf_aranges.nx

imports: syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main nx_dwar_new nx_dwar_cu_begin nx_dwar_u32 nx_dwar_byte nx_dwar_u16 nx_dwar_byte ↻ nx_dwar_byte ↻ nx_dwar_add nx_dwar_u64 nx_dwar_byte ↻ nx_dwar_cu_end nx_dwar_u64 ↻ nx_dwar_patch_u32

structs

38struct NxDwAranges

consts

34const NX_DWAR_VERSION: i64 = 2
35const NX_DWAR_ADDR_SIZE: i64 = 8
36const NX_DWAR_SEG_SIZE: i64 = 0
46const NX_DWARANGES_BYTES: i64 = 40

functions

48func nx_dwar_new(cap: i64) -> *NxDwAranges
called by 1: main
59func nx_dwar_byte(a: *NxDwAranges, b: i64) -> i64
66func nx_dwar_u16(a: *NxDwAranges, v: i64) -> i64
called by 1: nx_dwar_cu_begin calls 1: nx_dwar_byte
71func nx_dwar_u32(a: *NxDwAranges, v: i64) -> i64
called by 1: nx_dwar_cu_begin calls 1: nx_dwar_byte
78func nx_dwar_u64(a: *NxDwAranges, v: i64) -> i64
88func nx_dwar_patch_u32(a: *NxDwAranges, off: i64, v: i64) -> i64
called by 1: nx_dwar_cu_end
99func nx_dwar_cu_begin(a: *NxDwAranges, debug_info_off: i64) -> i64
122func nx_dwar_add(a: *NxDwAranges, start: i64, len: i64) -> i64
called by 1: main calls 1: nx_dwar_u64
130func nx_dwar_cu_end(a: *NxDwAranges) -> i64
called by 1: main calls 2: nx_dwar_u64nx_dwar_patch_u32
143func main() -> i64