diff options
author | Johnny Chen <johnny.chen@apple.com> | 2010-12-08 19:19:08 +0000 |
---|---|---|
committer | Johnny Chen <johnny.chen@apple.com> | 2010-12-08 19:19:08 +0000 |
commit | b340e6bb153e53ac4ecf5b48b590c516245265df (patch) | |
tree | bcb72b06ae02e6ff807392a4fec5eb9fb6dfd19e | |
parent | 174305b94e484550efcf54e6ff46396585729480 (diff) | |
download | bcm5719-llvm-b340e6bb153e53ac4ecf5b48b590c516245265df.tar.gz bcm5719-llvm-b340e6bb153e53ac4ecf5b48b590c516245265df.zip |
Add more docstring for the lldb_iter() utility function which provides a compact
way of iterating through an aggregate data structure. The added example usage
is from an actual use in test/foundation/TestSymbolTable.py:
2. Pass a container of aggregate which provides APIs to get to the size and
the element of the aggregate:
# Module is a container of symbol table
module = target.FindModule(filespec)
for symbol in lldb_iter(module, 'GetNumSymbols', 'GetSymbolAtIndex'):
name = symbol.GetName()
...
llvm-svn: 121271
-rw-r--r-- | lldb/test/lldbutil.py | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/lldb/test/lldbutil.py b/lldb/test/lldbutil.py index b4a6e40bdca..78bdc53f01a 100644 --- a/lldb/test/lldbutil.py +++ b/lldb/test/lldbutil.py @@ -11,19 +11,29 @@ import StringIO # =========================================== def lldb_iter(obj, getsize, getelem): - """ - A generator adaptor for lldb aggregate data structures. + """A generator adaptor for lldb aggregate data structures. + + API clients pass in an aggregate object or a container of it, the name of + the method to get the size of the aggregate, and the name of the method to + get the element by index. - API clients pass in the aggregate object, the name of the method to get the - size of the object, and the name of the method to get the element given an - index. + Example usages: - Example usage: + 1. Pass an aggregate as the first argument: def disassemble_instructions (insts): from lldbutil import lldb_iter for i in lldb_iter(insts, 'GetSize', 'GetInstructionAtIndex'): print i + + 2. Pass a container of aggregate which provides APIs to get to the size and + the element of the aggregate: + + # Module is a container of symbol table + module = target.FindModule(filespec) + for symbol in lldb_iter(module, 'GetNumSymbols', 'GetSymbolAtIndex'): + name = symbol.GetName() + ... """ size = getattr(obj, getsize) elem = getattr(obj, getelem) |