Пример #1
0
    def execute(self):
        session = SessionManager.get_instance()
        conn_mgr = ConnectionManager.get_instance()

        if not session.can_continue():
            print("Engine stopped. Cannot execute list command.")
            return

        if session['line_num'] != None:
            highlight = session['line_num']
        else:
            highlight = None

        if self._name == 'list':
            num_start = self._begin
            args = { '-f': session['file_uri'], '-b': self._begin, '-e': self._end }
        else:
            num_start = 1
            args = { '-f': session['file_uri'] }

        try:
            source_resp = conn_mgr.send_command('source', args)
        except ConnectionManagerException, e:
            session['list_b'] = None
            session['list_e'] = None
            print("Could not fetch source.")
            return
Пример #2
0
    def execute(self):
        session = SessionManager.get_instance()
        conn_mgr = ConnectionManager.get_instance()

        if session['status'] != 'break':
            print("Backtrace not allowed. The engine is not stopped on a line.")
            return

        stack_resp = conn_mgr.send_command('stack_get')
        elems = stack_resp.get_stack_elements()
        print(format_trace(elems))
Пример #3
0
    def execute(self):
        conn_mgr = ConnectionManager.get_instance()

        try:
            get_resp = conn_mgr.send_command('property_get',
                { '-n': self._long_name })
            prop = get_resp.get_property()
            if prop != None:
                if self._name == 'get':
                    print(format_value(prop))
                else:
                    print(format_property(prop))
        except ConnectionManagerException, e:
            print("Get failed: %s" % (e.message))
Пример #4
0
    def execute(self):
        session = SessionManager.get_instance()
        conn_mgr = ConnectionManager.get_instance()

        args = {
            '-t': 'call', 
            '-m': self._func
        }

        if self._class != None:
            args['-a'] = self._class

        resp = conn_mgr.send_command('breakpoint_set', args)

        print("Breakpoint %s set on %s" % (resp.id, self._func))
Пример #5
0
Файл: app.py Проект: gza/pdbg
    def _run_debug_session(self, conn):
        conn_mgr = ConnectionManager.get_instance()
        conn_mgr.set_connection(conn)

        init = conn_mgr.wait_for_response()
        engine_info = init.get_engine_info()

        print("")
        print("Got connection.")

        if engine_info.has_key('engine'):
            engine_str = engine_info['engine']
            if engine_info.has_key('engine_version'):
                engine_str += ' ' + engine_info['engine_version']
            print("Remote engine is: " + engine_str)

        session = SessionManager.get_instance()
        session.reset()

        status_resp = conn_mgr.send_command('status')
        session['status'] = status_resp.status

        if session['status'] == 'break':
            (session['file_uri'], session['line_num']) = conn_mgr.get_position()
        else:
            session['file_uri'] = init.file_uri

        print("Debugging script at uri: " + init.file_uri)
        print("Type help for more information, or quit to exit the program.")

        prev_cmd_line = None

        while True:
            cmd_line = raw_input('>>> ').strip()
            if cmd_line == '' and prev_cmd_line != None:
                cmd_line = prev_cmd_line
            elif cmd_line == '':
                continue

            try:
                command = command_factory(cmd_line)
                command.execute()
            except CommandParserException, e:
                print("Invalid command string: %s" % e.message)
            except ConnectionClosed, e:
                print("Connection was closed remotely.")
                return 
Пример #6
0
    def execute(self):
        session = SessionManager.get_instance()
        conn_mgr = ConnectionManager.get_instance()

        if not session.can_continue():
            print("Engine stopped. Continuation commands not allowed.")
            return

        step_resp = conn_mgr.send_command(self._name)
        status_resp = conn_mgr.send_command('status')

        session['list_b'] = None
        session['list_e'] = None

        session['status'] = status_resp.status
        session['reason'] = status_resp.reason

        if session['status'] in ('stopping', 'stopped'):
            session['line_num'] = None
            session['file_uri'] = None
            print("Engine stopped normally.")
            return

        # on a run command tell the user what happened.
        if self._name == 'run':
            if session['reason'] == 'ok':
                print("Hit breakpoint. Execution halted.")
            elif session['reason'] == 'error':
                print("Hit error. Execution halted.")
            elif session['reason'] == 'aborted':
                print("Engine aborted. Execution halted.")
            elif session['reason'] == 'exception':
                print("Exception occurred. Execution halted.")

        (file_uri, line_num) = conn_mgr.get_position()

        source_resp = conn_mgr.send_command('source',
            { '-f': file_uri, '-b': line_num, '-e': line_num })

        session['file_uri'] = file_uri
        session['line_num'] = line_num
        
        print(file_uri)
        print(format_lines(source_resp.source, line_num))
Пример #7
0
    def execute(self):
        session = SessionManager.get_instance()
        conn_mgr = ConnectionManager.get_instance()

        if self._file_uri == None:
            file_uri = session['file_uri']
        else:
            file_uri = session.append_base_uri(self._file_uri)

        args = {
            '-t': 'line', 
            '-f': file_uri,
            '-n': self._line_num
        }

        resp = conn_mgr.send_command('breakpoint_set', args)

        print("Breakpoint %s set on line %s of %s" % \
            (resp.id, self._line_num, file_uri))
Пример #8
0
    def execute(self):
        conn_mgr = ConnectionManager.get_instance()
        session = SessionManager.get_instance()

        value = session.input('enter value: ')

        if self._name == 'set_str':
            var_type = 'string'
        elif self._name == 'set_int':
            var_type = 'int'
        elif self._name == 'set_bool':
            var_type = 'bool'
            if value == 'true':
                value = '1'
            else:
                value = '0'
        elif self._name == 'set_float':
            var_type = 'float'

        try:
            set_resp = conn_mgr.send_command('property_set',
                {'-n': self._long_name, '-t': var_type}, value)
        except ConnectionManagerException, e:
            print("Set failed: %s" % e.message)
Пример #9
0
 def execute(self):
     ConnectionManager.get_instance().close()
     raise CloseCommandException()