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 10*cabee89bSRaphael Isemann 1199451b44SJordan Rupprechtclass ImportStdModule(TestBase): 1299451b44SJordan Rupprecht 1399451b44SJordan Rupprecht # We only emulate a fake libc++ in this test and don't use the real libc++, 1499451b44SJordan Rupprecht # but we still add the libc++ category so that this test is only run in 1599451b44SJordan Rupprecht # test configurations where libc++ is actually supposed to be tested. 1699451b44SJordan Rupprecht @add_test_categories(["libc++"]) 1752b2bae7SFred Riss @skipIfRemote 1899451b44SJordan Rupprecht @skipIf(compiler=no_match("clang")) 1999451b44SJordan Rupprecht def test(self): 2099451b44SJordan Rupprecht self.build() 2199451b44SJordan Rupprecht 2299451b44SJordan Rupprecht sysroot = os.path.join(os.getcwd(), "root") 2399451b44SJordan Rupprecht 2499451b44SJordan Rupprecht # Set the sysroot. 25*cabee89bSRaphael Isemann self.runCmd("platform select --sysroot '" + sysroot + "' host", 26*cabee89bSRaphael Isemann CURRENT_EXECUTABLE_SET) 2799451b44SJordan Rupprecht 2899451b44SJordan Rupprecht lldbutil.run_to_source_breakpoint(self, 29*cabee89bSRaphael Isemann "// Set break point at this line.", 30*cabee89bSRaphael Isemann lldb.SBFileSpec("main.cpp")) 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. 3799451b44SJordan Rupprecht 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*cabee89bSRaphael Isemann self.expect("expr (size_t)v.size()", 41*cabee89bSRaphael Isemann substrs=["Couldn't lookup symbols"], 42*cabee89bSRaphael Isemann error=True) 43