]>
git.saurik.com Git - apple/xnu.git/blob - tools/lldbmacros/core/lazytarget.py
2 """ Module to abstract lazy evaluation of lldb.SBTarget
8 class LazyTarget(object):
9 """ A common object that lazy-evaluates and caches the lldb.SBTarget
10 and lldb.SBProcess for the current interactive debugging session.
12 _debugger
= None # This holds an lldb.SBDebugger object for debugger state
13 _target
= None # This holds an lldb.SBTarget object for symbol lookup
14 _process
= None # This holds an lldb.SBProcess object for reading memory
17 def Initialize(debugger
):
18 """ Initialize the LazyTarget with an SBDebugger.
20 LazyTarget
._debugger
= debugger
21 LazyTarget
._target
= None
22 LazyTarget
._process
= None
26 """ Get an SBTarget for the most recently selected
27 target, or throw an exception.
29 if not LazyTarget
._target
is None:
30 return LazyTarget
._target
32 target
= LazyTarget
._debugger
.GetSelectedTarget()
34 raise AttributeError('No target selected')
36 if not target
.IsValid():
37 raise AttributeError('Target is not valid')
39 LazyTarget
._target
= target
44 """ Get an SBProcess for the most recently selected
45 target, or throw an exception.
48 target
= LazyTarget
.GetTarget()
49 process
= target
.process
52 raise AttributeError('Target does not have a process')
54 if not process
.IsValid():
55 raise AttributeError('Process is not valid')