diff options
author | dim <dim@FreeBSD.org> | 2016-01-06 20:12:03 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2016-01-06 20:12:03 +0000 |
commit | 78b9749c0a4ea980a8b934645da6ae98fcc665e8 (patch) | |
tree | dd2a1ddf0476664c2b823409c36cbccd52662ca7 /packages/Python/lldbsuite/test/lang/objc/ivar-IMP | |
parent | 60cb593f9d55fa5ca7a5372b731f2330345b4b9a (diff) | |
download | FreeBSD-src-78b9749c0a4ea980a8b934645da6ae98fcc665e8.zip FreeBSD-src-78b9749c0a4ea980a8b934645da6ae98fcc665e8.tar.gz |
Vendor import of lldb trunk r256945:
https://llvm.org/svn/llvm-project/lldb/trunk@256945
Diffstat (limited to 'packages/Python/lldbsuite/test/lang/objc/ivar-IMP')
5 files changed, 104 insertions, 0 deletions
diff --git a/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/Makefile b/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/Makefile new file mode 100644 index 0000000..329ceab --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/Makefile @@ -0,0 +1,12 @@ +LEVEL = ../../../make + +myclass.o: myclass.h myclass.m + $(CC) myclass.m -c -o myclass.o + +repro: myclass.o repro.m + $(CC) -g -O0 myclass.o repro.m -framework Foundation + +cleanup: + rm -r myclass.o + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/TestObjCiVarIMP.py b/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/TestObjCiVarIMP.py new file mode 100644 index 0000000..9ed2bb9 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/TestObjCiVarIMP.py @@ -0,0 +1,63 @@ +""" +Test that dynamically discovered ivars of type IMP do not crash LLDB +""" + +from __future__ import print_function + + + +import os, time +import re +import lldb +import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.lldbtest import * +import lldbsuite.support.seven as seven + +def execute_command (command): + # print('%% %s' % (command)) + (exit_status, output) = seven.get_command_status_output(command) + # if output: + # print(output) + # print('status = %u' % (exit_status)) + return exit_status + +class ObjCiVarIMPTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipUnlessDarwin + @no_debug_info_test + def test_imp_ivar_type(self): + """Test that dynamically discovered ivars of type IMP do not crash LLDB""" + if self.getArchitecture() == 'i386': + # rdar://problem/9946499 + self.skipTest("Dynamic types for ObjC V1 runtime not implemented") + + execute_command("make repro") + def cleanup(): + execute_command("make cleanup") + self.addTearDownHook(cleanup) + + exe = os.path.join(os.getcwd(), "a.out") + + # Create a target from the debugger. + target = self.dbg.CreateTarget (exe) + self.assertTrue(target, VALID_TARGET) + + # Set up our breakpoint + + bkpt = lldbutil.run_break_set_by_source_regexp (self, "break here") + + # Now launch the process, and do not stop at the entry point. + process = target.LaunchSimple (None, None, self.get_process_working_directory()) + + self.assertTrue(process.GetState() == lldb.eStateStopped, + PROCESS_STOPPED) + + self.expect('frame variable --ptr-depth=1 --show-types -d run -- object', substrs=[ + '(MyClass *) object = 0x', + '(void *) myImp = 0x' + ]) + self.expect('disassemble --start-address `((MyClass*)object)->myImp`', substrs=[ + '-[MyClass init]' + ]) diff --git a/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/myclass.h b/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/myclass.h new file mode 100644 index 0000000..da28d1e --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/myclass.h @@ -0,0 +1,6 @@ +#import <Foundation/Foundation.h> + +@interface MyClass : NSObject +{} +- (id)init; +@end diff --git a/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/myclass.m b/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/myclass.m new file mode 100644 index 0000000..85b2fcf --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/myclass.m @@ -0,0 +1,16 @@ +#import <Foundation/Foundation.h> +#import "myclass.h" + +@implementation MyClass +{ + IMP myImp; +} +- (id)init { + if (self = [super init]) + { + SEL theSelector = @selector(init); + self->myImp = [self methodForSelector:theSelector]; + } + return self; +} +@end diff --git a/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/repro.m b/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/repro.m new file mode 100644 index 0000000..14f911f --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/repro.m @@ -0,0 +1,7 @@ +#import <Foundation/Foundation.h> +#import "myclass.h" + +int main() { + id object = [MyClass new]; + return 0; // break here +} |