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)
| 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 |