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", "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        # Now see if we emit the correct error when the TLS is not yet
34        # initialized. Let's set a breakpoint on the first instruction
35        # of main.
36        main_module = target.FindModule(lldb.SBFileSpec(exe))
37        main_address = main_module.FindSymbol("main").GetStartAddress()
38        main_bkpt = target.BreakpointCreateBySBAddress(main_address)
39
40        process.Kill()
41        lldbutil.run_to_breakpoint_do_run(self, target, main_bkpt)
42
43        self.expect("expr tl_local_int", error=True,
44                    substrs=["couldn't get the value of variable tl_local_int",
45                             "No TLS data currently exists for this thread"])
46        self.expect("expr *tl_local_ptr", error=True,
47                    substrs=["couldn't get the value of variable tl_local_ptr",
48                             "No TLS data currently exists for this thread"])
49
50