-
Notifications
You must be signed in to change notification settings - Fork 3
/
gdb-watch-location.py
34 lines (26 loc) · 1.11 KB
/
gdb-watch-location.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
import gdb
def _watch_location(expr, watch_point_class):
l = gdb.parse_and_eval(expr).address
wp_str = '*(%(type)s)(%(address)s)' % dict(type=l.type, address=l)
gdb.Breakpoint(wp_str, gdb.BP_WATCHPOINT, watch_point_class)
class _WatchLocationCommand(gdb.Command):
'Like "watch -l" in gdb 7.4+'
def __init__(self):
gdb.Command.__init__(self, 'watch-l', gdb.COMMAND_BREAKPOINTS, gdb.COMPLETE_SYMBOL)
def invoke(self, arg, from_tty):
_watch_location(arg, gdb.WP_WRITE)
class _RWatchLocationCommand(gdb.Command):
'Like "rwatch -l" in gdb 7.4+'
def __init__(self):
gdb.Command.__init__(self, 'rwatch-l', gdb.COMMAND_BREAKPOINTS, gdb.COMPLETE_SYMBOL)
def invoke(self, arg, from_tty):
_watch_location(arg, gdb.WP_READ)
class _AWatchLocationCommand(gdb.Command):
'Like "awatch -l" in gdb 7.4+'
def __init__(self):
gdb.Command.__init__(self, 'awatch-l', gdb.COMMAND_BREAKPOINTS, gdb.COMPLETE_SYMBOL)
def invoke(self, arg, from_tty):
_watch_location(arg, gdb.WP_ACCESS)
_WatchLocationCommand()
_RWatchLocationCommand()
_AWatchLocationCommand()