[Lldb-commits] [lldb] r146164 - in /lldb/trunk: source/Expression/ASTResultSynthesizer.cpp source/Expression/IRForTarget.cpp test/lang/objc/foundation/TestObjCMethods2.py
Sean Callanan
scallanan at apple.com
Thu Dec 8 11:04:35 PST 2011
Author: spyffe
Date: Thu Dec 8 13:04:34 2011
New Revision: 146164
URL: http://llvm.org/viewvc/llvm-project?rev=146164&view=rev
Log:
Added the ability to dereference an Objective-C object
pointer to make the result of an expression. LLDB now
dumps the ivars of the Objective-C object and all of
its parents. This just required fixing a bug where we
didn't distinguish between Objective-C object pointers
and regular C-style pointers.
Also added a testcase to verify that this continues to
work.
Modified:
lldb/trunk/source/Expression/ASTResultSynthesizer.cpp
lldb/trunk/source/Expression/IRForTarget.cpp
lldb/trunk/test/lang/objc/foundation/TestObjCMethods2.py
Modified: lldb/trunk/source/Expression/ASTResultSynthesizer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ASTResultSynthesizer.cpp?rev=146164&r1=146163&r2=146164&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ASTResultSynthesizer.cpp (original)
+++ lldb/trunk/source/Expression/ASTResultSynthesizer.cpp Thu Dec 8 13:04:34 2011
@@ -331,7 +331,12 @@
else
result_ptr_id = &Ctx.Idents.get("$__lldb_expr_result_ptr");
- QualType ptr_qual_type = Ctx.getPointerType(expr_qual_type);
+ QualType ptr_qual_type;
+
+ if (isa<ObjCObjectType>(expr_qual_type))
+ ptr_qual_type = Ctx.getObjCObjectPointerType(expr_qual_type);
+ else
+ ptr_qual_type = Ctx.getPointerType(expr_qual_type);
result_decl = VarDecl::Create(Ctx,
DC,
Modified: lldb/trunk/source/Expression/IRForTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=146164&r1=146163&r2=146164&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRForTarget.cpp (original)
+++ lldb/trunk/source/Expression/IRForTarget.cpp Thu Dec 8 13:04:34 2011
@@ -631,9 +631,25 @@
{
clang::QualType pointer_qual_type = result_var->getType();
const clang::Type *pointer_type = pointer_qual_type.getTypePtr();
+
const clang::PointerType *pointer_pointertype = dyn_cast<clang::PointerType>(pointer_type);
+ const clang::ObjCObjectPointerType *pointer_objcobjpointertype = dyn_cast<clang::ObjCObjectPointerType>(pointer_type);
- if (!pointer_pointertype)
+ if (pointer_pointertype)
+ {
+ clang::QualType element_qual_type = pointer_pointertype->getPointeeType();
+
+ m_result_type = lldb_private::TypeFromParser(element_qual_type.getAsOpaquePtr(),
+ &result_decl->getASTContext());
+ }
+ else if (pointer_objcobjpointertype)
+ {
+ clang::QualType element_qual_type = clang::QualType(pointer_objcobjpointertype->getObjectType(), 0);
+
+ m_result_type = lldb_private::TypeFromParser(element_qual_type.getAsOpaquePtr(),
+ &result_decl->getASTContext());
+ }
+ else
{
if (log)
log->PutCString("Expected result to have pointer type, but it did not");
@@ -643,11 +659,6 @@
return false;
}
-
- clang::QualType element_qual_type = pointer_pointertype->getPointeeType();
-
- m_result_type = lldb_private::TypeFromParser(element_qual_type.getAsOpaquePtr(),
- &result_decl->getASTContext());
}
else
{
Modified: lldb/trunk/test/lang/objc/foundation/TestObjCMethods2.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/foundation/TestObjCMethods2.py?rev=146164&r1=146163&r2=146164&view=diff
==============================================================================
--- lldb/trunk/test/lang/objc/foundation/TestObjCMethods2.py (original)
+++ lldb/trunk/test/lang/objc/foundation/TestObjCMethods2.py Thu Dec 8 13:04:34 2011
@@ -42,6 +42,16 @@
self.buildDwarf()
self.NSString_expr()
+ def test_MyString_dump_with_dsym(self):
+ """Test dump of a known Objective-C object by dereferencing it."""
+ self.buildDsym()
+ self.MyString_dump()
+
+ def test_MyString_dump_with_dwarf(self):
+ """Test dump of a known Objective-C object by dereferencing it."""
+ self.buildDwarf()
+ self.MyString_dump()
+
def setUp(self):
# Call super's setUp().
TestBase.setUp(self)
@@ -51,7 +61,8 @@
self.lines.append(line_number('main.m', '// Expressions to test here for NSArray:'))
self.lines.append(line_number('main.m', '// Expressions to test here for NSString:'))
self.lines.append(line_number('main.m', "// Set a breakpoint on '-[MyString description]' and test expressions:"))
-
+ self.lines.append(line_number('main.m', '// Set break point at this line'))
+
def more_expr_objc(self):
"""More expression commands for objective-c."""
exe = os.path.join(os.getcwd(), "a.out")
@@ -149,6 +160,22 @@
self.expect('expression str = [NSString stringWithFormat: @"%cew", \'N\']')
self.runCmd("process continue")
+ def MyString_dump(self):
+ """Test dump of a known Objective-C object by dereferencing it."""
+ exe = os.path.join(os.getcwd(), "a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ line = self.lines[4]
+
+ self.expect("breakpoint set -f main.m -l %d" % line, BREAKPOINT_CREATED,
+ substrs = ["Breakpoint created:",
+ "file ='main.m', line = %d, locations = 1" % line])
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ self.expect("expression *my",
+ patterns = ["\(MyString\) \$.* = ", "\(MyBase\)", "\(NSObject\)", "\(Class\)"])
+ self.runCmd("process continue")
if __name__ == '__main__':
import atexit
More information about the lldb-commits
mailing list