199451b44SJordan Rupprechtfrom lldbsuite.test import decorators 299451b44SJordan Rupprecht 3*71db787cSFred Rissimport lldb 4*71db787cSFred Rissfrom lldbsuite.test.decorators import * 5*71db787cSFred Rissfrom lldbsuite.test.lldbtest import * 6*71db787cSFred Rissfrom lldbsuite.test import lldbutil 7*71db787cSFred Rissfrom lldbsuite.test import lldbtest 8*71db787cSFred Riss 9*71db787cSFred Riss 10*71db787cSFred Rissclass PlatformProcessCrashInfoTestCase(TestBase): 11*71db787cSFred Riss 12*71db787cSFred Riss mydir = TestBase.compute_mydir(__file__) 13*71db787cSFred Riss 14*71db787cSFred Riss @expectedFailureAll(oslist=["windows", "linux", "netbsd"]) 15*71db787cSFred Riss def test_thread_local(self): 16*71db787cSFred Riss # Set a breakpoint on the first instruction of the main function, 17*71db787cSFred Riss # before the TLS initialization has run. 18*71db787cSFred Riss self.build() 19*71db787cSFred Riss exe = self.getBuildArtifact("a.out") 20*71db787cSFred Riss 21*71db787cSFred Riss (target, process, _, _) = \ 22*71db787cSFred Riss lldbutil.run_to_source_breakpoint(self, "Set breakpoint here", 23*71db787cSFred Riss lldb.SBFileSpec("main.cpp")) 24*71db787cSFred Riss self.expect_expr("tl_local_int + 1", 25*71db787cSFred Riss result_type="int", result_value="323") 26*71db787cSFred Riss self.expect_expr("*tl_local_ptr + 2", 27*71db787cSFred Riss result_type="int", result_value="324") 28*71db787cSFred Riss self.expect_expr("tl_global_int", 29*71db787cSFred Riss result_type="int", result_value="123") 30*71db787cSFred Riss self.expect_expr("*tl_global_ptr", 31*71db787cSFred Riss result_type="int", result_value="45") 32*71db787cSFred Riss 33*71db787cSFred Riss # Now see if we emit the correct error when the TLS is not yet 34*71db787cSFred Riss # initialized. Let's set a breakpoint on the first instruction 35*71db787cSFred Riss # of main. 36*71db787cSFred Riss main_module = target.FindModule(lldb.SBFileSpec(exe)) 37*71db787cSFred Riss main_address = main_module.FindSymbol("main").GetStartAddress() 38*71db787cSFred Riss main_bkpt = target.BreakpointCreateBySBAddress(main_address) 39*71db787cSFred Riss 40*71db787cSFred Riss process.Kill() 41*71db787cSFred Riss lldbutil.run_to_breakpoint_do_run(self, target, main_bkpt) 42*71db787cSFred Riss 43*71db787cSFred Riss self.expect("expr tl_local_int", error=True, 44*71db787cSFred Riss substrs=["couldn't get the value of variable tl_local_int", 45*71db787cSFred Riss "No TLS data currently exists for this thread"]) 46*71db787cSFred Riss self.expect("expr *tl_local_ptr", error=True, 47*71db787cSFred Riss substrs=["couldn't get the value of variable tl_local_ptr", 48*71db787cSFred Riss "No TLS data currently exists for this thread"]) 49*71db787cSFred Riss 50