summaryrefslogtreecommitdiffstats
path: root/lldb/scripts/Python/interface/SBModule.i
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2013-03-07 03:25:11 +0000
committerGreg Clayton <gclayton@apple.com>2013-03-07 03:25:11 +0000
commit66a907a6bd94e19a8a2184d4e1c70d9041345f5a (patch)
treedbba4e9b82ad69cc9e0c565c355eef3b0f3cfbae /lldb/scripts/Python/interface/SBModule.i
parent9e0da9e0702440c74f02eb6419ca315d3d6b3255 (diff)
downloadbcm5719-llvm-66a907a6bd94e19a8a2184d4e1c70d9041345f5a.tar.gz
bcm5719-llvm-66a907a6bd94e19a8a2184d4e1c70d9041345f5a.zip
Added new properties to lldb.SBModule classes:
"compile_units" returns an array of all compile units in a module as a list() of lldb.SBCompileUnit objects. "compile_unit" returns a compile unit accessor object that allows indexed access, search by full or partial path, or by regex: (lldb) script comp_unit = lldb.target.module['TextEdit'].compile_unit['Document.m'] comp_unit = lldb.target.module['TextEdit'].compile_unit['/path/to/Document.m'] comp_unit = lldb.target.module['TextEdit'].compile_unit[0] comp_unit = lldb.target.module['TextEdit'].compile_unit[1] for comp_unit in lldb.target.module['TextEdit'].compile_unit[re.compile("\.m$")] print comp_unit This helps do quick searches and scripting while debugging. llvm-svn: 176613
Diffstat (limited to 'lldb/scripts/Python/interface/SBModule.i')
-rw-r--r--lldb/scripts/Python/interface/SBModule.i64
1 files changed, 61 insertions, 3 deletions
diff --git a/lldb/scripts/Python/interface/SBModule.i b/lldb/scripts/Python/interface/SBModule.i
index d00f28b6d3e..6bdc2a0f26e 100644
--- a/lldb/scripts/Python/interface/SBModule.i
+++ b/lldb/scripts/Python/interface/SBModule.i
@@ -282,7 +282,7 @@ public:
%pythoncode %{
class symbols_access(object):
re_compile_type = type(re.compile('.'))
- '''A helper object that will lazily hand out lldb.SBModule objects for a target when supplied an index, or by full or partial path.'''
+ '''A helper object that will lazily hand out lldb.SBSymbol objects for a module when supplied an index, name, or regular expression.'''
def __init__(self, sbmodule):
self.sbmodule = sbmodule
@@ -330,6 +330,10 @@ public:
'''An accessor function that returns a symbols_access() object which allows lazy symbol access from a lldb.SBModule object.'''
return self.symbols_access (self)
+ def get_compile_units_access_object (self):
+ '''An accessor function that returns a compile_units_access() object which allows lazy compile unit access from a lldb.SBModule object.'''
+ return self.compile_units_access (self)
+
def get_symbols_array(self):
'''An accessor function that returns a list() that contains all symbols in a lldb.SBModule object.'''
symbols = []
@@ -339,7 +343,7 @@ public:
class sections_access(object):
re_compile_type = type(re.compile('.'))
- '''A helper object that will lazily hand out lldb.SBModule objects for a target when supplied an index, or by full or partial path.'''
+ '''A helper object that will lazily hand out lldb.SBSection objects for a module when supplied an index, name, or regular expression.'''
def __init__(self, sbmodule):
self.sbmodule = sbmodule
@@ -371,7 +375,47 @@ public:
else:
print "error: unsupported item type: %s" % type(key)
return None
+
+ class compile_units_access(object):
+ re_compile_type = type(re.compile('.'))
+ '''A helper object that will lazily hand out lldb.SBCompileUnit objects for a module when supplied an index, full or partial path, or regular expression.'''
+ def __init__(self, sbmodule):
+ self.sbmodule = sbmodule
+ def __len__(self):
+ if self.sbmodule:
+ return int(self.sbmodule.GetNumCompileUnits())
+ return 0
+
+ def __getitem__(self, key):
+ count = len(self)
+ if type(key) is int:
+ if key < count:
+ return self.sbmodule.GetCompileUnitAtIndex(key)
+ elif type(key) is str:
+ is_full_path = key[0] == '/'
+ for idx in range(count):
+ comp_unit = self.sbmodule.GetCompileUnitAtIndex(idx)
+ if is_full_path:
+ if comp_unit.file.fullpath == key:
+ return comp_unit
+ else:
+ if comp_unit.file.basename == key:
+ return comp_unit
+ elif isinstance(key, self.re_compile_type):
+ matches = []
+ for idx in range(count):
+ comp_unit = self.sbmodule.GetCompileUnitAtIndex(idx)
+ fullpath = comp_unit.file.fullpath
+ if fullpath:
+ re_match = key.search(fullpath)
+ if re_match:
+ matches.append(comp_unit)
+ return matches
+ else:
+ print "error: unsupported item type: %s" % type(key)
+ return None
+
def get_sections_access_object(self):
'''An accessor function that returns a sections_access() object which allows lazy section array access.'''
return self.sections_access (self)
@@ -384,6 +428,14 @@ public:
self.sections_array.append(self.GetSectionAtIndex(idx))
return self.sections_array
+ def get_compile_units_array(self):
+ '''An accessor function that returns an array object that contains all compile_units in this module object.'''
+ if not hasattr(self, 'compile_units_array'):
+ self.compile_units_array = []
+ for idx in range(self.GetNumCompileUnits()):
+ self.compile_units_array.append(self.GetCompileUnitAtIndex(idx))
+ return self.compile_units_array
+
__swig_getmethods__["symbols"] = get_symbols_array
if _newclass: symbols = property(get_symbols_array, None, doc='''A read only property that returns a list() of lldb.SBSymbol objects contained in this module.''')
@@ -392,10 +444,16 @@ public:
__swig_getmethods__["sections"] = get_sections_array
if _newclass: sections = property(get_sections_array, None, doc='''A read only property that returns a list() of lldb.SBSection objects contained in this module.''')
-
+
+ __swig_getmethods__["compile_units"] = get_compile_units_array
+ if _newclass: compile_units = property(get_compile_units_array, None, doc='''A read only property that returns a list() of lldb.SBCompileUnit objects contained in this module.''')
+
__swig_getmethods__["section"] = get_sections_access_object
if _newclass: section = property(get_sections_access_object, None, doc='''A read only property that can be used to access symbols by index ("section = module.section[0]"), name ("sections = module.section[\'main\']"), or using a regular expression ("sections = module.section[re.compile(...)]"). The return value is a single lldb.SBSection object for array access, and a list() of lldb.SBSection objects for name and regular expression access''')
+ __swig_getmethods__["compile_unit"] = get_compile_units_access_object
+ if _newclass: section = property(get_sections_access_object, None, doc='''A read only property that can be used to access compile units by index ("compile_unit = module.compile_unit[0]"), name ("compile_unit = module.compile_unit[\'main.cpp\']"), or using a regular expression ("compile_unit = module.compile_unit[re.compile(...)]"). The return value is a single lldb.SBCompileUnit object for array access or by full or partial path, and a list() of lldb.SBCompileUnit objects regular expressions.''')
+
def get_uuid(self):
return uuid.UUID (self.GetUUIDString())
OpenPOWER on IntegriCloud