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