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