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
def execute(self): session = SessionManager.get_instance() if self._base == None: session['base_uri'] = re.sub('[^/]+$', '', session['file_uri']) else: session['base_uri'] = self._base print("Base URI set to " + session['base_uri'])
def set_args(self, args): session = SessionManager.get_instance() param = args.get(0) if param == None or param == '+': if session['list_e'] != None: self._set_from_end() elif session['line_num'] != None: self._set_around_current() else: self._set_from_start() elif param == '-': if session['list_b'] != None: self._set_from_begin() elif session['line_num'] != None: self._set_around_current() else: self._set_from_start() else: parts = param.split(':', 1) if len(parts) > 1: line = _to_int(parts[0], session.get('line_num', 1)) around = _to_int(parts[1], session['list_size']) self._set_around(line, around) else: line = _to_int(parts[0], session.get('line_num', 1)) self._set_around(line) session['list_b'] = self._begin session['list_e'] = self._end return True
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))
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))
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
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))
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))
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)
def _set_from_end(self): s = SessionManager.get_instance() self._begin = s['list_e'] + 1 self._end = self._begin + s['list_size'] - 1
def _set_from_begin(self): s = SessionManager.get_instance() self._end = s['list_b'] - 1 self._begin = max(1, self._end - s['list_size'] - 1)
def _set_around_current(self): s = SessionManager.get_instance() self._set_around(s['line_num'])
def _set_around(self, line, list_size=None): if list_size == None: s = SessionManager.get_instance() list_size = s['list_size'] self._begin = max(1, line - list_size // 2) self._end = line + list_size // 2
def execute(self): session = SessionManager.get_instance() session['queue'].append(self._text)