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 14*98257c30SMichał 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 335238b800SJonas Devlieghere # Create the filespec by which to locate our a.out module. 345238b800SJonas Devlieghere # 355238b800SJonas Devlieghere # - Use the absolute path to get the module for the current variant. 365238b800SJonas Devlieghere # - Use the relative path for reproducers. The modules are never 375238b800SJonas Devlieghere # orphaned because the SB objects are leaked intentionally. This 385238b800SJonas Devlieghere # causes LLDB to reuse the same module for every variant, because the 395238b800SJonas Devlieghere # UUID is the same for all the inferiors. FindModule below only 405238b800SJonas Devlieghere # compares paths and is oblivious to the fact that the UUIDs are the 415238b800SJonas Devlieghere # same. 425238b800SJonas Devlieghere if configuration.is_reproducer(): 435238b800SJonas Devlieghere filespec = lldb.SBFileSpec('a.out', False) 445238b800SJonas Devlieghere else: 455238b800SJonas Devlieghere filespec = lldb.SBFileSpec(exe, False) 465238b800SJonas Devlieghere 4771db787cSFred Riss # Now see if we emit the correct error when the TLS is not yet 4871db787cSFred Riss # initialized. Let's set a breakpoint on the first instruction 4971db787cSFred Riss # of main. 505238b800SJonas Devlieghere main_module = target.FindModule(filespec) 515238b800SJonas Devlieghere self.assertTrue(main_module, VALID_MODULE) 5271db787cSFred Riss main_address = main_module.FindSymbol("main").GetStartAddress() 5371db787cSFred Riss main_bkpt = target.BreakpointCreateBySBAddress(main_address) 5471db787cSFred Riss 5571db787cSFred Riss process.Kill() 5671db787cSFred Riss lldbutil.run_to_breakpoint_do_run(self, target, main_bkpt) 5771db787cSFred Riss 5871db787cSFred Riss self.expect("expr tl_local_int", error=True, 5971db787cSFred Riss substrs=["couldn't get the value of variable tl_local_int", 6071db787cSFred Riss "No TLS data currently exists for this thread"]) 6171db787cSFred Riss self.expect("expr *tl_local_ptr", error=True, 6271db787cSFred Riss substrs=["couldn't get the value of variable tl_local_ptr", 6371db787cSFred Riss "No TLS data currently exists for this thread"]) 6471db787cSFred Riss 65