1<html lang="en"> 2<head> 3<title>Threads In Python - Debugging with GDB</title> 4<meta http-equiv="Content-Type" content="text/html"> 5<meta name="description" content="Debugging with GDB"> 6<meta name="generator" content="makeinfo 4.13"> 7<link title="Top" rel="start" href="index.html#Top"> 8<link rel="up" href="Python-API.html#Python-API" title="Python API"> 9<link rel="prev" href="Inferiors-In-Python.html#Inferiors-In-Python" title="Inferiors In Python"> 10<link rel="next" href="Commands-In-Python.html#Commands-In-Python" title="Commands In Python"> 11<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> 12<!-- 13Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 141998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 15Free Software Foundation, Inc. 16 17Permission is granted to copy, distribute and/or modify this document 18under the terms of the GNU Free Documentation License, Version 1.3 or 19any later version published by the Free Software Foundation; with the 20Invariant Sections being ``Free Software'' and ``Free Software Needs 21Free Documentation'', with the Front-Cover Texts being ``A GNU Manual,'' 22and with the Back-Cover Texts as in (a) below. 23 24(a) The FSF's Back-Cover Text is: ``You are free to copy and modify 25this GNU Manual. Buying copies from GNU Press supports the FSF in 26developing GNU and promoting software freedom.''--> 27<meta http-equiv="Content-Style-Type" content="text/css"> 28<style type="text/css"><!-- 29 pre.display { font-family:inherit } 30 pre.format { font-family:inherit } 31 pre.smalldisplay { font-family:inherit; font-size:smaller } 32 pre.smallformat { font-family:inherit; font-size:smaller } 33 pre.smallexample { font-size:smaller } 34 pre.smalllisp { font-size:smaller } 35 span.sc { font-variant:small-caps } 36 span.roman { font-family:serif; font-weight:normal; } 37 span.sansserif { font-family:sans-serif; font-weight:normal; } 38--></style> 39<link rel="stylesheet" type="text/css" href="../cs.css"> 40</head> 41<body> 42<div class="node"> 43<a name="Threads-In-Python"></a> 44<p> 45Next: <a rel="next" accesskey="n" href="Commands-In-Python.html#Commands-In-Python">Commands In Python</a>, 46Previous: <a rel="previous" accesskey="p" href="Inferiors-In-Python.html#Inferiors-In-Python">Inferiors In Python</a>, 47Up: <a rel="up" accesskey="u" href="Python-API.html#Python-API">Python API</a> 48<hr> 49</div> 50 51<h5 class="subsubsection">23.2.2.9 Threads In Python</h5> 52 53<p><a name="index-threads-in-python-1713"></a> 54<a name="index-gdb_002eInferiorThread-1714"></a>Python scripts can access information about, and manipulate inferior threads 55controlled by <span class="sc">gdb</span>, via objects of the <code>gdb.InferiorThread</code> class. 56 57 <p>The following thread-related functions are available in the <code>gdb</code> 58module: 59 60 <p><a name="index-gdb_002eselected_005fthread-1715"></a> 61 62<div class="defun"> 63— Function: <b>selected_thread</b><var><a name="index-selected_005fthread-1716"></a></var><br> 64<blockquote><p>This function returns the thread object for the selected thread. If there 65is no selected thread, this will return <code>None</code>. 66</p></blockquote></div> 67 68 <p>A <code>gdb.InferiorThread</code> object has the following attributes: 69 70 <dl> 71 72 <div class="defun"> 73— Instance Variable of InferiorThread: <b>num</b><var><a name="index-num-1717"></a></var><br> 74<blockquote> <p>ID of the thread, as assigned by GDB. 75</p></blockquote></div> 76 77 <div class="defun"> 78— Instance Variable of InferiorThread: <b>ptid</b><var><a name="index-ptid-1718"></a></var><br> 79<blockquote> <p>ID of the thread, as assigned by the operating system. This attribute is a 80tuple containing three integers. The first is the Process ID (PID); the second 81is the Lightweight Process ID (LWPID), and the third is the Thread ID (TID). 82Either the LWPID or TID may be 0, which indicates that the operating system 83does not use that identifier. 84</p></blockquote></div> 85 </dl> 86 87 <p>A <code>gdb.InferiorThread</code> object has the following methods: 88 89 <dl> 90 91 <div class="defun"> 92— Method on InferiorThread: <b>switch</b><var><a name="index-switch-on-InferiorThread-1719"></a></var><br> 93<blockquote> <p>This changes <span class="sc">gdb</span>'s currently selected thread to the one represented 94by this object. 95</p></blockquote></div> 96 97 <div class="defun"> 98— Method on InferiorThread: <b>is_stopped</b><var><a name="index-is_005fstopped-on-InferiorThread-1720"></a></var><br> 99<blockquote> <p>Return a Boolean indicating whether the thread is stopped. 100</p></blockquote></div> 101 102 <div class="defun"> 103— Method on InferiorThread: <b>is_running</b><var><a name="index-is_005frunning-on-InferiorThread-1721"></a></var><br> 104<blockquote> <p>Return a Boolean indicating whether the thread is running. 105</p></blockquote></div> 106 107 <div class="defun"> 108— Method on InferiorThread: <b>is_exited</b><var><a name="index-is_005fexited-on-InferiorThread-1722"></a></var><br> 109<blockquote> <p>Return a Boolean indicating whether the thread is exited. 110</p></blockquote></div> 111 </dl> 112 113 </body></html> 114 115