1# encoding: utf-8 2""" 3Test lldb data formatter subsystem. 4""" 5 6 7import lldb 8from lldbsuite.test.decorators import * 9from lldbsuite.test.lldbtest import * 10from lldbsuite.test import lldbutil 11 12from ObjCDataFormatterTestCase import ObjCDataFormatterTestCase 13 14 15class ObjCDataFormatterExpr(ObjCDataFormatterTestCase): 16 17 @skipUnlessDarwin 18 def test_expr_with_run_command(self): 19 """Test common cases of expression parser <--> formatters interaction.""" 20 self.build() 21 self.target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( 22 self, '// Set break point at this line.', 23 lldb.SBFileSpec('main.m', False)) 24 25 # The stop reason of the thread should be breakpoint. 26 self.expect( 27 "thread list", 28 STOPPED_DUE_TO_BREAKPOINT, 29 substrs=['stopped', 'stop reason = breakpoint']) 30 31 # This is the function to remove the custom formats in order to have a 32 # clean slate for the next test case. 33 def cleanup(): 34 self.runCmd('type format clear', check=False) 35 self.runCmd('type summary clear', check=False) 36 self.runCmd('type synth clear', check=False) 37 38 # Execute the cleanup function during test case tear down. 39 self.addTearDownHook(cleanup) 40 41 # check that the formatters are able to deal safely and correctly 42 # with ValueObjects that the expression parser returns 43 self.expect( 44 'expression ((id)@"Hello for long enough to avoid short string types")', 45 matching=False, 46 substrs=['Hello for long enough to avoid short string types']) 47 48 self.expect( 49 'expression -d run -- ((id)@"Hello for long enough to avoid short string types")', 50 substrs=['Hello for long enough to avoid short string types']) 51 52 self.expect('expr -d run -- label1', substrs=['Process Name']) 53 54 self.expect( 55 'expr -d run -- @"Hello for long enough to avoid short string types"', 56 substrs=['Hello for long enough to avoid short string types']) 57 58 self.expect( 59 'expr -d run --object-description -- @"Hello for long enough to avoid short string types"', 60 substrs=['Hello for long enough to avoid short string types']) 61 self.expect( 62 'expr -d run --object-description -- @"Hello"', 63 matching=False, 64 substrs=['@"Hello" Hello']) 65