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]
 
__setattr__(self, name, value)
x.__setattr__('name', value) <==> x.name = value
source code
 
__getattr__(self, name) source code
 
__repr__(self)
repr(x)
source code
 
__iter__(self) source code
 
__len__(self) source code
 
__init__(self, *args)
__init__(lldb::SBThread self) -> SBThread __init__(lldb::SBThread self, SBThread thread) -> SBThread
source code
 
__swig_destroy__(...)
delete_SBThread(SBThread self)
 
__del__(self) source code
 
__nonzero__(self) source code
 
IsValid(self)
IsValid(SBThread self) -> bool
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
 
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)
GetThreadID(SBThread self) -> lldb::tid_t
source code
 
GetIndexID(self)
GetIndexID(SBThread self) -> uint32_t
source code
 
GetName(self)
GetName(SBThread self) -> str const *
source code
 
GetQueueName(self)
GetQueueName(SBThread self) -> str const *
source code
 
StepOver(self, *args)
StepOver(SBThread self, lldb::RunMode stop_other_threads=eOnlyDuringStepping) StepOver(SBThread self)
source code
 
StepInto(self, *args)
StepInto(SBThread self, lldb::RunMode stop_other_threads=eOnlyDuringStepping) StepInto(SBThread self) StepInto(SBThread self, str const * target_name, lldb::RunMode stop_other_threads=eOnlyDuringStepping) StepInto(SBThread self, str const * target_name)
source code
 
StepOut(self)
StepOut(SBThread self)
source code
 
StepOutOfFrame(self, *args)
StepOutOfFrame(SBThread self, SBFrame frame)
source code
 
StepInstruction(self, *args)
StepInstruction(SBThread self, bool step_over)
source code
 
StepOverUntil(self, *args)
StepOverUntil(SBThread self, SBFrame frame, SBFileSpec file_spec, uint32_t line) -> SBError
source code
 
RunToAddress(self, *args)
RunToAddress(SBThread self, lldb::addr_t addr)
source code
 
ReturnFromFrame(self, *args)
ReturnFromFrame(SBThread self, SBFrame frame, SBValue return_value) -> SBError
source code
 
Suspend(self)
Suspend(SBThread self) -> bool
source code
 
Resume(self)
Resume(SBThread self) -> 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
source code
 
GetStatus(self, *args)
GetStatus(SBThread self, SBStream status) -> bool
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

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __sizeof__, __subclasshook__

Static Methods [hide private]
 
EventIsThreadEvent(*args)
EventIsThreadEvent(SBEvent event) -> bool
source code
 
GetStackFrameFromEvent(*args)
GetStackFrameFromEvent(SBEvent event) -> SBFrame
source code
 
GetThreadFromEvent(*args)
GetThreadFromEvent(SBEvent event) -> SBThread
source code
Class Variables [hide private]
  __swig_setmethods__ = {}
  __swig_getmethods__ = {}
Properties [hide private]
  frame
A read only property that returns an object that can be used to access frames as an array ("frame_12 = lldb.thread.frame[12]").
  frames
A read only property that returns a list() of lldb.SBFrame objects for all frames in this thread.
  id
A read only property that returns the thread ID as an integer.
  idx
A read only property that returns the thread index ID as an integer.
  is_stopped
A read only property that returns a boolean value that indicates if this thread is stopped but not exited.
  is_suspended
A read only property that returns a boolean value that indicates if this thread is suspended.
  name
A read only property that returns the name of this thread as a string.
  num_frames
A read only property that returns the number of stack frames in this thread as an integer.
  process
A read only property that returns an lldb object that represents the process (lldb.SBProcess) that owns this thread.
  queue
A read only property that returns the dispatch queue name of this thread as a string.
  return_value
A read only property that returns an lldb object that represents the return value from the last stop (lldb.SBValue) if we just stopped due to stepping out of a function.
  stop_reason
A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eStopReason") that represents the reason this thread stopped.

Inherited from object: __class__

Method Details [hide private]

__setattr__(self, name, value)

source code 

x.__setattr__('name', value) <==> x.name = value

Overrides: object.__setattr__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

__init__(self, *args)
(Constructor)

source code 

__init__(lldb::SBThread self) -> SBThread __init__(lldb::SBThread self, SBThread thread) -> SBThread

Overrides: object.__init__

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

Suspend(self)

source code 

Suspend(SBThread self) -> 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 funtions 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.

__str__(self)
(Informal representation operator)

source code 

__str__(SBThread self) -> PyObject *

Overrides: object.__str__

Property Details [hide private]

frame

A read only property that returns an object that can be used to access frames as an array ("frame_12 = lldb.thread.frame[12]").

Get Method:
get_frames_access_object(self) - An accessor function that returns a frames_access() object which allows lazy frame access from a lldb.SBThread object.

frames

A read only property that returns a list() of lldb.SBFrame objects for all frames in this thread.

Get Method:
get_thread_frames(self) - An accessor function that returns a list() that contains all frames in a lldb.SBThread object.

id

A read only property that returns the thread ID as an integer.

Get Method:
GetThreadID(self) - GetThreadID(SBThread self) -> lldb::tid_t

idx

A read only property that returns the thread index ID as an integer. Thread index ID values start at 1 and increment as threads come and go and can be used to uniquely identify threads.

Get Method:
GetIndexID(self) - GetIndexID(SBThread self) -> uint32_t

is_stopped

A read only property that returns a boolean value that indicates if this thread is stopped but not exited.

Get Method:
IsStopped(self) - IsStopped(SBThread self) -> bool

is_suspended

A read only property that returns a boolean value that indicates if this thread is suspended.

Get Method:
IsSuspended(self) - IsSuspended(SBThread self) -> bool

name

A read only property that returns the name of this thread as a string.

Get Method:
GetName(self) - GetName(SBThread self) -> str const *

num_frames

A read only property that returns the number of stack frames in this thread as an integer.

Get Method:
GetNumFrames(self) - GetNumFrames(SBThread self) -> uint32_t

process

A read only property that returns an lldb object that represents the process (lldb.SBProcess) that owns this thread.

Get Method:
GetProcess(self) - GetProcess(SBThread self) -> SBProcess

queue

A read only property that returns the dispatch queue name of this thread as a string.

Get Method:
GetQueueName(self) - GetQueueName(SBThread self) -> str const *

return_value

A read only property that returns an lldb object that represents the return value from the last stop (lldb.SBValue) if we just stopped due to stepping out of a function.

Get Method:
GetStopReturnValue(self) - GetStopReturnValue(SBThread self) -> SBValue

stop_reason

A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eStopReason") that represents the reason this thread stopped.

Get Method:
GetStopReason(self) - GetStopReason(SBThread self) -> lldb::StopReason