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