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.
tbdbg ./progb maincregssq
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.
| Command | Effect |
|---|---|
b ADDR / b SYM | set a breakpoint at an address or symbol |
d ADDR / d SYM | delete a breakpoint |
Up to 16 breakpoints. Continuing from a breakpoint steps past it automatically.
| Command | Effect |
|---|---|
c | continue until a breakpoint, exit, or fault |
s / si | step one instruction |
n | step over a call (runs it to completion, then stops) |
q | quit 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.
| Command | Effect |
|---|---|
regs / r | all 16 registers plus pc (r13 = sp, r14 = fp, r15 = lr) |
x ADDR [N] | dump N words (default 8) from memory |
set rN VAL | set a register |
set pc VAL | set the program counter |
set *ADDR VAL | write a word to memory |
dis [ADDR] | disassemble 8 instructions (default at pc) |
bt | backtrace (walks the frame-pointer chain) |
info | current pc and run state |
Anywhere an address or value is expected:
| Form | Means |
|---|---|
0x1a2c | hexadecimal number |
42 | decimal number |
main | a symbol's runtime address |
$pc $sp $fp | the live pc / stack pointer / frame pointer |
r0 ... r15 | a register's current value |
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) +++
guestbook), the same rule Linux applies to ptrace. To study one, debug a non-setuid copy - it runs as you, so it never yields root.