Breakpoints not hitting when used in conjunction with exceptions (fixes #347). (#445)

Fixes #347
This commit is contained in:
Fabio Zadrozny 2018-05-30 13:43:42 -03:00 committed by Karthik Nadig
parent 4add62eb58
commit 63130cd36e
3 changed files with 35 additions and 1 deletions

View file

@ -621,7 +621,7 @@ class PyDBFrame:
self.do_wait_suspend(thread, frame, event, arg)
return self.trace_dispatch
else:
if not breakpoint and not is_return:
if not breakpoint and is_line:
# No stop from anyone and no breakpoint found in line (cache that).
frame_skips_cache[line_cache_key] = 0

View file

@ -0,0 +1,8 @@
if __name__ == '__main__':
for i in range(2):
print("one")
try:
raise AttributeError() # Breakpoint here
except:
pass
print('TEST SUCEEDED!')

View file

@ -1285,6 +1285,29 @@ class WriterThreadCaseEventExt(debugger_unittest.AbstractWriterThread):
env["VERIFY_EVENT_TEST"] = "1"
return env
#=======================================================================================================================
# WriterThreadCaseSkipBreakpointInExceptions - fix case where breakpoint is skipped after an exception is raised over it
#======================================================================================================================
class WriterThreadCaseSkipBreakpointInExceptions(debugger_unittest.AbstractWriterThread):
TEST_FILE = debugger_unittest._get_debugger_test_file('_debugger_case_skip_breakpoint_in_exceptions.py')
def run(self):
self.start_socket()
self.write_add_breakpoint(5, None)
self.write_make_initial_run()
thread_id, frame_id, line = self.wait_for_breakpoint_hit('111', True)
assert line == 5, 'Expected return to be in line 5, was: %s' % line
self.write_run_thread(thread_id)
thread_id, frame_id, line = self.wait_for_breakpoint_hit('111', True)
assert line == 5, 'Expected return to be in line 5, was: %s' % line
self.write_run_thread(thread_id)
self.finished_ok = True
#=======================================================================================================================
# Test
#=======================================================================================================================
@ -1463,6 +1486,9 @@ class Test(unittest.TestCase, debugger_unittest.DebuggerRunner):
def test_case_event_ext(self):
self.check_case(WriterThreadCaseEventExt)
def test_case_skip_breakpoints_in_exceptions(self):
self.check_case(WriterThreadCaseSkipBreakpointInExceptions)
@pytest.mark.skipif(not IS_CPYTHON, reason='CPython only test.')
class TestPythonRemoteDebugger(unittest.TestCase, debugger_unittest.DebuggerRunner):