3 <title>Debugging with GDB
</title>
4 <meta http-equiv=
"Content-Type" content=
"text/html">
5 <meta name=
"description" content=
"Debugging with GDB">
6 <meta name=
"generator" content=
"makeinfo 4.3">
7 <link href=
"http://www.gnu.org/software/texinfo/" rel=
"generator-home">
12 Node:
<a name=
"Input%2fOutput">Input/Output
</a>,
13 Next:
<a rel=
"next" accesskey=
"n" href=
"Attach.html#Attach">Attach
</a>,
14 Previous:
<a rel=
"previous" accesskey=
"p" href=
"Working-Directory.html#Working%20Directory">Working Directory
</a>,
15 Up:
<a rel=
"up" accesskey=
"u" href=
"Running.html#Running">Running
</a>
19 <h3 class=
"section">Your program's input and output
</h3>
21 <p>By default, the program you run under GDB does input and output to
22 the same terminal that GDB uses. GDB switches the terminal
23 to its own terminal modes to interact with you, but it records the terminal
24 modes your program was using and switches back to them when you continue
28 <dt><code>info terminal
</code>
29 <dd>Displays information recorded by GDB about the terminal modes your
33 <p>You can redirect your program's input and/or output using shell
34 redirection with the
<code>run
</code> command. For example,
36 <pre class=
"example"> run
> outfile
39 <p>starts your program, diverting its output to the file
<code>outfile
</code>.
41 <p>Another way to specify where your program should do input and output is
42 with the
<code>tty
</code> command. This command accepts a file name as
43 argument, and causes this file to be the default for future
<code>run
</code>
44 commands. It also resets the controlling terminal for the child
45 process, for future
<code>run
</code> commands. For example,
47 <pre class=
"example"> tty /dev/ttyb
50 <p>directs that processes started with subsequent
<code>run
</code> commands
51 default to do input and output on the terminal
<code>/dev/ttyb
</code> and have
52 that as their controlling terminal.
54 <p>An explicit redirection in
<code>run
</code> overrides the
<code>tty
</code> command's
55 effect on the input/output device, but not its effect on the controlling
58 <p>When you use the
<code>tty
</code> command or redirect input in the
<code>run
</code>
59 command, only the input
<em>for your program
</em> is affected. The input
60 for GDB still comes from your terminal.