-
Notifications
You must be signed in to change notification settings - Fork 160
/
Copy pathcontinue_instruction.py
56 lines (49 loc) · 1.3 KB
/
continue_instruction.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""
## Continue until instruction with given opcode
http://stackoverflow.com/questions/14031930/break-on-instruction-with-specific-opcode-in-gdb
TODO break at other breakpoints
"""
class ContinueI(gdb.Command):
"""
Continue until instruction with given opcode.
ci OPCODE
Example:
ci callq
ci mov
"""
def __init__(self):
super().__init__(
'ci',
gdb.COMMAND_BREAKPOINTS,
gdb.COMPLETE_NONE,
False
)
def invoke(self, arg, from_tty):
thread = gdb.inferiors()[0].threads()[0]
while thread.is_valid():
gdb.execute('si', to_string=True)
frame = gdb.selected_frame()
arch = frame.architecture()
pc = gdb.selected_frame().pc()
instruction = arch.disassemble(pc)[0]['asm']
if instruction.startswith('retq '):
gdb.write(instruction + '\n')
break
ContinueI()
#gdb.execute('file big_function.out', to_string=True)
#gdb.execute('start', to_string=True)
#gdb.execute('help ci')
#gdb.execute('disas')
#print()
#gdb.execute('ci callq')
#gdb.execute('disas')
#print()
#gdb.execute('ci callq')
#gdb.execute('disas')
#print()
#gdb.execute('ci callq')
#gdb.execute('disas')
#print()
#gdb.execute('ci callq')
#gdb.execute('disas')
#print()