Add a test sequence of iterating through a module's symbols belonging to a section.

Add the relevant utility functions to the lldbutil.py file.

llvm-svn: 140669
This commit is contained in:
Johnny Chen
2011-09-28 00:51:00 +00:00
parent fe6fd36b6c
commit a32a13d207
2 changed files with 79 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ import re
import unittest2
import lldb
from lldbtest import *
from lldbutil import symbol_iter, symbol_type_to_str
class ModuleAndSectionAPIsTestCase(TestBase):
@@ -39,12 +40,17 @@ class ModuleAndSectionAPIsTestCase(TestBase):
print "Exe module: %s" % repr(exe_module)
print "Number of sections: %d" % exe_module.GetNumSections()
INDENT = ' ' * 4
INDENT2 = INDENT * 2
for sec in exe_module.section_iter():
print sec
if sec.GetName() == "__TEXT":
print INDENT + "Number of subsections: %d" % sec.GetNumSubSections()
for subsec in sec:
print INDENT + repr(subsec)
# Now print the symbols belonging to the subsection....
for sym in symbol_iter(exe_module, subsec):
print INDENT2 + repr(sym)
print INDENT2 + "symbol type: %s" % symbol_type_to_str(sym.GetType())
if __name__ == '__main__':