Recording Input and Output

To help you make command files, as well as to help you see what has happened before, the debugger can write both its input and its output to files, as follows:

record_command

: record io [ filename ]

| record input [ filename ]

| record output [ filename ]

| unrecord io

| unrecord input

| unrecord output

Use record input to save debugger commands to a file. The commands in the file can be executed using the source command or the playback input command.

If no file name is specified, the debugger creates a file with a random file name in /tmp as the record file. The debugger issues a message giving the name of that file.

To stop recording debugger input or output, redirect as shown in the following example, use the appropriate version of the unrecord command, or exit the debugger:

(idb) record input /dev/null

(idb) record output /dev/null

The following example shows how to use the record input command to record a series of debugger commands in a file named myscript:

(idb) record input myscript

(idb) stop in main

[#1: stop in int main(void)]

(idb) run

[1] stopped at [int main(void):182 0x08051603]

    182     List<Node> nodeList;

(idb) unrecord input

This example results in the following recorded input in myscript:

(idb) sh cat myscript

stop in main

run

unrecord input

The record output command saves the debugger output to a file. The output is simultaneously written to stdout (normal output) or stderr (error messages). For example:

(idb) record output myscript

(idb) stop in List<Node>::append

[#2: stop in void List<Node>::append(class Node* const)]

(idb) cont

[2] stopped at [void List<Node>::append(class Node* const):148 0x0804ae5a]

    148     if (!_firstNode)

(idb) cont to 156

stopped at [void List<Node>::append(class Node* const):156 0x0804aed7]

    156 }

(idb) unrecord output

After the above commands are executed, myscript contains the following:

(idb) sh cat myscript

[#2: stop in void List<Node>::append(class Node* const)]

[2] stopped at [void List<Node>::append(class Node* const):148 0x0804ae5a]

    148     if (!_firstNode)

stopped at [void List<Node>::append(class Node* const):156 0x0804aed7]

    156 }

The record io command saves both input to and output from the debugger. For example:

(idb) record io myscript

(idb) stop in main

[#1: stop in int main(void) ]

(idb) run

[1] stopped at [int main(void):12 0x120001130]

     12 int i;

(idb) quit

% cat myscript

(idb) stop in main

[#1: stop in int main(void) ]

(idb) run

[1] stopped at [int main(void):12 0x120001130]

     12 int i;

(idb) quit

If input or output is already being recorded, a new record input command will close the old file and record to a new one, rather than record simultaneously to two files. In that connection, note that record io is equivalent to the combination of record input and record output, and will cause any open recording files to be closed.

Note that the prompt itself is only recorded for record io.