Wednesday, April 23, 2008

pc/tc for gdb

It would be nice if we can have the equivalent of windbg's pc and tc command in gdb, well, here is how:

def pc

set $continue_flag = 1

ni

while($continue_flag)

set $opcode = *(unsigned char *)$pc

x/i $pc

if ((unsigned int)$opcode == 0xe8)

set $continue_flag = 0

else

ni

end

end

end


def tc

si

set $continue_flag = 1

while($continue_flag)

set $opcode = *(unsigned char *)$pc

x/i $pc

if ((unsigned int)$opcode == 0xe8)

set $continue_flag = 0

else

si

end

end

end