def update_frame(self, cmd="", hide=False): """Update the frame sign.""" if hide: self.frame = {} if self.frame and isinstance(self.frame, dict): line = int(self.frame["line"]) # gdb 6.4 and above if "fullname" in self.frame: source = self.frame["fullname"] else: fullname = self.file["fullname"] source = self.frame["file"] if os.path.basename(fullname) == source: source = fullname pathname = self.get_fullpath(source) if pathname is not None: frame_location = {"pathname": pathname, "lnum": line} if not self.frame_prefix: keys = self.gdb.cmds.keys() keys.remove("frame") self.frame_prefix = misc.smallpref_inlist("frame", keys) # when the frame location has changed or when running the # 'frame' command if self.frame_location != frame_location or cmd.startswith(self.frame_prefix): self.gdb.show_frame(**frame_location) self.frame_location = frame_location return # hide frame sign self.gdb.show_frame() self.frame_location = {}
def __init__(self, gdb): """Constructor.""" OobCommand.__init__(self, gdb) assert self.__class__ is not OobGdbCommand assert hasattr(self, 'gdb_cmd') and isinstance(self.gdb_cmd, str) self.mi = not self.gdb_cmd.startswith('-interpreter-exec console') assert hasattr(self, 'info_attribute') \ and isinstance(self.info_attribute, str) \ and hasattr(self.gdb.info, self.info_attribute) assert hasattr(self, 'prefix') \ and isinstance(self.prefix, str) assert hasattr(self, 'regexp') \ and hasattr(self.regexp, 'findall') assert hasattr(self, 'gdblist') \ and isinstance(self.gdblist, bool) if hasattr(self, 'action'): assert hasattr(self.gdb.info, self.action) assert hasattr(self, 'trigger_list') \ and isinstance(self.trigger_list, tuple) assert hasattr(self, 'reqkeys') \ and isinstance(self.reqkeys, set) self.trigger = False # build prefix list that triggers the command after being notified keys = list(set(self.gdb.cmds.keys()).difference(set(self.trigger_list))) self.trigger_prefix = set([misc.smallpref_inlist(x, keys) for x in self.trigger_list])
def __init__(self, gdb): """Constructor.""" OobCommand.__init__(self, gdb) assert self.__class__ is not OobGdbCommand assert hasattr(self, "gdb_cmd") and isinstance(self.gdb_cmd, str) self.mi = not self.gdb_cmd.startswith("-interpreter-exec console") assert ( hasattr(self, "info_attribute") and isinstance(self.info_attribute, str) and hasattr(self.gdb.info, self.info_attribute) ) assert hasattr(self, "prefix") and isinstance(self.prefix, str) assert hasattr(self, "regexp") and hasattr(self.regexp, "findall") assert hasattr(self, "gdblist") and isinstance(self.gdblist, bool) if hasattr(self, "action"): assert hasattr(self.gdb.info, self.action) assert hasattr(self, "trigger_list") and isinstance(self.trigger_list, tuple) assert hasattr(self, "reqkeys") and isinstance(self.reqkeys, set) self.cmd = "" self.trigger = False # build prefix list that triggers the command after being notified keys = list(set(self.gdb.cmds.keys()).difference(set(self.trigger_list))) self.trigger_prefix = set([misc.smallpref_inlist(x, keys) for x in self.trigger_list])
def gdb_cmds(self): """Get the completion lists from gdb and build the GlobalSetup lists. Build the following lists: cmds: gdb commands illegal_cmds_prefix run_cmds_prefix illegal_setargs_prefix """ dash_cmds = [] # list of gdb commands including a '-' firstarg_complt = '' nocomplt_cmds = (self.illegal_cmds + self.filename_complt + self.symbol_complt) # get the list of gdb commands cmdlist = unwrap_stream_record(gdb_batch(self.gdbname, 'complete')) for cmd in cmdlist.splitlines(): if not cmd: continue else: cmd = cmd.split()[0] if cmd in nocomplt_cmds: continue elif '-' in cmd: dash_cmds.append(cmd) else: self.cmds[cmd] = [] firstarg_complt += 'complete %s \n' % cmd # get first arg completion commands cmdlist = unwrap_stream_record(gdb_batch(self.gdbname, firstarg_complt)) for result in cmdlist.splitlines(): matchobj = re_completion.match(result) if matchobj: cmd = matchobj.group('cmd') arg = matchobj.group('arg') rest = matchobj.group('rest') if not rest: self.cmds[cmd].append(arg) else: warning('invalid completion returned by gdb: %s', result) else: error('invalid completion returned by gdb: %s', result) # add file name completion commands for cmd in self.filename_complt: self.cmds[cmd] = None for cmd in self.symbol_complt: self.cmds[cmd] = None # add commands including a '-' and that can't be made to a vim command self.cmds[''] = dash_cmds # add pyclewn commands for cmd, completion in self.pyclewn_cmds.iteritems(): if cmd and cmd != 'help': self.cmds[cmd] = completion keys = list(set(self.cmds.keys()).difference(self.vim_implementation)) self.illegal_cmds_prefix = set([misc.smallpref_inlist(x, keys) for x in (self.illegal_cmds + self.vim_implementation)]) keys = list(set(keys).difference(set(self.run_cmds))) self.run_cmds_prefix = set([misc.smallpref_inlist(x, keys) for x in self.run_cmds]) if 'set' in self.cmds and self.cmds['set']: # remove the illegal arguments self.cmds['set'] = list( set(self.cmds['set']) .difference(set(self.illegal_setargs))) setargs = self.cmds['set'] self.illegal_setargs_prefix = set( [misc.smallpref_inlist(x, setargs) for x in self.illegal_setargs])
def gdb_cmds(self): """Get the completion lists from gdb and build the GlobalSetup lists. Build the following lists: cmds: gdb commands illegal_cmds_prefix run_cmds_prefix illegal_setargs_prefix """ dash_cmds = [] # list of gdb commands including a '-' firstarg_complt = '' nocomplt_cmds = (self.illegal_cmds + self.filename_complt + self.symbol_complt) # get the list of gdb commands cmdlist = unwrap_stream_record(gdb_batch(self.gdbname, 'complete')) for cmd in cmdlist.splitlines(): if not cmd: continue else: cmd = cmd.split()[0] if cmd in nocomplt_cmds: continue elif '-' in cmd: dash_cmds.append(cmd) else: self.cmds[cmd] = [] firstarg_complt += 'complete %s \n' % cmd # get first arg completion commands cmdlist = unwrap_stream_record(gdb_batch(self.gdbname, firstarg_complt)) for result in cmdlist.splitlines(): matchobj = re_completion.match(result) if matchobj: cmd = matchobj.group('cmd') arg = matchobj.group('arg') rest = matchobj.group('rest') if not rest: self.cmds[cmd].append(arg) else: warning('invalid completion returned by gdb: %s', result) else: error('invalid completion returned by gdb: %s', result) # add file name completion commands for cmd in self.filename_complt: self.cmds[cmd] = None for cmd in self.symbol_complt: self.cmds[cmd] = None # add commands including a '-' and that can't be made to a vim command self.cmds[''] = dash_cmds # add pyclewn commands for cmd, completion in self.pyclewn_cmds.iteritems(): if cmd and cmd != 'help': self.cmds[cmd] = completion keys = self.cmds.keys() self.illegal_cmds_prefix = set( [misc.smallpref_inlist(x, keys) for x in self.illegal_cmds]) keys = list(set(keys).difference(set(self.run_cmds))) self.run_cmds_prefix = set( [misc.smallpref_inlist(x, keys) for x in self.run_cmds]) if 'set' in self.cmds and self.cmds['set']: # remove the illegal arguments self.cmds['set'] = list( set(self.cmds['set']).difference(set(self.illegal_setargs))) setargs = self.cmds['set'] self.illegal_setargs_prefix = set([ misc.smallpref_inlist(x, setargs) for x in self.illegal_setargs ])