2 Test that LLDB doesn't crash if the std module we load is empty.
5 from lldbsuite.test.decorators import *
6 from lldbsuite.test.lldbtest import *
7 from lldbsuite.test import lldbutil
10 class ImportStdModule(TestBase):
12 mydir = TestBase.compute_mydir(__file__)
14 # We only emulate a fake libc++ in this test and don't use the real libc++,
15 # but we still add the libc++ category so that this test is only run in
16 # test configurations where libc++ is actually supposed to be tested.
17 @add_test_categories(["libc++"])
18 @skipIf(compiler=no_match("clang"))
22 sysroot = os.path.join(os.getcwd(), "root")
25 self.runCmd("platform select --sysroot '" + sysroot + "' host", CURRENT_EXECUTABLE_SET)
27 lldbutil.run_to_source_breakpoint(self,
28 "// Set break point at this line.", lldb.SBFileSpec("main.cpp"))
30 self.runCmd("settings set target.import-std-module true")
32 # Use the typedef that is only defined in our 'empty' module. If this fails, then LLDB
33 # somehow figured out the correct define for the header and compiled the right
34 # standard module that actually contains the std::vector template.
35 self.expect("expr MissingContent var = 3; var", substrs=['$0 = 3'])
36 # Try to access our mock std::vector. This should fail but not crash LLDB as the
37 # std::vector template should be missing from the std module.
38 self.expect("expr (size_t)v.size()", substrs=["Couldn't lookup symbols"], error=True)