1c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi"""Test that lldb functions correctly after the inferior has crashed.""" 2d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen 3d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chenimport os, time 4d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chenimport unittest2 580a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthiimport lldb, lldbutil 6d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chenfrom lldbtest import * 7d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen 8d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chenclass CrashingInferiorTestCase(TestBase): 9d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen 1017a1399a7e7fbc4d2adb4186cd472f7e72d8d161Johnny Chen mydir = os.path.join("functionalities", "inferior-crashing") 11d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen 12d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") 13d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen def test_inferior_crashing_dsym(self): 14d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen """Test that lldb reliably catches the inferior crashing (command).""" 15d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen self.buildDsym() 16d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen self.inferior_crashing() 17d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen 18d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen def test_inferior_crashing_dwarf(self): 19d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen """Test that lldb reliably catches the inferior crashing (command).""" 20d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen self.buildDwarf() 21d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen self.inferior_crashing() 22d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen 23c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") 24c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi def test_inferior_crashing_registers_dsym(self): 25c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi """Test that lldb reliably reads registers from the inferior after crashing (command).""" 26c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi self.buildDsym() 27c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi self.inferior_crashing_registers() 28c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi 29c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi def test_inferior_crashing_register_dwarf(self): 30c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi """Test that lldb reliably reads registers from the inferior after crashing (command).""" 31c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi self.buildDwarf() 32c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi self.inferior_crashing_registers() 33c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi 34d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen @python_api_test 35d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen def test_inferior_crashing_python(self): 36d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen """Test that lldb reliably catches the inferior crashing (Python API).""" 37d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen self.buildDefault() 38d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen self.inferior_crashing_python() 39d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen 40c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") 41aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor def test_inferior_crashing_expr_dsym(self): 42c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi """Test that the lldb expression interpreter can read from the inferior after crashing (command).""" 43c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi self.buildDsym() 44c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi self.inferior_crashing_expr() 45c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi 46aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor def test_inferior_crashing_expr_dwarf(self): 47c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi """Test that the lldb expression interpreter can read from the inferior after crashing (command).""" 48c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi self.buildDwarf() 49c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi self.inferior_crashing_expr() 50c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi 5180a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") 52aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor def test_inferior_crashing_step_dsym(self): 5380a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi """Test that lldb functions correctly after stepping through a crash.""" 5480a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi self.buildDsym() 5580a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi self.inferior_crashing_step() 5680a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi 57aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor def test_inferior_crashing_step_dwarf(self): 58aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor """Test that stepping after a crash behaves correctly.""" 5980a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi self.buildDwarf() 6080a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi self.inferior_crashing_step() 6180a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi 62aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") 63aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor def test_inferior_crashing_step_after_break_dsym(self): 64aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor """Test that stepping after a crash behaves correctly.""" 65aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor self.buildDsym() 66aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor self.inferior_crashing_step_after_break() 67aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor 686bc4dcdfbcdfa455299d2123011b82a77351ee72Daniel Malea @expectedFailureLinux # due to llvm.org/pr15988 -- step over misbehaves after crash 69aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor def test_inferior_crashing_step_after_break_dwarf(self): 70aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor """Test that lldb functions correctly after stepping through a crash.""" 71aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor self.buildDwarf() 72aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor self.inferior_crashing_step_after_break() 73aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor 74aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") 75aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor def test_inferior_crashing_expr_step_and_expr_dsym(self): 76aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor """Test that lldb expressions work before and after stepping after a crash.""" 77aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor self.buildDsym() 78aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor self.inferior_crashing_expr_step_expr() 79aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor 806bc4dcdfbcdfa455299d2123011b82a77351ee72Daniel Malea @expectedFailureLinux # due to llvm.org/pr15989 -- expression fails after crash and step 81aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor def test_inferior_crashing_expr_step_and_expr_dwarf(self): 82aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor """Test that lldb expressions work before and after stepping after a crash.""" 83aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor self.buildDwarf() 84aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor self.inferior_crashing_expr_step_expr() 85aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor 8680a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi def set_breakpoint(self, line): 8780a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi lldbutil.run_break_set_by_file_and_line (self, "main.c", line, num_expected_locations=1, loc_exact=True) 8880a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi 89d968be79118d913ad07bcd5df49d505d39832d18Ashok Thirumurthi def check_stop_reason(self): 90d968be79118d913ad07bcd5df49d505d39832d18Ashok Thirumurthi if sys.platform.startswith("darwin"): 91d968be79118d913ad07bcd5df49d505d39832d18Ashok Thirumurthi stop_reason = 'stop reason = EXC_BAD_ACCESS' 92d968be79118d913ad07bcd5df49d505d39832d18Ashok Thirumurthi else: 93d968be79118d913ad07bcd5df49d505d39832d18Ashok Thirumurthi stop_reason = 'stop reason = invalid address' 94d968be79118d913ad07bcd5df49d505d39832d18Ashok Thirumurthi 95d968be79118d913ad07bcd5df49d505d39832d18Ashok Thirumurthi # The stop reason of the thread should be a bad access exception. 96d968be79118d913ad07bcd5df49d505d39832d18Ashok Thirumurthi self.expect("thread list", STOPPED_DUE_TO_EXC_BAD_ACCESS, 97d968be79118d913ad07bcd5df49d505d39832d18Ashok Thirumurthi substrs = ['stopped', 98d968be79118d913ad07bcd5df49d505d39832d18Ashok Thirumurthi stop_reason]) 99d968be79118d913ad07bcd5df49d505d39832d18Ashok Thirumurthi 100d968be79118d913ad07bcd5df49d505d39832d18Ashok Thirumurthi return stop_reason 101d968be79118d913ad07bcd5df49d505d39832d18Ashok Thirumurthi 102d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen def setUp(self): 103d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen # Call super's setUp(). 104d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen TestBase.setUp(self) 105d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen # Find the line number of the crash. 106d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen self.line = line_number('main.c', '// Crash here.') 107d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen 108d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen def inferior_crashing(self): 109d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen """Inferior crashes upon launching; lldb should catch the event and stop.""" 110d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen exe = os.path.join(os.getcwd(), "a.out") 111d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) 112d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen 113d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen self.runCmd("run", RUN_SUCCEEDED) 114d968be79118d913ad07bcd5df49d505d39832d18Ashok Thirumurthi stop_reason = self.check_stop_reason() 115d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen 116d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen # And it should report the correct line number. 117219b929e8916448492575d824529655b473a0024Johnny Chen self.expect("thread backtrace all", 118aec6b329fe4f96cd5a52d7a0cf54f74ae0d34e50Andrew Kaylor substrs = [stop_reason, 119d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen 'main.c:%d' % self.line]) 120d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen 121d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen def inferior_crashing_python(self): 122d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen """Inferior crashes upon launching; lldb should catch the event and stop.""" 123d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen exe = os.path.join(os.getcwd(), "a.out") 124d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen 125d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen target = self.dbg.CreateTarget(exe) 126805fec7ec90a09b94bc4515fcac9b2b03bae153bJohnny Chen self.assertTrue(target, VALID_TARGET) 127d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen 128d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen # Now launch the process, and do not stop at entry point. 129d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen # Both argv and envp are null. 1303d8ae4681b81b42a404ad77a231c6f743040e644Johnny Chen process = target.LaunchSimple(None, None, os.getcwd()) 131d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen 1323d8ae4681b81b42a404ad77a231c6f743040e644Johnny Chen if process.GetState() != lldb.eStateStopped: 133d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen self.fail("Process should be in the 'stopped' state, " 134d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen "instead the actual state is: '%s'" % 1353d8ae4681b81b42a404ad77a231c6f743040e644Johnny Chen lldbutil.state_type_to_str(process.GetState())) 136d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen 1373d8ae4681b81b42a404ad77a231c6f743040e644Johnny Chen thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonException) 138d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen if not thread: 1396b41e0b08cac8a59bda19907eb71c05eb36c3af6Johnny Chen self.fail("Fail to stop the thread upon bad access exception") 140d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen 141ab6378a047f71aec5a12aeaf65ac2380f5ef808cJohnny Chen if self.TraceOn(): 142318aaa0b4b593ec3e69c5962bddab10c47066c4fJohnny Chen lldbutil.print_stacktrace(thread) 143d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen 144c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi def inferior_crashing_registers(self): 145c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi """Test that lldb can read registers after crashing.""" 146c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi exe = os.path.join(os.getcwd(), "a.out") 147c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) 148c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi 149c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi self.runCmd("run", RUN_SUCCEEDED) 150d968be79118d913ad07bcd5df49d505d39832d18Ashok Thirumurthi self.check_stop_reason() 151c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi 152c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi # lldb should be able to read from registers from the inferior after crashing. 153ac874f9cd547aa5bfcc70d5e6ef3c3d63f275844Ashok Thirumurthi self.expect("register read eax", 154ac874f9cd547aa5bfcc70d5e6ef3c3d63f275844Ashok Thirumurthi substrs = ['eax = 0x']) 155c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi 156c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi def inferior_crashing_expr(self): 157c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi """Test that the lldb expression interpreter can read symbols after crashing.""" 158c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi exe = os.path.join(os.getcwd(), "a.out") 159c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) 160c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi 161c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi self.runCmd("run", RUN_SUCCEEDED) 162d968be79118d913ad07bcd5df49d505d39832d18Ashok Thirumurthi self.check_stop_reason() 16380a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi 16480a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi # The lldb expression interpreter should be able to read from addresses of the inferior after a crash. 165c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi self.expect("p argc", 16680a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi startstr = '(int) $0 = 1') 16780a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi 16880a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi self.expect("p hello_world", 16980a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi substrs = ['Hello']) 17080a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi 17180a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi def inferior_crashing_step(self): 17280a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi """Test that lldb functions correctly after stepping through a crash.""" 17380a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi exe = os.path.join(os.getcwd(), "a.out") 17480a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) 17580a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi 17680a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi self.set_breakpoint(self.line) 17780a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi self.runCmd("run", RUN_SUCCEEDED) 17880a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi 17980a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, 18080a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi substrs = ['main.c:%d' % self.line, 18180a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi 'stop reason = breakpoint']) 18280a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi 18380a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi self.runCmd("next") 184d968be79118d913ad07bcd5df49d505d39832d18Ashok Thirumurthi stop_reason = self.check_stop_reason() 18580a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi 18680a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi # The lldb expression interpreter should be able to read from addresses of the inferior after a crash. 18780a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi self.expect("p argv[0]", 18880a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi substrs = ['a.out']) 18980a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi self.expect("p null_ptr", 19080a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi substrs = ['= 0x0']) 19180a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi 19280a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi # lldb should be able to read from registers from the inferior after crashing. 19380a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi self.expect("register read eax", 19480a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi substrs = ['eax = 0x']) 19580a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi 19680a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi # And it should report the correct line number. 19780a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi self.expect("thread backtrace all", 19880a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi substrs = [stop_reason, 19980a1fa60bff6a7ff9b68c2d79bac2d1dfba132edAshok Thirumurthi 'main.c:%d' % self.line]) 200c1fe32293be3a8795febd5769e185ca7dba8b43dAshok Thirumurthi 201aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor def inferior_crashing_step_after_break(self): 202aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor """Test that lldb behaves correctly when stepping after a crash.""" 203aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor exe = os.path.join(os.getcwd(), "a.out") 204aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) 205aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor 206aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor self.runCmd("run", RUN_SUCCEEDED) 207d968be79118d913ad07bcd5df49d505d39832d18Ashok Thirumurthi self.check_stop_reason() 208aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor 209aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor self.runCmd("next") 210d968be79118d913ad07bcd5df49d505d39832d18Ashok Thirumurthi self.check_stop_reason() 211aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor 212aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor def inferior_crashing_expr_step_expr(self): 213aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor """Test that lldb expressions work before and after stepping after a crash.""" 214aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor exe = os.path.join(os.getcwd(), "a.out") 215aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) 216aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor 217aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor self.runCmd("run", RUN_SUCCEEDED) 218d968be79118d913ad07bcd5df49d505d39832d18Ashok Thirumurthi self.check_stop_reason() 219aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor 220aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor # The lldb expression interpreter should be able to read from addresses of the inferior after a crash. 221aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor self.expect("p argv[0]", 222aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor substrs = ['a.out']) 223aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor 224aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor self.runCmd("next") 225d968be79118d913ad07bcd5df49d505d39832d18Ashok Thirumurthi self.check_stop_reason() 226aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor 227aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor # The lldb expression interpreter should be able to read from addresses of the inferior after a crash. 228aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor self.expect("p argv[0]", 229aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor substrs = ['a.out']) 230aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor 231aa44e6863d0ef7982ddbc8621b4d3d30ff920d70Andrew Kaylor 232d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chenif __name__ == '__main__': 233d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen import atexit 234d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen lldb.SBDebugger.Initialize() 235d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen atexit.register(lambda: lldb.SBDebugger.Terminate()) 236d2dff7bf2355c992b446d8a3c11690bfa24ce998Johnny Chen unittest2.main() 237