• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1"""
2Test lldb data formatter subsystem.
3"""
4
5from __future__ import print_function
6
7
8import lldb
9from lldbsuite.test.decorators import *
10from lldbsuite.test.lldbtest import *
11import lldbsuite.test.lldbutil as lldbutil
12
13
14class ValueObjectRecursionTestCase(TestBase):
15
16    mydir = TestBase.compute_mydir(__file__)
17
18    def setUp(self):
19        # Call super's setUp().
20        TestBase.setUp(self)
21        # Find the line number to break at.
22        self.line = line_number('main.cpp', '// Set break point at this line.')
23
24    @no_debug_info_test
25    def test_with_run_command(self):
26        """Test that deeply nested ValueObjects still work."""
27        self.build()
28        self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
29
30        lldbutil.run_break_set_by_file_and_line(
31            self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
32
33        self.runCmd("run", RUN_SUCCEEDED)
34
35        # The stop reason of the thread should be breakpoint.
36        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
37                    substrs=['stopped',
38                             'stop reason = breakpoint'])
39
40        # This is the function to remove the custom formats in order to have a
41        # clean slate for the next test case.
42        def cleanup():
43            self.runCmd('type format clear', check=False)
44            self.runCmd('type summary clear', check=False)
45
46        # Execute the cleanup function during test case tear down.
47        self.addTearDownHook(cleanup)
48
49        root = self.frame().FindVariable("root")
50        child = root.GetChildAtIndex(1)
51        if self.TraceOn():
52            print(root)
53            print(child)
54        for i in range(0, 15000):
55            child = child.GetChildAtIndex(1)
56        if self.TraceOn():
57            print(child)
58        self.assertTrue(
59            child.IsValid(),
60            "could not retrieve the deep ValueObject")
61        self.assertTrue(
62            child.GetChildAtIndex(0).IsValid(),
63            "the deep ValueObject has no value")
64        self.assertTrue(
65            child.GetChildAtIndex(0).GetValueAsUnsigned() != 0,
66            "the deep ValueObject has a zero value")
67        self.assertTrue(
68            child.GetChildAtIndex(1).GetValueAsUnsigned() != 0,
69            "the deep ValueObject has no next")
70