2 Test lldb data formatter subsystem.
8 from lldbsuite.test.lldbtest import *
9 import lldbsuite.test.lldbutil as lldbutil
12 class NamedSummariesDataFormatterTestCase(TestBase):
14 mydir = TestBase.compute_mydir(__file__)
17 # Call super's setUp().
19 # Find the line number to break at.
20 self.line = line_number('main.cpp', '// Set break point at this line.')
22 def test_with_run_command(self):
23 """Test that that file and class static variables display correctly."""
25 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
27 lldbutil.run_break_set_by_file_and_line(
28 self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
30 self.runCmd("run", RUN_SUCCEEDED)
32 # The stop reason of the thread should be breakpoint.
33 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
35 'stop reason = breakpoint'])
37 # This is the function to remove the custom formats in order to have a
38 # clean slate for the next test case.
40 self.runCmd('type format clear', check=False)
41 self.runCmd('type summary clear', check=False)
43 # Execute the cleanup function during test case tear down.
44 self.addTearDownHook(cleanup)
47 "type summary add --summary-string \"AllUseIt: x=${var.x} {y=${var.y}} {z=${var.z}}\" --name AllUseIt")
49 "type summary add --summary-string \"First: x=${var.x} y=${var.y} dummy=${var.dummy}\" First")
51 "type summary add --summary-string \"Second: x=${var.x} y=${var.y%hex}\" Second")
53 "type summary add --summary-string \"Third: x=${var.x} z=${var.z}\" Third")
55 self.expect('type summary list', substrs=['AllUseIt'])
57 self.expect("frame variable first",
58 substrs=['First: x=12'])
60 self.expect("frame variable first --summary AllUseIt",
61 substrs=['AllUseIt: x=12'])
63 # We *DO NOT* remember the summary choice anymore
64 self.expect("frame variable first", matching=False,
65 substrs=['AllUseIt: x=12'])
66 self.expect("frame variable first",
67 substrs=['First: x=12'])
69 self.runCmd("thread step-over") # 2
71 self.expect("frame variable first",
72 substrs=['First: x=12'])
74 self.expect("frame variable first --summary AllUseIt",
75 substrs=['AllUseIt: x=12',
78 self.expect("frame variable second --summary AllUseIt",
79 substrs=['AllUseIt: x=65',
82 self.expect("frame variable third --summary AllUseIt",
83 substrs=['AllUseIt: x=96',
87 self.runCmd("thread step-over") # 3
89 self.expect("frame variable second",
90 substrs=['Second: x=65',
93 # <rdar://problem/11576143> decided that invalid summaries will raise an error
94 # instead of just defaulting to the base summary
96 "frame variable second --summary NoSuchSummary",
98 substrs=['must specify a valid named summary'])
100 self.runCmd("thread step-over")
103 "type summary add --summary-string \"FirstAndFriends: x=${var.x} {y=${var.y}} {z=${var.z}}\" First --name FirstAndFriends")
105 self.expect("frame variable first",
106 substrs=['FirstAndFriends: x=12',
109 self.runCmd("type summary delete First")
111 self.expect("frame variable first --summary FirstAndFriends",
112 substrs=['FirstAndFriends: x=12',
115 self.expect("frame variable first", matching=True,
119 self.runCmd("type summary delete FirstAndFriends")
120 self.expect("type summary delete NoSuchSummary", error=True)
121 self.runCmd("type summary delete AllUseIt")
123 self.expect("frame variable first", matching=False,
124 substrs=['FirstAndFriends'])
126 self.runCmd("thread step-over") # 4
128 self.expect("frame variable first", matching=False,
129 substrs=['FirstAndFriends: x=12',