TonicBoxOS · debugger reference

tbdbg - the debugger

An interactive debugger for TB32 programs. It launches a program stopped at its entry point in a traced, de-privileged child and offers breakpoints, single-step, register and memory inspection, disassembly and backtraces. strace runs a program and prints every system call it makes. Both run inside the interactive terminal.

open tbdbg PROG break by symbol or address trace strace PROG ctf setuid binaries blocked
Survival kit
tbdbg ./prog
launch, stopped at entry
b main
breakpoint at a symbol
c
run to the breakpoint
regs
show the registers
s
step one instruction
q
quit the debugger

00Launching

tbdbg PROG [args] loads PROG into a separate, traced child and stops it at the entry point (_start), then opens a (tbdbg) prompt. The child runs in its own memory window and with your privileges - a debugged program can never gain more than the user running it.

(tbdbg) b main
breakpoint at 0x000291f8 <main>
(tbdbg) c
breakpoint at 0x000291f8 <main>
stopped at 0x000291f8 <main>

Symbols resolve through the program's own symbol table, and the per-session address randomization (ASLR) slide is applied automatically, so b main lands at the real runtime address.

01Breakpoints

CommandEffect
b ADDR / b SYMset a breakpoint at an address or symbol
d ADDR / d SYMdelete a breakpoint

Up to 16 breakpoints. Continuing from a breakpoint steps past it automatically.

02Running

CommandEffect
ccontinue until a breakpoint, exit, or fault
s / sistep one instruction
nstep over a call (runs it to completion, then stops)
qquit and end the traced program

Commands also accept long forms: cont, step, next, break, delete, quit, regs.

Each stop prints its reason and the current instruction. When the program ends, tbdbg reports the exit status.

03Inspecting

CommandEffect
regs / rall 16 registers plus pc (r13 = sp, r14 = fp, r15 = lr)
x ADDR [N]dump N words (default 8) from memory
set rN VALset a register
set pc VALset the program counter
set *ADDR VALwrite a word to memory
dis [ADDR]disassemble 8 instructions (default at pc)
btbacktrace (walks the frame-pointer chain)
infocurrent pc and run state

04Operands

Anywhere an address or value is expected:

FormMeans
0x1a2chexadecimal number
42decimal number
maina symbol's runtime address
$pc $sp $fpthe live pc / stack pointer / frame pointer
r0 ... r15a register's current value

05strace

strace PROG [args] runs a program and prints each system call it makes, with its arguments and return value, ending with the exit status.

$ strace ./prog
write(1, 0x00029274, 12) = 12
exit(0, 0, 0) = ?
+++ exited (status 0) +++

06Limits