MCPcopy Create free account
hub / github.com/HexHive/NASS / GefRestoreCommand

Class GefRestoreCommand

tools/gef.py:9742–9788  ·  view source on GitHub ↗

GEF restore sub-command. Loads settings from file '~/.gef.rc' and apply them to the configuration of GEF.

Source from the content-addressed store, hash-verified

9740
9741
9742class GefRestoreCommand(gdb.Command):
9743 """GEF restore sub-command.
9744 Loads settings from file '~/.gef.rc' and apply them to the configuration of GEF."""
9745 _cmdline_ = "gef restore"
9746 _syntax_ = _cmdline_
9747
9748 def __init__(self) -> None:
9749 super().__init__(self._cmdline_, gdb.COMMAND_SUPPORT, gdb.COMPLETE_NONE, False)
9750 self.reload(True)
9751 return
9752
9753 def invoke(self, args: str, from_tty: bool) -> None:
9754 self.dont_repeat()
9755 if GEF_RC.is_file():
9756 quiet = (args.lower() == "quiet")
9757 self.reload(quiet)
9758 return
9759
9760 def reload(self, quiet: bool):
9761 cfg = configparser.ConfigParser()
9762 cfg.read(GEF_RC)
9763
9764 for section in cfg.sections():
9765 if section == "aliases":
9766 # load the aliases
9767 for key in cfg.options(section):
9768 try:
9769 GefAlias(key, cfg.get(section, key))
9770 except:
9771 pass
9772 continue
9773
9774 # load the other options
9775 for optname in cfg.options(section):
9776 key = f"{section}.{optname}"
9777 try:
9778 setting = gef.config.raw_entry(key)
9779 except Exception:
9780 continue
9781 new_value = cfg.get(section, optname)
9782 if setting.type == bool:
9783 new_value = True if new_value.upper() in ("TRUE", "T", "1") else False
9784 setting.value = setting.type(new_value)
9785
9786 if not quiet:
9787 ok(f"Configuration from '{Color.colorify(str(GEF_RC), 'bold blue')}' restored")
9788 return
9789
9790
9791class GefMissingCommand(gdb.Command):

Callers 1

setupMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected