PythonGDB ,
using python script to handle GDB sequence, such as dump ASM, catch segment fault exceptions, debug, trace back..., it's very useful for me. because i can use this script to catch info what i want to see... as you known, i am a lazy man, typing redundant key words in gdb is very hard for me. XD
- install
- mkdir -p ~/archer/build ~/archer/install
- git clone git://sourceware.org/git/archer.git
- git checkout archer-tromey-python
- cd build/
- ../archer/configure --prefix=$(cd ../install && pwd)
- make all install
- PATH=/Users/Apple/prj/archer/install/bin:$PATH
- gdb
- (gdb) python print 23
- example
- GDB list macro definition
- gdb
- (gdb) python import gdb
- (gdb) gdb.execute('file xx') # = file xx load xx exec file
- (gdb) gdb.execute('b main') # = set break pp in main
- (gdb) gdb.execute('list') # = list
- (gdb) gdb.execute('bt') # = bt list all frames
- (gdb) gdb.execute('disas /m
') - script in python
def gdb_dump(self): try: global DETAIL gdb.execute('file ../add_py/add_py') o = gdb.execute('disas /m add', to_string = True) print "-"*24 print "pyobject asm func(add) call" print "-"*24 if DETAIL == True: logging.info(o) print "len %d" %(len(o.split("\n"))) except IOError as e: print "pyobject gdb dump error"Ref:
PythonGDB
PythonGdbTutorial
Low level debuger
IDAPython
沒有留言:
張貼留言