nx_dwarf_info.nx
buildroot/runtime/nx_dwarf_info.nx
about
nx_dwarf_info.nx -- DWARF .debug_info section builder.
The DIE (Debugging Information Entry) forest. Each DIE is:
abbrev_code uleb128 (refers to nx_dwarf_abbrev entry)
attribute values raw bytes shaped per the abbrev's form list
A compilation unit (CU) starts with a header:
length u32 (or extended u64 for >4GB CUs)
version u16 (= 5 for DWARF v5)
unit_type u8 (= DW_UT_compile = 0x01)
addr_size u8 (= 8 for RV64)
abbrev_offset u32 (offset into .debug_abbrev)
...DIE bytes...
The first DIE after the header is the CU's root DIE (usually
DW_TAG_compile_unit). Children DIEs follow when the abbrev
declared has_children=1, terminated by a NULL DIE (single 0 byte).
Pairs with:
nx_dwarf_abbrev -- supplies the codes referenced from each DIE
nx_dwarf_str -- supplies offsets for DW_FORM_strp values
nx_dwarf_line -- pointed-to by DW_AT_stmt_list
What this module ships (v0.0.1):
* CU-header writer (begin/finalize that fix up the length field)
* DIE-emit helpers: emit_die_open(code) / emit_die_close()
* Per-FORM attribute writers (addr / data4 / data8 / strp / ref4
/ flag_present / sec_offset / udata / sdata)
Doesn't yet validate that the (form, value) pairs match the
abbrev's declared schema -- caller responsibility for now.
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
| 47 | struct NxDwInfo |
consts
| 41 | const NX_MAGIC_1024: i64 = 1024 |
| 43 | const NX_DW_UT_compile: i64 = 0x01 |
| 56 | const NX_DW_INFO_BYTES: i64 = 48 |
functions
| 58 | func nx_dwinfo_new(cap: i64) -> *NxDwInfo called by 1: main |
| 72 | func nx_dwinfo_byte(d: *NxDwInfo, v: i64) -> i64 |
| 79 | func nx_dwinfo_u16(d: *NxDwInfo, v: i64) -> i64 |
| 85 | func nx_dwinfo_u32(d: *NxDwInfo, v: i64) -> i64 |
| 93 | func nx_dwinfo_u64(d: *NxDwInfo, v: i64) -> i64 |
| 105 | func nx_dwinfo_uleb(d: *NxDwInfo, v: i64) -> i64 |
| 118 | func nx_dwinfo_sleb(d: *NxDwInfo, v: i64) -> i64 |
| 139 | func nx_dwinfo_cu_begin(d: *NxDwInfo, abbrev_offset: i64) -> i64 |
| 152 | func nx_dwinfo_cu_finalize(d: *NxDwInfo) -> i64 called by 1: main |
| 168 | func nx_dwinfo_die_open(d: *NxDwInfo, abbrev_code: i64) -> i64 |
| 173 | func nx_dwinfo_die_null(d: *NxDwInfo) -> i64 |
| 179 | func nx_dwinfo_attr_addr(d: *NxDwInfo, addr: i64) -> i64 |
| 183 | func nx_dwinfo_attr_data1(d: *NxDwInfo, v: i64) -> i64 calls 1: nx_dwinfo_byte |
| 187 | func nx_dwinfo_attr_data2(d: *NxDwInfo, v: i64) -> i64 calls 1: nx_dwinfo_u16 |
| 191 | func nx_dwinfo_attr_data4(d: *NxDwInfo, v: i64) -> i64 calls 1: nx_dwinfo_u32 |
| 195 | func nx_dwinfo_attr_data8(d: *NxDwInfo, v: i64) -> i64 |
| 200 | func nx_dwinfo_attr_strp(d: *NxDwInfo, str_off: i64) -> i64 |
| 205 | func nx_dwinfo_attr_ref4(d: *NxDwInfo, cu_local_off: i64) -> i64 |
| 210 | func nx_dwinfo_attr_sec_offset(d: *NxDwInfo, off: i64) -> i64 |
| 215 | func nx_dwinfo_attr_flag(d: *NxDwInfo, b: i64) -> i64 calls 1: nx_dwinfo_byte |
| 223 | func nx_dwinfo_attr_udata(d: *NxDwInfo, v: i64) -> i64 calls 1: nx_dwinfo_uleb |
| 227 | func nx_dwinfo_attr_sdata(d: *NxDwInfo, v: i64) -> i64 calls 1: nx_dwinfo_sleb |
| 232 | func nx_dwinfo_attr_string(d: *NxDwInfo, src: *u8) -> i64 calls 1: nx_dwinfo_byte |
| 243 | func nx_dwinfo_size(d: *NxDwInfo) -> i64 { return d.used } |
| 244 | func nx_dwinfo_bytes(d: *NxDwInfo) -> *u8 { return d.buf } |
| 248 | func main() -> i64 |