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