From eeba4bc5650dd63a8ec15ecb87a8213fb33beba7 Mon Sep 17 00:00:00 2001 From: fabioz Date: Tue, 17 Jul 2018 16:12:33 -0300 Subject: [PATCH] #72: Provide a way to set breakpoint suspension policy. --- .../pydevd_process_net_command.py | 14 ++-- .../pydevd/tests_python/debugger_unittest.py | 32 +++++++--- .../resources/_debugger_case_remote.py | 3 +- .../resources/_debugger_case_remote_1.py | 3 +- ...bugger_case_remote_unhandled_exceptions.py | 3 +- ...ugger_case_remote_unhandled_exceptions2.py | 3 +- .../_debugger_case_suspend_policy.py | 32 ++++++++++ .../pydevd/tests_python/test_debugger.py | 64 +++++++++++++++---- 8 files changed, 123 insertions(+), 31 deletions(-) create mode 100644 ptvsd/_vendored/pydevd/tests_python/resources/_debugger_case_suspend_policy.py diff --git a/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command.py b/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command.py index 2203ee6ac..3d8f02f40 100644 --- a/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command.py +++ b/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command.py @@ -253,14 +253,18 @@ def process_net_command(py_db, cmd_id, seq, text): # func name: 'None': match anything. Empty: match global, specified: only method context. # command to add some breakpoint. # text is file\tline. Add to breakpoints dictionary - suspend_policy = "NONE" + suspend_policy = "NONE" # Can be 'NONE' or 'ALL' is_logpoint = False hit_condition = None if py_db._set_breakpoints_with_id: try: - breakpoint_id, type, file, line, func_name, condition, expression, hit_condition, is_logpoint = text.split('\t', 8) + try: + breakpoint_id, type, file, line, func_name, condition, expression, hit_condition, is_logpoint, suspend_policy = text.split('\t', 9) + except ValueError: # not enough values to unpack + # No suspend_policy passed (use default). + breakpoint_id, type, file, line, func_name, condition, expression, hit_condition, is_logpoint = text.split('\t', 8) is_logpoint = is_logpoint == 'True' - except Exception: + except ValueError: # not enough values to unpack breakpoint_id, type, file, line, func_name, condition, expression = text.split('\t', 6) breakpoint_id = int(breakpoint_id) @@ -274,8 +278,8 @@ def process_net_command(py_db, cmd_id, seq, text): expression = expression.replace("@_@NEW_LINE_CHAR@_@", '\n').\ replace("@_@TAB_CHAR@_@", '\t').strip() else: - #Note: this else should be removed after PyCharm migrates to setting - #breakpoints by id (and ideally also provides func_name). + # Note: this else should be removed after PyCharm migrates to setting + # breakpoints by id (and ideally also provides func_name). type, file, line, func_name, suspend_policy, condition, expression = text.split('\t', 6) # If we don't have an id given for each breakpoint, consider # the id to be the line. diff --git a/ptvsd/_vendored/pydevd/tests_python/debugger_unittest.py b/ptvsd/_vendored/pydevd/tests_python/debugger_unittest.py index 13f8cefaf..3452afdb5 100644 --- a/ptvsd/_vendored/pydevd/tests_python/debugger_unittest.py +++ b/ptvsd/_vendored/pydevd/tests_python/debugger_unittest.py @@ -502,16 +502,25 @@ def wait_for_breakpoint_hit(self, *args, **kwargs): def wait_for_breakpoint_hit_with_suspend_type(self, reason=REASON_STOP_ON_BREAKPOINT, get_line=False, get_name=False): ''' - 108 is over - 109 is return - 111 is breakpoint + 108 is over + 109 is return + 111 is breakpoint + + :param reason: may be the actual reason (int or string) or a list of reasons. ''' self.log.append('Start: wait_for_breakpoint_hit') # wait for hit breakpoint - last = self.reader_thread.get_next_message('wait_for_breakpoint_hit. reason=%s' % (reason,)) - while not ('stop_reason="%s"' % reason) in last: + if not isinstance(reason, (list, tuple)): + reason = (reason,) + while True: last = self.reader_thread.get_next_message('wait_for_breakpoint_hit. reason=%s' % (reason,)) - + found = False + for r in reason: + if ('stop_reason="%s"' % (r,)) in last: + found = True + break + if found: + break # we have something like