199451b44SJordan Rupprechtfrom lldbsuite.test import decorators 299451b44SJordan Rupprecht 371db787cSFred Rissimport lldb 471db787cSFred Rissfrom lldbsuite.test.decorators import * 571db787cSFred Rissfrom lldbsuite.test.lldbtest import * 671db787cSFred Rissfrom lldbsuite.test import lldbutil 771db787cSFred Rissfrom lldbsuite.test import lldbtest 871db787cSFred Riss 971db787cSFred Riss 1071db787cSFred Rissclass PlatformProcessCrashInfoTestCase(TestBase): 1171db787cSFred Riss 1271db787cSFred Riss mydir = TestBase.compute_mydir(__file__) 1371db787cSFred Riss 1498257c30SMichał Górny @expectedFailureAll(oslist=["windows", "linux", "freebsd", "netbsd"]) 1571db787cSFred Riss def test_thread_local(self): 1671db787cSFred Riss # Set a breakpoint on the first instruction of the main function, 1771db787cSFred Riss # before the TLS initialization has run. 1871db787cSFred Riss self.build() 1971db787cSFred Riss exe = self.getBuildArtifact("a.out") 2071db787cSFred Riss 2171db787cSFred Riss (target, process, _, _) = \ 2271db787cSFred Riss lldbutil.run_to_source_breakpoint(self, "Set breakpoint here", 2371db787cSFred Riss lldb.SBFileSpec("main.cpp")) 2471db787cSFred Riss self.expect_expr("tl_local_int + 1", 2571db787cSFred Riss result_type="int", result_value="323") 2671db787cSFred Riss self.expect_expr("*tl_local_ptr + 2", 2771db787cSFred Riss result_type="int", result_value="324") 2871db787cSFred Riss self.expect_expr("tl_global_int", 2971db787cSFred Riss result_type="int", result_value="123") 3071db787cSFred Riss self.expect_expr("*tl_global_ptr", 3171db787cSFred Riss result_type="int", result_value="45") 3271db787cSFred Riss 33*b505ed9dSJonas Devlieghere # Create the filespec by which to locate our a.out module. Use the 34*b505ed9dSJonas Devlieghere # absolute path to get the module for the current variant. 355238b800SJonas Devlieghere filespec = lldb.SBFileSpec(exe, False) 365238b800SJonas Devlieghere 3771db787cSFred Riss # Now see if we emit the correct error when the TLS is not yet 3871db787cSFred Riss # initialized. Let's set a breakpoint on the first instruction 3971db787cSFred Riss # of main. 405238b800SJonas Devlieghere main_module = target.FindModule(filespec) 415238b800SJonas Devlieghere self.assertTrue(main_module, VALID_MODULE) 4271db787cSFred Riss main_address = main_module.FindSymbol("main").GetStartAddress() 4371db787cSFred Riss main_bkpt = target.BreakpointCreateBySBAddress(main_address) 4471db787cSFred Riss 4571db787cSFred Riss process.Kill() 4671db787cSFred Riss lldbutil.run_to_breakpoint_do_run(self, target, main_bkpt) 4771db787cSFred Riss 4871db787cSFred Riss self.expect("expr tl_local_int", error=True, 4971db787cSFred Riss substrs=["couldn't get the value of variable tl_local_int", 5071db787cSFred Riss "No TLS data currently exists for this thread"]) 5171db787cSFred Riss self.expect("expr *tl_local_ptr", error=True, 5271db787cSFred Riss substrs=["couldn't get the value of variable tl_local_ptr", 5371db787cSFred Riss "No TLS data currently exists for this thread"]) 5471db787cSFred Riss 55