1 STRING_EXTENSION_OUTSIDE
(SBProcess
)
2 %extend lldb
::SBProcess
{
5 def WriteMemoryAsCString
(self
, addr
, str
, error
):
7 WriteMemoryAsCString
(self
, addr
, str
, error
):
8 This functions the same as `WriteMemory` except a null-terminator is appended
9 to the end of the buffer if it is not there already.
11 if not str or len
(str
) == 0:
13 if not str
[-1] == '\
0'
:
15 return self.WriteMemory
(addr
, str
, error
)
17 def __get_is_alive__
(self
):
18 '''Returns
"True" if the process is currently alive
, "False" otherwise'''
20 if
(s
== eStateAttaching or
21 s
== eStateLaunching or
24 s
== eStateStepping or
26 s
== eStateSuspended
):
30 def __get_is_running__
(self
):
31 '''Returns
"True" if the process is currently running
, "False" otherwise'''
32 state
= self.GetState
()
33 if state
== eStateRunning or state
== eStateStepping
:
37 def __get_is_stopped__
(self
):
38 '''Returns
"True" if the process is currently stopped
, "False" otherwise'''
39 state
= self.GetState
()
40 if state
== eStateStopped or state
== eStateCrashed or state
== eStateSuspended
:
44 class threads_access
(object
):
45 '''A helper object that will lazily hand out thread for a process when supplied an index.'''
46 def __init__
(self
, sbprocess
):
47 self.sbprocess
= sbprocess
51 return int
(self.sbprocess.GetNumThreads
())
54 def __getitem__
(self
, key
):
55 if isinstance
(key
, int
):
57 if
-count
<= key
< count
:
59 return self.sbprocess.GetThreadAtIndex
(key
)
62 def get_threads_access_object
(self
):
63 '''An accessor function that returns a modules_access
() object which allows lazy thread access from a lldb.SBProcess object.'''
64 return self.threads_access
(self
)
66 def get_process_thread_list
(self
):
67 '''An accessor function that returns a list
() that contains all threads in a lldb.SBProcess object.'''
69 accessor
= self.get_threads_access_object
()
70 for idx in range
(len
(accessor
)):
71 threads.append
(accessor
[idx
])
75 '''Iterate over all threads in a lldb.SBProcess object.'''
76 return lldb_iter
(self
, 'GetNumThreads'
, 'GetThreadAtIndex'
)
79 '''Return the number of threads in a lldb.SBProcess object.'''
80 return self.GetNumThreads
()
83 return self.GetProcessID
()
85 threads
= property
(get_process_thread_list
, None
, doc
='''A read only property that returns a list
() of lldb.SBThread objects for this process.'''
)
86 thread
= property
(get_threads_access_object
, None
, doc
='''A read only property that returns an object that can access threads by thread index
(thread
= lldb.process.thread
[12]).'''
)
87 is_alive
= property
(__get_is_alive__
, None
, doc
='''A read only property that returns a boolean value that indicates if this process is currently alive.'''
)
88 is_running
= property
(__get_is_running__
, None
, doc
='''A read only property that returns a boolean value that indicates if this process is currently running.'''
)
89 is_stopped
= property
(__get_is_stopped__
, None
, doc
='''A read only property that returns a boolean value that indicates if this process is currently stopped.'''
)
90 id
= property
(GetProcessID
, None
, doc
='''A read only property that returns the process ID as an integer.'''
)
91 target
= property
(GetTarget
, None
, doc
='''A read only property that an lldb object that represents the target
(lldb.SBTarget
) that owns this process.'''
)
92 num_threads
= property
(GetNumThreads
, None
, doc
='''A read only property that returns the number of threads in this process as an integer.'''
)
93 selected_thread
= property
(GetSelectedThread
, SetSelectedThread
, doc
='''A read
/write property that gets
/sets the currently selected thread in this process. The getter returns a lldb.SBThread object and the setter takes an lldb.SBThread object.'''
)
94 state
= property
(GetState
, None
, doc
='''A read only property that returns an lldb enumeration value
(see enumerations that start with
"lldb.eState") that represents the current state of this process
(running
, stopped
, exited
, etc.
).'''
)
95 exit_state
= property
(GetExitStatus
, None
, doc
='''A read only property that returns an exit status as an integer of this process when the process state is lldb.eStateExited.'''
)
96 exit_description
= property
(GetExitDescription
, None
, doc
='''A read only property that returns an exit description as a string of this process when the process state is lldb.eStateExited.'''
)
97 broadcaster
= property
(GetBroadcaster
, None
, doc
='''A read only property that an lldb object that represents the broadcaster
(lldb.SBBroadcaster
) for this process.'''
)