不是this question的重复,因为我正在通过python接口来处理gdb。
This one是类似的,但没有答案。通过python接口在gdb的断点处执行命令
我伸出Python中的gdb.breakpoint以便它写入特定的寄存器到文件,然后跳转到一个地址:在0x4021ee
,我想写的东西到文件,然后跳转到0x4021f3
然而,command
中的任何内容都不会被执行。
import gdb
class DebugPrintingBreakpoint(gdb.Breakpoint):
def __init__(self, spec, command):
super(DebugPrintingBreakpoint, self).__init__(spec, gdb.BP_BREAKPOINT, internal = False)
self.command = command
def stop(self):
with open('tracer', 'a') as f:
f.write(chr(gdb.parse_and_eval("$rbx")^0x71))
f.close()
return False
gdb.execute("start")
DebugPrintingBreakpoint("*0x4021ee", "jump *0x4021f3")
gdb.execute("continue")
如果我明确地添加到gdb.execute(self.command)
的stop()
末,我得到Python Exception <class 'gdb.error'> Cannot execute this command while the selected thread is running.:
任何人有命令列出的与蟒蛇GDB断点工作的例子吗?