Python gdb module 사용법

simplecommand.py

1
2
3
4
5
6
7
8
9
10
11
12
13
14
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()
cs

simplecommand.png

gdb.execute : gdb 명령을 사용할수 있게함

ex) gdb.execute(‘b*(주소값)’), gdb.execute(‘set pagination off’), gdb.execute(‘r’)

int(gdb.parse_and_eval(“$rip”)) : rip 값을 반환

xxd “파일이름” grep 찾을내용
objdump -d 파일 grep xxd값