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 1298257c30SMichał Górny @expectedFailureAll(oslist=["windows", "linux", "freebsd", "netbsd"]) 1371db787cSFred Riss def test_thread_local(self): 1471db787cSFred Riss # Set a breakpoint on the first instruction of the main function, 1571db787cSFred Riss # before the TLS initialization has run. 1671db787cSFred Riss self.build() 1771db787cSFred Riss exe = self.getBuildArtifact("a.out") 1871db787cSFred Riss 1971db787cSFred Riss (target, process, _, _) = \ 2071db787cSFred Riss lldbutil.run_to_source_breakpoint(self, "Set breakpoint here", 2171db787cSFred Riss lldb.SBFileSpec("main.cpp")) 2271db787cSFred Riss self.expect_expr("tl_local_int + 1", 2371db787cSFred Riss result_type="int", result_value="323") 2471db787cSFred Riss self.expect_expr("*tl_local_ptr + 2", 2571db787cSFred Riss result_type="int", result_value="324") 2671db787cSFred Riss self.expect_expr("tl_global_int", 2771db787cSFred Riss result_type="int", result_value="123") 2871db787cSFred Riss self.expect_expr("*tl_global_ptr", 2971db787cSFred Riss result_type="int", result_value="45") 3071db787cSFred Riss 31*b505ed9dSJonas Devlieghere # Create the filespec by which to locate our a.out module. Use the 32*b505ed9dSJonas Devlieghere # absolute path to get the module for the current variant. 335238b800SJonas Devlieghere filespec = lldb.SBFileSpec(exe, False) 345238b800SJonas Devlieghere 3571db787cSFred Riss # Now see if we emit the correct error when the TLS is not yet 3671db787cSFred Riss # initialized. Let's set a breakpoint on the first instruction 3771db787cSFred Riss # of main. 385238b800SJonas Devlieghere main_module = target.FindModule(filespec) 395238b800SJonas Devlieghere self.assertTrue(main_module, VALID_MODULE) 4071db787cSFred Riss main_address = main_module.FindSymbol("main").GetStartAddress() 4171db787cSFred Riss main_bkpt = target.BreakpointCreateBySBAddress(main_address) 4271db787cSFred Riss 4371db787cSFred Riss process.Kill() 4471db787cSFred Riss lldbutil.run_to_breakpoint_do_run(self, target, main_bkpt) 4571db787cSFred Riss 4671db787cSFred Riss self.expect("expr tl_local_int", error=True, 4771db787cSFred Riss substrs=["couldn't get the value of variable tl_local_int", 4871db787cSFred Riss "No TLS data currently exists for this thread"]) 4971db787cSFred Riss self.expect("expr *tl_local_ptr", error=True, 5071db787cSFred Riss substrs=["couldn't get the value of variable tl_local_ptr", 5171db787cSFred Riss "No TLS data currently exists for this thread"]) 5271db787cSFred Riss 53