예제 #1
0
    def report_threads(self, msg):
        thread_list = [{
            'id': threading.main_thread().ident,
            'name': threading.main_thread().name
        }]

        thread_body = {'threads': thread_list}
        self.send_msg(bp.ResponseProtocol(msg, body=thread_body))
예제 #2
0
    def disconnect(self, msg):
        assert msg['command'] == 'disconnect'
        self.send_msg(bp.ResponseProtocol(msg))

        if ('terminateDebuggee', True) in msg.items():
            self._active = False
        elif ('terminateDebuggee', False) in msg.items():
            pass
        else:
            self._active = False
예제 #3
0
    def launch(self, msg):
        launchArgs = lp.LaunchProtocol(msg)

        asyArgs = ['asy', '-noV']

        if ('noDebug', True) not in msg['arguments'].items():
            self._debugMode = False

        if os.name != 'nt':
            rx, wx = os.pipe()
            ra, wa = os.pipe()

            os.set_inheritable(rx, True)
            os.set_inheritable(wx, True)
            os.set_inheritable(ra, True)
            os.set_inheritable(wa, True)

            asyArgs += [
                '-inpipe={0:d}'.format(rx), '-outpipe={0:d}'.format(wa)
            ]

            self._fin = os.fdopen(ra, 'r')
            self._fout = os.fdopen(wx, 'w')

        self._fileName = launchArgs.filename
        self._workingDir = launchArgs.workingDir

        if self._workingDir is not None:
            asyArgs += ['-o', self._workingDir]

        self._asyProcess = subprocess.Popen(args=asyArgs,
                                            close_fds=False,
                                            stdout=subprocess.PIPE,
                                            stdin=subprocess.PIPE,
                                            stderr=subprocess.PIPE)

        self._asyReadThread = threading.Thread(target=self.fetch_asy_msg)
        self._asyReadThread.daemon = True
        self._asyReadThread.start()

        # launch

        self._fout.write('enableDbgAdapter();\n')
        # self._fout.write('stop("{0}", 1);\n'.format(self._fileName))
        self.send_msg(bp.ResponseProtocol(msg))
예제 #4
0
    def report_stack_trace(self, msg):

        response = bp.ResponseProtocol(msg)
        filename = self._lastBreakInfo['file']

        # NOTE: Until a proper stackframe is implemented, will remain incomplete.
        response['body'] = {
            'stackFrames': [{
                'id': self.stack_frame_counter,
                'name': 'asyframe',
                'source': {
                    'name': os.path.basename(filename),
                    'path': filename
                },
                'line': self._lastBreakInfo['line'],
                'column': self._lastBreakInfo['col']
            }]
        }

        self.stack_frame_counter += 1
        self.send_msg(response)
예제 #5
0
    def set_breakpoints(self, msg):
        breakpoints_args = df.JSInterface(msg['arguments'])
        filename = breakpoints_args.source.path

        self._breakpoints[filename] = breakpoints_args.breakpoints

        for filename in self._breakpoints:
            for bp_ in self._breakpoints[filename]:
                breakpoint_txt = 'stop("{0}", {1:d});'.format(
                    filename, bp_['line'])
                self._fout.write(breakpoint_txt + '\n')
                log(breakpoint_txt)

        response = bp.ResponseProtocol(msg,
                                       body={
                                           'breakpoints': [{
                                               'verified': False
                                           }] *
                                           len(self._breakpoints[filename])
                                       })

        self.send_msg(response)
예제 #6
0
    def initialize(self, msg):
        response = bp.ResponseProtocol(msg, body=self.capabilites)
        self.send_msg(response)

        initializedEvent = bp.EventProtcol('initialized')
        self.send_msg(initializedEvent)
예제 #7
0
    def finish_config(self, msg):
        self._fout.write('import "{0}" as __entry__;\n'.format(self._fileName))
        self._fout.flush()

        self.send_msg(bp.ResponseProtocol(msg))