mirror of
https://github.com/libretro/cpp-cheat.git
synced 2024-11-30 04:00:21 +00:00
31 lines
831 B
Python
31 lines
831 B
Python
"""
|
|
Define a new GDB command with Python.
|
|
|
|
https://sourceware.org/gdb/onlinedocs/gdb/Commands-In-Python.html
|
|
"""
|
|
|
|
class NewCmd(gdb.Command):
|
|
# Will appear on help newcmd.
|
|
"docstring"
|
|
def __init__(self):
|
|
super().__init__(
|
|
'newcmd', # Name.
|
|
gdb.COMMAND_NONE, # Category when `help` is entered.
|
|
gdb.COMPLETE_NONE, # No autocomplete.
|
|
False # Take subcommand?
|
|
)
|
|
def invoke(self, arg, from_tty):
|
|
"""
|
|
Everything printed here to stdout is captured by `execute to_string=True`.
|
|
"""
|
|
print('newcmd')
|
|
assert type(arg) is str
|
|
print('arg = ' + arg)
|
|
print('from_tty = ' + str(from_tty))
|
|
# This already registers it.
|
|
NewCmd()
|
|
|
|
gdb.execute('help newcmd')
|
|
print()
|
|
gdb.execute('newcmd a b')
|