You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Input_002fOutput.html 6.5KB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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 6.5, http://www.gnu.org/software/texinfo/ -->
  14. <head>
  15. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  16. <title>Input/Output (Debugging with GDB)</title>
  17. <meta name="description" content="Input/Output (Debugging with GDB)">
  18. <meta name="keywords" content="Input/Output (Debugging with GDB)">
  19. <meta name="resource-type" content="document">
  20. <meta name="distribution" content="global">
  21. <meta name="Generator" content="makeinfo">
  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="prev" title="Working Directory">
  28. <style type="text/css">
  29. <!--
  30. a.summary-letter {text-decoration: none}
  31. blockquote.indentedblock {margin-right: 0em}
  32. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  33. blockquote.smallquotation {font-size: smaller}
  34. div.display {margin-left: 3.2em}
  35. div.example {margin-left: 3.2em}
  36. div.lisp {margin-left: 3.2em}
  37. div.smalldisplay {margin-left: 3.2em}
  38. div.smallexample {margin-left: 3.2em}
  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.nolinebreak {white-space: nowrap}
  50. span.roman {font-family: initial; font-weight: normal}
  51. span.sansserif {font-family: sans-serif; font-weight: normal}
  52. ul.no-bullet {list-style: none}
  53. -->
  54. </style>
  55. </head>
  56. <body lang="en">
  57. <a name="Input_002fOutput"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Attach.html#Attach" accesskey="n" rel="next">Attach</a>, Previous: <a href="Working-Directory.html#Working-Directory" accesskey="p" rel="prev">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>
  61. </div>
  62. <hr>
  63. <a name="Your-Program_0027s-Input-and-Output"></a>
  64. <h3 class="section">4.6 Your Program&rsquo;s Input and Output</h3>
  65. <a name="index-redirection"></a>
  66. <a name="index-i_002fo"></a>
  67. <a name="index-terminal"></a>
  68. <p>By default, the program you run under <small>GDB</small> does input and output to
  69. the same terminal that <small>GDB</small> uses. <small>GDB</small> switches the terminal
  70. to its own terminal modes to interact with you, but it records the terminal
  71. modes your program was using and switches back to them when you continue
  72. running your program.
  73. </p>
  74. <dl compact="compact">
  75. <dd><a name="index-info-terminal"></a>
  76. </dd>
  77. <dt><code>info terminal</code></dt>
  78. <dd><p>Displays information recorded by <small>GDB</small> about the terminal modes your
  79. program is using.
  80. </p></dd>
  81. </dl>
  82. <p>You can redirect your program&rsquo;s input and/or output using shell
  83. redirection with the <code>run</code> command. For example,
  84. </p>
  85. <div class="smallexample">
  86. <pre class="smallexample">run &gt; outfile
  87. </pre></div>
  88. <p>starts your program, diverting its output to the file <samp>outfile</samp>.
  89. </p>
  90. <a name="index-tty"></a>
  91. <a name="index-controlling-terminal"></a>
  92. <p>Another way to specify where your program should do input and output is
  93. with the <code>tty</code> command. This command accepts a file name as
  94. argument, and causes this file to be the default for future <code>run</code>
  95. commands. It also resets the controlling terminal for the child
  96. process, for future <code>run</code> commands. For example,
  97. </p>
  98. <div class="smallexample">
  99. <pre class="smallexample">tty /dev/ttyb
  100. </pre></div>
  101. <p>directs that processes started with subsequent <code>run</code> commands
  102. default to do input and output on the terminal <samp>/dev/ttyb</samp> and have
  103. that as their controlling terminal.
  104. </p>
  105. <p>An explicit redirection in <code>run</code> overrides the <code>tty</code> command&rsquo;s
  106. effect on the input/output device, but not its effect on the controlling
  107. terminal.
  108. </p>
  109. <p>When you use the <code>tty</code> command or redirect input in the <code>run</code>
  110. command, only the input <em>for your program</em> is affected. The input
  111. for <small>GDB</small> still comes from your terminal. <code>tty</code> is an alias
  112. for <code>set inferior-tty</code>.
  113. </p>
  114. <a name="index-inferior-tty"></a>
  115. <a name="index-set-inferior-controlling-terminal"></a>
  116. <p>You can use the <code>show inferior-tty</code> command to tell <small>GDB</small> to
  117. display the name of the terminal that will be used for future runs of your
  118. program.
  119. </p>
  120. <dl compact="compact">
  121. <dt><code>set inferior-tty [ <var>tty</var> ]</code></dt>
  122. <dd><a name="index-set-inferior_002dtty"></a>
  123. <p>Set the tty for the program being debugged to <var>tty</var>. Omitting <var>tty</var>
  124. restores the default behavior, which is to use the same terminal as
  125. <small>GDB</small>.
  126. </p>
  127. </dd>
  128. <dt><code>show inferior-tty</code></dt>
  129. <dd><a name="index-show-inferior_002dtty"></a>
  130. <p>Show the current tty for the program being debugged.
  131. </p></dd>
  132. </dl>
  133. <hr>
  134. <div class="header">
  135. <p>
  136. Next: <a href="Attach.html#Attach" accesskey="n" rel="next">Attach</a>, Previous: <a href="Working-Directory.html#Working-Directory" accesskey="p" rel="prev">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>
  137. </div>
  138. </body>
  139. </html>