您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

182 行
8.5KB

  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 In Python (Debugging with GDB)</title>
  17. <meta name="description" content="Threads In Python (Debugging with GDB)">
  18. <meta name="keywords" content="Threads In Python (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="Python-API.html#Python-API" rel="up" title="Python API">
  26. <link href="Recordings-In-Python.html#Recordings-In-Python" rel="next" title="Recordings In Python">
  27. <link href="Events-In-Python.html#Events-In-Python" rel="prev" title="Events In Python">
  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-In-Python"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Recordings-In-Python.html#Recordings-In-Python" accesskey="n" rel="next">Recordings In Python</a>, Previous: <a href="Events-In-Python.html#Events-In-Python" accesskey="p" rel="prev">Events In Python</a>, Up: <a href="Python-API.html#Python-API" accesskey="u" rel="up">Python API</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="Threads-In-Python-1"></a>
  64. <h4 class="subsubsection">23.2.2.18 Threads In Python</h4>
  65. <a name="index-threads-in-python"></a>
  66. <a name="index-gdb_002eInferiorThread"></a>
  67. <p>Python scripts can access information about, and manipulate inferior threads
  68. controlled by <small>GDB</small>, via objects of the <code>gdb.InferiorThread</code> class.
  69. </p>
  70. <p>The following thread-related functions are available in the <code>gdb</code>
  71. module:
  72. </p>
  73. <a name="index-gdb_002eselected_005fthread"></a>
  74. <dl>
  75. <dt><a name="index-gdb_002eselected_005fthread-1"></a>Function: <strong>gdb.selected_thread</strong> <em>()</em></dt>
  76. <dd><p>This function returns the thread object for the selected thread. If there
  77. is no selected thread, this will return <code>None</code>.
  78. </p></dd></dl>
  79. <p>To get the list of threads for an inferior, use the <code>Inferior.threads()</code>
  80. method. See <a href="Inferiors-In-Python.html#Inferiors-In-Python">Inferiors In Python</a>.
  81. </p>
  82. <p>A <code>gdb.InferiorThread</code> object has the following attributes:
  83. </p>
  84. <dl>
  85. <dt><a name="index-InferiorThread_002ename"></a>Variable: <strong>InferiorThread.name</strong></dt>
  86. <dd><p>The name of the thread. If the user specified a name using
  87. <code>thread name</code>, then this returns that name. Otherwise, if an
  88. OS-supplied name is available, then it is returned. Otherwise, this
  89. returns <code>None</code>.
  90. </p>
  91. <p>This attribute can be assigned to. The new value must be a string
  92. object, which sets the new name, or <code>None</code>, which removes any
  93. user-specified thread name.
  94. </p></dd></dl>
  95. <dl>
  96. <dt><a name="index-InferiorThread_002enum"></a>Variable: <strong>InferiorThread.num</strong></dt>
  97. <dd><p>The per-inferior number of the thread, as assigned by GDB.
  98. </p></dd></dl>
  99. <dl>
  100. <dt><a name="index-InferiorThread_002eglobal_005fnum"></a>Variable: <strong>InferiorThread.global_num</strong></dt>
  101. <dd><p>The global ID of the thread, as assigned by GDB. You can use this to
  102. make Python breakpoints thread-specific, for example
  103. (see <a href="Breakpoints-In-Python.html#python_005fbreakpoint_005fthread">The Breakpoint.thread attribute</a>).
  104. </p></dd></dl>
  105. <dl>
  106. <dt><a name="index-InferiorThread_002eptid"></a>Variable: <strong>InferiorThread.ptid</strong></dt>
  107. <dd><p>ID of the thread, as assigned by the operating system. This attribute is a
  108. tuple containing three integers. The first is the Process ID (PID); the second
  109. is the Lightweight Process ID (LWPID), and the third is the Thread ID (TID).
  110. Either the LWPID or TID may be 0, which indicates that the operating system
  111. does not use that identifier.
  112. </p></dd></dl>
  113. <dl>
  114. <dt><a name="index-InferiorThread_002einferior"></a>Variable: <strong>InferiorThread.inferior</strong></dt>
  115. <dd><p>The inferior this thread belongs to. This attribute is represented as
  116. a <code>gdb.Inferior</code> object. This attribute is not writable.
  117. </p></dd></dl>
  118. <p>A <code>gdb.InferiorThread</code> object has the following methods:
  119. </p>
  120. <dl>
  121. <dt><a name="index-InferiorThread_002eis_005fvalid"></a>Function: <strong>InferiorThread.is_valid</strong> <em>()</em></dt>
  122. <dd><p>Returns <code>True</code> if the <code>gdb.InferiorThread</code> object is valid,
  123. <code>False</code> if not. A <code>gdb.InferiorThread</code> object will become
  124. invalid if the thread exits, or the inferior that the thread belongs
  125. is deleted. All other <code>gdb.InferiorThread</code> methods will throw an
  126. exception if it is invalid at the time the method is called.
  127. </p></dd></dl>
  128. <dl>
  129. <dt><a name="index-InferiorThread_002eswitch"></a>Function: <strong>InferiorThread.switch</strong> <em>()</em></dt>
  130. <dd><p>This changes <small>GDB</small>&rsquo;s currently selected thread to the one represented
  131. by this object.
  132. </p></dd></dl>
  133. <dl>
  134. <dt><a name="index-InferiorThread_002eis_005fstopped"></a>Function: <strong>InferiorThread.is_stopped</strong> <em>()</em></dt>
  135. <dd><p>Return a Boolean indicating whether the thread is stopped.
  136. </p></dd></dl>
  137. <dl>
  138. <dt><a name="index-InferiorThread_002eis_005frunning"></a>Function: <strong>InferiorThread.is_running</strong> <em>()</em></dt>
  139. <dd><p>Return a Boolean indicating whether the thread is running.
  140. </p></dd></dl>
  141. <dl>
  142. <dt><a name="index-InferiorThread_002eis_005fexited"></a>Function: <strong>InferiorThread.is_exited</strong> <em>()</em></dt>
  143. <dd><p>Return a Boolean indicating whether the thread is exited.
  144. </p></dd></dl>
  145. <dl>
  146. <dt><a name="index-InferiorThread_002ehandle"></a>Function: <strong>InferiorThread.handle</strong> <em>()</em></dt>
  147. <dd><p>Return the thread object&rsquo;s handle, represented as a Python <code>bytes</code>
  148. object. A <code>gdb.Value</code> representation of the handle may be
  149. constructed via <code>gdb.Value(bufobj, type)</code> where <var>bufobj</var> is
  150. the Python <code>bytes</code> representation of the handle and <var>type</var> is
  151. a <code>gdb.Type</code> for the handle type.
  152. </p></dd></dl>
  153. <hr>
  154. <div class="header">
  155. <p>
  156. Next: <a href="Recordings-In-Python.html#Recordings-In-Python" accesskey="n" rel="next">Recordings In Python</a>, Previous: <a href="Events-In-Python.html#Events-In-Python" accesskey="p" rel="prev">Events In Python</a>, Up: <a href="Python-API.html#Python-API" accesskey="u" rel="up">Python API</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>
  157. </div>
  158. </body>
  159. </html>