1662548c8SAlex Langford %feature("docstring", 2662548c8SAlex Langford "Represents a thread of execution. :py:class:`SBProcess` contains SBThread(s). 3662548c8SAlex Langford 4662548c8SAlex Langford SBThreads can be referred to by their ID, which maps to the system specific thread 5662548c8SAlex Langford identifier, or by IndexID. The ID may or may not be unique depending on whether the 6662548c8SAlex Langford system reuses its thread identifiers. The IndexID is a monotonically increasing identifier 7662548c8SAlex Langford that will always uniquely reference a particular thread, and when that thread goes 8662548c8SAlex Langford away it will not be reused. 9662548c8SAlex Langford 10662548c8SAlex Langford SBThread supports frame iteration. For example (from test/python_api/ 11662548c8SAlex Langford lldbutil/iter/TestLLDBIterator.py), :: 12662548c8SAlex Langford 13662548c8SAlex Langford from lldbutil import print_stacktrace 14662548c8SAlex Langford stopped_due_to_breakpoint = False 15662548c8SAlex Langford for thread in process: 16662548c8SAlex Langford if self.TraceOn(): 17662548c8SAlex Langford print_stacktrace(thread) 18662548c8SAlex Langford ID = thread.GetThreadID() 19662548c8SAlex Langford if thread.GetStopReason() == lldb.eStopReasonBreakpoint: 20662548c8SAlex Langford stopped_due_to_breakpoint = True 21662548c8SAlex Langford for frame in thread: 22662548c8SAlex Langford self.assertTrue(frame.GetThread().GetThreadID() == ID) 23662548c8SAlex Langford if self.TraceOn(): 24662548c8SAlex Langford print frame 25662548c8SAlex Langford 26662548c8SAlex Langford self.assertTrue(stopped_due_to_breakpoint) 27662548c8SAlex Langford 28662548c8SAlex Langford See also :py:class:`SBFrame` ." 29662548c8SAlex Langford ) lldb::SBThread; 30662548c8SAlex Langford 31662548c8SAlex Langford %feature("docstring", " 32662548c8SAlex Langford Get the number of words associated with the stop reason. 33662548c8SAlex Langford See also GetStopReasonDataAtIndex()." 34662548c8SAlex Langford ) lldb::SBThread::GetStopReasonDataCount; 35662548c8SAlex Langford 36662548c8SAlex Langford %feature("docstring", " 37662548c8SAlex Langford Get information associated with a stop reason. 38662548c8SAlex Langford 39662548c8SAlex Langford Breakpoint stop reasons will have data that consists of pairs of 40662548c8SAlex Langford breakpoint IDs followed by the breakpoint location IDs (they always come 41662548c8SAlex Langford in pairs). 42662548c8SAlex Langford 43662548c8SAlex Langford Stop Reason Count Data Type 44662548c8SAlex Langford ======================== ===== ========================================= 45662548c8SAlex Langford eStopReasonNone 0 46662548c8SAlex Langford eStopReasonTrace 0 47662548c8SAlex Langford eStopReasonBreakpoint N duple: {breakpoint id, location id} 48662548c8SAlex Langford eStopReasonWatchpoint 1 watchpoint id 49662548c8SAlex Langford eStopReasonSignal 1 unix signal number 50662548c8SAlex Langford eStopReasonException N exception data 51662548c8SAlex Langford eStopReasonExec 0 52662548c8SAlex Langford eStopReasonFork 1 pid of the child process 53662548c8SAlex Langford eStopReasonVFork 1 pid of the child process 54662548c8SAlex Langford eStopReasonVForkDone 0 55662548c8SAlex Langford eStopReasonPlanComplete 0" 56662548c8SAlex Langford ) lldb::SBThread::GetStopReasonDataAtIndex; 57662548c8SAlex Langford 58*e35fb3fbSJason Molenda %feature("docstring", " 59662548c8SAlex Langford Collects a thread's stop reason extended information dictionary and prints it 60662548c8SAlex Langford into the SBStream in a JSON format. The format of this JSON dictionary depends 61662548c8SAlex Langford on the stop reason and is currently used only for instrumentation plugins." 62662548c8SAlex Langford ) lldb::SBThread::GetStopReasonExtendedInfoAsJSON; 63662548c8SAlex Langford 64*e35fb3fbSJason Molenda %feature("docstring", " 65662548c8SAlex Langford Returns a collection of historical stack traces that are significant to the 66662548c8SAlex Langford current stop reason. Used by ThreadSanitizer, where we provide various stack 67662548c8SAlex Langford traces that were involved in a data race or other type of detected issue." 68662548c8SAlex Langford ) lldb::SBThread::GetStopReasonExtendedBacktraces; 69662548c8SAlex Langford 70*e35fb3fbSJason Molenda %feature("docstring", " 71662548c8SAlex Langford Pass only an (int)length and expect to get a Python string describing the 72662548c8SAlex Langford stop reason." 73662548c8SAlex Langford ) lldb::SBThread::GetStopDescription; 74662548c8SAlex Langford 75*e35fb3fbSJason Molenda %feature("docstring", " 76662548c8SAlex Langford Returns a unique thread identifier (type lldb::tid_t, typically a 64-bit type) 77662548c8SAlex Langford for the current SBThread that will remain constant throughout the thread's 78662548c8SAlex Langford lifetime in this process and will not be reused by another thread during this 79662548c8SAlex Langford process lifetime. On Mac OS X systems, this is a system-wide unique thread 80662548c8SAlex Langford identifier; this identifier is also used by other tools like sample which helps 81662548c8SAlex Langford to associate data from those tools with lldb. See related GetIndexID." 82662548c8SAlex Langford ) lldb::SBThread::GetThreadID; 83662548c8SAlex Langford 84*e35fb3fbSJason Molenda %feature("docstring", " 85662548c8SAlex Langford Return the index number for this SBThread. The index number is the same thing 86662548c8SAlex Langford that a user gives as an argument to 'thread select' in the command line lldb. 87662548c8SAlex Langford These numbers start at 1 (for the first thread lldb sees in a debug session) 88662548c8SAlex Langford and increments up throughout the process lifetime. An index number will not be 89662548c8SAlex Langford reused for a different thread later in a process - thread 1 will always be 90662548c8SAlex Langford associated with the same thread. See related GetThreadID. 91662548c8SAlex Langford This method returns a uint32_t index number, takes no arguments." 92662548c8SAlex Langford ) lldb::SBThread::GetIndexID; 93662548c8SAlex Langford 94*e35fb3fbSJason Molenda %feature("docstring", " 95662548c8SAlex Langford Return the queue name associated with this thread, if any, as a str. 96662548c8SAlex Langford For example, with a libdispatch (aka Grand Central Dispatch) queue." 97662548c8SAlex Langford ) lldb::SBThread::GetQueueName; 98662548c8SAlex Langford 99*e35fb3fbSJason Molenda %feature("docstring", " 100662548c8SAlex Langford Return the dispatch_queue_id for this thread, if any, as a lldb::queue_id_t. 101662548c8SAlex Langford For example, with a libdispatch (aka Grand Central Dispatch) queue." 102662548c8SAlex Langford ) lldb::SBThread::GetQueueID; 103662548c8SAlex Langford 104662548c8SAlex Langford %feature("docstring", " 105662548c8SAlex Langford Takes a path string and a SBStream reference as parameters, returns a bool. 106662548c8SAlex Langford Collects the thread's 'info' dictionary from the remote system, uses the path 107662548c8SAlex Langford argument to descend into the dictionary to an item of interest, and prints 108662548c8SAlex Langford it into the SBStream in a natural format. Return bool is to indicate if 109662548c8SAlex Langford anything was printed into the stream (true) or not (false)." 110662548c8SAlex Langford ) lldb::SBThread::GetInfoItemByPathAsString; 111662548c8SAlex Langford 112*e35fb3fbSJason Molenda %feature("docstring", " 113662548c8SAlex Langford Return the SBQueue for this thread. If this thread is not currently associated 114662548c8SAlex Langford with a libdispatch queue, the SBQueue object's IsValid() method will return false. 115662548c8SAlex Langford If this SBThread is actually a HistoryThread, we may be able to provide QueueID 116662548c8SAlex Langford and QueueName, but not provide an SBQueue. Those individual attributes may have 117662548c8SAlex Langford been saved for the HistoryThread without enough information to reconstitute the 118662548c8SAlex Langford entire SBQueue at that time. 119662548c8SAlex Langford This method takes no arguments, returns an SBQueue." 120662548c8SAlex Langford ) lldb::SBThread::GetQueue; 121662548c8SAlex Langford 122662548c8SAlex Langford %feature("docstring", 123662548c8SAlex Langford "Do a source level single step over in the currently selected thread." 124662548c8SAlex Langford ) lldb::SBThread::StepOver; 125662548c8SAlex Langford 126662548c8SAlex Langford %feature("docstring", " 127662548c8SAlex Langford Step the current thread from the current source line to the line given by end_line, stopping if 128662548c8SAlex Langford the thread steps into the function given by target_name. If target_name is None, then stepping will stop 129662548c8SAlex Langford in any of the places we would normally stop." 130662548c8SAlex Langford ) lldb::SBThread::StepInto; 131662548c8SAlex Langford 132662548c8SAlex Langford %feature("docstring", 133662548c8SAlex Langford "Step out of the currently selected thread." 134662548c8SAlex Langford ) lldb::SBThread::StepOut; 135662548c8SAlex Langford 136662548c8SAlex Langford %feature("docstring", 137662548c8SAlex Langford "Step out of the specified frame." 138662548c8SAlex Langford ) lldb::SBThread::StepOutOfFrame; 139662548c8SAlex Langford 140662548c8SAlex Langford %feature("docstring", 141662548c8SAlex Langford "Do an instruction level single step in the currently selected thread." 142662548c8SAlex Langford ) lldb::SBThread::StepInstruction; 143662548c8SAlex Langford 144*e35fb3fbSJason Molenda %feature("docstring", " 145662548c8SAlex Langford Force a return from the frame passed in (and any frames younger than it) 146662548c8SAlex Langford without executing any more code in those frames. If return_value contains 147662548c8SAlex Langford a valid SBValue, that will be set as the return value from frame. Note, at 148662548c8SAlex Langford present only scalar return values are supported." 149662548c8SAlex Langford ) lldb::SBThread::ReturnFromFrame; 150662548c8SAlex Langford 151*e35fb3fbSJason Molenda %feature("docstring", " 152662548c8SAlex Langford Unwind the stack frames from the innermost expression evaluation. 153662548c8SAlex Langford This API is equivalent to 'thread return -x'." 154662548c8SAlex Langford ) lldb::SBThread::UnwindInnermostExpression; 155662548c8SAlex Langford 156662548c8SAlex Langford %feature("docstring", " 157662548c8SAlex Langford LLDB currently supports process centric debugging which means when any 158662548c8SAlex Langford thread in a process stops, all other threads are stopped. The Suspend() 159662548c8SAlex Langford call here tells our process to suspend a thread and not let it run when 160662548c8SAlex Langford the other threads in a process are allowed to run. So when 161662548c8SAlex Langford SBProcess::Continue() is called, any threads that aren't suspended will 162662548c8SAlex Langford be allowed to run. If any of the SBThread functions for stepping are 163662548c8SAlex Langford called (StepOver, StepInto, StepOut, StepInstruction, RunToAddres), the 164662548c8SAlex Langford thread will now be allowed to run and these functions will simply return. 165662548c8SAlex Langford 166662548c8SAlex Langford Eventually we plan to add support for thread centric debugging where 167662548c8SAlex Langford each thread is controlled individually and each thread would broadcast 168662548c8SAlex Langford its state, but we haven't implemented this yet. 169662548c8SAlex Langford 170662548c8SAlex Langford Likewise the SBThread::Resume() call will again allow the thread to run 171662548c8SAlex Langford when the process is continued. 172662548c8SAlex Langford 173662548c8SAlex Langford Suspend() and Resume() functions are not currently reference counted, if 174662548c8SAlex Langford anyone has the need for them to be reference counted, please let us 175662548c8SAlex Langford know." 176662548c8SAlex Langford ) lldb::SBThread::Suspend; 177662548c8SAlex Langford 178662548c8SAlex Langford %feature("docstring", " 179662548c8SAlex Langford Get the description strings for this thread that match what the 180662548c8SAlex Langford lldb driver will present, using the thread-format (stop_format==false) 181662548c8SAlex Langford or thread-stop-format (stop_format = true)." 182662548c8SAlex Langford ) lldb::SBThread::GetDescription; 183662548c8SAlex Langford 184*e35fb3fbSJason Molenda %feature("docstring"," 185662548c8SAlex Langford Given an argument of str to specify the type of thread-origin extended 186662548c8SAlex Langford backtrace to retrieve, query whether the origin of this thread is 187662548c8SAlex Langford available. An SBThread is retured; SBThread.IsValid will return true 188662548c8SAlex Langford if an extended backtrace was available. The returned SBThread is not 189662548c8SAlex Langford a part of the SBProcess' thread list and it cannot be manipulated like 190662548c8SAlex Langford normal threads -- you cannot step or resume it, for instance -- it is 191662548c8SAlex Langford intended to used primarily for generating a backtrace. You may request 192662548c8SAlex Langford the returned thread's own thread origin in turn." 193662548c8SAlex Langford ) lldb::SBThread::GetExtendedBacktraceThread; 194662548c8SAlex Langford 195*e35fb3fbSJason Molenda %feature("docstring"," 196662548c8SAlex Langford If this SBThread is an ExtendedBacktrace thread, get the IndexID of the 197662548c8SAlex Langford original thread that this ExtendedBacktrace thread represents, if 198662548c8SAlex Langford available. The thread that was running this backtrace in the past may 199662548c8SAlex Langford not have been registered with lldb's thread index (if it was created, 200662548c8SAlex Langford did its work, and was destroyed without lldb ever stopping execution). 201662548c8SAlex Langford In that case, this ExtendedBacktrace thread's IndexID will be returned." 202662548c8SAlex Langford ) lldb::SBThread::GetExtendedBacktraceOriginatingIndexID; 203662548c8SAlex Langford 204*e35fb3fbSJason Molenda %feature("docstring"," 205662548c8SAlex Langford Returns an SBValue object represeting the current exception for the thread, 206662548c8SAlex Langford if there is any. Currently, this works for Obj-C code and returns an SBValue 207662548c8SAlex Langford representing the NSException object at the throw site or that's currently 208662548c8SAlex Langford being processes." 209662548c8SAlex Langford ) lldb::SBThread::GetCurrentException; 210662548c8SAlex Langford 211*e35fb3fbSJason Molenda %feature("docstring"," 212662548c8SAlex Langford Returns a historical (fake) SBThread representing the stack trace of an 213662548c8SAlex Langford exception, if there is one for the thread. Currently, this works for Obj-C 214662548c8SAlex Langford code, and can retrieve the throw-site backtrace of an NSException object 215662548c8SAlex Langford even when the program is no longer at the throw site." 216662548c8SAlex Langford ) lldb::SBThread::GetCurrentExceptionBacktrace; 217662548c8SAlex Langford 218*e35fb3fbSJason Molenda %feature("docstring"," 219662548c8SAlex Langford lldb may be able to detect that function calls should not be executed 220662548c8SAlex Langford on a given thread at a particular point in time. It is recommended that 221662548c8SAlex Langford this is checked before performing an inferior function call on a given 222662548c8SAlex Langford thread." 223662548c8SAlex Langford ) lldb::SBThread::SafeToCallFunctions; 224662548c8SAlex Langford 225*e35fb3fbSJason Molenda %feature("docstring"," 226*e35fb3fbSJason Molenda Returns a SBValue object representing the siginfo for the current signal. 227662548c8SAlex Langford " 228662548c8SAlex Langford ) lldb::SBThread::GetSiginfo; 229