Skip to content

Instantly share code, notes, and snippets.

@leveled
Created October 14, 2021 17:23
Show Gist options
  • Save leveled/85c283b479320a0fd279a71edb4843ad to your computer and use it in GitHub Desktop.
Save leveled/85c283b479320a0fd279a71edb4843ad to your computer and use it in GitHub Desktop.
GDB Python Boilerplate
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