1""" 2Test example snippets from the lldb 'help expression' output. 3""" 4 5 6import lldb 7from lldbsuite.test.decorators import * 8from lldbsuite.test.lldbtest import * 9from lldbsuite.test import lldbutil 10 11 12class Radar9673644TestCase(TestBase): 13 def setUp(self): 14 # Call super's setUp(). 15 TestBase.setUp(self) 16 # Find the line number to break inside main(). 17 self.main_source = "main.c" 18 self.line = line_number(self.main_source, "// Set breakpoint here.") 19 20 def test_expr_commands(self): 21 """The following expression commands should just work.""" 22 self.build() 23 24 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) 25 26 lldbutil.run_break_set_by_file_and_line( 27 self, self.main_source, self.line, num_expected_locations=1, loc_exact=True 28 ) 29 30 self.runCmd("run", RUN_SUCCEEDED) 31 32 # rdar://problem/9673664 lldb expression evaluation problem 33 34 self.expect('expr char str[] = "foo"; str[0]', substrs=["'f'"]) 35 # runCmd: expr char c[] = "foo"; c[0] 36 # output: (char) $0 = 'f' 37