-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.rrgdbinit
216 lines (194 loc) · 5.55 KB
/
.rrgdbinit
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
set python print-stack full
python
import re
def gdb_unescape(string):
result = ""
pos = 0
while pos < len(string):
result += chr(int(string[pos:pos+2], 16))
pos += 2
return result
def gdb_escape(string):
result = ""
pos = 0
for curr_char in string:
result += format(ord(curr_char), '02x')
return result
class RRWhere(gdb.Command):
"""Helper to get the location for checkpoints/history. Used by auto-args"""
def __init__(self):
gdb.Command.__init__(self, 'rr-where',
gdb.COMMAND_USER, gdb.COMPLETE_NONE, False)
def invoke(self, arg, from_tty):
#Get the symbol name from 'frame 0' in the format:
# '#0 0x00007f9d81a04c46 in _dl_start (arg=0x7ffee1f1c740) at rtld.c:356
# 356 in rtld.c'
try:
rv = gdb.execute('frame 0', to_string=True)
except:
rv = "???" # This may occurs if we're not running
m = re.match("#0\w*(.*)", rv);
if m:
rv = m.group(1)
else:
rv = rv + "???"
gdb.write(rv)
RRWhere()
class RRCmd(gdb.Command):
def __init__(self, name, auto_args):
gdb.Command.__init__(self, name,
gdb.COMMAND_USER, gdb.COMPLETE_NONE, False)
self.cmd_name = name
self.auto_args = auto_args
def invoke(self, arg, from_tty):
args = gdb.string_to_argv(arg)
self.rr_cmd(args)
def rr_cmd(self, args):
cmd_prefix = "maint packet qRRCmd:" + gdb_escape(self.cmd_name)
argStr = ""
for auto_arg in self.auto_args:
argStr += ":" + gdb_escape(gdb.execute(auto_arg, to_string=True))
for arg in args:
argStr += ":" + gdb_escape(arg)
rv = gdb.execute(cmd_prefix + argStr, to_string=True);
rv_match = re.search('received: "(.*)"', rv, re.MULTILINE);
if not rv_match:
gdb.write("Response error: " + rv)
return
response = gdb_unescape(rv_match.group(1))
gdb.write(response)
def history_push(p):
gdb.execute("rr-history-push", to_string=True)
rr_suppress_run_hook = False
class RRHookRun(gdb.Command):
def __init__(self):
gdb.Command.__init__(self, 'rr-hook-run',
gdb.COMMAND_USER, gdb.COMPLETE_NONE, False)
def invoke(self, arg, from_tty):
thread = int(gdb.parse_and_eval("$_thread"))
if thread != 0 and not rr_suppress_run_hook:
gdb.execute("stepi")
class RRSetSuppressRunHook(gdb.Command):
def __init__(self):
gdb.Command.__init__(self, 'rr-set-suppress-run-hook',
gdb.COMMAND_USER, gdb.COMPLETE_NONE, False)
def invoke(self, arg, from_tty):
rr_suppress_run_hook = arg == '1'
RRHookRun()
RRSetSuppressRunHook()
#Automatically push an history entry when the program execution stops
#(signal, breakpoint).This is fired before an interactive prompt is shown.
#Disabled for now since it's not fully working.
#gdb.events.stop.connect(history_push)
end
python RRCmd('elapsed-time', [])
document elapsed-time
Print elapsed time (in seconds) since the start of the trace, in the 'record' timeline.
end
python RRCmd('when', [])
document when
Print the current rr event number.
end
python RRCmd('when-ticks', [])
document when-ticks
Print the current rr tick count for the current thread.
end
python RRCmd('when-tid', [])
document when-tid
Print the real tid for the current thread.
end
python RRCmd('rr-history-push', [])
document rr-history-push
Push an entry into the rr history.
end
python RRCmd('back', [])
document back
Go back one entry in the rr history.
end
python RRCmd('forward', [])
document forward
Go forward one entry in the rr history.
end
python RRCmd('checkpoint', ['rr-where'])
document checkpoint
create a checkpoint representing a point in the execution
use the 'restart' command to return to the checkpoint
end
python RRCmd('delete checkpoint', [])
document delete checkpoint
remove a checkpoint created with the 'checkpoint' command
end
python RRCmd('info checkpoints', [])
document info checkpoints
list all checkpoints created with the 'checkpoint' command
end
define hookpost-back
frame
end
define hookpost-forward
frame
end
define restart
run c$arg0
end
document restart
restart at checkpoint N
checkpoints are created with the 'checkpoint' command
end
define seek-ticks
run t$arg0
end
document seek-ticks
restart at given ticks value
end
define hook-run
rr-hook-run
end
define hookpost-continue
rr-set-suppress-run-hook 1
end
define hookpost-step
rr-set-suppress-run-hook 1
end
define hookpost-stepi
rr-set-suppress-run-hook 1
end
define hookpost-next
rr-set-suppress-run-hook 1
end
define hookpost-nexti
rr-set-suppress-run-hook 1
end
define hookpost-finish
rr-set-suppress-run-hook 1
end
define hookpost-reverse-continue
rr-set-suppress-run-hook 1
end
define hookpost-reverse-step
rr-set-suppress-run-hook 1
end
define hookpost-reverse-stepi
rr-set-suppress-run-hook 1
end
define hookpost-reverse-finish
rr-set-suppress-run-hook 1
end
define hookpost-run
rr-set-suppress-run-hook 0
end
set unwindonsignal on
handle SIGURG stop
set prompt (rr)
python
import re
m = re.compile('.* ([0-9]+)\.([0-9]+)(\.([0-9]+))?.*').match(gdb.execute('show version', False, True))
ver = int(m.group(1))*10000 + int(m.group(2))*100
if m.group(4):
ver = ver + int(m.group(4))
if ver == 71100:
gdb.write('This version of gdb (7.11.0) has known bugs that break rr. Install 7.11.1 or later.\n', gdb.STDERR)
if ver < 71101:
gdb.execute('set target-async 0')
gdb.execute('maint set target-async 0')
end