1""" 2Tests that importing ObjC modules in a non-ObjC target doesn't crash LLDB. 3""" 4 5import lldb 6from lldbsuite.test.decorators import * 7from lldbsuite.test.lldbtest import * 8from lldbsuite.test import lldbutil 9 10class TestCase(TestBase): 11 12 mydir = TestBase.compute_mydir(__file__) 13 14 def test(self): 15 self.build() 16 lldbutil.run_to_source_breakpoint(self,"// break here", lldb.SBFileSpec("main.c")) 17 18 # Import foundation to get some ObjC types. 19 self.expect("expr --lang objc -- @import Foundation") 20 # Do something with NSString (which requires special handling when 21 # preparing to run in the target). The expression most likely can't 22 # be prepared to run in the target but it should at least not crash LLDB. 23 self.expect('expr --lang objc -- [NSString stringWithFormat:@"%d", 1];', 24 error=True, 25 substrs=["Rewriting an Objective-C constant string requires CFStringCreateWithBytes"]) 26