1 """ 2 Test lldb data formatter subsystem. 3 """ 4 5 import os, time 6 import unittest2 7 import lldb 8 from lldbtest import * 9 import lldbutil 10 11 class StdVBoolDataFormatterTestCase(TestBase): 12 13 mydir = os.path.join("functionalities", "data-formatter", "data-formatter-stl", "libstdcpp", "vbool") 14 15 @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") 16 @dsym_test 17 def test_with_dsym_and_run_command(self): 18 """Test data formatter commands.""" 19 self.buildDsym() 20 self.data_formatter_commands() 21 22 @dwarf_test 23 def test_with_dwarf_and_run_command(self): 24 """Test data formatter commands.""" 25 self.buildDwarf() 26 self.data_formatter_commands() 27 28 def setUp(self): 29 # Call super's setUp(). 30 TestBase.setUp(self) 31 # Find the line number to break at. 32 self.line = line_number('main.cpp', '// Set break point at this line.') 33 34 @expectedFailureGcc # llvm.org/pr15301: lldb does not print the correct sizes of STL containers when building with GCC 35 @expectedFailureIcc # llvm.org/pr15301: lldb does not print the correct sizes of STL containers when building with ICC 36 def data_formatter_commands(self): 37 """Test that that file and class static variables display correctly.""" 38 self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) 39 40 lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1) 41 42 self.runCmd("run", RUN_SUCCEEDED) 43 44 # The stop reason of the thread should be breakpoint. 45 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, 46 substrs = ['stopped', 47 'stop reason = breakpoint']) 48 49 # This is the function to remove the custom formats in order to have a 50 # clean slate for the next test case. 51 def cleanup(): 52 self.runCmd('type format clear', check=False) 53 self.runCmd('type summary clear', check=False) 54 self.runCmd('type filter clear', check=False) 55 self.runCmd('type synth clear', check=False) 56 self.runCmd("settings set target.max-children-count 256", check=False) 57 58 # Execute the cleanup function during test case tear down. 59 self.addTearDownHook(cleanup) 60 61 self.expect("frame variable vBool", 62 substrs = ['size=49','[0] = false','[1] = true','[18] = false','[27] = true','[36] = false','[47] = true','[48] = true']) 63 64 self.expect("expr vBool", 65 substrs = ['size=49','[0] = false','[1] = true','[18] = false','[27] = true','[36] = false','[47] = true','[48] = true']) 66 67 if __name__ == '__main__': 68 import atexit 69 lldb.SBDebugger.Initialize() 70 atexit.register(lambda: lldb.SBDebugger.Terminate()) 71 unittest2.main() 72