48e77c1a885d17c4ebaf70b194a75c192a64f59d
[openbsd] /
1 """
2 Test lldb data formatter subsystem.
3 """
4
5 from __future__ import print_function
6
7
8 import lldb
9 from lldbsuite.test.decorators import *
10 from lldbsuite.test.lldbtest import *
11 from lldbsuite.test import lldbutil
12
13
14 class LibCxxAtomicTestCase(TestBase):
15
16     mydir = TestBase.compute_mydir(__file__)
17
18     def get_variable(self, name):
19         var = self.frame().FindVariable(name)
20         var.SetPreferDynamicValue(lldb.eDynamicCanRunTarget)
21         var.SetPreferSyntheticValue(True)
22         return var
23
24     @skipIf(compiler=["gcc"])
25     @add_test_categories(["libc++"])
26     def test(self):
27         """Test that std::atomic as defined by libc++ is correctly printed by LLDB"""
28         self.build()
29         self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
30
31         bkpt = self.target().FindBreakpointByID(
32             lldbutil.run_break_set_by_source_regexp(
33                 self, "Set break point at this line."))
34
35         self.runCmd("run", RUN_SUCCEEDED)
36
37         lldbutil.skip_if_library_missing(
38             self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
39
40         # The stop reason of the thread should be breakpoint.
41         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
42                     substrs=['stopped',
43                              'stop reason = breakpoint'])
44
45         s = self.get_variable('s')
46         i = self.get_variable('i')
47
48         if self.TraceOn():
49             print(s)
50         if self.TraceOn():
51             print(i)
52
53         self.assertTrue(i.GetValueAsUnsigned(0) == 5, "i == 5")
54         self.assertTrue(s.GetNumChildren() == 2, "s has two children")
55         self.assertTrue(
56             s.GetChildAtIndex(0).GetValueAsUnsigned(0) == 1,
57             "s.x == 1")
58         self.assertTrue(
59             s.GetChildAtIndex(1).GetValueAsUnsigned(0) == 2,
60             "s.y == 2")