1*06c3fb27SDimitry Andric STRING_EXTENSION_OUTSIDE(SBThread) 2*06c3fb27SDimitry Andric 3*06c3fb27SDimitry Andric %extend lldb::SBThread { 4*06c3fb27SDimitry Andric #ifdef SWIGPYTHON 5*06c3fb27SDimitry Andric %pythoncode %{ 6*06c3fb27SDimitry Andric def __iter__(self): 7*06c3fb27SDimitry Andric '''Iterate over all frames in a lldb.SBThread object.''' 8*06c3fb27SDimitry Andric return lldb_iter(self, 'GetNumFrames', 'GetFrameAtIndex') 9*06c3fb27SDimitry Andric 10*06c3fb27SDimitry Andric def __len__(self): 11*06c3fb27SDimitry Andric '''Return the number of frames in a lldb.SBThread object.''' 12*06c3fb27SDimitry Andric return self.GetNumFrames() 13*06c3fb27SDimitry Andric 14*06c3fb27SDimitry Andric class frames_access(object): 15*06c3fb27SDimitry Andric '''A helper object that will lazily hand out frames for a thread when supplied an index.''' 16*06c3fb27SDimitry Andric def __init__(self, sbthread): 17*06c3fb27SDimitry Andric self.sbthread = sbthread 18*06c3fb27SDimitry Andric 19*06c3fb27SDimitry Andric def __len__(self): 20*06c3fb27SDimitry Andric if self.sbthread: 21*06c3fb27SDimitry Andric return int(self.sbthread.GetNumFrames()) 22*06c3fb27SDimitry Andric return 0 23*06c3fb27SDimitry Andric 24*06c3fb27SDimitry Andric def __getitem__(self, key): 25*06c3fb27SDimitry Andric if isinstance(key, int): 26*06c3fb27SDimitry Andric count = len(self) 27*06c3fb27SDimitry Andric if -count <= key < count: 28*06c3fb27SDimitry Andric key %= count 29*06c3fb27SDimitry Andric return self.sbthread.GetFrameAtIndex(key) 30*06c3fb27SDimitry Andric return None 31*06c3fb27SDimitry Andric 32*06c3fb27SDimitry Andric def get_frames_access_object(self): 33*06c3fb27SDimitry Andric '''An accessor function that returns a frames_access() object which allows lazy frame access from a lldb.SBThread object.''' 34*06c3fb27SDimitry Andric return self.frames_access (self) 35*06c3fb27SDimitry Andric 36*06c3fb27SDimitry Andric def get_thread_frames(self): 37*06c3fb27SDimitry Andric '''An accessor function that returns a list() that contains all frames in a lldb.SBThread object.''' 38*06c3fb27SDimitry Andric frames = [] 39*06c3fb27SDimitry Andric for frame in self: 40*06c3fb27SDimitry Andric frames.append(frame) 41*06c3fb27SDimitry Andric return frames 42*06c3fb27SDimitry Andric 43*06c3fb27SDimitry Andric id = property(GetThreadID, None, doc='''A read only property that returns the thread ID as an integer.''') 44*06c3fb27SDimitry Andric idx = property(GetIndexID, None, doc='''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.''') 45*06c3fb27SDimitry Andric return_value = property(GetStopReturnValue, None, doc='''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.''') 46*06c3fb27SDimitry Andric process = property(GetProcess, None, doc='''A read only property that returns an lldb object that represents the process (lldb.SBProcess) that owns this thread.''') 47*06c3fb27SDimitry Andric num_frames = property(GetNumFrames, None, doc='''A read only property that returns the number of stack frames in this thread as an integer.''') 48*06c3fb27SDimitry Andric frames = property(get_thread_frames, None, doc='''A read only property that returns a list() of lldb.SBFrame objects for all frames in this thread.''') 49*06c3fb27SDimitry Andric frame = property(get_frames_access_object, None, doc='''A read only property that returns an object that can be used to access frames as an array ("frame_12 = lldb.thread.frame[12]").''') 50*06c3fb27SDimitry Andric name = property(GetName, None, doc='''A read only property that returns the name of this thread as a string.''') 51*06c3fb27SDimitry Andric queue = property(GetQueueName, None, doc='''A read only property that returns the dispatch queue name of this thread as a string.''') 52*06c3fb27SDimitry Andric queue_id = property(GetQueueID, None, doc='''A read only property that returns the dispatch queue id of this thread as an integer.''') 53*06c3fb27SDimitry Andric stop_reason = property(GetStopReason, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eStopReason") that represents the reason this thread stopped.''') 54*06c3fb27SDimitry Andric is_suspended = property(IsSuspended, None, doc='''A read only property that returns a boolean value that indicates if this thread is suspended.''') 55*06c3fb27SDimitry Andric is_stopped = property(IsStopped, None, doc='''A read only property that returns a boolean value that indicates if this thread is stopped but not exited.''') 56*06c3fb27SDimitry Andric %} 57*06c3fb27SDimitry Andric #endif 58*06c3fb27SDimitry Andric } 59