Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

166 lines
7.1KB

  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>Invoking GDB (Debugging with GDB)</title>
  17. <meta name="description" content="Invoking GDB (Debugging with GDB)">
  18. <meta name="keywords" content="Invoking GDB (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="Invocation.html#Invocation" rel="up" title="Invocation">
  26. <link href="File-Options.html#File-Options" rel="next" title="File Options">
  27. <link href="Invocation.html#Invocation" rel="prev" title="Invocation">
  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="Invoking-GDB"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Quitting-GDB.html#Quitting-GDB" accesskey="n" rel="next">Quitting GDB</a>, Up: <a href="Invocation.html#Invocation" accesskey="u" rel="up">Invocation</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="Invoking-GDB-1"></a>
  64. <h3 class="section">2.1 Invoking <small>GDB</small></h3>
  65. <p>Invoke <small>GDB</small> by running the program <code>gdb</code>. Once started,
  66. <small>GDB</small> reads commands from the terminal until you tell it to exit.
  67. </p>
  68. <p>You can also run <code>gdb</code> with a variety of arguments and options,
  69. to specify more of your debugging environment at the outset.
  70. </p>
  71. <p>The command-line options described here are designed
  72. to cover a variety of situations; in some environments, some of these
  73. options may effectively be unavailable.
  74. </p>
  75. <p>The most usual way to start <small>GDB</small> is with one argument,
  76. specifying an executable program:
  77. </p>
  78. <div class="smallexample">
  79. <pre class="smallexample">gdb <var>program</var>
  80. </pre></div>
  81. <p>You can also start with both an executable program and a core file
  82. specified:
  83. </p>
  84. <div class="smallexample">
  85. <pre class="smallexample">gdb <var>program</var> <var>core</var>
  86. </pre></div>
  87. <p>You can, instead, specify a process ID as a second argument or use option
  88. <code>-p</code>, if you want to debug a running process:
  89. </p>
  90. <div class="smallexample">
  91. <pre class="smallexample">gdb <var>program</var> 1234
  92. gdb -p 1234
  93. </pre></div>
  94. <p>would attach <small>GDB</small> to process <code>1234</code>. With option <samp>-p</samp> you
  95. can omit the <var>program</var> filename.
  96. </p>
  97. <p>Taking advantage of the second command-line argument requires a fairly
  98. complete operating system; when you use <small>GDB</small> as a remote
  99. debugger attached to a bare board, there may not be any notion of
  100. &ldquo;process&rdquo;, and there is often no way to get a core dump. <small>GDB</small>
  101. will warn you if it is unable to attach or to read core dumps.
  102. </p>
  103. <p>You can optionally have <code>gdb</code> pass any arguments after the
  104. executable file to the inferior using <code>--args</code>. This option stops
  105. option processing.
  106. </p><div class="smallexample">
  107. <pre class="smallexample">gdb --args gcc -O2 -c foo.c
  108. </pre></div>
  109. <p>This will cause <code>gdb</code> to debug <code>gcc</code>, and to set
  110. <code>gcc</code>&rsquo;s command-line arguments (see <a href="Arguments.html#Arguments">Arguments</a>) to &lsquo;<samp>-O2 -c foo.c</samp>&rsquo;.
  111. </p>
  112. <p>You can run <code>gdb</code> without printing the front material, which describes
  113. <small>GDB</small>&rsquo;s non-warranty, by specifying <code>--silent</code>
  114. (or <code>-q</code>/<code>--quiet</code>):
  115. </p>
  116. <div class="smallexample">
  117. <pre class="smallexample">gdb --silent
  118. </pre></div>
  119. <p>You can further control how <small>GDB</small> starts up by using command-line
  120. options. <small>GDB</small> itself can remind you of the options available.
  121. </p>
  122. <p>Type
  123. </p>
  124. <div class="smallexample">
  125. <pre class="smallexample">gdb -help
  126. </pre></div>
  127. <p>to display all available options and briefly describe their use
  128. (&lsquo;<samp>gdb -h</samp>&rsquo; is a shorter equivalent).
  129. </p>
  130. <p>All options and command line arguments you give are processed
  131. in sequential order. The order makes a difference when the
  132. &lsquo;<samp>-x</samp>&rsquo; option is used.
  133. </p>
  134. <table class="menu" border="0" cellspacing="0">
  135. <tr><td align="left" valign="top">&bull; <a href="File-Options.html#File-Options" accesskey="1">File Options</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Choosing files
  136. </td></tr>
  137. <tr><td align="left" valign="top">&bull; <a href="Mode-Options.html#Mode-Options" accesskey="2">Mode Options</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Choosing modes
  138. </td></tr>
  139. <tr><td align="left" valign="top">&bull; <a href="Startup.html#Startup" accesskey="3">Startup</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">What <small>GDB</small> does during startup
  140. </td></tr>
  141. </table>
  142. <hr>
  143. <div class="header">
  144. <p>
  145. Next: <a href="Quitting-GDB.html#Quitting-GDB" accesskey="n" rel="next">Quitting GDB</a>, Up: <a href="Invocation.html#Invocation" accesskey="u" rel="up">Invocation</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>
  146. </div>
  147. </body>
  148. </html>