def on_setbreakpoints_request(self, py_db, request): ''' :param SetBreakpointsRequest request: ''' arguments = request.arguments # : :type arguments: SetBreakpointsArguments filename = arguments.source.path filename = self.api.filename_to_server(filename) func_name = 'None' self.api.remove_all_breakpoints(py_db, filename) btype = 'python-line' suspend_policy = 'ALL' if not filename.lower().endswith('.py'): if self._debug_options.get('DJANGO_DEBUG', False): btype = 'django-line' elif self._debug_options.get('FLASK_DEBUG', False): btype = 'jinja2-line' breakpoints_set = [] for source_breakpoint in arguments.breakpoints: source_breakpoint = SourceBreakpoint(**source_breakpoint) line = source_breakpoint.line condition = source_breakpoint.condition breakpoint_id = line hit_condition = self._get_hit_condition_expression( source_breakpoint.hitCondition) log_message = source_breakpoint.logMessage if not log_message: is_logpoint = None expression = None else: is_logpoint = True expression = convert_dap_log_message_to_expression(log_message) self.api.add_breakpoint(py_db, filename, btype, breakpoint_id, line, condition, func_name, expression, suspend_policy, hit_condition, is_logpoint) # Note that the id is made up (the id for pydevd is unique only within a file, so, the # line is used for it). # Also, the id is currently not used afterwards, so, we don't even keep a mapping. breakpoints_set.append({ 'id': self._next_breakpoint_id(), 'verified': True, 'line': line }) body = {'breakpoints': breakpoints_set} set_breakpoints_response = pydevd_base_schema.build_response( request, kwargs={'body': body}) return NetCommand(CMD_RETURN, 0, set_breakpoints_response, is_json=True)
def on_setbreakpoints_request(self, py_db, request): ''' :param SetBreakpointsRequest request: ''' arguments = request.arguments # : :type arguments: SetBreakpointsArguments filename = arguments.source.path filename = self.api.filename_to_server(filename) func_name = 'None' self.api.remove_all_breakpoints(py_db, filename) btype = 'python-line' suspend_policy = 'ALL' if not filename.lower().endswith('.py'): if self._debug_options.get('DJANGO_DEBUG', False): btype = 'django-line' elif self._debug_options.get('FLASK_DEBUG', False): btype = 'jinja2-line' breakpoints_set = [] for source_breakpoint in arguments.breakpoints: source_breakpoint = SourceBreakpoint(**source_breakpoint) line = source_breakpoint.line condition = source_breakpoint.condition breakpoint_id = line hit_condition = self._get_hit_condition_expression(source_breakpoint.hitCondition) log_message = source_breakpoint.logMessage if not log_message: is_logpoint = None expression = None else: is_logpoint = True expression = convert_dap_log_message_to_expression(log_message) self.api.add_breakpoint( py_db, filename, btype, breakpoint_id, line, condition, func_name, expression, suspend_policy, hit_condition, is_logpoint) # Note that the id is made up (the id for pydevd is unique only within a file, so, the # line is used for it). # Also, the id is currently not used afterwards, so, we don't even keep a mapping. breakpoints_set.append({'id':self._next_breakpoint_id(), 'verified': True, 'line': line}) body = {'breakpoints': breakpoints_set} set_breakpoints_response = pydevd_base_schema.build_response(request, kwargs={'body':body}) return NetCommand(CMD_RETURN, 0, set_breakpoints_response, is_json=True)
def check_dap_log_message(log_message, expected, evaluated, eval_locals=None): ret = convert_dap_log_message_to_expression(log_message) assert ret == expected assert (eval(ret, eval_locals)) == evaluated return ret
def on_setbreakpoints_request(self, py_db, request): ''' :param SetBreakpointsRequest request: ''' if not self._launch_or_attach_request_done: # Note that to validate the breakpoints we need the launch request to be done already # (otherwise the filters wouldn't be set for the breakpoint validation). body = SetBreakpointsResponseBody([]) response = pydevd_base_schema.build_response( request, kwargs={ 'body': body, 'success': False, 'message': 'Breakpoints may only be set after the launch request is received.' }) return NetCommand(CMD_RETURN, 0, response, is_json=True) arguments = request.arguments # : :type arguments: SetBreakpointsArguments # TODO: Path is optional here it could be source reference. filename = self.api.filename_to_str(arguments.source.path) func_name = 'None' self.api.remove_all_breakpoints(py_db, filename) btype = 'python-line' suspend_policy = 'ALL' if not filename.lower().endswith( '.py'): # Note: check based on original file, not mapping. if self._debug_options.get('DJANGO_DEBUG', False): btype = 'django-line' elif self._debug_options.get('FLASK_DEBUG', False): btype = 'jinja2-line' breakpoints_set = [] for source_breakpoint in arguments.breakpoints: source_breakpoint = SourceBreakpoint(**source_breakpoint) line = source_breakpoint.line condition = source_breakpoint.condition breakpoint_id = line hit_condition = self._get_hit_condition_expression( source_breakpoint.hitCondition) log_message = source_breakpoint.logMessage if not log_message: is_logpoint = None expression = None else: is_logpoint = True expression = convert_dap_log_message_to_expression(log_message) result = self.api.add_breakpoint(py_db, filename, btype, breakpoint_id, line, condition, func_name, expression, suspend_policy, hit_condition, is_logpoint, adjust_line=True) error_code = result.error_code if error_code: if error_code == self.api.ADD_BREAKPOINT_FILE_NOT_FOUND: error_msg = 'Breakpoint in file that does not exist.' elif error_code == self.api.ADD_BREAKPOINT_FILE_EXCLUDED_BY_FILTERS: error_msg = 'Breakpoint in file excluded by filters.' if py_db.get_use_libraries_filter(): error_msg += ( '\nNote: may be excluded because of "justMyCode" option (default == true).' 'Try setting \"justMyCode\": false in the debug configuration (e.g., launch.json).' ) else: # Shouldn't get here. error_msg = 'Breakpoint not validated (reason unknown -- please report as bug).' breakpoints_set.append( pydevd_schema.Breakpoint( verified=False, line=result.translated_line, message=error_msg, source=arguments.source).to_dict()) else: # Note that the id is made up (the id for pydevd is unique only within a file, so, the # line is used for it). # Also, the id is currently not used afterwards, so, we don't even keep a mapping. breakpoints_set.append( pydevd_schema.Breakpoint( verified=True, id=self._next_breakpoint_id(), line=result.translated_line, source=arguments.source).to_dict()) body = {'breakpoints': breakpoints_set} set_breakpoints_response = pydevd_base_schema.build_response( request, kwargs={'body': body}) return NetCommand(CMD_RETURN, 0, set_breakpoints_response, is_json=True)
def on_setbreakpoints_request(self, py_db, request): ''' :param SetBreakpointsRequest request: ''' arguments = request.arguments # : :type arguments: SetBreakpointsArguments # TODO: Path is optional here it could be source reference. filename = arguments.source.path filename = self.api.filename_to_server(filename) func_name = 'None' self.api.remove_all_breakpoints(py_db, filename) # Validate breakpoints and adjust their positions. try: lines = sorted(_get_code_lines(filename)) except Exception: pass else: for bp in arguments.breakpoints: line = bp['line'] if line not in lines: # Adjust to the first preceding valid line. idx = bisect.bisect_left(lines, line) if idx > 0: bp['line'] = lines[idx - 1] btype = 'python-line' suspend_policy = 'ALL' if not filename.lower().endswith('.py'): if self._debug_options.get('DJANGO_DEBUG', False): btype = 'django-line' elif self._debug_options.get('FLASK_DEBUG', False): btype = 'jinja2-line' breakpoints_set = [] for source_breakpoint in arguments.breakpoints: source_breakpoint = SourceBreakpoint(**source_breakpoint) line = source_breakpoint.line condition = source_breakpoint.condition breakpoint_id = line hit_condition = self._get_hit_condition_expression( source_breakpoint.hitCondition) log_message = source_breakpoint.logMessage if not log_message: is_logpoint = None expression = None else: is_logpoint = True expression = convert_dap_log_message_to_expression(log_message) self.api.add_breakpoint(py_db, filename, btype, breakpoint_id, line, condition, func_name, expression, suspend_policy, hit_condition, is_logpoint) # Note that the id is made up (the id for pydevd is unique only within a file, so, the # line is used for it). # Also, the id is currently not used afterwards, so, we don't even keep a mapping. breakpoints_set.append({ 'id': self._next_breakpoint_id(), 'verified': True, 'line': line }) body = {'breakpoints': breakpoints_set} set_breakpoints_response = pydevd_base_schema.build_response( request, kwargs={'body': body}) return NetCommand(CMD_RETURN, 0, set_breakpoints_response, is_json=True)
def on_setbreakpoints_request(self, py_db, request): ''' :param SetBreakpointsRequest request: ''' if not self._launch_or_attach_request_done: # Note that to validate the breakpoints we need the launch request to be done already # (otherwise the filters wouldn't be set for the breakpoint validation). body = SetBreakpointsResponseBody([]) response = pydevd_base_schema.build_response( request, kwargs={ 'body': body, 'success': False, 'message': 'Breakpoints may only be set after the launch request is received.' }) return NetCommand(CMD_RETURN, 0, response, is_json=True) arguments = request.arguments # : :type arguments: SetBreakpointsArguments # TODO: Path is optional here it could be source reference. filename = arguments.source.path filename = self.api.filename_to_server(filename) func_name = 'None' self.api.remove_all_breakpoints(py_db, filename) # Validate breakpoints and adjust their positions. try: lines = sorted(_get_code_lines(filename)) except Exception: pass else: for bp in arguments.breakpoints: line = bp['line'] if line not in lines: # Adjust to the first preceding valid line. idx = bisect.bisect_left(lines, line) if idx > 0: bp['line'] = lines[idx - 1] btype = 'python-line' suspend_policy = 'ALL' if not filename.lower().endswith('.py'): if self._debug_options.get('DJANGO_DEBUG', False): btype = 'django-line' elif self._debug_options.get('FLASK_DEBUG', False): btype = 'jinja2-line' breakpoints_set = [] for source_breakpoint in arguments.breakpoints: source_breakpoint = SourceBreakpoint(**source_breakpoint) line = source_breakpoint.line condition = source_breakpoint.condition breakpoint_id = line hit_condition = self._get_hit_condition_expression(source_breakpoint.hitCondition) log_message = source_breakpoint.logMessage if not log_message: is_logpoint = None expression = None else: is_logpoint = True expression = convert_dap_log_message_to_expression(log_message) error_code = self.api.add_breakpoint( py_db, filename, btype, breakpoint_id, line, condition, func_name, expression, suspend_policy, hit_condition, is_logpoint) if error_code: if error_code == self.api.ADD_BREAKPOINT_FILE_NOT_FOUND: error_msg = 'Breakpoint in file that does not exist.' elif error_code == self.api.ADD_BREAKPOINT_FILE_EXCLUDED_BY_FILTERS: error_msg = 'Breakpoint in file excluded by filters.' if py_db.get_use_libraries_filter(): error_msg += '\nNote: may be excluded because of "justMyCode" option (default == true).' else: # Shouldn't get here. error_msg = 'Breakpoint not validated (reason unknown -- please report as bug).' breakpoints_set.append(pydevd_schema.Breakpoint( verified=False, line=line, message=error_msg).to_dict()) else: # Note that the id is made up (the id for pydevd is unique only within a file, so, the # line is used for it). # Also, the id is currently not used afterwards, so, we don't even keep a mapping. breakpoints_set.append(pydevd_schema.Breakpoint( verified=True, id=self._next_breakpoint_id(), line=line).to_dict()) body = {'breakpoints': breakpoints_set} set_breakpoints_response = pydevd_base_schema.build_response(request, kwargs={'body': body}) return NetCommand(CMD_RETURN, 0, set_breakpoints_response, is_json=True)
def on_setbreakpoints_request(self, py_db, request): ''' :param SetBreakpointsRequest request: ''' arguments = request.arguments # : :type arguments: SetBreakpointsArguments # TODO: Path is optional here it could be source reference. filename = arguments.source.path filename = self.api.filename_to_server(filename) func_name = 'None' self.api.remove_all_breakpoints(py_db, filename) # Validate breakpoints and adjust their positions. try: lines = sorted(_get_code_lines(filename)) except Exception: pass else: for bp in arguments.breakpoints: line = bp['line'] if line not in lines: # Adjust to the first preceding valid line. idx = bisect.bisect_left(lines, line) if idx > 0: bp['line'] = lines[idx - 1] btype = 'python-line' suspend_policy = 'ALL' if not filename.lower().endswith('.py'): if self._debug_options.get('DJANGO_DEBUG', False): btype = 'django-line' elif self._debug_options.get('FLASK_DEBUG', False): btype = 'jinja2-line' breakpoints_set = [] for source_breakpoint in arguments.breakpoints: source_breakpoint = SourceBreakpoint(**source_breakpoint) line = source_breakpoint.line condition = source_breakpoint.condition breakpoint_id = line hit_condition = self._get_hit_condition_expression(source_breakpoint.hitCondition) log_message = source_breakpoint.logMessage if not log_message: is_logpoint = None expression = None else: is_logpoint = True expression = convert_dap_log_message_to_expression(log_message) self.api.add_breakpoint( py_db, filename, btype, breakpoint_id, line, condition, func_name, expression, suspend_policy, hit_condition, is_logpoint) # Note that the id is made up (the id for pydevd is unique only within a file, so, the # line is used for it). # Also, the id is currently not used afterwards, so, we don't even keep a mapping. breakpoints_set.append({'id': self._next_breakpoint_id(), 'verified': True, 'line': line}) body = {'breakpoints': breakpoints_set} set_breakpoints_response = pydevd_base_schema.build_response(request, kwargs={'body': body}) return NetCommand(CMD_RETURN, 0, set_breakpoints_response, is_json=True)