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