Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

3 лет назад
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  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>Threads (Debugging with GDB)</title>
  17. <meta name="description" content="Threads (Debugging with GDB)">
  18. <meta name="keywords" content="Threads (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="Forks.html#Forks" rel="next" title="Forks">
  27. <link href="Inferiors-Connections-and-Programs.html#Inferiors-Connections-and-Programs" rel="prev" title="Inferiors Connections and Programs">
  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="Threads"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Forks.html#Forks" accesskey="n" rel="next">Forks</a>, Previous: <a href="Inferiors-Connections-and-Programs.html#Inferiors-Connections-and-Programs" accesskey="p" rel="prev">Inferiors Connections and Programs</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="Debugging-Programs-with-Multiple-Threads"></a>
  64. <h3 class="section">4.10 Debugging Programs with Multiple Threads</h3>
  65. <a name="index-threads-of-execution"></a>
  66. <a name="index-multiple-threads"></a>
  67. <a name="index-switching-threads"></a>
  68. <p>In some operating systems, such as GNU/Linux and Solaris, a single program
  69. may have more than one <em>thread</em> of execution. The precise semantics
  70. of threads differ from one operating system to another, but in general
  71. the threads of a single program are akin to multiple processes&mdash;except
  72. that they share one address space (that is, they can all examine and
  73. modify the same variables). On the other hand, each thread has its own
  74. registers and execution stack, and perhaps private memory.
  75. </p>
  76. <p><small>GDB</small> provides these facilities for debugging multi-thread
  77. programs:
  78. </p>
  79. <ul>
  80. <li> automatic notification of new threads
  81. </li><li> &lsquo;<samp>thread <var>thread-id</var></samp>&rsquo;, a command to switch among threads
  82. </li><li> &lsquo;<samp>info threads</samp>&rsquo;, a command to inquire about existing threads
  83. </li><li> &lsquo;<samp>thread apply [<var>thread-id-list</var> | all] <var>args</var></samp>&rsquo;,
  84. a command to apply a command to a list of threads
  85. </li><li> thread-specific breakpoints
  86. </li><li> &lsquo;<samp>set print thread-events</samp>&rsquo;, which controls printing of
  87. messages on thread start and exit.
  88. </li><li> &lsquo;<samp>set libthread-db-search-path <var>path</var></samp>&rsquo;, which lets
  89. the user specify which <code>libthread_db</code> to use if the default choice
  90. isn&rsquo;t compatible with the program.
  91. </li></ul>
  92. <a name="index-focus-of-debugging"></a>
  93. <a name="index-current-thread"></a>
  94. <p>The <small>GDB</small> thread debugging facility allows you to observe all
  95. threads while your program runs&mdash;but whenever <small>GDB</small> takes
  96. control, one thread in particular is always the focus of debugging.
  97. This thread is called the <em>current thread</em>. Debugging commands show
  98. program information from the perspective of the current thread.
  99. </p>
  100. <a name="index-New-systag-message"></a>
  101. <a name="index-thread-identifier-_0028system_0029"></a>
  102. <p>Whenever <small>GDB</small> detects a new thread in your program, it displays
  103. the target system&rsquo;s identification for the thread with a message in the
  104. form &lsquo;<samp>[New <var>systag</var>]</samp>&rsquo;, where <var>systag</var> is a thread identifier
  105. whose form varies depending on the particular system. For example, on
  106. <small>GNU</small>/Linux, you might see
  107. </p>
  108. <div class="smallexample">
  109. <pre class="smallexample">[New Thread 0x41e02940 (LWP 25582)]
  110. </pre></div>
  111. <p>when <small>GDB</small> notices a new thread. In contrast, on other systems,
  112. the <var>systag</var> is simply something like &lsquo;<samp>process 368</samp>&rsquo;, with no
  113. further qualifier.
  114. </p>
  115. <a name="thread-numbers"></a><a name="index-thread-number_002c-per-inferior"></a>
  116. <a name="index-thread-identifier-_0028GDB_0029"></a>
  117. <p>For debugging purposes, <small>GDB</small> associates its own thread number
  118. &mdash;always a single integer&mdash;with each thread of an inferior. This
  119. number is unique between all threads of an inferior, but not unique
  120. between threads of different inferiors.
  121. </p>
  122. <a name="index-qualified-thread-ID"></a>
  123. <p>You can refer to a given thread in an inferior using the qualified
  124. <var>inferior-num</var>.<var>thread-num</var> syntax, also known as
  125. <em>qualified thread ID</em>, with <var>inferior-num</var> being the inferior
  126. number and <var>thread-num</var> being the thread number of the given
  127. inferior. For example, thread <code>2.3</code> refers to thread number 3 of
  128. inferior 2. If you omit <var>inferior-num</var> (e.g., <code>thread 3</code>),
  129. then <small>GDB</small> infers you&rsquo;re referring to a thread of the current
  130. inferior.
  131. </p>
  132. <p>Until you create a second inferior, <small>GDB</small> does not show the
  133. <var>inferior-num</var> part of thread IDs, even though you can always use
  134. the full <var>inferior-num</var>.<var>thread-num</var> form to refer to threads
  135. of inferior 1, the initial inferior.
  136. </p>
  137. <a name="thread-ID-lists"></a><a name="index-thread-ID-lists"></a>
  138. <p>Some commands accept a space-separated <em>thread ID list</em> as
  139. argument. A list element can be:
  140. </p>
  141. <ol>
  142. <li> A thread ID as shown in the first field of the &lsquo;<samp>info threads</samp>&rsquo;
  143. display, with or without an inferior qualifier. E.g., &lsquo;<samp>2.1</samp>&rsquo; or
  144. &lsquo;<samp>1</samp>&rsquo;.
  145. </li><li> A range of thread numbers, again with or without an inferior
  146. qualifier, as in <var>inf</var>.<var>thr1</var>-<var>thr2</var> or
  147. <var>thr1</var>-<var>thr2</var>. E.g., &lsquo;<samp>1.2-4</samp>&rsquo; or &lsquo;<samp>2-4</samp>&rsquo;.
  148. </li><li> All threads of an inferior, specified with a star wildcard, with or
  149. without an inferior qualifier, as in <var>inf</var>.<code>*</code> (e.g.,
  150. &lsquo;<samp>1.*</samp>&rsquo;) or <code>*</code>. The former refers to all threads of the
  151. given inferior, and the latter form without an inferior qualifier
  152. refers to all threads of the current inferior.
  153. </li></ol>
  154. <p>For example, if the current inferior is 1, and inferior 7 has one
  155. thread with ID 7.1, the thread list &lsquo;<samp>1 2-3 4.5 6.7-9 7.*</samp>&rsquo;
  156. includes threads 1 to 3 of inferior 1, thread 5 of inferior 4, threads
  157. 7 to 9 of inferior 6 and all threads of inferior 7. That is, in
  158. expanded qualified form, the same as &lsquo;<samp>1.1 1.2 1.3 4.5 6.7 6.8 6.9
  159. 7.1</samp>&rsquo;.
  160. </p>
  161. <a name="global-thread-numbers"></a><a name="index-global-thread-number"></a>
  162. <a name="index-global-thread-identifier-_0028GDB_0029"></a>
  163. <p>In addition to a <em>per-inferior</em> number, each thread is also
  164. assigned a unique <em>global</em> number, also known as <em>global
  165. thread ID</em>, a single integer. Unlike the thread number component of
  166. the thread ID, no two threads have the same global ID, even when
  167. you&rsquo;re debugging multiple inferiors.
  168. </p>
  169. <p>From <small>GDB</small>&rsquo;s perspective, a process always has at least one
  170. thread. In other words, <small>GDB</small> assigns a thread number to the
  171. program&rsquo;s &ldquo;main thread&rdquo; even if the program is not multi-threaded.
  172. </p>
  173. <a name="index-_0024_005fthread_002c-convenience-variable"></a>
  174. <a name="index-_0024_005fgthread_002c-convenience-variable"></a>
  175. <p>The debugger convenience variables &lsquo;<samp>$_thread</samp>&rsquo; and
  176. &lsquo;<samp>$_gthread</samp>&rsquo; contain, respectively, the per-inferior thread number
  177. and the global thread number of the current thread. You may find this
  178. useful in writing breakpoint conditional expressions, command scripts,
  179. and so forth. See <a href="Convenience-Vars.html#Convenience-Vars">Convenience Variables</a>, for
  180. general information on convenience variables.
  181. </p>
  182. <p>If <small>GDB</small> detects the program is multi-threaded, it augments the
  183. usual message about stopping at a breakpoint with the ID and name of
  184. the thread that hit the breakpoint.
  185. </p>
  186. <div class="smallexample">
  187. <pre class="smallexample">Thread 2 &quot;client&quot; hit Breakpoint 1, send_message () at client.c:68
  188. </pre></div>
  189. <p>Likewise when the program receives a signal:
  190. </p>
  191. <div class="smallexample">
  192. <pre class="smallexample">Thread 1 &quot;main&quot; received signal SIGINT, Interrupt.
  193. </pre></div>
  194. <dl compact="compact">
  195. <dd><a name="index-info-threads"></a>
  196. </dd>
  197. <dt><code>info threads <span class="roman">[</span><var>thread-id-list</var><span class="roman">]</span></code></dt>
  198. <dd>
  199. <p>Display information about one or more threads. With no arguments
  200. displays information about all threads. You can specify the list of
  201. threads that you want to display using the thread ID list syntax
  202. (see <a href="#thread-ID-lists">thread ID lists</a>).
  203. </p>
  204. <p><small>GDB</small> displays for each thread (in this order):
  205. </p>
  206. <ol>
  207. <li> the per-inferior thread number assigned by <small>GDB</small>
  208. </li><li> the global thread number assigned by <small>GDB</small>, if the &lsquo;<samp>-gid</samp>&rsquo;
  209. option was specified
  210. </li><li> the target system&rsquo;s thread identifier (<var>systag</var>)
  211. </li><li> the thread&rsquo;s name, if one is known. A thread can either be named by
  212. the user (see <code>thread name</code>, below), or, in some cases, by the
  213. program itself.
  214. </li><li> the current stack frame summary for that thread
  215. </li></ol>
  216. <p>An asterisk &lsquo;<samp>*</samp>&rsquo; to the left of the <small>GDB</small> thread number
  217. indicates the current thread.
  218. </p>
  219. <p>For example,
  220. </p></dd>
  221. </dl>
  222. <div class="smallexample">
  223. <pre class="smallexample">(gdb) info threads
  224. Id Target Id Frame
  225. * 1 process 35 thread 13 main (argc=1, argv=0x7ffffff8)
  226. 2 process 35 thread 23 0x34e5 in sigpause ()
  227. 3 process 35 thread 27 0x34e5 in sigpause ()
  228. at threadtest.c:68
  229. </pre></div>
  230. <p>If you&rsquo;re debugging multiple inferiors, <small>GDB</small> displays thread
  231. IDs using the qualified <var>inferior-num</var>.<var>thread-num</var> format.
  232. Otherwise, only <var>thread-num</var> is shown.
  233. </p>
  234. <p>If you specify the &lsquo;<samp>-gid</samp>&rsquo; option, <small>GDB</small> displays a column
  235. indicating each thread&rsquo;s global thread ID:
  236. </p>
  237. <div class="smallexample">
  238. <pre class="smallexample">(gdb) info threads
  239. Id GId Target Id Frame
  240. 1.1 1 process 35 thread 13 main (argc=1, argv=0x7ffffff8)
  241. 1.2 3 process 35 thread 23 0x34e5 in sigpause ()
  242. 1.3 4 process 35 thread 27 0x34e5 in sigpause ()
  243. * 2.1 2 process 65 thread 1 main (argc=1, argv=0x7ffffff8)
  244. </pre></div>
  245. <p>On Solaris, you can display more information about user threads with a
  246. Solaris-specific command:
  247. </p>
  248. <dl compact="compact">
  249. <dt><code>maint info sol-threads</code></dt>
  250. <dd><a name="index-maint-info-sol_002dthreads"></a>
  251. <a name="index-thread-info-_0028Solaris_0029"></a>
  252. <p>Display info on Solaris user threads.
  253. </p></dd>
  254. </dl>
  255. <dl compact="compact">
  256. <dd><a name="index-thread-thread_002did"></a>
  257. </dd>
  258. <dt><code>thread <var>thread-id</var></code></dt>
  259. <dd><p>Make thread ID <var>thread-id</var> the current thread. The command
  260. argument <var>thread-id</var> is the <small>GDB</small> thread ID, as shown in
  261. the first field of the &lsquo;<samp>info threads</samp>&rsquo; display, with or without an
  262. inferior qualifier (e.g., &lsquo;<samp>2.1</samp>&rsquo; or &lsquo;<samp>1</samp>&rsquo;).
  263. </p>
  264. <p><small>GDB</small> responds by displaying the system identifier of the
  265. thread you selected, and its current stack frame summary:
  266. </p>
  267. <div class="smallexample">
  268. <pre class="smallexample">(gdb) thread 2
  269. [Switching to thread 2 (Thread 0xb7fdab70 (LWP 12747))]
  270. #0 some_function (ignore=0x0) at example.c:8
  271. 8 printf (&quot;hello\n&quot;);
  272. </pre></div>
  273. <p>As with the &lsquo;<samp>[New &hellip;]</samp>&rsquo; message, the form of the text after
  274. &lsquo;<samp>Switching to</samp>&rsquo; depends on your system&rsquo;s conventions for identifying
  275. threads.
  276. </p>
  277. <a name="thread-apply-all"></a><a name="index-thread-apply"></a>
  278. <a name="index-apply-command-to-several-threads"></a>
  279. </dd>
  280. <dt><code>thread apply [<var>thread-id-list</var> | all [-ascending]] [<var>flag</var>]&hellip; <var>command</var></code></dt>
  281. <dd><p>The <code>thread apply</code> command allows you to apply the named
  282. <var>command</var> to one or more threads. Specify the threads that you
  283. want affected using the thread ID list syntax (see <a href="#thread-ID-lists">thread ID lists</a>), or specify <code>all</code> to apply to all threads. To apply a
  284. command to all threads in descending order, type <kbd>thread apply all
  285. <var>command</var></kbd>. To apply a command to all threads in ascending order,
  286. type <kbd>thread apply all -ascending <var>command</var></kbd>.
  287. </p>
  288. <p>The <var>flag</var> arguments control what output to produce and how to handle
  289. errors raised when applying <var>command</var> to a thread. <var>flag</var>
  290. must start with a <code>-</code> directly followed by one letter in
  291. <code>qcs</code>. If several flags are provided, they must be given
  292. individually, such as <code>-c -q</code>.
  293. </p>
  294. <p>By default, <small>GDB</small> displays some thread information before the
  295. output produced by <var>command</var>, and an error raised during the
  296. execution of a <var>command</var> will abort <code>thread apply</code>. The
  297. following flags can be used to fine-tune this behavior:
  298. </p>
  299. <dl compact="compact">
  300. <dt><code>-c</code></dt>
  301. <dd><p>The flag <code>-c</code>, which stands for &lsquo;<samp>continue</samp>&rsquo;, causes any
  302. errors in <var>command</var> to be displayed, and the execution of
  303. <code>thread apply</code> then continues.
  304. </p></dd>
  305. <dt><code>-s</code></dt>
  306. <dd><p>The flag <code>-s</code>, which stands for &lsquo;<samp>silent</samp>&rsquo;, causes any errors
  307. or empty output produced by a <var>command</var> to be silently ignored.
  308. That is, the execution continues, but the thread information and errors
  309. are not printed.
  310. </p></dd>
  311. <dt><code>-q</code></dt>
  312. <dd><p>The flag <code>-q</code> (&lsquo;<samp>quiet</samp>&rsquo;) disables printing the thread
  313. information.
  314. </p></dd>
  315. </dl>
  316. <p>Flags <code>-c</code> and <code>-s</code> cannot be used together.
  317. </p>
  318. <a name="index-taas"></a>
  319. <a name="index-apply-command-to-all-threads-_0028ignoring-errors-and-empty-output_0029"></a>
  320. </dd>
  321. <dt><code>taas [<var>option</var>]&hellip; <var>command</var></code></dt>
  322. <dd><p>Shortcut for <code>thread apply all -s [<var>option</var>]&hellip; <var>command</var></code>.
  323. Applies <var>command</var> on all threads, ignoring errors and empty output.
  324. </p>
  325. <p>The <code>taas</code> command accepts the same options as the <code>thread
  326. apply all</code> command. See <a href="#thread-apply-all">thread apply all</a>.
  327. </p>
  328. <a name="index-tfaas"></a>
  329. <a name="index-apply-a-command-to-all-frames-of-all-threads-_0028ignoring-errors-and-empty-output_0029"></a>
  330. </dd>
  331. <dt><code>tfaas [<var>option</var>]&hellip; <var>command</var></code></dt>
  332. <dd><p>Shortcut for <code>thread apply all -s -- frame apply all -s [<var>option</var>]&hellip; <var>command</var></code>.
  333. Applies <var>command</var> on all frames of all threads, ignoring errors
  334. and empty output. Note that the flag <code>-s</code> is specified twice:
  335. The first <code>-s</code> ensures that <code>thread apply</code> only shows the thread
  336. information of the threads for which <code>frame apply</code> produces
  337. some output. The second <code>-s</code> is needed to ensure that <code>frame
  338. apply</code> shows the frame information of a frame only if the
  339. <var>command</var> successfully produced some output.
  340. </p>
  341. <p>It can for example be used to print a local variable or a function
  342. argument without knowing the thread or frame where this variable or argument
  343. is, using:
  344. </p><div class="smallexample">
  345. <pre class="smallexample">(gdb) tfaas p some_local_var_i_do_not_remember_where_it_is
  346. </pre></div>
  347. <p>The <code>tfaas</code> command accepts the same options as the <code>frame
  348. apply</code> command. See <a href="Frame-Apply.html#Frame-Apply">frame apply</a>.
  349. </p>
  350. <a name="index-thread-name"></a>
  351. <a name="index-name-a-thread"></a>
  352. </dd>
  353. <dt><code>thread name [<var>name</var>]</code></dt>
  354. <dd><p>This command assigns a name to the current thread. If no argument is
  355. given, any existing user-specified name is removed. The thread name
  356. appears in the &lsquo;<samp>info threads</samp>&rsquo; display.
  357. </p>
  358. <p>On some systems, such as <small>GNU</small>/Linux, <small>GDB</small> is able to
  359. determine the name of the thread as given by the OS. On these
  360. systems, a name specified with &lsquo;<samp>thread name</samp>&rsquo; will override the
  361. system-give name, and removing the user-specified name will cause
  362. <small>GDB</small> to once again display the system-specified name.
  363. </p>
  364. <a name="index-thread-find"></a>
  365. <a name="index-search-for-a-thread"></a>
  366. </dd>
  367. <dt><code>thread find [<var>regexp</var>]</code></dt>
  368. <dd><p>Search for and display thread ids whose name or <var>systag</var>
  369. matches the supplied regular expression.
  370. </p>
  371. <p>As well as being the complement to the &lsquo;<samp>thread name</samp>&rsquo; command,
  372. this command also allows you to identify a thread by its target
  373. <var>systag</var>. For instance, on <small>GNU</small>/Linux, the target <var>systag</var>
  374. is the LWP id.
  375. </p>
  376. <div class="smallexample">
  377. <pre class="smallexample">(GDB) thread find 26688
  378. Thread 4 has target id 'Thread 0x41e02940 (LWP 26688)'
  379. (GDB) info thread 4
  380. Id Target Id Frame
  381. 4 Thread 0x41e02940 (LWP 26688) 0x00000031ca6cd372 in select ()
  382. </pre></div>
  383. <a name="index-set-print-thread_002devents"></a>
  384. <a name="index-print-messages-on-thread-start-and-exit"></a>
  385. </dd>
  386. <dt><code>set print thread-events</code></dt>
  387. <dt><code>set print thread-events on</code></dt>
  388. <dt><code>set print thread-events off</code></dt>
  389. <dd><p>The <code>set print thread-events</code> command allows you to enable or
  390. disable printing of messages when <small>GDB</small> notices that new threads have
  391. started or that threads have exited. By default, these messages will
  392. be printed if detection of these events is supported by the target.
  393. Note that these messages cannot be disabled on all targets.
  394. </p>
  395. <a name="index-show-print-thread_002devents"></a>
  396. </dd>
  397. <dt><code>show print thread-events</code></dt>
  398. <dd><p>Show whether messages will be printed when <small>GDB</small> detects that threads
  399. have started and exited.
  400. </p></dd>
  401. </dl>
  402. <p>See <a href="Thread-Stops.html#Thread-Stops">Stopping and Starting Multi-thread Programs</a>, for
  403. more information about how <small>GDB</small> behaves when you stop and start
  404. programs with multiple threads.
  405. </p>
  406. <p>See <a href="Set-Watchpoints.html#Set-Watchpoints">Setting Watchpoints</a>, for information about
  407. watchpoints in programs with multiple threads.
  408. </p>
  409. <a name="set-libthread_002ddb_002dsearch_002dpath"></a><dl compact="compact">
  410. <dd><a name="index-set-libthread_002ddb_002dsearch_002dpath"></a>
  411. <a name="index-search-path-for-libthread_005fdb"></a>
  412. </dd>
  413. <dt><code>set libthread-db-search-path <span class="roman">[</span><var>path</var><span class="roman">]</span></code></dt>
  414. <dd><p>If this variable is set, <var>path</var> is a colon-separated list of
  415. directories <small>GDB</small> will use to search for <code>libthread_db</code>.
  416. If you omit <var>path</var>, &lsquo;<samp>libthread-db-search-path</samp>&rsquo; will be reset to
  417. its default value (<code>$sdir:$pdir</code> on <small>GNU</small>/Linux and Solaris systems).
  418. Internally, the default value comes from the <code>LIBTHREAD_DB_SEARCH_PATH</code>
  419. macro.
  420. </p>
  421. <p>On <small>GNU</small>/Linux and Solaris systems, <small>GDB</small> uses a &ldquo;helper&rdquo;
  422. <code>libthread_db</code> library to obtain information about threads in the
  423. inferior process. <small>GDB</small> will use &lsquo;<samp>libthread-db-search-path</samp>&rsquo;
  424. to find <code>libthread_db</code>. <small>GDB</small> also consults first if inferior
  425. specific thread debugging library loading is enabled
  426. by &lsquo;<samp>set auto-load libthread-db</samp>&rsquo; (see <a href="libthread_005fdb_002eso_002e1-file.html#libthread_005fdb_002eso_002e1-file">libthread_db.so.1 file</a>).
  427. </p>
  428. <p>A special entry &lsquo;<samp>$sdir</samp>&rsquo; for &lsquo;<samp>libthread-db-search-path</samp>&rsquo;
  429. refers to the default system directories that are
  430. normally searched for loading shared libraries. The &lsquo;<samp>$sdir</samp>&rsquo; entry
  431. is the only kind not needing to be enabled by &lsquo;<samp>set auto-load libthread-db</samp>&rsquo;
  432. (see <a href="libthread_005fdb_002eso_002e1-file.html#libthread_005fdb_002eso_002e1-file">libthread_db.so.1 file</a>).
  433. </p>
  434. <p>A special entry &lsquo;<samp>$pdir</samp>&rsquo; for &lsquo;<samp>libthread-db-search-path</samp>&rsquo;
  435. refers to the directory from which <code>libpthread</code>
  436. was loaded in the inferior process.
  437. </p>
  438. <p>For any <code>libthread_db</code> library <small>GDB</small> finds in above directories,
  439. <small>GDB</small> attempts to initialize it with the current inferior process.
  440. If this initialization fails (which could happen because of a version
  441. mismatch between <code>libthread_db</code> and <code>libpthread</code>), <small>GDB</small>
  442. will unload <code>libthread_db</code>, and continue with the next directory.
  443. If none of <code>libthread_db</code> libraries initialize successfully,
  444. <small>GDB</small> will issue a warning and thread debugging will be disabled.
  445. </p>
  446. <p>Setting <code>libthread-db-search-path</code> is currently implemented
  447. only on some platforms.
  448. </p>
  449. <a name="index-show-libthread_002ddb_002dsearch_002dpath"></a>
  450. </dd>
  451. <dt><code>show libthread-db-search-path</code></dt>
  452. <dd><p>Display current libthread_db search path.
  453. </p>
  454. <a name="index-set-debug-libthread_002ddb"></a>
  455. <a name="index-show-debug-libthread_002ddb"></a>
  456. <a name="index-debugging-libthread_005fdb"></a>
  457. </dd>
  458. <dt><code>set debug libthread-db</code></dt>
  459. <dt><code>show debug libthread-db</code></dt>
  460. <dd><p>Turns on or off display of <code>libthread_db</code>-related events.
  461. Use <code>1</code> to enable, <code>0</code> to disable.
  462. </p></dd>
  463. </dl>
  464. <hr>
  465. <div class="header">
  466. <p>
  467. Next: <a href="Forks.html#Forks" accesskey="n" rel="next">Forks</a>, Previous: <a href="Inferiors-Connections-and-Programs.html#Inferiors-Connections-and-Programs" accesskey="p" rel="prev">Inferiors Connections and Programs</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>
  468. </div>
  469. </body>
  470. </html>