Created
October 14, 2021 17:23
-
-
Save leveled/85c283b479320a0fd279a71edb4843ad to your computer and use it in GitHub Desktop.
GDB Python Boilerplate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gdb | |
class SimpleCommand(gdb.Command): | |
def __init__(self): | |
# This registers our class as "simple_command" | |
super(SimpleCommand, self).__init__("simple_command", gdb.COMMAND_DATA) | |
def invoke(self, arg, from_tty): | |
# When we call "simple_command" from gdb, this is the method | |
# that will be called. | |
print("Hello from simple_command!") | |
# This registers our class to the gdb runtime at "source" time. | |
SimpleCommand() | |
""" | |
(gdb) source debug_naughty.py | |
(gdb) simple_command | |
Hello from simple_command! | |
(gdb) | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment