To repeat the last command line, enter two exclamation points (!) or press the Enter key. You can also enter !-1.
command_repetition_command
: !!
| ! integer
| !- integer
| ! string
To repeat a command line entered during the current debugging session, enter an exclamation point followed by the integer associated with the command line. (Use the history command to see a list of commands used.) For example, to repeat the seventh command used in the current debugging session, enter !7. Enter !-3 to repeat the third-to-the-last command. See also History replacement of the line.
To repeat the most-recent command starting with a string, use the last form of the command. For example, to repeat a command that started with bp, enter !bp.
Following are other ways to reuse old commands and save typing effort:
If you place commands in a file, you can execute them directly from the file rather than cutting and pasting them to the terminal. For example:
execute_commands_from_file_command
Use the source command to read and execute commands from a file. (You can also execute debugger commands when you invoke the debugger by creating an initialization file named .dbxinit.) These commands can be nested, and as each comes to an end, reading resumes from where it left off in the previous file.
Be aware, however, that blank lines in these files do not repeat the last command, unlike what blank lines do when entered from the terminal. Format the commands as if they were entered at the debugger prompt.
Use the pound character (#) to create comments to format your scripts.
The following is an example debugger script:
(idb) sh cat ../src/myscript
step
where 2
The following example shows how to execute it:
(idb) run
[1] stopped at [int main(void):187 0x08052ec4]
187 nodeList.append(newNode); {static int somethingToReturnTo; somethingToReturnTo++; }
(idb) source ../src/myscript
stopped at [void List<Node>::append(class Node* const):148 0x0804c55e]
148 if (!_firstNode)
>0 0x0804c55e in ((List<Node>*)0xbfffce78)->List<Node>::append(node=0x805e5f8) "src/x_list.cxx":148
#1 0x08052edc in main() "src/x_list.cxx":187
When a command file is executed, the value of the $pimode debugger variable determines whether the commands are echoed. If the $pimode variable is set to 1, commands are echoed; if $pimode is set to 0 (the default), commands are not echoed. The debugger output resulting from the commands is always echoed.