GDB_002fMI-Thread-Commands.html 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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: GDB/MI Thread Commands</title>
  16. <meta name="description" content="Debugging with GDB: GDB/MI Thread Commands">
  17. <meta name="keywords" content="Debugging with GDB: GDB/MI Thread Commands">
  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="GDB_002fMI.html#GDB_002fMI" rel="up" title="GDB/MI">
  26. <link href="GDB_002fMI-Ada-Tasking-Commands.html#GDB_002fMI-Ada-Tasking-Commands" rel="next" title="GDB/MI Ada Tasking Commands">
  27. <link href="GDB_002fMI-Program-Context.html#GDB_002fMI-Program-Context" rel="previous" title="GDB/MI Program Context">
  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="GDB_002fMI-Thread-Commands"></a>
  59. <div class="header">
  60. <p>
  61. Next: <a href="GDB_002fMI-Ada-Tasking-Commands.html#GDB_002fMI-Ada-Tasking-Commands" accesskey="n" rel="next">GDB/MI Ada Tasking Commands</a>, Previous: <a href="GDB_002fMI-Program-Context.html#GDB_002fMI-Program-Context" accesskey="p" rel="previous">GDB/MI Program Context</a>, Up: <a href="GDB_002fMI.html#GDB_002fMI" accesskey="u" rel="up">GDB/MI</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="GDB_002fMI-Thread-Commands-1"></a>
  65. <h3 class="section">27.11 <small>GDB/MI</small> Thread Commands</h3>
  66. <a name="The-_002dthread_002dinfo-Command"></a>
  67. <h4 class="subheading">The <code>-thread-info</code> Command</h4>
  68. <a name="index-_002dthread_002dinfo"></a>
  69. <a name="Synopsis-26"></a>
  70. <h4 class="subsubheading">Synopsis</h4>
  71. <div class="smallexample">
  72. <pre class="smallexample"> -thread-info [ <var>thread-id</var> ]
  73. </pre></div>
  74. <p>Reports information about either a specific thread, if the
  75. <var>thread-id</var> parameter is present, or about all threads.
  76. <var>thread-id</var> is the thread&rsquo;s global thread ID. When printing
  77. information about all threads, also reports the global ID of the
  78. current thread.
  79. </p>
  80. <a name="GDB-Command-25"></a>
  81. <h4 class="subsubheading"><small>GDB</small> Command</h4>
  82. <p>The &lsquo;<samp>info thread</samp>&rsquo; command prints the same information
  83. about all threads.
  84. </p>
  85. <a name="Result-3"></a>
  86. <h4 class="subsubheading">Result</h4>
  87. <p>The result contains the following attributes:
  88. </p>
  89. <dl compact="compact">
  90. <dt>&lsquo;<samp>threads</samp>&rsquo;</dt>
  91. <dd><p>A list of threads. The format of the elements of the list is described in
  92. <a href="GDB_002fMI-Thread-Information.html#GDB_002fMI-Thread-Information">GDB/MI Thread Information</a>.
  93. </p>
  94. </dd>
  95. <dt>&lsquo;<samp>current-thread-id</samp>&rsquo;</dt>
  96. <dd><p>The global id of the currently selected thread. This field is omitted if there
  97. is no selected thread (for example, when the selected inferior is not running,
  98. and therefore has no threads) or if a <var>thread-id</var> argument was passed to
  99. the command.
  100. </p>
  101. </dd>
  102. </dl>
  103. <a name="Example-25"></a>
  104. <h4 class="subsubheading">Example</h4>
  105. <div class="smallexample">
  106. <pre class="smallexample">-thread-info
  107. ^done,threads=[
  108. {id=&quot;2&quot;,target-id=&quot;Thread 0xb7e14b90 (LWP 21257)&quot;,
  109. frame={level=&quot;0&quot;,addr=&quot;0xffffe410&quot;,func=&quot;__kernel_vsyscall&quot;,
  110. args=[]},state=&quot;running&quot;},
  111. {id=&quot;1&quot;,target-id=&quot;Thread 0xb7e156b0 (LWP 21254)&quot;,
  112. frame={level=&quot;0&quot;,addr=&quot;0x0804891f&quot;,func=&quot;foo&quot;,
  113. args=[{name=&quot;i&quot;,value=&quot;10&quot;}],
  114. file=&quot;/tmp/a.c&quot;,fullname=&quot;/tmp/a.c&quot;,line=&quot;158&quot;,arch=&quot;i386:x86_64&quot;},
  115. state=&quot;running&quot;}],
  116. current-thread-id=&quot;1&quot;
  117. (gdb)
  118. </pre></div>
  119. <a name="The-_002dthread_002dlist_002dids-Command"></a>
  120. <h4 class="subheading">The <code>-thread-list-ids</code> Command</h4>
  121. <a name="index-_002dthread_002dlist_002dids"></a>
  122. <a name="Synopsis-27"></a>
  123. <h4 class="subsubheading">Synopsis</h4>
  124. <div class="smallexample">
  125. <pre class="smallexample"> -thread-list-ids
  126. </pre></div>
  127. <p>Produces a list of the currently known global <small>GDB</small> thread ids.
  128. At the end of the list it also prints the total number of such
  129. threads.
  130. </p>
  131. <p>This command is retained for historical reasons, the
  132. <code>-thread-info</code> command should be used instead.
  133. </p>
  134. <a name="GDB-Command-26"></a>
  135. <h4 class="subsubheading"><small>GDB</small> Command</h4>
  136. <p>Part of &lsquo;<samp>info threads</samp>&rsquo; supplies the same information.
  137. </p>
  138. <a name="Example-26"></a>
  139. <h4 class="subsubheading">Example</h4>
  140. <div class="smallexample">
  141. <pre class="smallexample">(gdb)
  142. -thread-list-ids
  143. ^done,thread-ids={thread-id=&quot;3&quot;,thread-id=&quot;2&quot;,thread-id=&quot;1&quot;},
  144. current-thread-id=&quot;1&quot;,number-of-threads=&quot;3&quot;
  145. (gdb)
  146. </pre></div>
  147. <a name="The-_002dthread_002dselect-Command"></a>
  148. <h4 class="subheading">The <code>-thread-select</code> Command</h4>
  149. <a name="index-_002dthread_002dselect"></a>
  150. <a name="Synopsis-28"></a>
  151. <h4 class="subsubheading">Synopsis</h4>
  152. <div class="smallexample">
  153. <pre class="smallexample"> -thread-select <var>thread-id</var>
  154. </pre></div>
  155. <p>Make thread with global thread number <var>thread-id</var> the current
  156. thread. It prints the number of the new current thread, and the
  157. topmost frame for that thread.
  158. </p>
  159. <p>This command is deprecated in favor of explicitly using the
  160. &lsquo;<samp>--thread</samp>&rsquo; option to each command.
  161. </p>
  162. <a name="GDB-Command-27"></a>
  163. <h4 class="subsubheading"><small>GDB</small> Command</h4>
  164. <p>The corresponding <small>GDB</small> command is &lsquo;<samp>thread</samp>&rsquo;.
  165. </p>
  166. <a name="Example-27"></a>
  167. <h4 class="subsubheading">Example</h4>
  168. <div class="smallexample">
  169. <pre class="smallexample">(gdb)
  170. -exec-next
  171. ^running
  172. (gdb)
  173. *stopped,reason=&quot;end-stepping-range&quot;,thread-id=&quot;2&quot;,line=&quot;187&quot;,
  174. file=&quot;../../../devo/gdb/testsuite/gdb.threads/linux-dp.c&quot;
  175. (gdb)
  176. -thread-list-ids
  177. ^done,
  178. thread-ids={thread-id=&quot;3&quot;,thread-id=&quot;2&quot;,thread-id=&quot;1&quot;},
  179. number-of-threads=&quot;3&quot;
  180. (gdb)
  181. -thread-select 3
  182. ^done,new-thread-id=&quot;3&quot;,
  183. frame={level=&quot;0&quot;,func=&quot;vprintf&quot;,
  184. args=[{name=&quot;format&quot;,value=&quot;0x8048e9c \&quot;%*s%c %d %c\\n\&quot;&quot;},
  185. {name=&quot;arg&quot;,value=&quot;0x2&quot;}],file=&quot;vprintf.c&quot;,line=&quot;31&quot;,arch=&quot;i386:x86_64&quot;}
  186. (gdb)
  187. </pre></div>
  188. <hr>
  189. <div class="header">
  190. <p>
  191. Next: <a href="GDB_002fMI-Ada-Tasking-Commands.html#GDB_002fMI-Ada-Tasking-Commands" accesskey="n" rel="next">GDB/MI Ada Tasking Commands</a>, Previous: <a href="GDB_002fMI-Program-Context.html#GDB_002fMI-Program-Context" accesskey="p" rel="previous">GDB/MI Program Context</a>, Up: <a href="GDB_002fMI.html#GDB_002fMI" accesskey="u" rel="up">GDB/MI</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>
  192. </div>
  193. </body>
  194. </html>