1""" 2Test lldb data formatter subsystem. 3""" 4 5 6 7import lldb 8from lldbsuite.test.decorators import * 9from lldbsuite.test.lldbtest import * 10from lldbsuite.test import lldbutil 11 12 13class DataFormatterDisablingTestCase(TestBase): 14 15 mydir = TestBase.compute_mydir(__file__) 16 17 def setUp(self): 18 # Call super's setUp(). 19 TestBase.setUp(self) 20 # Find the line number to break at. 21 self.line = line_number('main.cpp', '// Set break point at this line.') 22 23 @expectedFailureAll( 24 oslist=["windows"], 25 bugnumber="llvm.org/pr24462, Data formatters have problems on Windows") 26 def test_with_run_command(self): 27 """Check that we can properly disable all data formatter categories.""" 28 self.build() 29 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) 30 31 lldbutil.run_break_set_by_file_and_line( 32 self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 33 34 self.runCmd("run", RUN_SUCCEEDED) 35 36 # The stop reason of the thread should be breakpoint. 37 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, 38 substrs=['stopped', 39 'stop reason = breakpoint']) 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('type category list', substrs=['system', 'enabled', ]) 52 53 self.expect("frame variable numbers", 54 substrs=['[0] = 1', '[3] = 1234']) 55 56 self.expect('frame variable string1', substrs=['hello world']) 57 58 # now disable them all and check that nothing is formatted 59 self.runCmd('type category disable *') 60 61 self.expect("frame variable numbers", matching=False, 62 substrs=['[0] = 1', '[3] = 1234']) 63 64 self.expect( 65 'frame variable string1', 66 matching=False, 67 substrs=['hello world']) 68 69 self.expect('type summary list', substrs=[ 70 'Category: system (disabled)']) 71 72 self.expect('type category list', substrs=['system', 'disabled', ]) 73 74 # now enable and check that we are back to normal 75 self.runCmd("type category enable *") 76 77 self.expect('type category list', substrs=['system', 'enabled']) 78 79 self.expect("frame variable numbers", 80 substrs=['[0] = 1', '[3] = 1234']) 81 82 self.expect('frame variable string1', substrs=['hello world']) 83 84 self.expect('type category list', substrs=['system', 'enabled']) 85 86 # last check - our cleanup will re-enable everything 87 self.runCmd('type category disable *') 88 self.expect('type category list', substrs=['system', 'disabled']) 89