Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

3 роки тому
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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>Break Commands (Debugging with GDB)</title>
  17. <meta name="description" content="Break Commands (Debugging with GDB)">
  18. <meta name="keywords" content="Break Commands (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="Breakpoints.html#Breakpoints" rel="up" title="Breakpoints">
  26. <link href="Dynamic-Printf.html#Dynamic-Printf" rel="next" title="Dynamic Printf">
  27. <link href="Conditions.html#Conditions" rel="prev" title="Conditions">
  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="Break-Commands"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Dynamic-Printf.html#Dynamic-Printf" accesskey="n" rel="next">Dynamic Printf</a>, Previous: <a href="Conditions.html#Conditions" accesskey="p" rel="prev">Conditions</a>, Up: <a href="Breakpoints.html#Breakpoints" accesskey="u" rel="up">Breakpoints</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="Breakpoint-Command-Lists"></a>
  64. <h4 class="subsection">5.1.7 Breakpoint Command Lists</h4>
  65. <a name="index-breakpoint-commands"></a>
  66. <p>You can give any breakpoint (or watchpoint or catchpoint) a series of
  67. commands to execute when your program stops due to that breakpoint. For
  68. example, you might want to print the values of certain expressions, or
  69. enable other breakpoints.
  70. </p>
  71. <dl compact="compact">
  72. <dd><a name="index-commands"></a>
  73. <a name="index-end-_0028breakpoint-commands_0029"></a>
  74. </dd>
  75. <dt><code>commands <span class="roman">[</span><var>list</var>&hellip;<span class="roman">]</span></code></dt>
  76. <dt><code>&hellip; <var>command-list</var> &hellip;</code></dt>
  77. <dt><code>end</code></dt>
  78. <dd><p>Specify a list of commands for the given breakpoints. The commands
  79. themselves appear on the following lines. Type a line containing just
  80. <code>end</code> to terminate the commands.
  81. </p>
  82. <p>To remove all commands from a breakpoint, type <code>commands</code> and
  83. follow it immediately with <code>end</code>; that is, give no commands.
  84. </p>
  85. <p>With no argument, <code>commands</code> refers to the last breakpoint,
  86. watchpoint, or catchpoint set (not to the breakpoint most recently
  87. encountered). If the most recent breakpoints were set with a single
  88. command, then the <code>commands</code> will apply to all the breakpoints
  89. set by that command. This applies to breakpoints set by
  90. <code>rbreak</code>, and also applies when a single <code>break</code> command
  91. creates multiple breakpoints (see <a href="Ambiguous-Expressions.html#Ambiguous-Expressions">Ambiguous
  92. Expressions</a>).
  93. </p></dd>
  94. </dl>
  95. <p>Pressing <tt class="key">RET</tt> as a means of repeating the last <small>GDB</small> command is
  96. disabled within a <var>command-list</var>.
  97. </p>
  98. <p>You can use breakpoint commands to start your program up again. Simply
  99. use the <code>continue</code> command, or <code>step</code>, or any other command
  100. that resumes execution.
  101. </p>
  102. <p>Any other commands in the command list, after a command that resumes
  103. execution, are ignored. This is because any time you resume execution
  104. (even with a simple <code>next</code> or <code>step</code>), you may encounter
  105. another breakpoint&mdash;which could have its own command list, leading to
  106. ambiguities about which list to execute.
  107. </p>
  108. <a name="index-silent"></a>
  109. <p>If the first command you specify in a command list is <code>silent</code>, the
  110. usual message about stopping at a breakpoint is not printed. This may
  111. be desirable for breakpoints that are to print a specific message and
  112. then continue. If none of the remaining commands print anything, you
  113. see no sign that the breakpoint was reached. <code>silent</code> is
  114. meaningful only at the beginning of a breakpoint command list.
  115. </p>
  116. <p>The commands <code>echo</code>, <code>output</code>, and <code>printf</code> allow you to
  117. print precisely controlled output, and are often useful in silent
  118. breakpoints. See <a href="Output.html#Output">Commands for Controlled Output</a>.
  119. </p>
  120. <p>For example, here is how you could use breakpoint commands to print the
  121. value of <code>x</code> at entry to <code>foo</code> whenever <code>x</code> is positive.
  122. </p>
  123. <div class="smallexample">
  124. <pre class="smallexample">break foo if x&gt;0
  125. commands
  126. silent
  127. printf &quot;x is %d\n&quot;,x
  128. cont
  129. end
  130. </pre></div>
  131. <p>One application for breakpoint commands is to compensate for one bug so
  132. you can test for another. Put a breakpoint just after the erroneous line
  133. of code, give it a condition to detect the case in which something
  134. erroneous has been done, and give it commands to assign correct values
  135. to any variables that need them. End with the <code>continue</code> command
  136. so that your program does not stop, and start with the <code>silent</code>
  137. command so that no output is produced. Here is an example:
  138. </p>
  139. <div class="smallexample">
  140. <pre class="smallexample">break 403
  141. commands
  142. silent
  143. set x = y + 4
  144. cont
  145. end
  146. </pre></div>
  147. <hr>
  148. <div class="header">
  149. <p>
  150. Next: <a href="Dynamic-Printf.html#Dynamic-Printf" accesskey="n" rel="next">Dynamic Printf</a>, Previous: <a href="Conditions.html#Conditions" accesskey="p" rel="prev">Conditions</a>, Up: <a href="Breakpoints.html#Breakpoints" accesskey="u" rel="up">Breakpoints</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>
  151. </div>
  152. </body>
  153. </html>