1""" 2Test the robustness of lldb expression parser. 3""" 4 5import os, time 6import unittest2 7import lldb 8from lldbtest import * 9 10class Radar8638051TestCase(TestBase): 11 12 mydir = os.path.join("expression_command", "radar_8638051") 13 14 def test_expr_commands(self): 15 """The following expression commands should not crash.""" 16 self.buildDefault() 17 18 self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) 19 20 self.runCmd("breakpoint set -n c") 21 22 self.runCmd("run", RUN_SUCCEEDED) 23 24 self.expect("expression val", 25 startstr = "(int) $0 = 1") 26 # (int) $0 = 1 27 28 self.expect("expression *(&val)", 29 startstr = "(int) $1 = 1") 30 # (int) $1 = 1 31 32 # rdar://problem/8638051 33 # lldb expression command: Could this crash be avoided 34 self.expect("expression &val", 35 startstr = "(int *) $2 = ") 36 # (int *) $2 = 0x.... 37 38 39if __name__ == '__main__': 40 import atexit 41 lldb.SBDebugger.Initialize() 42 atexit.register(lambda: lldb.SBDebugger.Terminate()) 43 unittest2.main() 44