Improved "objc_refs" a bit to be able to find all instances of a class'
superclasses on top of finding the exact class. The current attempt is still
too slow, but it lays the groundwork.
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@163135 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/examples/darwin/heap_find/heap.py b/examples/darwin/heap_find/heap.py
index 3a04846..170dcc0 100644
--- a/examples/darwin/heap_find/heap.py
+++ b/examples/darwin/heap_find/heap.py
@@ -249,14 +249,17 @@
description += ', ivar = %s' % (member_path)
if print_entry:
match_idx += 1
+ result_output = ''
if description:
- result.AppendMessage(description)
+ result_output += description
if options.print_type and derefed_dynamic_value:
- result.AppendMessage('%s' % (derefed_dynamic_value))
+ result_output += '%s' % (derefed_dynamic_value)
if options.print_object_description and dynamic_value:
desc = dynamic_value.GetObjectDescription()
if desc:
- result.AppendMessage(', po=%s' % (desc))
+ result_output += ', po=%s' % (desc)
+ if result_output:
+ result.AppendMessage(result_output)
if options.memory:
cmd_result = lldb.SBCommandReturnObject()
memory_command = "memory read -f %s 0x%x 0x%x" % (options.format, malloc_addr, malloc_addr + malloc_size)
@@ -270,7 +273,7 @@
elif print_no_matches:
result.AppendMessage('no matches found for %s' % (arg_str_description))
else:
- result.AppendMessage(expr_sbvalue.error )
+ result.AppendMessage(str(expr_sbvalue.error))
return 0
def heap_search(result, options, arg_str):
@@ -286,7 +289,8 @@
if options.format == None:
options.format = "A" # 'A' is "address" format
elif options.type == 'isa':
- expr = 'find_pointer_in_heap((void *)%s)' % (arg_str)
+ expr = 'find_objc_objects_in_memory ((void *)%s)' % (arg_str)
+ #result.AppendMessage ('expr -u0 -- %s' % expr) # REMOVE THIS LINE
arg_str_description = 'objective C classes with isa %s' % arg_str
options.offset = 0
if options.format == None:
@@ -473,7 +477,9 @@
else:
result.AppendMessage('error: expression error for "%s": %s' % (addr_expr_str, expr_sbvalue.error))
else:
- result.AppendMessage('error: no address expressions were specified')
+ # Find all objective C objects by not specifying an isa
+ options.type = 'isa'
+ heap_search (result, options, '0x0')
if __name__ == '__main__':
lldb.debugger = lldb.SBDebugger.Create()