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.

All_002dStop-Mode.html 8.4KB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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>All-Stop Mode (Debugging with GDB)</title>
  17. <meta name="description" content="All-Stop Mode (Debugging with GDB)">
  18. <meta name="keywords" content="All-Stop Mode (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="Thread-Stops.html#Thread-Stops" rel="up" title="Thread Stops">
  26. <link href="Non_002dStop-Mode.html#Non_002dStop-Mode" rel="next" title="Non-Stop Mode">
  27. <link href="Thread-Stops.html#Thread-Stops" rel="prev" title="Thread Stops">
  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="All_002dStop-Mode"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Non_002dStop-Mode.html#Non_002dStop-Mode" accesskey="n" rel="next">Non-Stop Mode</a>, Up: <a href="Thread-Stops.html#Thread-Stops" accesskey="u" rel="up">Thread Stops</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="All_002dStop-Mode-1"></a>
  64. <h4 class="subsection">5.5.1 All-Stop Mode</h4>
  65. <a name="index-all_002dstop-mode"></a>
  66. <p>In all-stop mode, whenever your program stops under <small>GDB</small> for any reason,
  67. <em>all</em> threads of execution stop, not just the current thread. This
  68. allows you to examine the overall state of the program, including
  69. switching between threads, without worrying that things may change
  70. underfoot.
  71. </p>
  72. <p>Conversely, whenever you restart the program, <em>all</em> threads start
  73. executing. <em>This is true even when single-stepping</em> with commands
  74. like <code>step</code> or <code>next</code>.
  75. </p>
  76. <p>In particular, <small>GDB</small> cannot single-step all threads in lockstep.
  77. Since thread scheduling is up to your debugging target&rsquo;s operating
  78. system (not controlled by <small>GDB</small>), other threads may
  79. execute more than one statement while the current thread completes a
  80. single step. Moreover, in general other threads stop in the middle of a
  81. statement, rather than at a clean statement boundary, when the program
  82. stops.
  83. </p>
  84. <p>You might even find your program stopped in another thread after
  85. continuing or even single-stepping. This happens whenever some other
  86. thread runs into a breakpoint, a signal, or an exception before the
  87. first thread completes whatever you requested.
  88. </p>
  89. <a name="index-automatic-thread-selection"></a>
  90. <a name="index-switching-threads-automatically"></a>
  91. <a name="index-threads_002c-automatic-switching"></a>
  92. <p>Whenever <small>GDB</small> stops your program, due to a breakpoint or a
  93. signal, it automatically selects the thread where that breakpoint or
  94. signal happened. <small>GDB</small> alerts you to the context switch with a
  95. message such as &lsquo;<samp>[Switching to Thread <var>n</var>]</samp>&rsquo; to identify the
  96. thread.
  97. </p>
  98. <p>On some OSes, you can modify <small>GDB</small>&rsquo;s default behavior by
  99. locking the OS scheduler to allow only a single thread to run.
  100. </p>
  101. <dl compact="compact">
  102. <dt><code>set scheduler-locking <var>mode</var></code></dt>
  103. <dd><a name="index-scheduler-locking-mode"></a>
  104. <a name="index-lock-scheduler"></a>
  105. <p>Set the scheduler locking mode. It applies to normal execution,
  106. record mode, and replay mode. If it is <code>off</code>, then there is no
  107. locking and any thread may run at any time. If <code>on</code>, then only
  108. the current thread may run when the inferior is resumed. The
  109. <code>step</code> mode optimizes for single-stepping; it prevents other
  110. threads from preempting the current thread while you are stepping, so
  111. that the focus of debugging does not change unexpectedly. Other
  112. threads never get a chance to run when you step, and they are
  113. completely free to run when you use commands like &lsquo;<samp>continue</samp>&rsquo;,
  114. &lsquo;<samp>until</samp>&rsquo;, or &lsquo;<samp>finish</samp>&rsquo;. However, unless another thread hits a
  115. breakpoint during its timeslice, <small>GDB</small> does not change the
  116. current thread away from the thread that you are debugging. The
  117. <code>replay</code> mode behaves like <code>off</code> in record mode and like
  118. <code>on</code> in replay mode.
  119. </p>
  120. </dd>
  121. <dt><code>show scheduler-locking</code></dt>
  122. <dd><p>Display the current scheduler locking mode.
  123. </p></dd>
  124. </dl>
  125. <a name="index-resume-threads-of-multiple-processes-simultaneously"></a>
  126. <p>By default, when you issue one of the execution commands such as
  127. <code>continue</code>, <code>next</code> or <code>step</code>, <small>GDB</small> allows only
  128. threads of the current inferior to run. For example, if <small>GDB</small>
  129. is attached to two inferiors, each with two threads, the
  130. <code>continue</code> command resumes only the two threads of the current
  131. inferior. This is useful, for example, when you debug a program that
  132. forks and you want to hold the parent stopped (so that, for instance,
  133. it doesn&rsquo;t run to exit), while you debug the child. In other
  134. situations, you may not be interested in inspecting the current state
  135. of any of the processes <small>GDB</small> is attached to, and you may want
  136. to resume them all until some breakpoint is hit. In the latter case,
  137. you can instruct <small>GDB</small> to allow all threads of all the
  138. inferiors to run with the <code>set&nbsp;<span class="nolinebreak">schedule-multiple</span></code><!-- /@w --> command.
  139. </p>
  140. <dl compact="compact">
  141. <dd><a name="index-set-schedule_002dmultiple"></a>
  142. </dd>
  143. <dt><code>set schedule-multiple</code></dt>
  144. <dd><p>Set the mode for allowing threads of multiple processes to be resumed
  145. when an execution command is issued. When <code>on</code>, all threads of
  146. all processes are allowed to run. When <code>off</code>, only the threads
  147. of the current process are resumed. The default is <code>off</code>. The
  148. <code>scheduler-locking</code> mode takes precedence when set to <code>on</code>,
  149. or while you are stepping and set to <code>step</code>.
  150. </p>
  151. </dd>
  152. <dt><code>show schedule-multiple</code></dt>
  153. <dd><p>Display the current mode for resuming the execution of threads of
  154. multiple processes.
  155. </p></dd>
  156. </dl>
  157. <hr>
  158. <div class="header">
  159. <p>
  160. Next: <a href="Non_002dStop-Mode.html#Non_002dStop-Mode" accesskey="n" rel="next">Non-Stop Mode</a>, Up: <a href="Thread-Stops.html#Thread-Stops" accesskey="u" rel="up">Thread Stops</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>
  161. </div>
  162. </body>
  163. </html>