def make_get_frame_message(self, seq, payload):
     try:
         return NetCommand(CMD_GET_FRAME, seq, payload)
     except Exception:
         return self.make_error_message(seq, get_exception_traceback_str())
Example #2
0
 def make_version_message(self, seq):
     try:
         return NetCommand(CMD_VERSION, seq, VERSION_STRING)
     except:
         return self.make_error_message(seq, get_exception_traceback_str())
Example #3
0
 def make_thread_resume_single_notification(self, thread_id):
     try:
         return NetCommand(CMD_THREAD_RESUME_SINGLE_NOTIFICATION, 0,
                           json.dumps({'thread_id': thread_id}))
     except:
         return self.make_error_message(0, get_exception_traceback_str())
Example #4
0
 def make_io_message(self, v, ctx):
     category = 'stdout' if int(ctx) == 1 else 'stderr'
     body = OutputEventBody(v, category)
     event = OutputEvent(body)
     return NetCommand(CMD_WRITE_TO_CONSOLE, 0, event, is_json=True)
Example #5
0
 def make_exit_command(self, py_db):
     event = pydevd_schema.TerminatedEvent(
         pydevd_schema.TerminatedEventBody())
     return NetCommand(CMD_EXIT, 0, event, is_json=True)
 def make_show_cython_warning_message(self):
     try:
         return NetCommand(CMD_SHOW_CYTHON_WARNING, 0, '')
     except:
         return self.make_error_message(0, get_exception_traceback_str())
Example #7
0
    def make_thread_killed_message(self, tid):
        msg = pydevd_schema.ThreadEvent(
            pydevd_schema.ThreadEventBody('exited', tid), )

        return NetCommand(CMD_THREAD_KILL, 0, msg, is_json=True)
 def make_send_console_message(self, seq, payload):
     try:
         return NetCommand(CMD_EVALUATE_CONSOLE_EXPRESSION, seq, payload)
     except Exception:
         return self.make_error_message(seq, get_exception_traceback_str())
 def make_custom_operation_message(self, seq, payload):
     try:
         return NetCommand(CMD_RUN_CUSTOM_OPERATION, seq, payload)
     except Exception:
         return self.make_error_message(seq, get_exception_traceback_str())
 def make_send_breakpoint_exception_message(self, seq, payload):
     try:
         return NetCommand(CMD_GET_BREAKPOINT_EXCEPTION, seq, payload)
     except Exception:
         return self.make_error_message(seq, get_exception_traceback_str())
 def make_send_curr_exception_trace_proceeded_message(self, seq, thread_id):
     try:
         return NetCommand(CMD_SEND_CURR_EXCEPTION_TRACE_PROCEEDED, 0,
                           str(thread_id))
     except:
         return self.make_error_message(0, get_exception_traceback_str())
 def make_get_file_contents(self, seq, payload):
     try:
         return NetCommand(CMD_GET_FILE_CONTENTS, seq, payload)
     except Exception:
         return self.make_error_message(seq, get_exception_traceback_str())
 def make_get_completions_message(self, seq, completions, qualifier, start):
     try:
         payload = completions_to_xml(completions)
         return NetCommand(CMD_GET_COMPLETIONS, seq, payload)
     except Exception:
         return self.make_error_message(seq, get_exception_traceback_str())
 def make_evaluate_expression_message(self, seq, payload):
     try:
         return NetCommand(CMD_EVALUATE_EXPRESSION, seq, payload)
     except Exception:
         return self.make_error_message(seq, get_exception_traceback_str())
 def make_thread_created_message(self, thread):
     cmdText = "<xml>" + self._thread_to_xml(thread) + "</xml>"
     return NetCommand(CMD_THREAD_CREATE, 0, cmdText)
 def make_load_source_message(self, seq, source):
     return NetCommand(CMD_LOAD_SOURCE, seq, source)
 def make_process_created_message(self):
     cmdText = '<process/>'
     return NetCommand(CMD_PROCESS_CREATED, 0, cmdText)
 def make_load_source_from_frame_id_message(self, seq, source):
     return NetCommand(CMD_LOAD_SOURCE_FROM_FRAME_ID, seq, source)
 def make_custom_frame_created_message(self, frame_id, frame_description):
     frame_description = pydevd_xml.make_valid_xml_value(frame_description)
     return NetCommand(
         CMD_THREAD_CREATE, 0, '<xml><thread name="%s" id="%s"/></xml>' %
         (frame_description, frame_id))
 def make_input_requested_message(self, started):
     try:
         return NetCommand(CMD_INPUT_REQUESTED, 0, str(started))
     except:
         return self.make_error_message(0, get_exception_traceback_str())
Example #21
0
    def make_get_thread_stack_message(self,
                                      py_db,
                                      seq,
                                      thread_id,
                                      topmost_frame,
                                      fmt,
                                      must_be_suspended=False,
                                      start_frame=0,
                                      levels=0):
        frames = []
        module_events = []

        try:
            # : :type suspended_frames_manager: SuspendedFramesManager
            suspended_frames_manager = py_db.suspended_frames_manager
            frames_list = suspended_frames_manager.get_frames_list(thread_id)
            if frames_list is None:
                # Could not find stack of suspended frame...
                if must_be_suspended:
                    return None
                else:
                    frames_list = pydevd_frame_utils.create_frames_list_from_frame(
                        topmost_frame)

            for frame_id, frame, method_name, original_filename, filename_in_utf8, lineno, applied_mapping in self._iter_visible_frames_info(
                    py_db, frames_list):

                try:
                    module_name = str(frame.f_globals.get('__name__', ''))
                except:
                    module_name = '<unknown>'

                module_events.extend(
                    self.modules_manager.track_module(filename_in_utf8,
                                                      module_name, frame))

                presentation_hint = None
                if not getattr(frame, 'IS_PLUGIN_FRAME',
                               False):  # Never filter out plugin frames!
                    if py_db.is_files_filter_enabled and py_db.apply_files_filter(
                            frame, original_filename, False):
                        continue

                    if not py_db.in_project_scope(frame):
                        presentation_hint = 'subtle'

                formatted_name = self._format_frame_name(
                    fmt, method_name, module_name, lineno, filename_in_utf8)
                source_reference = pydevd_file_utils.get_client_filename_source_reference(
                    filename_in_utf8)

                if not source_reference and not applied_mapping and not os.path.exists(
                        original_filename):
                    if getattr(frame.f_code, 'co_lnotab', None):
                        # Create a source-reference to be used where we provide the source by decompiling the code.
                        # Note: When the time comes to retrieve the source reference in this case, we'll
                        # check the linecache first (see: get_decompiled_source_from_frame_id).
                        source_reference = pydevd_file_utils.create_source_reference_for_frame_id(
                            frame_id)
                    else:
                        # Check if someone added a source reference to the linecache (Python attrs does this).
                        if linecache.getline(original_filename, 1):
                            source_reference = pydevd_file_utils.create_source_reference_for_linecache(
                                original_filename)

                frames.append(
                    pydevd_schema.StackFrame(
                        frame_id,
                        formatted_name,
                        lineno,
                        column=1,
                        source={
                            'path': filename_in_utf8,
                            'sourceReference': source_reference,
                        },
                        presentationHint=presentation_hint).to_dict())
        finally:
            topmost_frame = None

        for module_event in module_events:
            py_db.writer.add_command(module_event)

        total_frames = len(frames)
        stack_frames = frames
        if bool(levels):
            start = start_frame
            end = min(start + levels, total_frames)
            stack_frames = frames[start:end]

        response = pydevd_schema.StackTraceResponse(
            request_seq=seq,
            success=True,
            command='stackTrace',
            body=pydevd_schema.StackTraceResponseBody(
                stackFrames=stack_frames, totalFrames=total_frames))
        return NetCommand(CMD_RETURN, 0, response, is_json=True)
 def make_load_full_value_message(self, seq, payload):
     try:
         return NetCommand(CMD_LOAD_FULL_VALUE, seq, payload)
     except Exception:
         return self.make_error_message(seq, get_exception_traceback_str())
Example #23
0
 def make_input_requested_message(self, started):
     event = pydevd_schema.PydevdInputRequestedEvent(body={})
     return NetCommand(CMD_INPUT_REQUESTED, 0, event, is_json=True)
 def make_get_next_statement_targets_message(self, seq, payload):
     try:
         return NetCommand(CMD_GET_NEXT_STATEMENT_TARGETS, seq, payload)
     except Exception:
         return self.make_error_message(seq, get_exception_traceback_str())
Example #25
0
 def make_variable_changed_message(self, seq, payload):
     # notify debugger that value was changed successfully
     return NetCommand(CMD_RETURN, seq, payload)
 def make_error_message(self, seq, text):
     cmd = NetCommand(CMD_ERROR, seq, text)
     if DebugInfoHolder.DEBUG_TRACE_LEVEL > 2:
         pydev_log.error("Error: %s" % (text, ))
     return cmd
Example #27
0
 def make_thread_killed_message(self, tid):
     try:
         return NetCommand(CMD_THREAD_KILL, 0, str(tid))
     except:
         return self.make_error_message(0, get_exception_traceback_str())
 def make_protocol_set_message(self, seq):
     return NetCommand(CMD_SET_PROTOCOL, seq, '')
Example #29
0
 def make_thread_run_message(self, thread_id, reason):
     try:
         return NetCommand(CMD_THREAD_RUN, 0,
                           "%s\t%s" % (thread_id, reason))
     except:
         return self.make_error_message(0, get_exception_traceback_str())
 def make_get_description_message(self, seq, payload):
     try:
         return NetCommand(CMD_GET_DESCRIPTION, seq, payload)
     except Exception:
         return self.make_error_message(seq, get_exception_traceback_str())