nx_dwarf_aranges.nx
buildroot/runtime/nx_dwarf_aranges.nx
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
imports: syscalls.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| 38 | struct NxDwAranges |
consts
| 34 | const NX_DWAR_VERSION: i64 = 2 |
| 35 | const NX_DWAR_ADDR_SIZE: i64 = 8 |
| 36 | const NX_DWAR_SEG_SIZE: i64 = 0 |
| 46 | const NX_DWARANGES_BYTES: i64 = 40 |
functions
| 48 | func nx_dwar_new(cap: i64) -> *NxDwAranges called by 1: main |
| 59 | func nx_dwar_byte(a: *NxDwAranges, b: i64) -> i64 |
| 66 | func nx_dwar_u16(a: *NxDwAranges, v: i64) -> i64 |
| 71 | func nx_dwar_u32(a: *NxDwAranges, v: i64) -> i64 |
| 78 | func nx_dwar_u64(a: *NxDwAranges, v: i64) -> i64 |
| 88 | func nx_dwar_patch_u32(a: *NxDwAranges, off: i64, v: i64) -> i64 called by 1: nx_dwar_cu_end |
| 99 | func nx_dwar_cu_begin(a: *NxDwAranges, debug_info_off: i64) -> i64 |
| 122 | func nx_dwar_add(a: *NxDwAranges, start: i64, len: i64) -> i64 |
| 130 | func nx_dwar_cu_end(a: *NxDwAranges) -> i64 |
| 143 | func main() -> i64 |