[Lldb-commits] [lldb] r121271 - /lldb/trunk/test/lldbutil.py
Johnny Chen
johnny.chen at apple.com
Wed Dec 8 11:19:08 PST 2010
Author: johnny
Date: Wed Dec 8 13:19:08 2010
New Revision: 121271
URL: http://llvm.org/viewvc/llvm-project?rev=121271&view=rev
Log:
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()
...
Modified:
lldb/trunk/test/lldbutil.py
Modified: lldb/trunk/test/lldbutil.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=121271&r1=121270&r2=121271&view=diff
==============================================================================
--- lldb/trunk/test/lldbutil.py (original)
+++ lldb/trunk/test/lldbutil.py Wed Dec 8 13:19:08 2010
@@ -11,19 +11,29 @@
# ===========================================
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)
More information about the lldb-commits
mailing list