blob: b50a49b417975bb377a47bd0fd8adbf87e11a791 (
plain) (
blame)
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
57
58
59
60
61
62
63
64
65
|
# vim: ft=python
# set auto-load safe-path /
python
try:
gdb.execute('set auto-load safe-path /')
except:
pass
gdb.execute('file %s' % file_to_load)
end
set logging file /dev/null
set logging redirect on
set logging off
python
import re
import sys
def hit_breakpoint():
sys.stdout.write('.')
value = str(gdb.parse_and_eval('*&value'))
expected = gdb.parse_and_eval('expected').string()
if False and expected.startswith('regex:'):
def compare(value, expected):
m = re.match(expected[6:], value)
return m and m.end() == m.endpos
else:
def compare(value, expected):
return value == expected
if not compare(value, expected):
print('Error: mismatch, aborting ...')
print('actual: %r' % value)
print('expect: %r' % str(expected))
gdb.execute('bt')
sys.exit(1)
end
# register a pretty-printer for 'char *' instead
#set print address off
set print static-members off
set print elements 9999
set print frame-arguments none
set python print-stack full
set logging on
# Workaround "Function... not defined in.." (breakpoints not found) (GDB bug)
# https://sourceware.org/bugzilla/show_bug.cgi?id=15962
# In some gdb versions rbreak works, in some break does.
# This code should work for any.
python
bpoint = gdb.Breakpoint("do_breakpoint")
if bpoint.pending:
print("`break ...` found no breakpoints, trying `rbreak ...`")
bpoint.delete()
gdb.execute("rbreak do_breakpoint")
end
set logging off
commands
silent
python hit_breakpoint()
continue
end
run
|