summaryrefslogtreecommitdiff
path: root/tools/debug-debug.gdb
blob: 314e0498a06fdf9d98f9ea33a12e04e5bd427660 (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
# vim: ft=python
# set auto-load safe-path /
python
try:
    gdb.execute('set auto-load safe-path /')
except:
    pass
end
file bin/test-debug-debug
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
rbreak do_breakpoint
set logging off
commands
silent
python hit_breakpoint()
continue
end
run