c71cffe788ac194cf9a3edeb31ac49527829ce1f
[openbsd] /
1 """
2 Test lldb data formatter subsystem.
3 """
4
5
6 import lldb
7 from lldbsuite.test.decorators import *
8 from lldbsuite.test.lldbtest import *
9 from lldbsuite.test import lldbutil
10
11
12 class StdTupleDataFormatterTestCase(TestBase):
13     mydir = TestBase.compute_mydir(__file__)
14
15     @add_test_categories(["libstdcxx"])
16     def test_with_run_command(self):
17         self.build()
18         self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
19
20         lldbutil.run_break_set_by_source_regexp(
21             self, "Set break point at this line.")
22         self.runCmd("run", RUN_SUCCEEDED)
23
24         # The stop reason of the thread should be breakpoint.
25         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
26                     substrs=['stopped', 'stop reason = breakpoint'])
27
28         frame = self.frame()
29         self.assertTrue(frame.IsValid())
30
31         self.expect("frame variable ti", substrs=['[0] = 1'])
32         self.expect("frame variable ts", substrs=['[0] = "foobar"'])
33         self.expect("frame variable tt", substrs=['[0] = 1', '[1] = "baz"', '[2] = 2'])
34
35         self.assertEqual(1, frame.GetValueForVariablePath("ti[0]").GetValueAsUnsigned())
36         self.assertFalse(frame.GetValueForVariablePath("ti[1]").IsValid())
37
38         self.assertEqual('"foobar"', frame.GetValueForVariablePath("ts[0]").GetSummary())
39         self.assertFalse(frame.GetValueForVariablePath("ts[1]").IsValid())
40
41         self.assertEqual(1, frame.GetValueForVariablePath("tt[0]").GetValueAsUnsigned())
42         self.assertEqual('"baz"', frame.GetValueForVariablePath("tt[1]").GetSummary())
43         self.assertEqual(2, frame.GetValueForVariablePath("tt[2]").GetValueAsUnsigned())
44         self.assertFalse(frame.GetValueForVariablePath("tt[3]").IsValid())