2 Check if changing Format on an SBValue correctly propagates that new format to children as it should
8 from lldbsuite.test.lldbtest import *
9 import lldbsuite.test.lldbutil as lldbutil
12 class FormatPropagationTestCase(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 # rdar://problem/14035604
23 def test_with_run_command(self):
24 """Check for an issue where capping does not work because the Target pointer appears to be changing behind our backs."""
26 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
28 lldbutil.run_break_set_by_file_and_line(
29 self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
31 self.runCmd("run", RUN_SUCCEEDED)
33 # The stop reason of the thread should be breakpoint.
34 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
36 'stop reason = breakpoint'])
38 # This is the function to remove the custom formats in order to have a
39 # clean slate for the next test case.
43 # Execute the cleanup function during test case tear down.
44 self.addTearDownHook(cleanup)
46 # extract the parent and the children
48 parent = self.frame().FindVariable("f")
50 parent is not None and parent.IsValid(),
52 X = parent.GetChildMemberWithName("X")
53 self.assertTrue(X is not None and X.IsValid(), "could not find X")
54 Y = parent.GetChildMemberWithName("Y")
55 self.assertTrue(Y is not None and Y.IsValid(), "could not find Y")
56 # check their values now
57 self.assertTrue(X.GetValue() == "1", "X has an invalid value")
58 self.assertTrue(Y.GetValue() == "2", "Y has an invalid value")
59 # set the format on the parent
60 parent.SetFormat(lldb.eFormatHex)
62 X.GetValue() == "0x00000001",
63 "X has not changed format")
65 Y.GetValue() == "0x00000002",
66 "Y has not changed format")
67 # Step and check if the values make sense still
69 self.assertTrue(X.GetValue() == "0x00000004", "X has not become 4")
70 self.assertTrue(Y.GetValue() == "0x00000002", "Y has not stuck as hex")
71 # Check that children can still make their own choices
72 Y.SetFormat(lldb.eFormatDecimal)
73 self.assertTrue(X.GetValue() == "0x00000004", "X is still hex")
74 self.assertTrue(Y.GetValue() == "2", "Y has not been reset")
75 # Make a few more changes
76 parent.SetFormat(lldb.eFormatDefault)
77 X.SetFormat(lldb.eFormatHex)
78 Y.SetFormat(lldb.eFormatDefault)
80 X.GetValue() == "0x00000004",
81 "X is not hex as it asked")
82 self.assertTrue(Y.GetValue() == "2", "Y is not defaulted")