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

Class GefConfigCommand

tools/gef.py:9586–9701  ·  view source on GitHub ↗

GEF configuration sub-command This command will help set/view GEF settings for the current debugging session. It is possible to make those changes permanent by running `gef save` (refer to this command help), and/or restore previously saved settings by running `gef restore` (refer he

Source from the content-addressed store, hash-verified

9584
9585
9586class GefConfigCommand(gdb.Command):
9587 """GEF configuration sub-command
9588 This command will help set/view GEF settings for the current debugging session.
9589 It is possible to make those changes permanent by running `gef save` (refer
9590 to this command help), and/or restore previously saved settings by running
9591 `gef restore` (refer help).
9592 """
9593 _cmdline_ = "gef config"
9594 _syntax_ = f"{_cmdline_} [setting_name] [setting_value]"
9595
9596 def __init__(self) -> None:
9597 super().__init__(self._cmdline_, gdb.COMMAND_NONE, prefix=False)
9598 return
9599
9600 def invoke(self, args: str, from_tty: bool) -> None:
9601 self.dont_repeat()
9602 argv = gdb.string_to_argv(args)
9603 argc = len(argv)
9604
9605 if not (0 <= argc <= 2):
9606 err("Invalid number of arguments")
9607 return
9608
9609 if argc == 0:
9610 gef_print(titlify("GEF configuration settings"))
9611 self.print_settings()
9612 return
9613
9614 if argc == 1:
9615 prefix = argv[0]
9616 names = [x for x in gef.config.keys() if x.startswith(prefix)]
9617 if names:
9618 if len(names) == 1:
9619 gef_print(titlify(f"GEF configuration setting: {names[0]}"))
9620 self.print_setting(names[0], verbose=True)
9621 else:
9622 gef_print(titlify(f"GEF configuration settings matching '{argv[0]}'"))
9623 for name in names: self.print_setting(name)
9624 return
9625
9626 self.set_setting(argv)
9627 return
9628
9629 def print_setting(self, plugin_name: str, verbose: bool = False) -> None:
9630 res = gef.config.raw_entry(plugin_name)
9631 string_color = gef.config["theme.dereference_string"]
9632 misc_color = gef.config["theme.dereference_base_address"]
9633
9634 if not res:
9635 return
9636
9637 _setting = Color.colorify(plugin_name, "green")
9638 _type = res.type.__name__
9639 if _type == "str":
9640 _value = f'"{Color.colorify(res.value, string_color)}"'
9641 else:
9642 _value = Color.colorify(res.value, misc_color)
9643

Callers 1

setupMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected