summaryrefslogtreecommitdiffstats
path: root/lldb/scripts/Python/interface
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2014-12-15 21:30:36 +0000
committerEnrico Granata <egranata@apple.com>2014-12-15 21:30:36 +0000
commita6a1d5a623cb1030450f015daa0ba8ec28ab37db (patch)
treeba1e768ee442f968723d00794faf6574edbc336b /lldb/scripts/Python/interface
parentacbed5e5307a23250f9cea16138c9b3b23eba751 (diff)
downloadbcm5719-llvm-a6a1d5a623cb1030450f015daa0ba8ec28ab37db.tar.gz
bcm5719-llvm-a6a1d5a623cb1030450f015daa0ba8ec28ab37db.zip
Provide a SBFrame.register/.reg helper on the Python side of SBFrame to vend a flattened view of registers
Our actual view of registers is a set of register sets, each one of which contains a subset of the actual registers This makes trivial scripting operations tedious ("I just want to read r7!") This helper allows things like: print lldb.frame.reg["r7"] Fixes rdar://19185662 llvm-svn: 224275
Diffstat (limited to 'lldb/scripts/Python/interface')
-rw-r--r--lldb/scripts/Python/interface/SBFrame.i24
1 files changed, 24 insertions, 0 deletions
diff --git a/lldb/scripts/Python/interface/SBFrame.i b/lldb/scripts/Python/interface/SBFrame.i
index b3f0a7a721a..207f282a263 100644
--- a/lldb/scripts/Python/interface/SBFrame.i
+++ b/lldb/scripts/Python/interface/SBFrame.i
@@ -276,6 +276,24 @@ public:
a value that represents the variable expression path'''
return self.GetValueForVariablePath(var_expr_path)
+ def get_registers_access(self):
+ class registers_access(object):
+ '''A helper object that exposes a flattened view of registers, masking away the notion of register sets for easy scripting.'''
+ def __init__(self, regs):
+ self.regs = regs
+
+ def __getitem__(self, key):
+ if type(key) is str:
+ for i in range(0,len(self.regs)):
+ rs = self.regs[i]
+ for j in range (0,rs.num_children):
+ reg = rs.GetChildAtIndex(j)
+ if reg.name == key: return reg
+ else:
+ return lldb.SBValue()
+
+ return registers_access(self.registers)
+
__swig_getmethods__["pc"] = GetPC
__swig_setmethods__["pc"] = SetPC
if _newclass: pc = property(GetPC, SetPC)
@@ -346,6 +364,12 @@ public:
__swig_getmethods__["regs"] = GetRegisters
if _newclass: regs = property(GetRegisters, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the CPU registers for this stack frame.''')
+ __swig_getmethods__["register"] = get_registers_access
+ if _newclass: register = property(get_registers_access, None, doc='''A read only property that returns an helper object providing a flattened indexable view of the CPU registers for this stack frame.''')
+
+ __swig_getmethods__["reg"] = get_registers_access
+ if _newclass: reg = property(get_registers_access, None, doc='''A read only property that returns an helper object providing a flattened indexable view of the CPU registers for this stack frame''')
+
%}
};
OpenPOWER on IntegriCloud