199451b44SJordan Rupprecht""" 299451b44SJordan RupprechtTest that LLDB doesn't crash if the std module we load is empty. 399451b44SJordan Rupprecht""" 499451b44SJordan Rupprecht 599451b44SJordan Rupprechtfrom lldbsuite.test.decorators import * 699451b44SJordan Rupprechtfrom lldbsuite.test.lldbtest import * 799451b44SJordan Rupprechtfrom lldbsuite.test import lldbutil 899451b44SJordan Rupprechtimport os 999451b44SJordan Rupprecht 10cabee89bSRaphael Isemann 1199451b44SJordan Rupprechtclass ImportStdModule(TestBase): 1299451b44SJordan Rupprecht # We only emulate a fake libc++ in this test and don't use the real libc++, 1399451b44SJordan Rupprecht # but we still add the libc++ category so that this test is only run in 1499451b44SJordan Rupprecht # test configurations where libc++ is actually supposed to be tested. 1599451b44SJordan Rupprecht @add_test_categories(["libc++"]) 1652b2bae7SFred Riss @skipIfRemote 1799451b44SJordan Rupprecht @skipIf(compiler=no_match("clang")) 1899451b44SJordan Rupprecht def test(self): 1999451b44SJordan Rupprecht self.build() 2099451b44SJordan Rupprecht 2199451b44SJordan Rupprecht sysroot = os.path.join(os.getcwd(), "root") 2299451b44SJordan Rupprecht 2399451b44SJordan Rupprecht # Set the sysroot. 24*2238dcc3SJonas Devlieghere self.runCmd( 25*2238dcc3SJonas Devlieghere "platform select --sysroot '" + sysroot + "' host", CURRENT_EXECUTABLE_SET 26*2238dcc3SJonas Devlieghere ) 2799451b44SJordan Rupprecht 28*2238dcc3SJonas Devlieghere lldbutil.run_to_source_breakpoint( 29*2238dcc3SJonas Devlieghere self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp") 30*2238dcc3SJonas Devlieghere ) 3199451b44SJordan Rupprecht 3299451b44SJordan Rupprecht self.runCmd("settings set target.import-std-module true") 3399451b44SJordan Rupprecht 3499451b44SJordan Rupprecht # Use the typedef that is only defined in our 'empty' module. If this fails, then LLDB 3599451b44SJordan Rupprecht # somehow figured out the correct define for the header and compiled the right 3699451b44SJordan Rupprecht # standard module that actually contains the std::vector template. 37*2238dcc3SJonas Devlieghere self.expect("expr MissingContent var = 3; var", substrs=["$0 = 3"]) 3899451b44SJordan Rupprecht # Try to access our mock std::vector. This should fail but not crash LLDB as the 3999451b44SJordan Rupprecht # std::vector template should be missing from the std module. 40*2238dcc3SJonas Devlieghere self.expect( 41*2238dcc3SJonas Devlieghere "expr (size_t)v.size()", substrs=["Couldn't look up symbols"], error=True 42*2238dcc3SJonas Devlieghere ) 43