1""" 2Test lldb data formatter subsystem. 3""" 4 5 6import lldb 7from lldbsuite.test.decorators import * 8from lldbsuite.test.lldbtest import * 9from lldbsuite.test import lldbutil 10 11 12class DataFormatterDisablingTestCase(TestBase): 13 def setUp(self): 14 # Call super's setUp(). 15 TestBase.setUp(self) 16 # Find the line number to break at. 17 self.line = line_number("main.cpp", "// Set break point at this line.") 18 19 @expectedFailureAll( 20 oslist=["windows"], 21 bugnumber="llvm.org/pr24462, Data formatters have problems on Windows", 22 ) 23 def test_with_run_command(self): 24 """Check that we can properly disable all data formatter categories.""" 25 self.build() 26 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) 27 28 lldbutil.run_break_set_by_file_and_line( 29 self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True 30 ) 31 32 self.runCmd("run", RUN_SUCCEEDED) 33 34 # The stop reason of the thread should be breakpoint. 35 self.expect( 36 "thread list", 37 STOPPED_DUE_TO_BREAKPOINT, 38 substrs=["stopped", "stop reason = breakpoint"], 39 ) 40 41 # This is the function to remove the custom formats in order to have a 42 # clean slate for the next test case. 43 def cleanup(): 44 self.runCmd("type category enable *", check=False) 45 46 # Execute the cleanup function during test case tear down. 47 self.addTearDownHook(cleanup) 48 49 # self.runCmd('type category enable system VectorTypes libcxx gnu-libstdc++ CoreGraphics CoreServices AppKit CoreFoundation objc default', check=False) 50 51 self.expect( 52 "type category list", 53 substrs=[ 54 "system", 55 "enabled", 56 ], 57 ) 58 59 self.expect("frame variable numbers", substrs=["[0] = 1", "[3] = 1234"]) 60 61 self.expect("frame variable string1", substrs=["hello world"]) 62 63 # now disable them all and check that nothing is formatted 64 self.runCmd("type category disable *") 65 66 self.expect( 67 "frame variable numbers", matching=False, substrs=["[0] = 1", "[3] = 1234"] 68 ) 69 70 self.expect("frame variable string1", matching=False, substrs=["hello world"]) 71 72 self.expect("type summary list", substrs=["Category: system (disabled)"]) 73 74 self.expect( 75 "type category list", 76 substrs=[ 77 "system", 78 "disabled", 79 ], 80 ) 81 82 # now enable and check that we are back to normal 83 self.runCmd("type category enable *") 84 85 self.expect("type category list", substrs=["system", "enabled"]) 86 87 self.expect("frame variable numbers", substrs=["[0] = 1", "[3] = 1234"]) 88 89 self.expect("frame variable string1", substrs=["hello world"]) 90 91 self.expect("type category list", substrs=["system", "enabled"]) 92 93 # last check - our cleanup will re-enable everything 94 self.runCmd("type category disable *") 95 self.expect("type category list", substrs=["system", "disabled"]) 96