MCPcopy Create free account
hub / github.com/microsoft/debugpy / set_breakpoints

Method set_breakpoints

tests/debug/session.py:811–852  ·  view source on GitHub ↗

Sets breakpoints in the specified file, and returns the list of all the corresponding DAP Breakpoint objects in the same order. If lines are specified, it should be an iterable in which every element is either a line number or a string. If it is a string, then it is translat

(self, path, lines)

Source from the content-addressed store, hash-verified

809 self.request("continue", freeze=False)
810
811 def set_breakpoints(self, path, lines):
812 """Sets breakpoints in the specified file, and returns the list of all the
813 corresponding DAP Breakpoint objects in the same order.
814
815 If lines are specified, it should be an iterable in which every element is
816 either a line number or a string. If it is a string, then it is translated
817 to the corresponding line number via get_marked_line_numbers(path).
818
819 If lines=all, breakpoints will be set on all the marked lines in the file.
820 """
821
822 # Don't fetch line markers unless needed - in some cases, the breakpoints
823 # might be set in a file that does not exist on disk (e.g. remote attach).
824 get_marked_line_numbers = lambda: code.get_marked_line_numbers(path)
825
826 if lines is all:
827 lines = get_marked_line_numbers().keys()
828
829 def make_breakpoint(line):
830 if isinstance(line, int):
831 descr = str(line)
832 else:
833 marker = line
834 line = get_marked_line_numbers()[marker]
835 descr = f"{line} (@{marker})"
836 bp_log.append((line, descr))
837 return {"line": line}
838
839 bp_log = []
840 breakpoints = self.request(
841 "setBreakpoints",
842 {
843 "source": {"path": path},
844 "breakpoints": [make_breakpoint(line) for line in lines],
845 },
846 )("breakpoints", json.array())
847
848 bp_log = sorted(bp_log, key=lambda pair: pair[0])
849 bp_log = ", ".join((descr for _, descr in bp_log))
850 log.info("Breakpoints set in {0}: {1}", path, bp_log)
851
852 return breakpoints
853
854 def get_variables(self, *varnames, **kwargs):
855 """Fetches the specified variables from the frame specified by frame_id, or

Callers 15

test_attach_pid_clientFunction · 0.95
test_with_no_outputFunction · 0.80
test_with_tab_in_outputFunction · 0.80
test_redirect_outputFunction · 0.80
test_non_ascii_outputFunction · 0.80
test_pythonw_outputFunction · 0.80
test_with_path_mappingsFunction · 0.80
test_stack_formatFunction · 0.80

Calls 5

requestMethod · 0.95
get_marked_line_numbersFunction · 0.85
keysMethod · 0.80
infoMethod · 0.80
joinMethod · 0.45

Tested by 15

test_attach_pid_clientFunction · 0.76
test_with_no_outputFunction · 0.64
test_with_tab_in_outputFunction · 0.64
test_redirect_outputFunction · 0.64
test_non_ascii_outputFunction · 0.64
test_pythonw_outputFunction · 0.64
test_with_path_mappingsFunction · 0.64
test_stack_formatFunction · 0.64