1#coding=utf8 2""" 3Test lldb data formatter subsystem. 4""" 5 6import os, time 7import unittest2 8import lldb 9from lldbtest import * 10import lldbutil 11 12class LibcxxStringDataFormatterTestCase(TestBase): 13 14 mydir = os.path.join("functionalities", "data-formatter", "data-formatter-stl", "libcxx", "string") 15 16 @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") 17 @dsym_test 18 def test_with_dsym_and_run_command(self): 19 """Test data formatter commands.""" 20 self.buildDsym() 21 self.data_formatter_commands() 22 23 @skipIfLinux # No standard locations for libc++ on Linux, so skip for now 24 @dwarf_test 25 def test_with_dwarf_and_run_command(self): 26 """Test data formatter commands.""" 27 self.buildDwarf() 28 self.data_formatter_commands() 29 30 def setUp(self): 31 # Call super's setUp(). 32 TestBase.setUp(self) 33 # Find the line number to break at. 34 self.line = line_number('main.cpp', '// Set break point at this line.') 35 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", 62 substrs = ['(std::__1::wstring) s = L"hello world! מזל טוב!"', 63 '(std::__1::wstring) S = L"!!!!"', 64 '(const wchar_t *) mazeltov = 0x','L"מזל טוב"', 65 '(std::__1::string) q = "hello world"', 66 '(std::__1::string) Q = "quite a long std::strin with lots of info inside it"']) 67 68 self.runCmd("n") 69 70 self.expect("frame variable", 71 substrs = ['(std::__1::wstring) s = L"hello world! מזל טוב!"', 72 '(std::__1::wstring) S = L"!!!!!"', 73 '(const wchar_t *) mazeltov = 0x','L"מזל טוב"', 74 '(std::__1::string) q = "hello world"', 75 '(std::__1::string) Q = "quite a long std::strin with lots of info inside it"']) 76 77if __name__ == '__main__': 78 import atexit 79 lldb.SBDebugger.Initialize() 80 atexit.register(lambda: lldb.SBDebugger.Terminate()) 81 unittest2.main() 82