code wiki / (root) / nx_dbg.nx

nx_dbg.nx

buildroot/runtime/nx_dbg.nx

7631 B234 linesdepth 5pulls 10 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_dbg.nx -- sovereign single-step debugger primitive. Wraps nx_rv64_sim with debugger superpowers: * step run one instruction, return control * cont run until breakpoint / halt / illegal * break_at set a code-address breakpoint * break_clr clear a code-address breakpoint * dump_regs print all 32 GPR + pc to fd * dump_stack print N words above sp * locate PC -> source (file_idx, line) via nx_addr2line All operations work without GDB / qemu / docker. When wired with nxc_native_wrap, this is the sovereign equivalent of: gdb --batch -ex "break main" -ex "run" -ex "info reg" my.elf Pairs with our existing primitives: nx_rv64_sim -- VM nx_dis -- disassemble PC at current state nx_addr2line -- map PC -> source line nx_strfmt -- formatted output v0.0.1 scope: simple breakpoint set (linear scan, up to 64 breakpoints). Future commits add: watchpoints, conditional breakpoints, scripted recipes, GDB-stub remote-protocol.

dependencies 5 imports · 0 importers

syscalls.nx nx_rv64_sim.nx nx_dis.nx nx_addr2line.nx nx_strfmt.nx nx_dbg.nx

imports: syscalls.nxnx_rv64_sim.nxnx_dis.nxnx_addr2line.nxnx_strfmt.nx

imported by: nobody (leaf or entry point)

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

main nx_rv64_cpu_new nx_dbg_new nx_dbg_break_at nx_dbg_cont nx_rv64_step nx_rv64c_decode nx_c_decode_q0 nx_c_field nx_c_enc_i nx_c_reg3 nx_c_enc_s nx_c_decode_q1 nx_c_field ↻ nx_c_sext nx_c_enc_i ↻ nx_c_enc_u nx_c_reg3 ↻ nx_c_enc_r nx_c_enc_j nx_c_enc_b nx_c_decode_q2 nx_c_field ↻ nx_c_enc_i ↻ nx_c_enc_r ↻ nx_c_enc_s ↻ nx_dis_word_at nx_dis_opcode nx_dis_rd nx_dis_rs1 nx_dis_rs2 nx_dis_funct3 nx_dis_funct7 nx_rv64_rd nx_rv64_wr nx_dis_imm_i nx_rv64_load_u64 nx_rv64_load_u8 nx_rv64_load_u32 nx_rv64_load_u8 ↻

structs

43struct NxDbg

consts

39const NX_MAGIC_9999: i64 = 9999
41const NX_DBG_MAX_BREAKPOINTS: i64 = 64
49const NX_DBG_BYTES: i64 = 24

functions

51func nx_dbg_new(cpu: *NxRv64Cpu) -> *NxDbg
called by 1: main
64func nx_dbg_break_at(d: *NxDbg, addr: i64) -> i64
called by 1: main
77func nx_dbg_break_clr(d: *NxDbg, addr: i64) -> i64
called by 1: main
92func nx_dbg_at_bp(d: *NxDbg) -> i64
called by 1: nx_dbg_cont
105func nx_dbg_step(d: *NxDbg) -> i64
called by 1: main calls 1: nx_rv64_step
113func nx_dbg_cont(d: *NxDbg, max_insns: i64) -> i64
called by 1: main calls 2: nx_rv64_stepnx_dbg_at_bp
131func nx_dbg_dump_regs(d: *NxDbg, fd: i64) -> i64
149func nx_dbg_dump_disasm(d: *NxDbg, n: i64, fd: i64) -> i64
167func nx_dbg_dump_mem(d: *NxDbg, addr: i64, n: i64, fd: i64) -> i64
183func main() -> i64