Name

commands

Synopsis

commands [bp]
... commands ...
end

Supply GDB commands that should run when the program stops at a given breakpoint. With no bp, the list of commands is associated with the most recent breakpoint, watchpoint, or catchpoint that was set, not the one that was most recently executed. To clear a list of commands, supply the commands keyword and follow it immediately with end.

Example

break myfunc if x > 42       Break myfunc if x > 42
    commands                     List of commands
    silent                       Don't print GDB commands
    printf "x = %d\n", x         Print variable value
    cont                         Continue execution
    endEnd of command list

Get Unix in a Nutshell, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.