Name

define

define commandname
... commands ...
end

Create a user-defined command named commandname. The series of commands makes up the definition of commandname. Whenever you type commandname, GDB executes the commands. This is similar to functions or procedures in regular programming languages. See also document.

Hooks

If commandname has the form hook-command, where command is a built-in GDB command, when you enter command, GDB runs commandname before it runs command.

Similarly, if commandname has the form hookpost-command, then GDB runs the provided sequence of commands after command finishes. You thus have available both pre- and post-execution hook facilities.

Finally, for the purposes of providing hooks, GDB recognizes a pseudocommand named stop that “executes” every time the debuggee stops. This allows you to define a hook of the form hook-stop in order to execute a sequence of commands every time the program stops.

Get GDB Pocket Reference 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.