diff options
| author | Enrico Granata <egranata@apple.com> | 2013-06-18 22:40:36 +0000 |
|---|---|---|
| committer | Enrico Granata <egranata@apple.com> | 2013-06-18 22:40:36 +0000 |
| commit | a2e7f9ab2bc4a144f094b48850ce7431ebb69b93 (patch) | |
| tree | 14096bb0e336db13465982ebd7038c3fc59571cf /lldb/test/python_api | |
| parent | 07ac471914d27ce1e6fad3ff11c683b6bd09ffad (diff) | |
| download | bcm5719-llvm-a2e7f9ab2bc4a144f094b48850ce7431ebb69b93.tar.gz bcm5719-llvm-a2e7f9ab2bc4a144f094b48850ce7431ebb69b93.zip | |
<rdar://problem/14194128>
ClangASTContext was failing to retrieve fields and base class info for ObjC variables
This checkin fixes that and adds a test case
llvm-svn: 184248
Diffstat (limited to 'lldb/test/python_api')
| -rw-r--r-- | lldb/test/python_api/objc_type/Makefile | 9 | ||||
| -rw-r--r-- | lldb/test/python_api/objc_type/TestObjCType.py | 79 | ||||
| -rw-r--r-- | lldb/test/python_api/objc_type/main.m | 52 |
3 files changed, 140 insertions, 0 deletions
diff --git a/lldb/test/python_api/objc_type/Makefile b/lldb/test/python_api/objc_type/Makefile new file mode 100644 index 00000000000..4562b048d20 --- /dev/null +++ b/lldb/test/python_api/objc_type/Makefile @@ -0,0 +1,9 @@ +LEVEL = ../../make + +OBJC_SOURCES := main.m + +CFLAGS_EXTRAS += -w + +include $(LEVEL)/Makefile.rules + +LDFLAGS += -framework Cocoa diff --git a/lldb/test/python_api/objc_type/TestObjCType.py b/lldb/test/python_api/objc_type/TestObjCType.py new file mode 100644 index 00000000000..35f83c4b15e --- /dev/null +++ b/lldb/test/python_api/objc_type/TestObjCType.py @@ -0,0 +1,79 @@ +""" +Test SBType for ObjC classes. +""" + +import os, time +import re +import unittest2 +import lldb, lldbutil +from lldbtest import * + +class ObjCSBTypeTestCase(TestBase): + + mydir = os.path.join("python_api", "objc_type") + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + @python_api_test + @dsym_test + def test_with_dsym(self): + """Test SBType for ObjC classes.""" + self.buildDsym() + self.objc_sbtype_test() + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + @python_api_test + @dwarf_test + def test_with_dwarf(self): + """Test SBType for ObjC classes.""" + self.buildDwarf() + self.objc_sbtype_test() + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + self.line = line_number("main.m", '// Break at this line') + + def objc_sbtype_test(self): + """Exercise SBType and SBTypeList API.""" + exe = os.path.join(os.getcwd(), "a.out") + + # Create a target by the debugger. + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + + # Create the breakpoint inside function 'main'. + breakpoint = target.BreakpointCreateByLocation("main.m", self.line) + self.assertTrue(breakpoint, VALID_BREAKPOINT) + + # Now launch the process, and do not stop at entry point. + process = target.LaunchSimple(None, None, os.getcwd()) + self.assertTrue(process, PROCESS_IS_VALID) + + + + # Get Frame #0. + self.assertTrue(process.GetState() == lldb.eStateStopped) + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) + self.assertTrue(thread.IsValid(), "There should be a thread stopped due to breakpoint condition") + + aBar = self.frame().FindVariable("aBar") + aBarType = aBar.GetType() + self.assertTrue(aBarType.IsValid(), "Bar should be a valid data type") + self.assertTrue(aBarType.GetName() == "Bar *", "Bar has the right name") + + self.assertTrue(aBarType.GetNumberOfDirectBaseClasses() == 1, "Bar has a superclass") + aFooType = aBarType.GetDirectBaseClassAtIndex(0) + + self.assertTrue(aFooType.IsValid(), "Foo should be a valid data type") + self.assertTrue(aFooType.GetName() == "Foo", "Foo has the right name") + + self.assertTrue(aBarType.GetNumberOfFields() == 1, "Bar has a field") + aBarField = aBarType.GetFieldAtIndex(0) + + self.assertTrue(aBarField.GetName() == "_iVar", "The field has the right name") + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() diff --git a/lldb/test/python_api/objc_type/main.m b/lldb/test/python_api/objc_type/main.m new file mode 100644 index 00000000000..f63f0c5040e --- /dev/null +++ b/lldb/test/python_api/objc_type/main.m @@ -0,0 +1,52 @@ +//===-- main.m ------------------------------------------------*- ObjC -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#import <Cocoa/Cocoa.h> + +@interface Foo: NSObject +{} +- (id) init; +@end + +@interface Bar: Foo +{ + int _iVar; +} +- (id) init; +@end + +@implementation Foo + +- (id) init +{ + self = [super init]; + return self; +} + +@end + +@implementation Bar + +- (id) init +{ + self = [super init]; + if (self) + self->_iVar = 5; + return self; +} + +@end + +int main() +{ + Bar* aBar = [Bar new]; + id nothing = [aBar noSuchSelector]; // Break at this line + return 0; +} + |

