Input_002fOutput.html 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-2020 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Free Software" and "Free Software Needs
  8. Free Documentation", with the Front-Cover Texts being "A GNU Manual,"
  9. and with the Back-Cover Texts as in (a) below.
  10. (a) The FSF's Back-Cover Text is: "You are free to copy and modify
  11. this GNU Manual. Buying copies from GNU Press supports the FSF in
  12. developing GNU and promoting software freedom." -->
  13. <!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
  14. <head>
  15. <title>Debugging with GDB: Input/Output</title>
  16. <meta name="description" content="Debugging with GDB: Input/Output">
  17. <meta name="keywords" content="Debugging with GDB: Input/Output">
  18. <meta name="resource-type" content="document">
  19. <meta name="distribution" content="global">
  20. <meta name="Generator" content="makeinfo">
  21. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  22. <link href="index.html#Top" rel="start" title="Top">
  23. <link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
  24. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  25. <link href="Running.html#Running" rel="up" title="Running">
  26. <link href="Attach.html#Attach" rel="next" title="Attach">
  27. <link href="Working-Directory.html#Working-Directory" rel="previous" title="Working Directory">
  28. <style type="text/css">
  29. <!--
  30. a.summary-letter {text-decoration: none}
  31. blockquote.smallquotation {font-size: smaller}
  32. div.display {margin-left: 3.2em}
  33. div.example {margin-left: 3.2em}
  34. div.indentedblock {margin-left: 3.2em}
  35. div.lisp {margin-left: 3.2em}
  36. div.smalldisplay {margin-left: 3.2em}
  37. div.smallexample {margin-left: 3.2em}
  38. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  39. div.smalllisp {margin-left: 3.2em}
  40. kbd {font-style:oblique}
  41. pre.display {font-family: inherit}
  42. pre.format {font-family: inherit}
  43. pre.menu-comment {font-family: serif}
  44. pre.menu-preformatted {font-family: serif}
  45. pre.smalldisplay {font-family: inherit; font-size: smaller}
  46. pre.smallexample {font-size: smaller}
  47. pre.smallformat {font-family: inherit; font-size: smaller}
  48. pre.smalllisp {font-size: smaller}
  49. span.nocodebreak {white-space:nowrap}
  50. span.nolinebreak {white-space:nowrap}
  51. span.roman {font-family:serif; font-weight:normal}
  52. span.sansserif {font-family:sans-serif; font-weight:normal}
  53. ul.no-bullet {list-style: none}
  54. -->
  55. </style>
  56. </head>
  57. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  58. <a name="Input_002fOutput"></a>
  59. <div class="header">
  60. <p>
  61. Next: <a href="Attach.html#Attach" accesskey="n" rel="next">Attach</a>, Previous: <a href="Working-Directory.html#Working-Directory" accesskey="p" rel="previous">Working Directory</a>, Up: <a href="Running.html#Running" accesskey="u" rel="up">Running</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
  62. </div>
  63. <hr>
  64. <a name="Your-Program_0027s-Input-and-Output"></a>
  65. <h3 class="section">4.6 Your Program&rsquo;s Input and Output</h3>
  66. <a name="index-redirection"></a>
  67. <a name="index-i_002fo"></a>
  68. <a name="index-terminal"></a>
  69. <p>By default, the program you run under <small>GDB</small> does input and output to
  70. the same terminal that <small>GDB</small> uses. <small>GDB</small> switches the terminal
  71. to its own terminal modes to interact with you, but it records the terminal
  72. modes your program was using and switches back to them when you continue
  73. running your program.
  74. </p>
  75. <dl compact="compact">
  76. <dd><a name="index-info-terminal"></a>
  77. </dd>
  78. <dt><code>info terminal</code></dt>
  79. <dd><p>Displays information recorded by <small>GDB</small> about the terminal modes your
  80. program is using.
  81. </p></dd>
  82. </dl>
  83. <p>You can redirect your program&rsquo;s input and/or output using shell
  84. redirection with the <code>run</code> command. For example,
  85. </p>
  86. <div class="smallexample">
  87. <pre class="smallexample">run &gt; outfile
  88. </pre></div>
  89. <p>starts your program, diverting its output to the file <samp>outfile</samp>.
  90. </p>
  91. <a name="index-tty"></a>
  92. <a name="index-controlling-terminal"></a>
  93. <p>Another way to specify where your program should do input and output is
  94. with the <code>tty</code> command. This command accepts a file name as
  95. argument, and causes this file to be the default for future <code>run</code>
  96. commands. It also resets the controlling terminal for the child
  97. process, for future <code>run</code> commands. For example,
  98. </p>
  99. <div class="smallexample">
  100. <pre class="smallexample">tty /dev/ttyb
  101. </pre></div>
  102. <p>directs that processes started with subsequent <code>run</code> commands
  103. default to do input and output on the terminal <samp>/dev/ttyb</samp> and have
  104. that as their controlling terminal.
  105. </p>
  106. <p>An explicit redirection in <code>run</code> overrides the <code>tty</code> command&rsquo;s
  107. effect on the input/output device, but not its effect on the controlling
  108. terminal.
  109. </p>
  110. <p>When you use the <code>tty</code> command or redirect input in the <code>run</code>
  111. command, only the input <em>for your program</em> is affected. The input
  112. for <small>GDB</small> still comes from your terminal. <code>tty</code> is an alias
  113. for <code>set inferior-tty</code>.
  114. </p>
  115. <a name="index-inferior-tty"></a>
  116. <a name="index-set-inferior-controlling-terminal"></a>
  117. <p>You can use the <code>show inferior-tty</code> command to tell <small>GDB</small> to
  118. display the name of the terminal that will be used for future runs of your
  119. program.
  120. </p>
  121. <dl compact="compact">
  122. <dt><code>set inferior-tty [ <var>tty</var> ]</code></dt>
  123. <dd><a name="index-set-inferior_002dtty"></a>
  124. <p>Set the tty for the program being debugged to <var>tty</var>. Omitting <var>tty</var>
  125. restores the default behavior, which is to use the same terminal as
  126. <small>GDB</small>.
  127. </p>
  128. </dd>
  129. <dt><code>show inferior-tty</code></dt>
  130. <dd><a name="index-show-inferior_002dtty"></a>
  131. <p>Show the current tty for the program being debugged.
  132. </p></dd>
  133. </dl>
  134. <hr>
  135. <div class="header">
  136. <p>
  137. Next: <a href="Attach.html#Attach" accesskey="n" rel="next">Attach</a>, Previous: <a href="Working-Directory.html#Working-Directory" accesskey="p" rel="previous">Working Directory</a>, Up: <a href="Running.html#Running" accesskey="u" rel="up">Running</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
  138. </div>
  139. </body>
  140. </html>