1""" 2Test lldb data formatter subsystem. 3""" 4 5import os, time 6import unittest2 7import lldb 8from lldbtest import * 9import lldbutil 10 11class LibcxxIteratorDataFormatterTestCase(TestBase): 12 13 mydir = os.path.join("functionalities", "data-formatter", "data-formatter-stl", "libcxx", "iterator") 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 @skipIfLinux # No standard locations for libc++ on Linux, so skip for now 23 @dwarf_test 24 def test_with_dwarf_and_run_command(self): 25 """Test data formatter commands.""" 26 self.buildDwarf() 27 self.data_formatter_commands() 28 29 def setUp(self): 30 # Call super's setUp(). 31 TestBase.setUp(self) 32 # Find the line number to break at. 33 self.line = line_number('main.cpp', '// Set break point at this line.') 34 35 def data_formatter_commands(self): 36 """Test that libc++ iterators format properly.""" 37 self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) 38 39 lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1) 40 41 self.runCmd("run", RUN_SUCCEEDED) 42 43 # The stop reason of the thread should be breakpoint. 44 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, 45 substrs = ['stopped', 46 'stop reason = breakpoint']) 47 48 # This is the function to remove the custom formats in order to have a 49 # clean slate for the next test case. 50 def cleanup(): 51 self.runCmd('type format clear', check=False) 52 self.runCmd('type summary clear', check=False) 53 self.runCmd('type filter clear', check=False) 54 self.runCmd('type synth clear', check=False) 55 self.runCmd("settings set target.max-children-count 256", check=False) 56 57 # Execute the cleanup function during test case tear down. 58 self.addTearDownHook(cleanup) 59 60 self.expect('image list',substrs=['libc++.1.dylib','libc++abi.dylib']) 61 62 self.expect('frame variable ivI', substrs = ['item = 3']) 63 self.expect('expr ivI', substrs = ['item = 3']) 64 65 self.expect('frame variable iimI', substrs = ['first = 0','second = 12']) 66 self.expect('expr iimI', substrs = ['first = 0','second = 12']) 67 68 self.expect('frame variable simI', substrs = ['first = "world"','second = 42']) 69 self.expect('expr simI', substrs = ['first = "world"','second = 42']) 70 71 self.expect('frame variable svI', substrs = ['item = "hello"']) 72 self.expect('expr svI', substrs = ['item = "hello"']) 73 74if __name__ == '__main__': 75 import atexit 76 lldb.SBDebugger.Initialize() 77 atexit.register(lambda: lldb.SBDebugger.Terminate()) 78 unittest2.main() 79