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

Class GefHelpCommand

tools/gef.py:9533–9583  ·  view source on GitHub ↗

GEF help sub-command.

Source from the content-addressed store, hash-verified

9531
9532
9533class GefHelpCommand(gdb.Command):
9534 """GEF help sub-command."""
9535 _cmdline_ = "gef help"
9536 _syntax_ = _cmdline_
9537
9538 def __init__(self) -> None:
9539 super().__init__(self._cmdline_, gdb.COMMAND_SUPPORT, gdb.COMPLETE_NONE, False)
9540 self.docs = []
9541 self.should_refresh = True
9542 self.command_size = 0
9543 return
9544
9545 def invoke(self, args: Any, from_tty: bool) -> None:
9546 self.dont_repeat()
9547 gef_print(titlify("GEF - GDB Enhanced Features"))
9548 gef_print(str(self))
9549 return
9550
9551 def __rebuild(self) -> None:
9552 """Rebuild the documentation."""
9553 for name, cmd in gef.gdb.commands.items():
9554 self += (name, cmd)
9555
9556 self.command_size = len(gef.gdb.commands)
9557 _, cols = get_terminal_size()
9558 separator = HORIZONTAL_LINE*cols
9559 self.__doc__ = f"\n{separator}\n".join(sorted(self.docs))
9560 self.should_refresh = False
9561 return
9562
9563 def __add__(self, command: Tuple[str, GenericCommand]):
9564 """Add command to GEF documentation."""
9565 cmd, class_obj = command
9566 if " " in cmd:
9567 # do not print subcommands in gef help
9568 return self
9569 doc = getattr(class_obj, "__doc__", "").lstrip()
9570 aliases = f"Aliases: {', '.join(class_obj._aliases_)}" if hasattr(class_obj, "_aliases_") else ""
9571 msg = f"{Color.colorify(cmd, 'bold red')}\n{doc}\n{aliases}"
9572 self.docs.append(msg)
9573 return self
9574
9575 def __radd__(self, command: Tuple[str, GenericCommand]):
9576 return self.__add__(command)
9577
9578 def __str__(self) -> str:
9579 """Lazily regenerate the `gef help` object if it was modified"""
9580 # quick check in case the docs have changed
9581 if self.should_refresh or self.command_size != len(gef.gdb.commands):
9582 self.__rebuild()
9583 return self.__doc__ or ""
9584
9585
9586class GefConfigCommand(gdb.Command):

Callers 1

setupMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected