LOGBOOK

HELP

Quiz Entry - updated: 2026.12.01

What is the difference between next and nexti in GDB, and why does a debugging session without source code rely on nexti?

next runs one source line; nexti runs one machine instruction. Without debug information GDB doesn't know where source lines begin, so stepping has to happen instruction by instruction.

next asks GDB to run until the line number changes, which it can only work out from DWARF line tables. Without them GDB cannot step by line and instead runs to the end of the function. nexti (ni) needs no such table: it executes exactly one instruction and stops. Like next, it steps over calls (a call instruction runs the whole callee); stepi (si) steps into them.

The rest of the commands in a machine-level session:

Command Purpose
Ctrl+C Halt the running target
cont (c) Resume until the next breakpoint
break <function> Stop at a function's entry, using the symbol table
disass Show the assembly of the current function, with an arrow at the next instruction
p /x $pc Print the program counter in hex
info registers Show all CPU registers

display/i $pc is a handy addition: it prints the next instruction automatically after every step.

Go deeper:

From Quiz: SIOT / Firmware Analysis and Hardening Against JTAG Attacks | Updated: Dec 01, 2026