Package lldb :: Class SBThread
[hide private]
[frames] | no frames]

Class SBThread

source code



Represents a thread of execution. SBProcess contains SBThread(s).

SBThreads can be referred to by their ID, which maps to the system specific thread
identifier, or by IndexID.  The ID may or may not be unique depending on whether the
system reuses its thread identifiers.  The IndexID is a monotonically increasing identifier
that will always uniquely reference a particular thread, and when that thread goes
away it will not be reused.

SBThread supports frame iteration. For example (from test/python_api/
lldbutil/iter/TestLLDBIterator.py),

        from lldbutil import print_stacktrace
        stopped_due_to_breakpoint = False
        for thread in process:
            if self.TraceOn():
                print_stacktrace(thread)
            ID = thread.GetThreadID()
            if thread.GetStopReason() == lldb.eStopReasonBreakpoint:
                stopped_due_to_breakpoint = True
            for frame in thread:
                self.assertTrue(frame.GetThread().GetThreadID() == ID)
                if self.TraceOn():
                    print frame

        self.assertTrue(stopped_due_to_breakpoint)

See also SBProcess and SBFrame.

Nested Classes [hide private]
  frames_access
A helper object that will lazily hand out frames for a thread when supplied an index.
Instance Methods [hide private]
 
__repr__(self) source code
 
__init__(self, *args)
__init__(lldb::SBThread self) -> SBThread __init__(lldb::SBThread self, SBThread thread) -> SBThread
source code
char const *
GetBroadcasterClassName() source code
 
EventIsThreadEvent(*args)
EventIsThreadEvent(SBEvent event) -> bool
source code
 
GetStackFrameFromEvent(*args)
GetStackFrameFromEvent(SBEvent event) -> SBFrame
source code
 
GetThreadFromEvent(*args)
GetThreadFromEvent(SBEvent event) -> SBThread
source code
 
IsValid(self)
IsValid(SBThread self) -> bool
source code
 
__nonzero__(self) source code
 
__bool__(self) source code
 
Clear(self)
Clear(SBThread self)
source code
 
GetStopReason(self)
GetStopReason(SBThread self) -> lldb::StopReason
source code
 
GetStopReasonDataCount(self)
GetStopReasonDataCount(SBThread self) -> size_t
source code
 
GetStopReasonDataAtIndex(self, *args)
GetStopReasonDataAtIndex(SBThread self, uint32_t idx) -> uint64_t
source code
 
GetStopReasonExtendedInfoAsJSON(self, *args)
Collects a thread's stop reason extended information dictionary and prints it into the SBStream in a JSON format.
source code
 
GetStopReasonExtendedBacktraces(self, *args)
Returns a collection of historical stack traces that are significant to the current stop reason.
source code
 
GetStopDescription(self, *args)
Pass only an (int)length and expect to get a Python string describing the stop reason.
source code
 
GetStopReturnValue(self)
GetStopReturnValue(SBThread self) -> SBValue
source code
 
GetThreadID(self)
Returns a unique thread identifier (type lldb::tid_t, typically a 64-bit type) for the current SBThread that will remain constant throughout the thread's lifetime in this process and will not be reused by another thread during this process lifetime.
source code
 
GetIndexID(self)
Return the index number for this SBThread.
source code
 
GetName(self)
GetName(SBThread self) -> char const *
source code
 
GetQueueName(self)
Return the queue name associated with this thread, if any, as a str.
source code
 
GetQueueID(self)
Return the dispatch_queue_id for this thread, if any, as a lldb::queue_id_t.
source code
 
GetInfoItemByPathAsString(self, *args)
GetInfoItemByPathAsString(SBThread self, char const * path, SBStream strm) -> bool
source code
 
GetQueue(self)
Return the SBQueue for this thread.
source code
 
StepOver(self, *args)
StepOver(SBThread self, lldb::RunMode stop_other_threads=eOnlyDuringStepping) StepOver(SBThread self) Do a source level single step over in the currently selected thread.
source code
 
StepInto(self, *args)
StepInto(SBThread self, lldb::RunMode stop_other_threads=eOnlyDuringStepping) StepInto(SBThread self) StepInto(SBThread self, char const * target_name, lldb::RunMode stop_other_threads=eOnlyDuringStepping) StepInto(SBThread self, char const * target_name)
source code
 
StepOut(self, *args)
StepOut(SBThread self) Step out of the currently selected thread.
source code
 
StepOutOfFrame(self, *args)
StepOutOfFrame(SBThread self, SBFrame frame) Step out of the specified frame.
source code
 
StepInstruction(self, *args)
StepInstruction(SBThread self, bool step_over) Do an instruction level single step in the currently selected thread.
source code
 
StepOverUntil(self, *args)
StepOverUntil(SBThread self, SBFrame frame, SBFileSpec file_spec, uint32_t line) -> SBError
source code
 
StepUsingScriptedThreadPlan(self, *args)
StepUsingScriptedThreadPlan(SBThread self, char const * script_class_name) -> SBError StepUsingScriptedThreadPlan(SBThread self, char const * script_class_name, bool resume_immediately) -> SBError
source code
 
JumpToLine(self, *args)
JumpToLine(SBThread self, SBFileSpec file_spec, uint32_t line) -> SBError
source code
 
RunToAddress(self, *args)
RunToAddress(SBThread self, lldb::addr_t addr) RunToAddress(SBThread self, lldb::addr_t addr, SBError error)
source code
 
ReturnFromFrame(self, *args)
Force a return from the frame passed in (and any frames younger than it) without executing any more code in those frames.
source code
 
UnwindInnermostExpression(self)
Unwind the stack frames from the innermost expression evaluation.
source code
 
Suspend(self, *args)
Suspend(SBThread self) -> bool Suspend(SBThread self, SBError error) -> bool
source code
 
Resume(self, *args)
Resume(SBThread self) -> bool Resume(SBThread self, SBError error) -> bool
source code
 
IsSuspended(self)
IsSuspended(SBThread self) -> bool
source code
 
IsStopped(self)
IsStopped(SBThread self) -> bool
source code
 
GetNumFrames(self)
GetNumFrames(SBThread self) -> uint32_t
source code
 
GetFrameAtIndex(self, *args)
GetFrameAtIndex(SBThread self, uint32_t idx) -> SBFrame
source code
 
GetSelectedFrame(self)
GetSelectedFrame(SBThread self) -> SBFrame
source code
 
SetSelectedFrame(self, *args)
SetSelectedFrame(SBThread self, uint32_t frame_idx) -> SBFrame
source code
 
GetProcess(self)
GetProcess(SBThread self) -> SBProcess
source code
 
GetDescription(self, *args)
GetDescription(SBThread self, SBStream description) -> bool GetDescription(SBThread self, SBStream description, bool stop_format) -> bool
source code
 
GetStatus(self, *args)
GetStatus(SBThread self, SBStream status) -> bool
source code
 
GetExtendedBacktraceThread(self, *args)
Given an argument of str to specify the type of thread-origin extended backtrace to retrieve, query whether the origin of this thread is available.
source code
 
GetExtendedBacktraceOriginatingIndexID(self)
Takes no arguments, returns a uint32_t.
source code
 
GetCurrentException(self)
Returns an SBValue object represeting the current exception for the thread, if there is any.
source code
 
GetCurrentExceptionBacktrace(self)
Returns a historical (fake) SBThread representing the stack trace of an exception, if there is one for the thread.
source code
 
SafeToCallFunctions(self)
Takes no arguments, returns a bool.
source code
 
__iter__(self)
Iterate over all frames in a lldb.SBThread object.
source code
 
__len__(self)
Return the number of frames in a lldb.SBThread object.
source code
 
get_frames_access_object(self)
An accessor function that returns a frames_access() object which allows lazy frame access from a lldb.SBThread object.
source code
 
get_thread_frames(self)
An accessor function that returns a list() that contains all frames in a lldb.SBThread object.
source code
 
__str__(self)
__str__(SBThread self) -> PyObject *
source code
 
__eq__(self, rhs) source code
 
__ne__(self, rhs) source code
Class Variables [hide private]
  __swig_setmethods__ = {}
  __setattr__ = lambda self, name, value:
  __swig_getmethods__ = {}
  __getattr__ = lambda self, name:
  eBroadcastBitStackChanged = _lldb.SBThread_eBroadcastBitStackC...
  eBroadcastBitThreadSuspended = _lldb.SBThread_eBroadcastBitThr...
  eBroadcastBitThreadResumed = _lldb.SBThread_eBroadcastBitThrea...
  eBroadcastBitSelectedFrameChanged = _lldb.SBThread_eBroadcastB...
  eBroadcastBitThreadSelected = _lldb.SBThread_eBroadcastBitThre...
  __swig_destroy__ = _lldb.delete_SBThread
  __del__ = lambda self:
Method Details [hide private]

GetStopReasonDataCount(self)

source code 

GetStopReasonDataCount(SBThread self) -> size_t

Get the number of words associated with the stop reason. See also GetStopReasonDataAtIndex().

GetStopReasonDataAtIndex(self, *args)

source code 

GetStopReasonDataAtIndex(SBThread self, uint32_t idx) -> uint64_t

Get information associated with a stop reason.

Breakpoint stop reasons will have data that consists of pairs of breakpoint IDs followed by the breakpoint location IDs (they always come in pairs).

Stop Reason Count Data Type ======================== ===== ========================================= eStopReasonNone 0 eStopReasonTrace 0 eStopReasonBreakpoint N duple: {breakpoint id, location id} eStopReasonWatchpoint 1 watchpoint id eStopReasonSignal 1 unix signal number eStopReasonException N exception data eStopReasonExec 0 eStopReasonPlanComplete 0

GetStopReasonExtendedInfoAsJSON(self, *args)

source code 

Collects a thread's stop reason extended information dictionary and prints it into the SBStream in a JSON format. The format of this JSON dictionary depends on the stop reason and is currently used only for instrumentation plugins.

GetStopReasonExtendedBacktraces(self, *args)

source code 

Returns a collection of historical stack traces that are significant to the current stop reason. Used by ThreadSanitizer, where we provide various stack traces that were involved in a data race or other type of detected issue.

GetThreadID(self)

source code 

Returns a unique thread identifier (type lldb::tid_t, typically a 64-bit type) for the current SBThread that will remain constant throughout the thread's lifetime in this process and will not be reused by another thread during this process lifetime. On Mac OS X systems, this is a system-wide unique thread identifier; this identifier is also used by other tools like sample which helps to associate data from those tools with lldb. See related GetIndexID.

GetIndexID(self)

source code 

Return the index number for this SBThread. The index number is the same thing that a user gives as an argument to 'thread select' in the command line lldb. These numbers start at 1 (for the first thread lldb sees in a debug session) and increments up throughout the process lifetime. An index number will not be reused for a different thread later in a process - thread 1 will always be associated with the same thread. See related GetThreadID. This method returns a uint32_t index number, takes no arguments.

GetQueueName(self)

source code 

Return the queue name associated with this thread, if any, as a str. For example, with a libdispatch (aka Grand Central Dispatch) queue.

GetQueueID(self)

source code 

Return the dispatch_queue_id for this thread, if any, as a lldb::queue_id_t. For example, with a libdispatch (aka Grand Central Dispatch) queue.

GetInfoItemByPathAsString(self, *args)

source code 

GetInfoItemByPathAsString(SBThread self, char const * path, SBStream strm) -> bool

Takes a path string and a SBStream reference as parameters, returns a bool. Collects the thread's 'info' dictionary from the remote system, uses the path argument to descend into the dictionary to an item of interest, and prints it into the SBStream in a natural format. Return bool is to indicate if anything was printed into the stream (true) or not (false).

GetQueue(self)

source code 

Return the SBQueue for this thread. If this thread is not currently associated with a libdispatch queue, the SBQueue object's IsValid() method will return false. If this SBThread is actually a HistoryThread, we may be able to provide QueueID and QueueName, but not provide an SBQueue. Those individual attributes may have been saved for the HistoryThread without enough information to reconstitute the entire SBQueue at that time. This method takes no arguments, returns an SBQueue.

StepInto(self, *args)

source code 

StepInto(SBThread self, lldb::RunMode stop_other_threads=eOnlyDuringStepping)
StepInto(SBThread self)
StepInto(SBThread self, char const * target_name, lldb::RunMode stop_other_threads=eOnlyDuringStepping)
StepInto(SBThread self, char const * target_name)

    Step the current thread from the current source line to the line given by end_line, stopping if
    the thread steps into the function given by target_name.  If target_name is None, then stepping will stop
    in any of the places we would normally stop.

    Step the current thread from the current source line to the line given by end_line, stopping if
    the thread steps into the function given by target_name.  If target_name is None, then stepping will stop
    in any of the places we would normally stop.

ReturnFromFrame(self, *args)

source code 

Force a return from the frame passed in (and any frames younger than it) without executing any more code in those frames. If return_value contains a valid SBValue, that will be set as the return value from frame. Note, at present only scalar return values are supported.

UnwindInnermostExpression(self)

source code 

Unwind the stack frames from the innermost expression evaluation. This API is equivalent to 'thread return -x'.

Suspend(self, *args)

source code 

Suspend(SBThread self) -> bool Suspend(SBThread self, SBError error) -> bool

LLDB currently supports process centric debugging which means when any thread in a process stops, all other threads are stopped. The Suspend() call here tells our process to suspend a thread and not let it run when the other threads in a process are allowed to run. So when SBProcess::Continue() is called, any threads that aren't suspended will be allowed to run. If any of the SBThread functions for stepping are called (StepOver, StepInto, StepOut, StepInstruction, RunToAddres), the thread will now be allowed to run and these functions will simply return.

Eventually we plan to add support for thread centric debugging where each thread is controlled individually and each thread would broadcast its state, but we haven't implemented this yet.

Likewise the SBThread::Resume() call will again allow the thread to run when the process is continued.

Suspend() and Resume() functions are not currently reference counted, if anyone has the need for them to be reference counted, please let us know.

GetDescription(self, *args)

source code 

GetDescription(SBThread self, SBStream description) -> bool GetDescription(SBThread self, SBStream description, bool stop_format) -> bool

Get the description strings for this thread that match what the lldb driver will present, using the thread-format (stop_format==false) or thread-stop-format (stop_format = true).

GetExtendedBacktraceThread(self, *args)

source code 

Given an argument of str to specify the type of thread-origin extended backtrace to retrieve, query whether the origin of this thread is available. An SBThread is retured; SBThread.IsValid will return true if an extended backtrace was available. The returned SBThread is not a part of the SBProcess' thread list and it cannot be manipulated like normal threads -- you cannot step or resume it, for instance -- it is intended to used primarily for generating a backtrace. You may request the returned thread's own thread origin in turn.

GetExtendedBacktraceOriginatingIndexID(self)

source code 

Takes no arguments, returns a uint32_t. If this SBThread is an ExtendedBacktrace thread, get the IndexID of the original thread that this ExtendedBacktrace thread represents, if available. The thread that was running this backtrace in the past may not have been registered with lldb's thread index (if it was created, did its work, and was destroyed without lldb ever stopping execution). In that case, this ExtendedBacktrace thread's IndexID will be returned.

GetCurrentException(self)

source code 

Returns an SBValue object represeting the current exception for the thread, if there is any. Currently, this works for Obj-C code and returns an SBValue representing the NSException object at the throw site or that's currently being processes.

GetCurrentExceptionBacktrace(self)

source code 

Returns a historical (fake) SBThread representing the stack trace of an exception, if there is one for the thread. Currently, this works for Obj-C code, and can retrieve the throw-site backtrace of an NSException object even when the program is no longer at the throw site.

SafeToCallFunctions(self)

source code 

Takes no arguments, returns a bool. lldb may be able to detect that function calls should not be executed on a given thread at a particular point in time. It is recommended that this is checked before performing an inferior function call on a given thread.


Class Variable Details [hide private]

eBroadcastBitStackChanged

Value:
_lldb.SBThread_eBroadcastBitStackChanged

eBroadcastBitThreadSuspended

Value:
_lldb.SBThread_eBroadcastBitThreadSuspended

eBroadcastBitThreadResumed

Value:
_lldb.SBThread_eBroadcastBitThreadResumed

eBroadcastBitSelectedFrameChanged

Value:
_lldb.SBThread_eBroadcastBitSelectedFrameChanged

eBroadcastBitThreadSelected

Value:
_lldb.SBThread_eBroadcastBitThreadSelected