Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Check that removing breakpoints works properly. #1126 #1134

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,15 @@ def _pydev_stop_at_break(line):
abs_path_real_path_and_base = get_abs_path_real_path_and_base_from_frame(frame)
filename = abs_path_real_path_and_base[1]

breakpoints_for_file = debugger.breakpoints.get(filename)

try:
python_breakpoint = breakpoints_for_file[line]
except KeyError:
pydev_log.debug("Couldn't find breakpoint in the file {} on line {}".format(frame.f_code.co_filename, line))
python_breakpoint = debugger.breakpoints[filename][line]
except:
# print("Couldn't find breakpoint in the file %s on line %s" % (frame.f_code.co_filename, line))
# Could be KeyError if line is not there or TypeError if breakpoints_for_file is None.
# Note: using catch-all exception for performance reasons (if the user adds a breakpoint
# and then removes it after hitting it once, this method added for the programmatic
# breakpoint will keep on being called and one of those exceptions will always be raised
# here).
return

if python_breakpoint:
Expand Down
25 changes: 23 additions & 2 deletions src/ptvsd/_vendored/pydevd/tests_python/test_debugger_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def write_make_initial_run(self):
def write_list_threads(self):
return self.wait_for_response(self.write_request(pydevd_schema.ThreadsRequest()))

def write_add_breakpoints(self, lines, filename=None, line_to_info=None):
def write_set_breakpoints(self, lines, filename=None, line_to_info=None):
'''
Adds a breakpoint.
'''
Expand Down Expand Up @@ -102,14 +102,35 @@ def write_disconnect(self):
self.wait_for_response(self.write_request(request))


@pytest.mark.skipif(IS_JYTHON, reason='Must check why it is failing in Jython.')
def test_case_json_change_breaks(case_setup):
with case_setup.test_file('_debugger_case_change_breaks.py') as writer:
json_facade = JsonFacade(writer)

writer.write_set_protocol('http_json')
json_facade.write_launch()
json_facade.write_set_breakpoints(writer.get_line_index_with_content('break 1'))
json_facade.write_make_initial_run()
hit = writer.wait_for_breakpoint_hit()
writer.write_run_thread(hit.thread_id)

hit = writer.wait_for_breakpoint_hit()
writer.write_run_thread(hit.thread_id)

json_facade.write_set_breakpoints([])
writer.write_run_thread(hit.thread_id)

writer.finished_ok = True


@pytest.mark.skipif(IS_JYTHON, reason='Must check why it is failing in Jython.')
def test_case_json_protocol(case_setup):
with case_setup.test_file('_debugger_case_print.py') as writer:
json_facade = JsonFacade(writer)

writer.write_set_protocol('http_json')
json_facade.write_launch()
json_facade.write_add_breakpoints(writer.get_line_index_with_content('Break here'))
json_facade.write_set_breakpoints(writer.get_line_index_with_content('Break here'))
json_facade.write_make_initial_run()

json_facade.wait_for_json_message(ThreadEvent, lambda event: event.body.reason == 'started')
Expand Down