Sequences
User Defined Commands
You can assign a name to a sequence of commands. You can allow for arguments. They are accessed using $argN where \(N=0\) means the first argument. Below is the syntax to define your own command:
define adder print $arg0 + $arg1 + $arg2 end
To invoke, do adder 1 2 3.
You can use $argc to see how many arguments were passed.
You can use eval to allow for an arbitrary number of arguments.
You can document commands, and can control if it is “repeatable” by pressing Enter.
To see all user defined commands, do help user-defined.
User Defined Command Hooks
You can create hooks for existing commands. Both pre and post hooks.
Command Files
You can make command files with GDB commands to execute. To execute it use the source command. You can specify the search path if it is in a nonstandard location.
This section lists flow control commands (conditionals, etc).
Commands For Controlled Output
This section is about controlling what output is suppressed.
Controlling Auto-loading Native GDB Scripts
You can autoload scripts when loading an object file. There is a naming convention for such script files. Extending GDB Using Python There’s a lot of stuff here. Read later or find a dedicated tutorial. Extending GDB Using Guile You can do this. Autoloading Extensions More information on autoloading files. Creating New Spellings of Existing Commands
You can define aliases:
alias [-a] [--] ALIAS = COMMAND
-a means it is an abbreviation.
-- means there are no more options. Useful if your alias begins with a hyphen.