Author: Raphael Isemann Date: 2020-03-17T12:49:48+01:00 New Revision: f5e0f8b10ab95e94b5ffb32e380f95d21415c3e8
URL: https://github.com/llvm/llvm-project/commit/f5e0f8b10ab95e94b5ffb32e380f95d21415c3e8 DIFF: https://github.com/llvm/llvm-project/commit/f5e0f8b10ab95e94b5ffb32e380f95d21415c3e8.diff LOG: [lldb] Add test for importing ObjC modules in a non-ObjC target This was previously crashing due to a missing nullptr check (see e2d8aa6bf774ef29e134c40f886c55557bb5f970 ). This just adds a test that should make sure this doesn't crash in case a user ends up in this strange setup. Added: lldb/test/API/lang/objc/modules-non-objc-target/Makefile lldb/test/API/lang/objc/modules-non-objc-target/TestObjCModulesNonObjCTarget.py lldb/test/API/lang/objc/modules-non-objc-target/main.c Modified: Removed: ################################################################################ diff --git a/lldb/test/API/lang/objc/modules-non-objc-target/Makefile b/lldb/test/API/lang/objc/modules-non-objc-target/Makefile new file mode 100644 index 000000000000..10495940055b --- /dev/null +++ b/lldb/test/API/lang/objc/modules-non-objc-target/Makefile @@ -0,0 +1,3 @@ +C_SOURCES := main.c + +include Makefile.rules diff --git a/lldb/test/API/lang/objc/modules-non-objc-target/TestObjCModulesNonObjCTarget.py b/lldb/test/API/lang/objc/modules-non-objc-target/TestObjCModulesNonObjCTarget.py new file mode 100644 index 000000000000..18283f6d2b33 --- /dev/null +++ b/lldb/test/API/lang/objc/modules-non-objc-target/TestObjCModulesNonObjCTarget.py @@ -0,0 +1,26 @@ +""" +Tests that importing ObjC modules in a non-ObjC target doesn't crash LLDB. +""" + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipUnlessDarwin + def test(self): + self.build() + lldbutil.run_to_source_breakpoint(self,"// break here", lldb.SBFileSpec("main.c")) + + # Import foundation to get some ObjC types. + self.expect("expr --lang objc -- @import Foundation") + # Do something with NSString (which requires special handling when + # preparing to run in the target). The expression most likely can't + # be prepared to run in the target but it should at least not crash LLDB. + self.expect('expr --lang objc -- [NSString stringWithFormat:@"%d", 1];', + error=True, + substrs=["error: The expression could not be prepared to run in the target"]) diff --git a/lldb/test/API/lang/objc/modules-non-objc-target/main.c b/lldb/test/API/lang/objc/modules-non-objc-target/main.c new file mode 100644 index 000000000000..ba45ee316cd4 --- /dev/null +++ b/lldb/test/API/lang/objc/modules-non-objc-target/main.c @@ -0,0 +1,3 @@ +int main() { + return 0; // break here +} _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits