Commit | Line | Data |
---|---|---|
d02ed0bb MM |
1 | /* Process record and replay target for GDB, the GNU debugger. |
2 | ||
3 | Copyright (C) 2013 Free Software Foundation, Inc. | |
4 | ||
5 | This file is part of GDB. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 3 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
19 | ||
20 | #include "defs.h" | |
21 | #include "gdbcmd.h" | |
22 | #include "regcache.h" | |
23 | #include "gdbthread.h" | |
24 | #include "event-top.h" | |
25 | #include "exceptions.h" | |
26 | #include "completer.h" | |
27 | #include "arch-utils.h" | |
28 | #include "gdbcore.h" | |
29 | #include "exec.h" | |
30 | #include "record.h" | |
31 | #include "record-full.h" | |
32 | #include "elf-bfd.h" | |
33 | #include "gcore.h" | |
34 | #include "event-loop.h" | |
35 | #include "inf-loop.h" | |
36 | #include "gdb_bfd.h" | |
37 | #include "observer.h" | |
38 | ||
39 | #include <signal.h> | |
40 | ||
41 | /* This module implements "target record-full", also known as "process | |
42 | record and replay". This target sits on top of a "normal" target | |
43 | (a target that "has execution"), and provides a record and replay | |
44 | functionality, including reverse debugging. | |
45 | ||
46 | Target record has two modes: recording, and replaying. | |
47 | ||
48 | In record mode, we intercept the to_resume and to_wait methods. | |
49 | Whenever gdb resumes the target, we run the target in single step | |
50 | mode, and we build up an execution log in which, for each executed | |
51 | instruction, we record all changes in memory and register state. | |
52 | This is invisible to the user, to whom it just looks like an | |
53 | ordinary debugging session (except for performance degredation). | |
54 | ||
55 | In replay mode, instead of actually letting the inferior run as a | |
56 | process, we simulate its execution by playing back the recorded | |
57 | execution log. For each instruction in the log, we simulate the | |
58 | instruction's side effects by duplicating the changes that it would | |
59 | have made on memory and registers. */ | |
60 | ||
88d1aa9d | 61 | #define DEFAULT_RECORD_FULL_INSN_MAX_NUM 200000 |
d02ed0bb | 62 | |
88d1aa9d MM |
63 | #define RECORD_FULL_IS_REPLAY \ |
64 | (record_full_list->next || execution_direction == EXEC_REVERSE) | |
d02ed0bb | 65 | |
88d1aa9d | 66 | #define RECORD_FULL_FILE_MAGIC netorder32(0x20091016) |
d02ed0bb MM |
67 | |
68 | /* These are the core structs of the process record functionality. | |
69 | ||
88d1aa9d MM |
70 | A record_full_entry is a record of the value change of a register |
71 | ("record_full_reg") or a part of memory ("record_full_mem"). And each | |
72 | instruction must have a struct record_full_entry ("record_full_end") | |
73 | that indicates that this is the last struct record_full_entry of this | |
d02ed0bb MM |
74 | instruction. |
75 | ||
88d1aa9d MM |
76 | Each struct record_full_entry is linked to "record_full_list" by "prev" |
77 | and "next" pointers. */ | |
d02ed0bb | 78 | |
88d1aa9d | 79 | struct record_full_mem_entry |
d02ed0bb MM |
80 | { |
81 | CORE_ADDR addr; | |
82 | int len; | |
83 | /* Set this flag if target memory for this entry | |
84 | can no longer be accessed. */ | |
85 | int mem_entry_not_accessible; | |
86 | union | |
87 | { | |
88 | gdb_byte *ptr; | |
89 | gdb_byte buf[sizeof (gdb_byte *)]; | |
90 | } u; | |
91 | }; | |
92 | ||
88d1aa9d | 93 | struct record_full_reg_entry |
d02ed0bb MM |
94 | { |
95 | unsigned short num; | |
96 | unsigned short len; | |
97 | union | |
98 | { | |
99 | gdb_byte *ptr; | |
100 | gdb_byte buf[2 * sizeof (gdb_byte *)]; | |
101 | } u; | |
102 | }; | |
103 | ||
88d1aa9d | 104 | struct record_full_end_entry |
d02ed0bb MM |
105 | { |
106 | enum gdb_signal sigval; | |
107 | ULONGEST insn_num; | |
108 | }; | |
109 | ||
88d1aa9d | 110 | enum record_full_type |
d02ed0bb | 111 | { |
88d1aa9d MM |
112 | record_full_end = 0, |
113 | record_full_reg, | |
114 | record_full_mem | |
d02ed0bb MM |
115 | }; |
116 | ||
117 | /* This is the data structure that makes up the execution log. | |
118 | ||
119 | The execution log consists of a single linked list of entries | |
88d1aa9d | 120 | of type "struct record_full_entry". It is doubly linked so that it |
d02ed0bb MM |
121 | can be traversed in either direction. |
122 | ||
123 | The start of the list is anchored by a struct called | |
88d1aa9d MM |
124 | "record_full_first". The pointer "record_full_list" either points |
125 | to the last entry that was added to the list (in record mode), or to | |
126 | the next entry in the list that will be executed (in replay mode). | |
d02ed0bb | 127 | |
88d1aa9d MM |
128 | Each list element (struct record_full_entry), in addition to next |
129 | and prev pointers, consists of a union of three entry types: mem, | |
130 | reg, and end. A field called "type" determines which entry type is | |
d02ed0bb MM |
131 | represented by a given list element. |
132 | ||
133 | Each instruction that is added to the execution log is represented | |
134 | by a variable number of list elements ('entries'). The instruction | |
135 | will have one "reg" entry for each register that is changed by | |
136 | executing the instruction (including the PC in every case). It | |
137 | will also have one "mem" entry for each memory change. Finally, | |
138 | each instruction will have an "end" entry that separates it from | |
139 | the changes associated with the next instruction. */ | |
140 | ||
88d1aa9d | 141 | struct record_full_entry |
d02ed0bb | 142 | { |
88d1aa9d MM |
143 | struct record_full_entry *prev; |
144 | struct record_full_entry *next; | |
145 | enum record_full_type type; | |
d02ed0bb MM |
146 | union |
147 | { | |
148 | /* reg */ | |
88d1aa9d | 149 | struct record_full_reg_entry reg; |
d02ed0bb | 150 | /* mem */ |
88d1aa9d | 151 | struct record_full_mem_entry mem; |
d02ed0bb | 152 | /* end */ |
88d1aa9d | 153 | struct record_full_end_entry end; |
d02ed0bb MM |
154 | } u; |
155 | }; | |
156 | ||
157 | /* If true, query if PREC cannot record memory | |
158 | change of next instruction. */ | |
25ea693b | 159 | int record_full_memory_query = 0; |
d02ed0bb | 160 | |
88d1aa9d | 161 | struct record_full_core_buf_entry |
d02ed0bb | 162 | { |
88d1aa9d | 163 | struct record_full_core_buf_entry *prev; |
d02ed0bb MM |
164 | struct target_section *p; |
165 | bfd_byte *buf; | |
166 | }; | |
167 | ||
168 | /* Record buf with core target. */ | |
88d1aa9d MM |
169 | static gdb_byte *record_full_core_regbuf = NULL; |
170 | static struct target_section *record_full_core_start; | |
171 | static struct target_section *record_full_core_end; | |
172 | static struct record_full_core_buf_entry *record_full_core_buf_list = NULL; | |
d02ed0bb MM |
173 | |
174 | /* The following variables are used for managing the linked list that | |
175 | represents the execution log. | |
176 | ||
88d1aa9d MM |
177 | record_full_first is the anchor that holds down the beginning of |
178 | the list. | |
d02ed0bb | 179 | |
88d1aa9d | 180 | record_full_list serves two functions: |
d02ed0bb MM |
181 | 1) In record mode, it anchors the end of the list. |
182 | 2) In replay mode, it traverses the list and points to | |
183 | the next instruction that must be emulated. | |
184 | ||
88d1aa9d MM |
185 | record_full_arch_list_head and record_full_arch_list_tail are used |
186 | to manage a separate list, which is used to build up the change | |
187 | elements of the currently executing instruction during record mode. | |
188 | When this instruction has been completely annotated in the "arch | |
189 | list", it will be appended to the main execution log. */ | |
d02ed0bb | 190 | |
88d1aa9d MM |
191 | static struct record_full_entry record_full_first; |
192 | static struct record_full_entry *record_full_list = &record_full_first; | |
193 | static struct record_full_entry *record_full_arch_list_head = NULL; | |
194 | static struct record_full_entry *record_full_arch_list_tail = NULL; | |
d02ed0bb | 195 | |
88d1aa9d MM |
196 | /* 1 ask user. 0 auto delete the last struct record_full_entry. */ |
197 | static int record_full_stop_at_limit = 1; | |
d02ed0bb | 198 | /* Maximum allowed number of insns in execution log. */ |
88d1aa9d MM |
199 | static unsigned int record_full_insn_max_num |
200 | = DEFAULT_RECORD_FULL_INSN_MAX_NUM; | |
d02ed0bb | 201 | /* Actual count of insns presently in execution log. */ |
7ee70bf5 | 202 | static unsigned int record_full_insn_num = 0; |
d02ed0bb MM |
203 | /* Count of insns logged so far (may be larger |
204 | than count of insns presently in execution log). */ | |
88d1aa9d | 205 | static ULONGEST record_full_insn_count; |
d02ed0bb MM |
206 | |
207 | /* The target_ops of process record. */ | |
88d1aa9d MM |
208 | static struct target_ops record_full_ops; |
209 | static struct target_ops record_full_core_ops; | |
d02ed0bb MM |
210 | |
211 | /* Command lists for "set/show record full". */ | |
212 | static struct cmd_list_element *set_record_full_cmdlist; | |
213 | static struct cmd_list_element *show_record_full_cmdlist; | |
214 | ||
215 | /* Command list for "record full". */ | |
216 | static struct cmd_list_element *record_full_cmdlist; | |
217 | ||
218 | /* The beneath function pointers. */ | |
88d1aa9d MM |
219 | static struct target_ops *record_full_beneath_to_resume_ops; |
220 | static void (*record_full_beneath_to_resume) (struct target_ops *, ptid_t, int, | |
221 | enum gdb_signal); | |
222 | static struct target_ops *record_full_beneath_to_wait_ops; | |
223 | static ptid_t (*record_full_beneath_to_wait) (struct target_ops *, ptid_t, | |
224 | struct target_waitstatus *, | |
225 | int); | |
226 | static struct target_ops *record_full_beneath_to_store_registers_ops; | |
227 | static void (*record_full_beneath_to_store_registers) (struct target_ops *, | |
228 | struct regcache *, | |
229 | int regno); | |
230 | static struct target_ops *record_full_beneath_to_xfer_partial_ops; | |
4ac248ca | 231 | static target_xfer_partial_ftype *record_full_beneath_to_xfer_partial; |
88d1aa9d MM |
232 | static int |
233 | (*record_full_beneath_to_insert_breakpoint) (struct gdbarch *, | |
234 | struct bp_target_info *); | |
235 | static int | |
236 | (*record_full_beneath_to_remove_breakpoint) (struct gdbarch *, | |
237 | struct bp_target_info *); | |
238 | static int (*record_full_beneath_to_stopped_by_watchpoint) (void); | |
239 | static int (*record_full_beneath_to_stopped_data_address) (struct target_ops *, | |
240 | CORE_ADDR *); | |
241 | static void | |
242 | (*record_full_beneath_to_async) (void (*) (enum inferior_event_type, void *), | |
243 | void *); | |
244 | ||
245 | static void record_full_goto_insn (struct record_full_entry *entry, | |
246 | enum exec_direction_kind dir); | |
85e1311a | 247 | static void record_full_save (const char *recfilename); |
88d1aa9d MM |
248 | |
249 | /* Alloc and free functions for record_full_reg, record_full_mem, and | |
250 | record_full_end entries. */ | |
251 | ||
252 | /* Alloc a record_full_reg record entry. */ | |
253 | ||
254 | static inline struct record_full_entry * | |
255 | record_full_reg_alloc (struct regcache *regcache, int regnum) | |
256 | { | |
257 | struct record_full_entry *rec; | |
d02ed0bb MM |
258 | struct gdbarch *gdbarch = get_regcache_arch (regcache); |
259 | ||
88d1aa9d MM |
260 | rec = xcalloc (1, sizeof (struct record_full_entry)); |
261 | rec->type = record_full_reg; | |
d02ed0bb MM |
262 | rec->u.reg.num = regnum; |
263 | rec->u.reg.len = register_size (gdbarch, regnum); | |
264 | if (rec->u.reg.len > sizeof (rec->u.reg.u.buf)) | |
265 | rec->u.reg.u.ptr = (gdb_byte *) xmalloc (rec->u.reg.len); | |
266 | ||
267 | return rec; | |
268 | } | |
269 | ||
88d1aa9d | 270 | /* Free a record_full_reg record entry. */ |
d02ed0bb MM |
271 | |
272 | static inline void | |
88d1aa9d | 273 | record_full_reg_release (struct record_full_entry *rec) |
d02ed0bb | 274 | { |
88d1aa9d | 275 | gdb_assert (rec->type == record_full_reg); |
d02ed0bb MM |
276 | if (rec->u.reg.len > sizeof (rec->u.reg.u.buf)) |
277 | xfree (rec->u.reg.u.ptr); | |
278 | xfree (rec); | |
279 | } | |
280 | ||
88d1aa9d | 281 | /* Alloc a record_full_mem record entry. */ |
d02ed0bb | 282 | |
88d1aa9d MM |
283 | static inline struct record_full_entry * |
284 | record_full_mem_alloc (CORE_ADDR addr, int len) | |
d02ed0bb | 285 | { |
88d1aa9d | 286 | struct record_full_entry *rec; |
d02ed0bb | 287 | |
88d1aa9d MM |
288 | rec = xcalloc (1, sizeof (struct record_full_entry)); |
289 | rec->type = record_full_mem; | |
d02ed0bb MM |
290 | rec->u.mem.addr = addr; |
291 | rec->u.mem.len = len; | |
292 | if (rec->u.mem.len > sizeof (rec->u.mem.u.buf)) | |
293 | rec->u.mem.u.ptr = (gdb_byte *) xmalloc (len); | |
294 | ||
295 | return rec; | |
296 | } | |
297 | ||
88d1aa9d | 298 | /* Free a record_full_mem record entry. */ |
d02ed0bb MM |
299 | |
300 | static inline void | |
88d1aa9d | 301 | record_full_mem_release (struct record_full_entry *rec) |
d02ed0bb | 302 | { |
88d1aa9d | 303 | gdb_assert (rec->type == record_full_mem); |
d02ed0bb MM |
304 | if (rec->u.mem.len > sizeof (rec->u.mem.u.buf)) |
305 | xfree (rec->u.mem.u.ptr); | |
306 | xfree (rec); | |
307 | } | |
308 | ||
88d1aa9d | 309 | /* Alloc a record_full_end record entry. */ |
d02ed0bb | 310 | |
88d1aa9d MM |
311 | static inline struct record_full_entry * |
312 | record_full_end_alloc (void) | |
d02ed0bb | 313 | { |
88d1aa9d | 314 | struct record_full_entry *rec; |
d02ed0bb | 315 | |
88d1aa9d MM |
316 | rec = xcalloc (1, sizeof (struct record_full_entry)); |
317 | rec->type = record_full_end; | |
d02ed0bb MM |
318 | |
319 | return rec; | |
320 | } | |
321 | ||
88d1aa9d | 322 | /* Free a record_full_end record entry. */ |
d02ed0bb MM |
323 | |
324 | static inline void | |
88d1aa9d | 325 | record_full_end_release (struct record_full_entry *rec) |
d02ed0bb MM |
326 | { |
327 | xfree (rec); | |
328 | } | |
329 | ||
330 | /* Free one record entry, any type. | |
331 | Return entry->type, in case caller wants to know. */ | |
332 | ||
88d1aa9d MM |
333 | static inline enum record_full_type |
334 | record_full_entry_release (struct record_full_entry *rec) | |
d02ed0bb | 335 | { |
88d1aa9d | 336 | enum record_full_type type = rec->type; |
d02ed0bb MM |
337 | |
338 | switch (type) { | |
88d1aa9d MM |
339 | case record_full_reg: |
340 | record_full_reg_release (rec); | |
d02ed0bb | 341 | break; |
88d1aa9d MM |
342 | case record_full_mem: |
343 | record_full_mem_release (rec); | |
d02ed0bb | 344 | break; |
88d1aa9d MM |
345 | case record_full_end: |
346 | record_full_end_release (rec); | |
d02ed0bb MM |
347 | break; |
348 | } | |
349 | return type; | |
350 | } | |
351 | ||
352 | /* Free all record entries in list pointed to by REC. */ | |
353 | ||
354 | static void | |
88d1aa9d | 355 | record_full_list_release (struct record_full_entry *rec) |
d02ed0bb MM |
356 | { |
357 | if (!rec) | |
358 | return; | |
359 | ||
360 | while (rec->next) | |
361 | rec = rec->next; | |
362 | ||
363 | while (rec->prev) | |
364 | { | |
365 | rec = rec->prev; | |
88d1aa9d | 366 | record_full_entry_release (rec->next); |
d02ed0bb MM |
367 | } |
368 | ||
88d1aa9d | 369 | if (rec == &record_full_first) |
d02ed0bb | 370 | { |
88d1aa9d MM |
371 | record_full_insn_num = 0; |
372 | record_full_first.next = NULL; | |
d02ed0bb MM |
373 | } |
374 | else | |
88d1aa9d | 375 | record_full_entry_release (rec); |
d02ed0bb MM |
376 | } |
377 | ||
378 | /* Free all record entries forward of the given list position. */ | |
379 | ||
380 | static void | |
88d1aa9d | 381 | record_full_list_release_following (struct record_full_entry *rec) |
d02ed0bb | 382 | { |
88d1aa9d | 383 | struct record_full_entry *tmp = rec->next; |
d02ed0bb MM |
384 | |
385 | rec->next = NULL; | |
386 | while (tmp) | |
387 | { | |
388 | rec = tmp->next; | |
88d1aa9d | 389 | if (record_full_entry_release (tmp) == record_full_end) |
d02ed0bb | 390 | { |
88d1aa9d MM |
391 | record_full_insn_num--; |
392 | record_full_insn_count--; | |
d02ed0bb MM |
393 | } |
394 | tmp = rec; | |
395 | } | |
396 | } | |
397 | ||
398 | /* Delete the first instruction from the beginning of the log, to make | |
399 | room for adding a new instruction at the end of the log. | |
400 | ||
88d1aa9d | 401 | Note -- this function does not modify record_full_insn_num. */ |
d02ed0bb MM |
402 | |
403 | static void | |
88d1aa9d | 404 | record_full_list_release_first (void) |
d02ed0bb | 405 | { |
88d1aa9d | 406 | struct record_full_entry *tmp; |
d02ed0bb | 407 | |
88d1aa9d | 408 | if (!record_full_first.next) |
d02ed0bb MM |
409 | return; |
410 | ||
88d1aa9d | 411 | /* Loop until a record_full_end. */ |
d02ed0bb MM |
412 | while (1) |
413 | { | |
88d1aa9d MM |
414 | /* Cut record_full_first.next out of the linked list. */ |
415 | tmp = record_full_first.next; | |
416 | record_full_first.next = tmp->next; | |
417 | tmp->next->prev = &record_full_first; | |
d02ed0bb MM |
418 | |
419 | /* tmp is now isolated, and can be deleted. */ | |
88d1aa9d MM |
420 | if (record_full_entry_release (tmp) == record_full_end) |
421 | break; /* End loop at first record_full_end. */ | |
d02ed0bb | 422 | |
88d1aa9d | 423 | if (!record_full_first.next) |
d02ed0bb | 424 | { |
88d1aa9d | 425 | gdb_assert (record_full_insn_num == 1); |
d02ed0bb MM |
426 | break; /* End loop when list is empty. */ |
427 | } | |
428 | } | |
429 | } | |
430 | ||
88d1aa9d | 431 | /* Add a struct record_full_entry to record_full_arch_list. */ |
d02ed0bb MM |
432 | |
433 | static void | |
88d1aa9d | 434 | record_full_arch_list_add (struct record_full_entry *rec) |
d02ed0bb MM |
435 | { |
436 | if (record_debug > 1) | |
437 | fprintf_unfiltered (gdb_stdlog, | |
88d1aa9d | 438 | "Process record: record_full_arch_list_add %s.\n", |
d02ed0bb MM |
439 | host_address_to_string (rec)); |
440 | ||
88d1aa9d | 441 | if (record_full_arch_list_tail) |
d02ed0bb | 442 | { |
88d1aa9d MM |
443 | record_full_arch_list_tail->next = rec; |
444 | rec->prev = record_full_arch_list_tail; | |
445 | record_full_arch_list_tail = rec; | |
d02ed0bb MM |
446 | } |
447 | else | |
448 | { | |
88d1aa9d MM |
449 | record_full_arch_list_head = rec; |
450 | record_full_arch_list_tail = rec; | |
d02ed0bb MM |
451 | } |
452 | } | |
453 | ||
454 | /* Return the value storage location of a record entry. */ | |
455 | static inline gdb_byte * | |
88d1aa9d | 456 | record_full_get_loc (struct record_full_entry *rec) |
d02ed0bb MM |
457 | { |
458 | switch (rec->type) { | |
88d1aa9d | 459 | case record_full_mem: |
d02ed0bb MM |
460 | if (rec->u.mem.len > sizeof (rec->u.mem.u.buf)) |
461 | return rec->u.mem.u.ptr; | |
462 | else | |
463 | return rec->u.mem.u.buf; | |
88d1aa9d | 464 | case record_full_reg: |
d02ed0bb MM |
465 | if (rec->u.reg.len > sizeof (rec->u.reg.u.buf)) |
466 | return rec->u.reg.u.ptr; | |
467 | else | |
468 | return rec->u.reg.u.buf; | |
88d1aa9d | 469 | case record_full_end: |
d02ed0bb | 470 | default: |
88d1aa9d | 471 | gdb_assert_not_reached ("unexpected record_full_entry type"); |
d02ed0bb MM |
472 | return NULL; |
473 | } | |
474 | } | |
475 | ||
88d1aa9d | 476 | /* Record the value of a register NUM to record_full_arch_list. */ |
d02ed0bb MM |
477 | |
478 | int | |
25ea693b | 479 | record_full_arch_list_add_reg (struct regcache *regcache, int regnum) |
d02ed0bb | 480 | { |
88d1aa9d | 481 | struct record_full_entry *rec; |
d02ed0bb MM |
482 | |
483 | if (record_debug > 1) | |
484 | fprintf_unfiltered (gdb_stdlog, | |
485 | "Process record: add register num = %d to " | |
486 | "record list.\n", | |
487 | regnum); | |
488 | ||
88d1aa9d | 489 | rec = record_full_reg_alloc (regcache, regnum); |
d02ed0bb | 490 | |
88d1aa9d | 491 | regcache_raw_read (regcache, regnum, record_full_get_loc (rec)); |
d02ed0bb | 492 | |
88d1aa9d | 493 | record_full_arch_list_add (rec); |
d02ed0bb MM |
494 | |
495 | return 0; | |
496 | } | |
497 | ||
498 | /* Record the value of a region of memory whose address is ADDR and | |
88d1aa9d | 499 | length is LEN to record_full_arch_list. */ |
d02ed0bb MM |
500 | |
501 | int | |
25ea693b | 502 | record_full_arch_list_add_mem (CORE_ADDR addr, int len) |
d02ed0bb | 503 | { |
88d1aa9d | 504 | struct record_full_entry *rec; |
d02ed0bb MM |
505 | |
506 | if (record_debug > 1) | |
507 | fprintf_unfiltered (gdb_stdlog, | |
508 | "Process record: add mem addr = %s len = %d to " | |
509 | "record list.\n", | |
510 | paddress (target_gdbarch (), addr), len); | |
511 | ||
512 | if (!addr) /* FIXME: Why? Some arch must permit it... */ | |
513 | return 0; | |
514 | ||
88d1aa9d | 515 | rec = record_full_mem_alloc (addr, len); |
d02ed0bb | 516 | |
88d1aa9d MM |
517 | if (record_read_memory (target_gdbarch (), addr, |
518 | record_full_get_loc (rec), len)) | |
d02ed0bb | 519 | { |
88d1aa9d | 520 | record_full_mem_release (rec); |
d02ed0bb MM |
521 | return -1; |
522 | } | |
523 | ||
88d1aa9d | 524 | record_full_arch_list_add (rec); |
d02ed0bb MM |
525 | |
526 | return 0; | |
527 | } | |
528 | ||
88d1aa9d MM |
529 | /* Add a record_full_end type struct record_full_entry to |
530 | record_full_arch_list. */ | |
d02ed0bb MM |
531 | |
532 | int | |
25ea693b | 533 | record_full_arch_list_add_end (void) |
d02ed0bb | 534 | { |
88d1aa9d | 535 | struct record_full_entry *rec; |
d02ed0bb MM |
536 | |
537 | if (record_debug > 1) | |
538 | fprintf_unfiltered (gdb_stdlog, | |
539 | "Process record: add end to arch list.\n"); | |
540 | ||
88d1aa9d | 541 | rec = record_full_end_alloc (); |
d02ed0bb | 542 | rec->u.end.sigval = GDB_SIGNAL_0; |
88d1aa9d | 543 | rec->u.end.insn_num = ++record_full_insn_count; |
d02ed0bb | 544 | |
88d1aa9d | 545 | record_full_arch_list_add (rec); |
d02ed0bb MM |
546 | |
547 | return 0; | |
548 | } | |
549 | ||
550 | static void | |
88d1aa9d | 551 | record_full_check_insn_num (int set_terminal) |
d02ed0bb | 552 | { |
7ee70bf5 | 553 | if (record_full_insn_num == record_full_insn_max_num) |
d02ed0bb | 554 | { |
7ee70bf5 PA |
555 | /* Ask user what to do. */ |
556 | if (record_full_stop_at_limit) | |
d02ed0bb | 557 | { |
7ee70bf5 PA |
558 | int q; |
559 | ||
560 | if (set_terminal) | |
561 | target_terminal_ours (); | |
562 | q = yquery (_("Do you want to auto delete previous execution " | |
563 | "log entries when record/replay buffer becomes " | |
564 | "full (record full stop-at-limit)?")); | |
565 | if (set_terminal) | |
566 | target_terminal_inferior (); | |
567 | if (q) | |
568 | record_full_stop_at_limit = 0; | |
569 | else | |
570 | error (_("Process record: stopped by user.")); | |
d02ed0bb MM |
571 | } |
572 | } | |
573 | } | |
574 | ||
575 | static void | |
88d1aa9d | 576 | record_full_arch_list_cleanups (void *ignore) |
d02ed0bb | 577 | { |
88d1aa9d | 578 | record_full_list_release (record_full_arch_list_tail); |
d02ed0bb MM |
579 | } |
580 | ||
581 | /* Before inferior step (when GDB record the running message, inferior | |
582 | only can step), GDB will call this function to record the values to | |
88d1aa9d | 583 | record_full_list. This function will call gdbarch_process_record to |
d02ed0bb | 584 | record the running message of inferior and set them to |
88d1aa9d | 585 | record_full_arch_list, and add it to record_full_list. */ |
d02ed0bb MM |
586 | |
587 | static int | |
88d1aa9d | 588 | record_full_message (struct regcache *regcache, enum gdb_signal signal) |
d02ed0bb MM |
589 | { |
590 | int ret; | |
591 | struct gdbarch *gdbarch = get_regcache_arch (regcache); | |
88d1aa9d MM |
592 | struct cleanup *old_cleanups |
593 | = make_cleanup (record_full_arch_list_cleanups, 0); | |
d02ed0bb | 594 | |
88d1aa9d MM |
595 | record_full_arch_list_head = NULL; |
596 | record_full_arch_list_tail = NULL; | |
d02ed0bb | 597 | |
88d1aa9d MM |
598 | /* Check record_full_insn_num. */ |
599 | record_full_check_insn_num (1); | |
d02ed0bb MM |
600 | |
601 | /* If gdb sends a signal value to target_resume, | |
602 | save it in the 'end' field of the previous instruction. | |
603 | ||
604 | Maybe process record should record what really happened, | |
605 | rather than what gdb pretends has happened. | |
606 | ||
607 | So if Linux delivered the signal to the child process during | |
608 | the record mode, we will record it and deliver it again in | |
609 | the replay mode. | |
610 | ||
611 | If user says "ignore this signal" during the record mode, then | |
612 | it will be ignored again during the replay mode (no matter if | |
613 | the user says something different, like "deliver this signal" | |
614 | during the replay mode). | |
615 | ||
616 | User should understand that nothing he does during the replay | |
617 | mode will change the behavior of the child. If he tries, | |
618 | then that is a user error. | |
619 | ||
620 | But we should still deliver the signal to gdb during the replay, | |
621 | if we delivered it during the recording. Therefore we should | |
88d1aa9d MM |
622 | record the signal during record_full_wait, not |
623 | record_full_resume. */ | |
624 | if (record_full_list != &record_full_first) /* FIXME better way to check */ | |
d02ed0bb | 625 | { |
88d1aa9d MM |
626 | gdb_assert (record_full_list->type == record_full_end); |
627 | record_full_list->u.end.sigval = signal; | |
d02ed0bb MM |
628 | } |
629 | ||
630 | if (signal == GDB_SIGNAL_0 | |
631 | || !gdbarch_process_record_signal_p (gdbarch)) | |
632 | ret = gdbarch_process_record (gdbarch, | |
633 | regcache, | |
634 | regcache_read_pc (regcache)); | |
635 | else | |
636 | ret = gdbarch_process_record_signal (gdbarch, | |
637 | regcache, | |
638 | signal); | |
639 | ||
640 | if (ret > 0) | |
641 | error (_("Process record: inferior program stopped.")); | |
642 | if (ret < 0) | |
643 | error (_("Process record: failed to record execution log.")); | |
644 | ||
645 | discard_cleanups (old_cleanups); | |
646 | ||
88d1aa9d MM |
647 | record_full_list->next = record_full_arch_list_head; |
648 | record_full_arch_list_head->prev = record_full_list; | |
649 | record_full_list = record_full_arch_list_tail; | |
d02ed0bb | 650 | |
7ee70bf5 | 651 | if (record_full_insn_num == record_full_insn_max_num) |
88d1aa9d | 652 | record_full_list_release_first (); |
d02ed0bb | 653 | else |
88d1aa9d | 654 | record_full_insn_num++; |
d02ed0bb MM |
655 | |
656 | return 1; | |
657 | } | |
658 | ||
88d1aa9d | 659 | struct record_full_message_args { |
d02ed0bb MM |
660 | struct regcache *regcache; |
661 | enum gdb_signal signal; | |
662 | }; | |
663 | ||
664 | static int | |
88d1aa9d | 665 | record_full_message_wrapper (void *args) |
d02ed0bb | 666 | { |
88d1aa9d | 667 | struct record_full_message_args *record_full_args = args; |
d02ed0bb | 668 | |
88d1aa9d MM |
669 | return record_full_message (record_full_args->regcache, |
670 | record_full_args->signal); | |
d02ed0bb MM |
671 | } |
672 | ||
673 | static int | |
88d1aa9d MM |
674 | record_full_message_wrapper_safe (struct regcache *regcache, |
675 | enum gdb_signal signal) | |
d02ed0bb | 676 | { |
88d1aa9d | 677 | struct record_full_message_args args; |
d02ed0bb MM |
678 | |
679 | args.regcache = regcache; | |
680 | args.signal = signal; | |
681 | ||
88d1aa9d MM |
682 | return catch_errors (record_full_message_wrapper, &args, NULL, |
683 | RETURN_MASK_ALL); | |
d02ed0bb MM |
684 | } |
685 | ||
88d1aa9d | 686 | /* Set to 1 if record_full_store_registers and record_full_xfer_partial |
d02ed0bb MM |
687 | doesn't need record. */ |
688 | ||
88d1aa9d | 689 | static int record_full_gdb_operation_disable = 0; |
d02ed0bb MM |
690 | |
691 | struct cleanup * | |
25ea693b | 692 | record_full_gdb_operation_disable_set (void) |
d02ed0bb MM |
693 | { |
694 | struct cleanup *old_cleanups = NULL; | |
695 | ||
696 | old_cleanups = | |
88d1aa9d MM |
697 | make_cleanup_restore_integer (&record_full_gdb_operation_disable); |
698 | record_full_gdb_operation_disable = 1; | |
d02ed0bb MM |
699 | |
700 | return old_cleanups; | |
701 | } | |
702 | ||
703 | /* Flag set to TRUE for target_stopped_by_watchpoint. */ | |
88d1aa9d | 704 | static int record_full_hw_watchpoint = 0; |
d02ed0bb MM |
705 | |
706 | /* Execute one instruction from the record log. Each instruction in | |
707 | the log will be represented by an arbitrary sequence of register | |
708 | entries and memory entries, followed by an 'end' entry. */ | |
709 | ||
710 | static inline void | |
88d1aa9d MM |
711 | record_full_exec_insn (struct regcache *regcache, |
712 | struct gdbarch *gdbarch, | |
713 | struct record_full_entry *entry) | |
d02ed0bb MM |
714 | { |
715 | switch (entry->type) | |
716 | { | |
88d1aa9d | 717 | case record_full_reg: /* reg */ |
d02ed0bb MM |
718 | { |
719 | gdb_byte reg[MAX_REGISTER_SIZE]; | |
720 | ||
721 | if (record_debug > 1) | |
722 | fprintf_unfiltered (gdb_stdlog, | |
88d1aa9d | 723 | "Process record: record_full_reg %s to " |
d02ed0bb MM |
724 | "inferior num = %d.\n", |
725 | host_address_to_string (entry), | |
726 | entry->u.reg.num); | |
727 | ||
728 | regcache_cooked_read (regcache, entry->u.reg.num, reg); | |
729 | regcache_cooked_write (regcache, entry->u.reg.num, | |
88d1aa9d MM |
730 | record_full_get_loc (entry)); |
731 | memcpy (record_full_get_loc (entry), reg, entry->u.reg.len); | |
d02ed0bb MM |
732 | } |
733 | break; | |
734 | ||
88d1aa9d | 735 | case record_full_mem: /* mem */ |
d02ed0bb MM |
736 | { |
737 | /* Nothing to do if the entry is flagged not_accessible. */ | |
738 | if (!entry->u.mem.mem_entry_not_accessible) | |
739 | { | |
740 | gdb_byte *mem = alloca (entry->u.mem.len); | |
741 | ||
742 | if (record_debug > 1) | |
743 | fprintf_unfiltered (gdb_stdlog, | |
88d1aa9d | 744 | "Process record: record_full_mem %s to " |
d02ed0bb MM |
745 | "inferior addr = %s len = %d.\n", |
746 | host_address_to_string (entry), | |
747 | paddress (gdbarch, entry->u.mem.addr), | |
748 | entry->u.mem.len); | |
749 | ||
750 | if (record_read_memory (gdbarch, | |
751 | entry->u.mem.addr, mem, entry->u.mem.len)) | |
752 | entry->u.mem.mem_entry_not_accessible = 1; | |
753 | else | |
754 | { | |
755 | if (target_write_memory (entry->u.mem.addr, | |
88d1aa9d | 756 | record_full_get_loc (entry), |
d02ed0bb MM |
757 | entry->u.mem.len)) |
758 | { | |
759 | entry->u.mem.mem_entry_not_accessible = 1; | |
760 | if (record_debug) | |
761 | warning (_("Process record: error writing memory at " | |
762 | "addr = %s len = %d."), | |
763 | paddress (gdbarch, entry->u.mem.addr), | |
764 | entry->u.mem.len); | |
765 | } | |
766 | else | |
767 | { | |
88d1aa9d MM |
768 | memcpy (record_full_get_loc (entry), mem, |
769 | entry->u.mem.len); | |
d02ed0bb MM |
770 | |
771 | /* We've changed memory --- check if a hardware | |
772 | watchpoint should trap. Note that this | |
773 | presently assumes the target beneath supports | |
774 | continuable watchpoints. On non-continuable | |
775 | watchpoints target, we'll want to check this | |
776 | _before_ actually doing the memory change, and | |
777 | not doing the change at all if the watchpoint | |
778 | traps. */ | |
779 | if (hardware_watchpoint_inserted_in_range | |
780 | (get_regcache_aspace (regcache), | |
781 | entry->u.mem.addr, entry->u.mem.len)) | |
88d1aa9d | 782 | record_full_hw_watchpoint = 1; |
d02ed0bb MM |
783 | } |
784 | } | |
785 | } | |
786 | } | |
787 | break; | |
788 | } | |
789 | } | |
790 | ||
791 | static struct target_ops *tmp_to_resume_ops; | |
792 | static void (*tmp_to_resume) (struct target_ops *, ptid_t, int, | |
793 | enum gdb_signal); | |
794 | static struct target_ops *tmp_to_wait_ops; | |
795 | static ptid_t (*tmp_to_wait) (struct target_ops *, ptid_t, | |
796 | struct target_waitstatus *, | |
797 | int); | |
798 | static struct target_ops *tmp_to_store_registers_ops; | |
799 | static void (*tmp_to_store_registers) (struct target_ops *, | |
800 | struct regcache *, | |
801 | int regno); | |
802 | static struct target_ops *tmp_to_xfer_partial_ops; | |
4ac248ca | 803 | static target_xfer_partial_ftype *tmp_to_xfer_partial; |
d02ed0bb MM |
804 | static int (*tmp_to_insert_breakpoint) (struct gdbarch *, |
805 | struct bp_target_info *); | |
806 | static int (*tmp_to_remove_breakpoint) (struct gdbarch *, | |
807 | struct bp_target_info *); | |
808 | static int (*tmp_to_stopped_by_watchpoint) (void); | |
809 | static int (*tmp_to_stopped_data_address) (struct target_ops *, CORE_ADDR *); | |
810 | static int (*tmp_to_stopped_data_address) (struct target_ops *, CORE_ADDR *); | |
811 | static void (*tmp_to_async) (void (*) (enum inferior_event_type, void *), void *); | |
812 | ||
88d1aa9d | 813 | static void record_full_restore (void); |
d02ed0bb MM |
814 | |
815 | /* Asynchronous signal handle registered as event loop source for when | |
816 | we have pending events ready to be passed to the core. */ | |
817 | ||
88d1aa9d | 818 | static struct async_event_handler *record_full_async_inferior_event_token; |
d02ed0bb MM |
819 | |
820 | static void | |
88d1aa9d | 821 | record_full_async_inferior_event_handler (gdb_client_data data) |
d02ed0bb MM |
822 | { |
823 | inferior_event_handler (INF_REG_EVENT, NULL); | |
824 | } | |
825 | ||
826 | /* Open the process record target. */ | |
827 | ||
828 | static void | |
88d1aa9d | 829 | record_full_core_open_1 (char *name, int from_tty) |
d02ed0bb MM |
830 | { |
831 | struct regcache *regcache = get_current_regcache (); | |
832 | int regnum = gdbarch_num_regs (get_regcache_arch (regcache)); | |
833 | int i; | |
834 | ||
88d1aa9d | 835 | /* Get record_full_core_regbuf. */ |
d02ed0bb | 836 | target_fetch_registers (regcache, -1); |
88d1aa9d | 837 | record_full_core_regbuf = xmalloc (MAX_REGISTER_SIZE * regnum); |
d02ed0bb MM |
838 | for (i = 0; i < regnum; i ++) |
839 | regcache_raw_collect (regcache, i, | |
88d1aa9d | 840 | record_full_core_regbuf + MAX_REGISTER_SIZE * i); |
d02ed0bb | 841 | |
88d1aa9d MM |
842 | /* Get record_full_core_start and record_full_core_end. */ |
843 | if (build_section_table (core_bfd, &record_full_core_start, | |
844 | &record_full_core_end)) | |
d02ed0bb | 845 | { |
88d1aa9d MM |
846 | xfree (record_full_core_regbuf); |
847 | record_full_core_regbuf = NULL; | |
d02ed0bb MM |
848 | error (_("\"%s\": Can't find sections: %s"), |
849 | bfd_get_filename (core_bfd), bfd_errmsg (bfd_get_error ())); | |
850 | } | |
851 | ||
88d1aa9d MM |
852 | push_target (&record_full_core_ops); |
853 | record_full_restore (); | |
d02ed0bb MM |
854 | } |
855 | ||
856 | /* "to_open" target method for 'live' processes. */ | |
857 | ||
858 | static void | |
88d1aa9d | 859 | record_full_open_1 (char *name, int from_tty) |
d02ed0bb MM |
860 | { |
861 | if (record_debug) | |
88d1aa9d | 862 | fprintf_unfiltered (gdb_stdlog, "Process record: record_full_open\n"); |
d02ed0bb MM |
863 | |
864 | /* check exec */ | |
865 | if (!target_has_execution) | |
866 | error (_("Process record: the program is not being run.")); | |
867 | if (non_stop) | |
868 | error (_("Process record target can't debug inferior in non-stop mode " | |
869 | "(non-stop).")); | |
870 | ||
871 | if (!gdbarch_process_record_p (target_gdbarch ())) | |
872 | error (_("Process record: the current architecture doesn't support " | |
873 | "record function.")); | |
874 | ||
875 | if (!tmp_to_resume) | |
876 | error (_("Could not find 'to_resume' method on the target stack.")); | |
877 | if (!tmp_to_wait) | |
878 | error (_("Could not find 'to_wait' method on the target stack.")); | |
879 | if (!tmp_to_store_registers) | |
880 | error (_("Could not find 'to_store_registers' " | |
881 | "method on the target stack.")); | |
882 | if (!tmp_to_insert_breakpoint) | |
883 | error (_("Could not find 'to_insert_breakpoint' " | |
884 | "method on the target stack.")); | |
885 | if (!tmp_to_remove_breakpoint) | |
886 | error (_("Could not find 'to_remove_breakpoint' " | |
887 | "method on the target stack.")); | |
888 | if (!tmp_to_stopped_by_watchpoint) | |
889 | error (_("Could not find 'to_stopped_by_watchpoint' " | |
890 | "method on the target stack.")); | |
891 | if (!tmp_to_stopped_data_address) | |
892 | error (_("Could not find 'to_stopped_data_address' " | |
893 | "method on the target stack.")); | |
894 | ||
88d1aa9d | 895 | push_target (&record_full_ops); |
d02ed0bb MM |
896 | } |
897 | ||
88d1aa9d | 898 | static void record_full_init_record_breakpoints (void); |
d02ed0bb MM |
899 | |
900 | /* "to_open" target method. Open the process record target. */ | |
901 | ||
902 | static void | |
88d1aa9d | 903 | record_full_open (char *name, int from_tty) |
d02ed0bb MM |
904 | { |
905 | struct target_ops *t; | |
906 | ||
907 | if (record_debug) | |
88d1aa9d | 908 | fprintf_unfiltered (gdb_stdlog, "Process record: record_full_open\n"); |
d02ed0bb MM |
909 | |
910 | /* Check if record target is already running. */ | |
911 | if (current_target.to_stratum == record_stratum) | |
912 | error (_("Process record target already running. Use \"record stop\" to " | |
913 | "stop record target first.")); | |
914 | ||
915 | /* Reset the tmp beneath pointers. */ | |
916 | tmp_to_resume_ops = NULL; | |
917 | tmp_to_resume = NULL; | |
918 | tmp_to_wait_ops = NULL; | |
919 | tmp_to_wait = NULL; | |
920 | tmp_to_store_registers_ops = NULL; | |
921 | tmp_to_store_registers = NULL; | |
922 | tmp_to_xfer_partial_ops = NULL; | |
923 | tmp_to_xfer_partial = NULL; | |
924 | tmp_to_insert_breakpoint = NULL; | |
925 | tmp_to_remove_breakpoint = NULL; | |
926 | tmp_to_stopped_by_watchpoint = NULL; | |
927 | tmp_to_stopped_data_address = NULL; | |
928 | tmp_to_async = NULL; | |
929 | ||
930 | /* Set the beneath function pointers. */ | |
931 | for (t = current_target.beneath; t != NULL; t = t->beneath) | |
932 | { | |
933 | if (!tmp_to_resume) | |
934 | { | |
935 | tmp_to_resume = t->to_resume; | |
936 | tmp_to_resume_ops = t; | |
937 | } | |
938 | if (!tmp_to_wait) | |
939 | { | |
940 | tmp_to_wait = t->to_wait; | |
941 | tmp_to_wait_ops = t; | |
942 | } | |
943 | if (!tmp_to_store_registers) | |
944 | { | |
945 | tmp_to_store_registers = t->to_store_registers; | |
946 | tmp_to_store_registers_ops = t; | |
947 | } | |
948 | if (!tmp_to_xfer_partial) | |
949 | { | |
950 | tmp_to_xfer_partial = t->to_xfer_partial; | |
951 | tmp_to_xfer_partial_ops = t; | |
952 | } | |
953 | if (!tmp_to_insert_breakpoint) | |
954 | tmp_to_insert_breakpoint = t->to_insert_breakpoint; | |
955 | if (!tmp_to_remove_breakpoint) | |
956 | tmp_to_remove_breakpoint = t->to_remove_breakpoint; | |
957 | if (!tmp_to_stopped_by_watchpoint) | |
958 | tmp_to_stopped_by_watchpoint = t->to_stopped_by_watchpoint; | |
959 | if (!tmp_to_stopped_data_address) | |
960 | tmp_to_stopped_data_address = t->to_stopped_data_address; | |
961 | if (!tmp_to_async) | |
962 | tmp_to_async = t->to_async; | |
963 | } | |
964 | if (!tmp_to_xfer_partial) | |
965 | error (_("Could not find 'to_xfer_partial' method on the target stack.")); | |
966 | ||
967 | /* Reset */ | |
88d1aa9d MM |
968 | record_full_insn_num = 0; |
969 | record_full_insn_count = 0; | |
970 | record_full_list = &record_full_first; | |
971 | record_full_list->next = NULL; | |
d02ed0bb MM |
972 | |
973 | /* Set the tmp beneath pointers to beneath pointers. */ | |
88d1aa9d MM |
974 | record_full_beneath_to_resume_ops = tmp_to_resume_ops; |
975 | record_full_beneath_to_resume = tmp_to_resume; | |
976 | record_full_beneath_to_wait_ops = tmp_to_wait_ops; | |
977 | record_full_beneath_to_wait = tmp_to_wait; | |
978 | record_full_beneath_to_store_registers_ops = tmp_to_store_registers_ops; | |
979 | record_full_beneath_to_store_registers = tmp_to_store_registers; | |
980 | record_full_beneath_to_xfer_partial_ops = tmp_to_xfer_partial_ops; | |
981 | record_full_beneath_to_xfer_partial = tmp_to_xfer_partial; | |
982 | record_full_beneath_to_insert_breakpoint = tmp_to_insert_breakpoint; | |
983 | record_full_beneath_to_remove_breakpoint = tmp_to_remove_breakpoint; | |
984 | record_full_beneath_to_stopped_by_watchpoint = tmp_to_stopped_by_watchpoint; | |
985 | record_full_beneath_to_stopped_data_address = tmp_to_stopped_data_address; | |
986 | record_full_beneath_to_async = tmp_to_async; | |
d02ed0bb MM |
987 | |
988 | if (core_bfd) | |
88d1aa9d | 989 | record_full_core_open_1 (name, from_tty); |
d02ed0bb | 990 | else |
88d1aa9d | 991 | record_full_open_1 (name, from_tty); |
d02ed0bb MM |
992 | |
993 | /* Register extra event sources in the event loop. */ | |
88d1aa9d MM |
994 | record_full_async_inferior_event_token |
995 | = create_async_event_handler (record_full_async_inferior_event_handler, | |
d02ed0bb MM |
996 | NULL); |
997 | ||
88d1aa9d | 998 | record_full_init_record_breakpoints (); |
d02ed0bb MM |
999 | |
1000 | observer_notify_record_changed (current_inferior (), 1); | |
1001 | } | |
1002 | ||
1003 | /* "to_close" target method. Close the process record target. */ | |
1004 | ||
1005 | static void | |
460014f5 | 1006 | record_full_close (void) |
d02ed0bb | 1007 | { |
88d1aa9d | 1008 | struct record_full_core_buf_entry *entry; |
d02ed0bb MM |
1009 | |
1010 | if (record_debug) | |
88d1aa9d | 1011 | fprintf_unfiltered (gdb_stdlog, "Process record: record_full_close\n"); |
d02ed0bb | 1012 | |
88d1aa9d | 1013 | record_full_list_release (record_full_list); |
d02ed0bb | 1014 | |
88d1aa9d MM |
1015 | /* Release record_full_core_regbuf. */ |
1016 | if (record_full_core_regbuf) | |
d02ed0bb | 1017 | { |
88d1aa9d MM |
1018 | xfree (record_full_core_regbuf); |
1019 | record_full_core_regbuf = NULL; | |
d02ed0bb MM |
1020 | } |
1021 | ||
88d1aa9d MM |
1022 | /* Release record_full_core_buf_list. */ |
1023 | if (record_full_core_buf_list) | |
d02ed0bb | 1024 | { |
88d1aa9d MM |
1025 | for (entry = record_full_core_buf_list->prev; entry; |
1026 | entry = entry->prev) | |
d02ed0bb | 1027 | { |
88d1aa9d MM |
1028 | xfree (record_full_core_buf_list); |
1029 | record_full_core_buf_list = entry; | |
d02ed0bb | 1030 | } |
88d1aa9d | 1031 | record_full_core_buf_list = NULL; |
d02ed0bb MM |
1032 | } |
1033 | ||
88d1aa9d MM |
1034 | if (record_full_async_inferior_event_token) |
1035 | delete_async_event_handler (&record_full_async_inferior_event_token); | |
d02ed0bb MM |
1036 | } |
1037 | ||
88d1aa9d | 1038 | static int record_full_resume_step = 0; |
d02ed0bb | 1039 | |
88d1aa9d MM |
1040 | /* True if we've been resumed, and so each record_full_wait call should |
1041 | advance execution. If this is false, record_full_wait will return a | |
d02ed0bb | 1042 | TARGET_WAITKIND_IGNORE. */ |
88d1aa9d | 1043 | static int record_full_resumed = 0; |
d02ed0bb MM |
1044 | |
1045 | /* The execution direction of the last resume we got. This is | |
1046 | necessary for async mode. Vis (order is not strictly accurate): | |
1047 | ||
1048 | 1. user has the global execution direction set to forward | |
1049 | 2. user does a reverse-step command | |
88d1aa9d | 1050 | 3. record_full_resume is called with global execution direction |
d02ed0bb MM |
1051 | temporarily switched to reverse |
1052 | 4. GDB's execution direction is reverted back to forward | |
1053 | 5. target record notifies event loop there's an event to handle | |
1054 | 6. infrun asks the target which direction was it going, and switches | |
1055 | the global execution direction accordingly (to reverse) | |
1056 | 7. infrun polls an event out of the record target, and handles it | |
1057 | 8. GDB goes back to the event loop, and goto #4. | |
1058 | */ | |
88d1aa9d | 1059 | static enum exec_direction_kind record_full_execution_dir = EXEC_FORWARD; |
d02ed0bb MM |
1060 | |
1061 | /* "to_resume" target method. Resume the process record target. */ | |
1062 | ||
1063 | static void | |
88d1aa9d MM |
1064 | record_full_resume (struct target_ops *ops, ptid_t ptid, int step, |
1065 | enum gdb_signal signal) | |
d02ed0bb | 1066 | { |
88d1aa9d MM |
1067 | record_full_resume_step = step; |
1068 | record_full_resumed = 1; | |
1069 | record_full_execution_dir = execution_direction; | |
d02ed0bb | 1070 | |
88d1aa9d | 1071 | if (!RECORD_FULL_IS_REPLAY) |
d02ed0bb MM |
1072 | { |
1073 | struct gdbarch *gdbarch = target_thread_architecture (ptid); | |
1074 | ||
88d1aa9d | 1075 | record_full_message (get_current_regcache (), signal); |
d02ed0bb MM |
1076 | |
1077 | if (!step) | |
1078 | { | |
1079 | /* This is not hard single step. */ | |
1080 | if (!gdbarch_software_single_step_p (gdbarch)) | |
1081 | { | |
1082 | /* This is a normal continue. */ | |
1083 | step = 1; | |
1084 | } | |
1085 | else | |
1086 | { | |
1087 | /* This arch support soft sigle step. */ | |
1088 | if (single_step_breakpoints_inserted ()) | |
1089 | { | |
1090 | /* This is a soft single step. */ | |
88d1aa9d | 1091 | record_full_resume_step = 1; |
d02ed0bb MM |
1092 | } |
1093 | else | |
1094 | { | |
1095 | /* This is a continue. | |
1096 | Try to insert a soft single step breakpoint. */ | |
1097 | if (!gdbarch_software_single_step (gdbarch, | |
1098 | get_current_frame ())) | |
1099 | { | |
1100 | /* This system don't want use soft single step. | |
1101 | Use hard sigle step. */ | |
1102 | step = 1; | |
1103 | } | |
1104 | } | |
1105 | } | |
1106 | } | |
1107 | ||
1108 | /* Make sure the target beneath reports all signals. */ | |
1109 | target_pass_signals (0, NULL); | |
1110 | ||
88d1aa9d MM |
1111 | record_full_beneath_to_resume (record_full_beneath_to_resume_ops, |
1112 | ptid, step, signal); | |
d02ed0bb MM |
1113 | } |
1114 | ||
1115 | /* We are about to start executing the inferior (or simulate it), | |
1116 | let's register it with the event loop. */ | |
1117 | if (target_can_async_p ()) | |
1118 | { | |
1119 | target_async (inferior_event_handler, 0); | |
1120 | /* Notify the event loop there's an event to wait for. We do | |
88d1aa9d MM |
1121 | most of the work in record_full_wait. */ |
1122 | mark_async_event_handler (record_full_async_inferior_event_token); | |
d02ed0bb MM |
1123 | } |
1124 | } | |
1125 | ||
88d1aa9d | 1126 | static int record_full_get_sig = 0; |
d02ed0bb MM |
1127 | |
1128 | /* SIGINT signal handler, registered by "to_wait" method. */ | |
1129 | ||
1130 | static void | |
88d1aa9d | 1131 | record_full_sig_handler (int signo) |
d02ed0bb MM |
1132 | { |
1133 | if (record_debug) | |
1134 | fprintf_unfiltered (gdb_stdlog, "Process record: get a signal\n"); | |
1135 | ||
1136 | /* It will break the running inferior in replay mode. */ | |
88d1aa9d | 1137 | record_full_resume_step = 1; |
d02ed0bb | 1138 | |
88d1aa9d | 1139 | /* It will let record_full_wait set inferior status to get the signal |
d02ed0bb | 1140 | SIGINT. */ |
88d1aa9d | 1141 | record_full_get_sig = 1; |
d02ed0bb MM |
1142 | } |
1143 | ||
1144 | static void | |
88d1aa9d | 1145 | record_full_wait_cleanups (void *ignore) |
d02ed0bb MM |
1146 | { |
1147 | if (execution_direction == EXEC_REVERSE) | |
1148 | { | |
88d1aa9d MM |
1149 | if (record_full_list->next) |
1150 | record_full_list = record_full_list->next; | |
d02ed0bb MM |
1151 | } |
1152 | else | |
88d1aa9d | 1153 | record_full_list = record_full_list->prev; |
d02ed0bb MM |
1154 | } |
1155 | ||
1156 | /* "to_wait" target method for process record target. | |
1157 | ||
1158 | In record mode, the target is always run in singlestep mode | |
1159 | (even when gdb says to continue). The to_wait method intercepts | |
1160 | the stop events and determines which ones are to be passed on to | |
1161 | gdb. Most stop events are just singlestep events that gdb is not | |
1162 | to know about, so the to_wait method just records them and keeps | |
1163 | singlestepping. | |
1164 | ||
1165 | In replay mode, this function emulates the recorded execution log, | |
1166 | one instruction at a time (forward or backward), and determines | |
1167 | where to stop. */ | |
1168 | ||
1169 | static ptid_t | |
88d1aa9d MM |
1170 | record_full_wait_1 (struct target_ops *ops, |
1171 | ptid_t ptid, struct target_waitstatus *status, | |
1172 | int options) | |
d02ed0bb | 1173 | { |
25ea693b | 1174 | struct cleanup *set_cleanups = record_full_gdb_operation_disable_set (); |
d02ed0bb MM |
1175 | |
1176 | if (record_debug) | |
1177 | fprintf_unfiltered (gdb_stdlog, | |
88d1aa9d MM |
1178 | "Process record: record_full_wait " |
1179 | "record_full_resume_step = %d, " | |
1180 | "record_full_resumed = %d, direction=%s\n", | |
1181 | record_full_resume_step, record_full_resumed, | |
1182 | record_full_execution_dir == EXEC_FORWARD | |
1183 | ? "forward" : "reverse"); | |
1184 | ||
1185 | if (!record_full_resumed) | |
d02ed0bb MM |
1186 | { |
1187 | gdb_assert ((options & TARGET_WNOHANG) != 0); | |
1188 | ||
1189 | /* No interesting event. */ | |
1190 | status->kind = TARGET_WAITKIND_IGNORE; | |
1191 | return minus_one_ptid; | |
1192 | } | |
1193 | ||
88d1aa9d MM |
1194 | record_full_get_sig = 0; |
1195 | signal (SIGINT, record_full_sig_handler); | |
d02ed0bb | 1196 | |
88d1aa9d | 1197 | if (!RECORD_FULL_IS_REPLAY && ops != &record_full_core_ops) |
d02ed0bb | 1198 | { |
88d1aa9d | 1199 | if (record_full_resume_step) |
d02ed0bb MM |
1200 | { |
1201 | /* This is a single step. */ | |
88d1aa9d MM |
1202 | return record_full_beneath_to_wait (record_full_beneath_to_wait_ops, |
1203 | ptid, status, options); | |
d02ed0bb MM |
1204 | } |
1205 | else | |
1206 | { | |
1207 | /* This is not a single step. */ | |
1208 | ptid_t ret; | |
1209 | CORE_ADDR tmp_pc; | |
1210 | struct gdbarch *gdbarch = target_thread_architecture (inferior_ptid); | |
1211 | ||
1212 | while (1) | |
1213 | { | |
88d1aa9d MM |
1214 | ret = record_full_beneath_to_wait |
1215 | (record_full_beneath_to_wait_ops, ptid, status, options); | |
d02ed0bb MM |
1216 | if (status->kind == TARGET_WAITKIND_IGNORE) |
1217 | { | |
1218 | if (record_debug) | |
1219 | fprintf_unfiltered (gdb_stdlog, | |
88d1aa9d | 1220 | "Process record: record_full_wait " |
d02ed0bb MM |
1221 | "target beneath not done yet\n"); |
1222 | return ret; | |
1223 | } | |
1224 | ||
1225 | if (single_step_breakpoints_inserted ()) | |
1226 | remove_single_step_breakpoints (); | |
1227 | ||
88d1aa9d | 1228 | if (record_full_resume_step) |
d02ed0bb MM |
1229 | return ret; |
1230 | ||
1231 | /* Is this a SIGTRAP? */ | |
1232 | if (status->kind == TARGET_WAITKIND_STOPPED | |
1233 | && status->value.sig == GDB_SIGNAL_TRAP) | |
1234 | { | |
1235 | struct regcache *regcache; | |
1236 | struct address_space *aspace; | |
1237 | ||
1238 | /* Yes -- this is likely our single-step finishing, | |
1239 | but check if there's any reason the core would be | |
1240 | interested in the event. */ | |
1241 | ||
1242 | registers_changed (); | |
1243 | regcache = get_current_regcache (); | |
1244 | tmp_pc = regcache_read_pc (regcache); | |
1245 | aspace = get_regcache_aspace (regcache); | |
1246 | ||
1247 | if (target_stopped_by_watchpoint ()) | |
1248 | { | |
1249 | /* Always interested in watchpoints. */ | |
1250 | } | |
1251 | else if (breakpoint_inserted_here_p (aspace, tmp_pc)) | |
1252 | { | |
1253 | /* There is a breakpoint here. Let the core | |
1254 | handle it. */ | |
1255 | if (software_breakpoint_inserted_here_p (aspace, tmp_pc)) | |
1256 | { | |
1257 | struct gdbarch *gdbarch | |
1258 | = get_regcache_arch (regcache); | |
1259 | CORE_ADDR decr_pc_after_break | |
1260 | = gdbarch_decr_pc_after_break (gdbarch); | |
1261 | if (decr_pc_after_break) | |
1262 | regcache_write_pc (regcache, | |
1263 | tmp_pc + decr_pc_after_break); | |
1264 | } | |
1265 | } | |
1266 | else | |
1267 | { | |
1268 | /* This is a single-step trap. Record the | |
1269 | insn and issue another step. | |
1270 | FIXME: this part can be a random SIGTRAP too. | |
1271 | But GDB cannot handle it. */ | |
1272 | int step = 1; | |
1273 | ||
88d1aa9d MM |
1274 | if (!record_full_message_wrapper_safe (regcache, |
1275 | GDB_SIGNAL_0)) | |
d02ed0bb MM |
1276 | { |
1277 | status->kind = TARGET_WAITKIND_STOPPED; | |
1278 | status->value.sig = GDB_SIGNAL_0; | |
1279 | break; | |
1280 | } | |
1281 | ||
1282 | if (gdbarch_software_single_step_p (gdbarch)) | |
1283 | { | |
1284 | /* Try to insert the software single step breakpoint. | |
1285 | If insert success, set step to 0. */ | |
1286 | set_executing (inferior_ptid, 0); | |
1287 | reinit_frame_cache (); | |
1288 | if (gdbarch_software_single_step (gdbarch, | |
1289 | get_current_frame ())) | |
1290 | step = 0; | |
1291 | set_executing (inferior_ptid, 1); | |
1292 | } | |
1293 | ||
1294 | if (record_debug) | |
1295 | fprintf_unfiltered (gdb_stdlog, | |
88d1aa9d MM |
1296 | "Process record: record_full_wait " |
1297 | "issuing one more step in the " | |
1298 | "target beneath\n"); | |
1299 | record_full_beneath_to_resume | |
1300 | (record_full_beneath_to_resume_ops, ptid, step, | |
1301 | GDB_SIGNAL_0); | |
d02ed0bb MM |
1302 | continue; |
1303 | } | |
1304 | } | |
1305 | ||
1306 | /* The inferior is broken by a breakpoint or a signal. */ | |
1307 | break; | |
1308 | } | |
1309 | ||
1310 | return ret; | |
1311 | } | |
1312 | } | |
1313 | else | |
1314 | { | |
1315 | struct regcache *regcache = get_current_regcache (); | |
1316 | struct gdbarch *gdbarch = get_regcache_arch (regcache); | |
1317 | struct address_space *aspace = get_regcache_aspace (regcache); | |
1318 | int continue_flag = 1; | |
88d1aa9d MM |
1319 | int first_record_full_end = 1; |
1320 | struct cleanup *old_cleanups | |
1321 | = make_cleanup (record_full_wait_cleanups, 0); | |
d02ed0bb MM |
1322 | CORE_ADDR tmp_pc; |
1323 | ||
88d1aa9d | 1324 | record_full_hw_watchpoint = 0; |
d02ed0bb MM |
1325 | status->kind = TARGET_WAITKIND_STOPPED; |
1326 | ||
1327 | /* Check breakpoint when forward execute. */ | |
1328 | if (execution_direction == EXEC_FORWARD) | |
1329 | { | |
1330 | tmp_pc = regcache_read_pc (regcache); | |
1331 | if (breakpoint_inserted_here_p (aspace, tmp_pc)) | |
1332 | { | |
1333 | int decr_pc_after_break = gdbarch_decr_pc_after_break (gdbarch); | |
1334 | ||
1335 | if (record_debug) | |
1336 | fprintf_unfiltered (gdb_stdlog, | |
1337 | "Process record: break at %s.\n", | |
1338 | paddress (gdbarch, tmp_pc)); | |
1339 | ||
1340 | if (decr_pc_after_break | |
88d1aa9d | 1341 | && !record_full_resume_step |
d02ed0bb MM |
1342 | && software_breakpoint_inserted_here_p (aspace, tmp_pc)) |
1343 | regcache_write_pc (regcache, | |
1344 | tmp_pc + decr_pc_after_break); | |
1345 | goto replay_out; | |
1346 | } | |
1347 | } | |
1348 | ||
1349 | /* If GDB is in terminal_inferior mode, it will not get the signal. | |
1350 | And in GDB replay mode, GDB doesn't need to be in terminal_inferior | |
1351 | mode, because inferior will not executed. | |
1352 | Then set it to terminal_ours to make GDB get the signal. */ | |
1353 | target_terminal_ours (); | |
1354 | ||
88d1aa9d | 1355 | /* In EXEC_FORWARD mode, record_full_list points to the tail of prev |
d02ed0bb | 1356 | instruction. */ |
88d1aa9d MM |
1357 | if (execution_direction == EXEC_FORWARD && record_full_list->next) |
1358 | record_full_list = record_full_list->next; | |
d02ed0bb | 1359 | |
88d1aa9d | 1360 | /* Loop over the record_full_list, looking for the next place to |
d02ed0bb MM |
1361 | stop. */ |
1362 | do | |
1363 | { | |
1364 | /* Check for beginning and end of log. */ | |
1365 | if (execution_direction == EXEC_REVERSE | |
88d1aa9d | 1366 | && record_full_list == &record_full_first) |
d02ed0bb MM |
1367 | { |
1368 | /* Hit beginning of record log in reverse. */ | |
1369 | status->kind = TARGET_WAITKIND_NO_HISTORY; | |
1370 | break; | |
1371 | } | |
88d1aa9d | 1372 | if (execution_direction != EXEC_REVERSE && !record_full_list->next) |
d02ed0bb MM |
1373 | { |
1374 | /* Hit end of record log going forward. */ | |
1375 | status->kind = TARGET_WAITKIND_NO_HISTORY; | |
1376 | break; | |
1377 | } | |
1378 | ||
88d1aa9d | 1379 | record_full_exec_insn (regcache, gdbarch, record_full_list); |
d02ed0bb | 1380 | |
88d1aa9d | 1381 | if (record_full_list->type == record_full_end) |
d02ed0bb MM |
1382 | { |
1383 | if (record_debug > 1) | |
1384 | fprintf_unfiltered (gdb_stdlog, | |
88d1aa9d | 1385 | "Process record: record_full_end %s to " |
d02ed0bb | 1386 | "inferior.\n", |
88d1aa9d | 1387 | host_address_to_string (record_full_list)); |
d02ed0bb | 1388 | |
88d1aa9d | 1389 | if (first_record_full_end && execution_direction == EXEC_REVERSE) |
d02ed0bb | 1390 | { |
88d1aa9d MM |
1391 | /* When reverse excute, the first record_full_end is the |
1392 | part of current instruction. */ | |
1393 | first_record_full_end = 0; | |
d02ed0bb MM |
1394 | } |
1395 | else | |
1396 | { | |
88d1aa9d | 1397 | /* In EXEC_REVERSE mode, this is the record_full_end of prev |
d02ed0bb | 1398 | instruction. |
88d1aa9d MM |
1399 | In EXEC_FORWARD mode, this is the record_full_end of |
1400 | current instruction. */ | |
d02ed0bb | 1401 | /* step */ |
88d1aa9d | 1402 | if (record_full_resume_step) |
d02ed0bb MM |
1403 | { |
1404 | if (record_debug > 1) | |
1405 | fprintf_unfiltered (gdb_stdlog, | |
1406 | "Process record: step.\n"); | |
1407 | continue_flag = 0; | |
1408 | } | |
1409 | ||
1410 | /* check breakpoint */ | |
1411 | tmp_pc = regcache_read_pc (regcache); | |
1412 | if (breakpoint_inserted_here_p (aspace, tmp_pc)) | |
1413 | { | |
1414 | int decr_pc_after_break | |
1415 | = gdbarch_decr_pc_after_break (gdbarch); | |
1416 | ||
1417 | if (record_debug) | |
1418 | fprintf_unfiltered (gdb_stdlog, | |
1419 | "Process record: break " | |
1420 | "at %s.\n", | |
1421 | paddress (gdbarch, tmp_pc)); | |
1422 | if (decr_pc_after_break | |
1423 | && execution_direction == EXEC_FORWARD | |
88d1aa9d | 1424 | && !record_full_resume_step |
d02ed0bb MM |
1425 | && software_breakpoint_inserted_here_p (aspace, |
1426 | tmp_pc)) | |
1427 | regcache_write_pc (regcache, | |
1428 | tmp_pc + decr_pc_after_break); | |
1429 | continue_flag = 0; | |
1430 | } | |
1431 | ||
88d1aa9d | 1432 | if (record_full_hw_watchpoint) |
d02ed0bb MM |
1433 | { |
1434 | if (record_debug) | |
1435 | fprintf_unfiltered (gdb_stdlog, | |
1436 | "Process record: hit hw " | |
1437 | "watchpoint.\n"); | |
1438 | continue_flag = 0; | |
1439 | } | |
1440 | /* Check target signal */ | |
88d1aa9d | 1441 | if (record_full_list->u.end.sigval != GDB_SIGNAL_0) |
d02ed0bb MM |
1442 | /* FIXME: better way to check */ |
1443 | continue_flag = 0; | |
1444 | } | |
1445 | } | |
1446 | ||
1447 | if (continue_flag) | |
1448 | { | |
1449 | if (execution_direction == EXEC_REVERSE) | |
1450 | { | |
88d1aa9d MM |
1451 | if (record_full_list->prev) |
1452 | record_full_list = record_full_list->prev; | |
d02ed0bb MM |
1453 | } |
1454 | else | |
1455 | { | |
88d1aa9d MM |
1456 | if (record_full_list->next) |
1457 | record_full_list = record_full_list->next; | |
d02ed0bb MM |
1458 | } |
1459 | } | |
1460 | } | |
1461 | while (continue_flag); | |
1462 | ||
1463 | replay_out: | |
88d1aa9d | 1464 | if (record_full_get_sig) |
d02ed0bb | 1465 | status->value.sig = GDB_SIGNAL_INT; |
88d1aa9d | 1466 | else if (record_full_list->u.end.sigval != GDB_SIGNAL_0) |
d02ed0bb | 1467 | /* FIXME: better way to check */ |
88d1aa9d | 1468 | status->value.sig = record_full_list->u.end.sigval; |
d02ed0bb MM |
1469 | else |
1470 | status->value.sig = GDB_SIGNAL_TRAP; | |
1471 | ||
1472 | discard_cleanups (old_cleanups); | |
1473 | } | |
1474 | ||
1475 | signal (SIGINT, handle_sigint); | |
1476 | ||
1477 | do_cleanups (set_cleanups); | |
1478 | return inferior_ptid; | |
1479 | } | |
1480 | ||
1481 | static ptid_t | |
88d1aa9d MM |
1482 | record_full_wait (struct target_ops *ops, |
1483 | ptid_t ptid, struct target_waitstatus *status, | |
1484 | int options) | |
d02ed0bb MM |
1485 | { |
1486 | ptid_t return_ptid; | |
1487 | ||
88d1aa9d | 1488 | return_ptid = record_full_wait_1 (ops, ptid, status, options); |
d02ed0bb MM |
1489 | if (status->kind != TARGET_WAITKIND_IGNORE) |
1490 | { | |
1491 | /* We're reporting a stop. Make sure any spurious | |
1492 | target_wait(WNOHANG) doesn't advance the target until the | |
1493 | core wants us resumed again. */ | |
88d1aa9d | 1494 | record_full_resumed = 0; |
d02ed0bb MM |
1495 | } |
1496 | return return_ptid; | |
1497 | } | |
1498 | ||
1499 | static int | |
88d1aa9d | 1500 | record_full_stopped_by_watchpoint (void) |
d02ed0bb | 1501 | { |
88d1aa9d MM |
1502 | if (RECORD_FULL_IS_REPLAY) |
1503 | return record_full_hw_watchpoint; | |
d02ed0bb | 1504 | else |
88d1aa9d | 1505 | return record_full_beneath_to_stopped_by_watchpoint (); |
d02ed0bb MM |
1506 | } |
1507 | ||
d02ed0bb | 1508 | static int |
88d1aa9d | 1509 | record_full_stopped_data_address (struct target_ops *ops, CORE_ADDR *addr_p) |
d02ed0bb | 1510 | { |
88d1aa9d | 1511 | if (RECORD_FULL_IS_REPLAY) |
d02ed0bb MM |
1512 | return 0; |
1513 | else | |
88d1aa9d | 1514 | return record_full_beneath_to_stopped_data_address (ops, addr_p); |
d02ed0bb MM |
1515 | } |
1516 | ||
1517 | /* Record registers change (by user or by GDB) to list as an instruction. */ | |
1518 | ||
1519 | static void | |
88d1aa9d | 1520 | record_full_registers_change (struct regcache *regcache, int regnum) |
d02ed0bb | 1521 | { |
88d1aa9d MM |
1522 | /* Check record_full_insn_num. */ |
1523 | record_full_check_insn_num (0); | |
d02ed0bb | 1524 | |
88d1aa9d MM |
1525 | record_full_arch_list_head = NULL; |
1526 | record_full_arch_list_tail = NULL; | |
d02ed0bb MM |
1527 | |
1528 | if (regnum < 0) | |
1529 | { | |
1530 | int i; | |
1531 | ||
1532 | for (i = 0; i < gdbarch_num_regs (get_regcache_arch (regcache)); i++) | |
1533 | { | |
25ea693b | 1534 | if (record_full_arch_list_add_reg (regcache, i)) |
d02ed0bb | 1535 | { |
88d1aa9d | 1536 | record_full_list_release (record_full_arch_list_tail); |
d02ed0bb MM |
1537 | error (_("Process record: failed to record execution log.")); |
1538 | } | |
1539 | } | |
1540 | } | |
1541 | else | |
1542 | { | |
25ea693b | 1543 | if (record_full_arch_list_add_reg (regcache, regnum)) |
d02ed0bb | 1544 | { |
88d1aa9d | 1545 | record_full_list_release (record_full_arch_list_tail); |
d02ed0bb MM |
1546 | error (_("Process record: failed to record execution log.")); |
1547 | } | |
1548 | } | |
25ea693b | 1549 | if (record_full_arch_list_add_end ()) |
d02ed0bb | 1550 | { |
88d1aa9d | 1551 | record_full_list_release (record_full_arch_list_tail); |
d02ed0bb MM |
1552 | error (_("Process record: failed to record execution log.")); |
1553 | } | |
88d1aa9d MM |
1554 | record_full_list->next = record_full_arch_list_head; |
1555 | record_full_arch_list_head->prev = record_full_list; | |
1556 | record_full_list = record_full_arch_list_tail; | |
d02ed0bb | 1557 | |
7ee70bf5 | 1558 | if (record_full_insn_num == record_full_insn_max_num) |
88d1aa9d | 1559 | record_full_list_release_first (); |
d02ed0bb | 1560 | else |
88d1aa9d | 1561 | record_full_insn_num++; |
d02ed0bb MM |
1562 | } |
1563 | ||
1564 | /* "to_store_registers" method for process record target. */ | |
1565 | ||
1566 | static void | |
88d1aa9d MM |
1567 | record_full_store_registers (struct target_ops *ops, |
1568 | struct regcache *regcache, | |
1569 | int regno) | |
d02ed0bb | 1570 | { |
88d1aa9d | 1571 | if (!record_full_gdb_operation_disable) |
d02ed0bb | 1572 | { |
88d1aa9d | 1573 | if (RECORD_FULL_IS_REPLAY) |
d02ed0bb MM |
1574 | { |
1575 | int n; | |
1576 | ||
1577 | /* Let user choose if he wants to write register or not. */ | |
1578 | if (regno < 0) | |
1579 | n = | |
1580 | query (_("Because GDB is in replay mode, changing the " | |
1581 | "value of a register will make the execution " | |
1582 | "log unusable from this point onward. " | |
1583 | "Change all registers?")); | |
1584 | else | |
1585 | n = | |
1586 | query (_("Because GDB is in replay mode, changing the value " | |
1587 | "of a register will make the execution log unusable " | |
1588 | "from this point onward. Change register %s?"), | |
1589 | gdbarch_register_name (get_regcache_arch (regcache), | |
1590 | regno)); | |
1591 | ||
1592 | if (!n) | |
1593 | { | |
1594 | /* Invalidate the value of regcache that was set in function | |
1595 | "regcache_raw_write". */ | |
1596 | if (regno < 0) | |
1597 | { | |
1598 | int i; | |
1599 | ||
1600 | for (i = 0; | |
1601 | i < gdbarch_num_regs (get_regcache_arch (regcache)); | |
1602 | i++) | |
1603 | regcache_invalidate (regcache, i); | |
1604 | } | |
1605 | else | |
1606 | regcache_invalidate (regcache, regno); | |
1607 | ||
1608 | error (_("Process record canceled the operation.")); | |
1609 | } | |
1610 | ||
1611 | /* Destroy the record from here forward. */ | |
88d1aa9d | 1612 | record_full_list_release_following (record_full_list); |
d02ed0bb MM |
1613 | } |
1614 | ||
88d1aa9d | 1615 | record_full_registers_change (regcache, regno); |
d02ed0bb | 1616 | } |
88d1aa9d MM |
1617 | record_full_beneath_to_store_registers |
1618 | (record_full_beneath_to_store_registers_ops, regcache, regno); | |
d02ed0bb MM |
1619 | } |
1620 | ||
88d1aa9d MM |
1621 | /* "to_xfer_partial" method. Behavior is conditional on |
1622 | RECORD_FULL_IS_REPLAY. | |
d02ed0bb MM |
1623 | In replay mode, we cannot write memory unles we are willing to |
1624 | invalidate the record/replay log from this point forward. */ | |
1625 | ||
1626 | static LONGEST | |
88d1aa9d MM |
1627 | record_full_xfer_partial (struct target_ops *ops, enum target_object object, |
1628 | const char *annex, gdb_byte *readbuf, | |
1629 | const gdb_byte *writebuf, ULONGEST offset, | |
1630 | LONGEST len) | |
d02ed0bb | 1631 | { |
88d1aa9d | 1632 | if (!record_full_gdb_operation_disable |
d02ed0bb MM |
1633 | && (object == TARGET_OBJECT_MEMORY |
1634 | || object == TARGET_OBJECT_RAW_MEMORY) && writebuf) | |
1635 | { | |
88d1aa9d | 1636 | if (RECORD_FULL_IS_REPLAY) |
d02ed0bb MM |
1637 | { |
1638 | /* Let user choose if he wants to write memory or not. */ | |
1639 | if (!query (_("Because GDB is in replay mode, writing to memory " | |
1640 | "will make the execution log unusable from this " | |
1641 | "point onward. Write memory at address %s?"), | |
1642 | paddress (target_gdbarch (), offset))) | |
1643 | error (_("Process record canceled the operation.")); | |
1644 | ||
1645 | /* Destroy the record from here forward. */ | |
88d1aa9d | 1646 | record_full_list_release_following (record_full_list); |
d02ed0bb MM |
1647 | } |
1648 | ||
88d1aa9d MM |
1649 | /* Check record_full_insn_num */ |
1650 | record_full_check_insn_num (0); | |
d02ed0bb MM |
1651 | |
1652 | /* Record registers change to list as an instruction. */ | |
88d1aa9d MM |
1653 | record_full_arch_list_head = NULL; |
1654 | record_full_arch_list_tail = NULL; | |
25ea693b | 1655 | if (record_full_arch_list_add_mem (offset, len)) |
d02ed0bb | 1656 | { |
88d1aa9d | 1657 | record_full_list_release (record_full_arch_list_tail); |
d02ed0bb MM |
1658 | if (record_debug) |
1659 | fprintf_unfiltered (gdb_stdlog, | |
1660 | "Process record: failed to record " | |
1661 | "execution log."); | |
1662 | return -1; | |
1663 | } | |
25ea693b | 1664 | if (record_full_arch_list_add_end ()) |
d02ed0bb | 1665 | { |
88d1aa9d | 1666 | record_full_list_release (record_full_arch_list_tail); |
d02ed0bb MM |
1667 | if (record_debug) |
1668 | fprintf_unfiltered (gdb_stdlog, | |
1669 | "Process record: failed to record " | |
1670 | "execution log."); | |
1671 | return -1; | |
1672 | } | |
88d1aa9d MM |
1673 | record_full_list->next = record_full_arch_list_head; |
1674 | record_full_arch_list_head->prev = record_full_list; | |
1675 | record_full_list = record_full_arch_list_tail; | |
d02ed0bb | 1676 | |
7ee70bf5 | 1677 | if (record_full_insn_num == record_full_insn_max_num) |
88d1aa9d | 1678 | record_full_list_release_first (); |
d02ed0bb | 1679 | else |
88d1aa9d | 1680 | record_full_insn_num++; |
d02ed0bb MM |
1681 | } |
1682 | ||
88d1aa9d MM |
1683 | return record_full_beneath_to_xfer_partial |
1684 | (record_full_beneath_to_xfer_partial_ops, object, annex, | |
1685 | readbuf, writebuf, offset, len); | |
d02ed0bb MM |
1686 | } |
1687 | ||
1688 | /* This structure represents a breakpoint inserted while the record | |
1689 | target is active. We use this to know when to install/remove | |
1690 | breakpoints in/from the target beneath. For example, a breakpoint | |
1691 | may be inserted while recording, but removed when not replaying nor | |
1692 | recording. In that case, the breakpoint had not been inserted on | |
1693 | the target beneath, so we should not try to remove it there. */ | |
1694 | ||
88d1aa9d | 1695 | struct record_full_breakpoint |
d02ed0bb MM |
1696 | { |
1697 | /* The address and address space the breakpoint was set at. */ | |
1698 | struct address_space *address_space; | |
1699 | CORE_ADDR addr; | |
1700 | ||
1701 | /* True when the breakpoint has been also installed in the target | |
1702 | beneath. This will be false for breakpoints set during replay or | |
1703 | when recording. */ | |
1704 | int in_target_beneath; | |
1705 | }; | |
1706 | ||
88d1aa9d MM |
1707 | typedef struct record_full_breakpoint *record_full_breakpoint_p; |
1708 | DEF_VEC_P(record_full_breakpoint_p); | |
d02ed0bb MM |
1709 | |
1710 | /* The list of breakpoints inserted while the record target is | |
1711 | active. */ | |
88d1aa9d | 1712 | VEC(record_full_breakpoint_p) *record_full_breakpoints = NULL; |
d02ed0bb MM |
1713 | |
1714 | static void | |
88d1aa9d | 1715 | record_full_sync_record_breakpoints (struct bp_location *loc, void *data) |
d02ed0bb MM |
1716 | { |
1717 | if (loc->loc_type != bp_loc_software_breakpoint) | |
1718 | return; | |
1719 | ||
1720 | if (loc->inserted) | |
1721 | { | |
88d1aa9d | 1722 | struct record_full_breakpoint *bp = XNEW (struct record_full_breakpoint); |
d02ed0bb MM |
1723 | |
1724 | bp->addr = loc->target_info.placed_address; | |
1725 | bp->address_space = loc->target_info.placed_address_space; | |
1726 | ||
1727 | bp->in_target_beneath = 1; | |
1728 | ||
88d1aa9d | 1729 | VEC_safe_push (record_full_breakpoint_p, record_full_breakpoints, bp); |
d02ed0bb MM |
1730 | } |
1731 | } | |
1732 | ||
88d1aa9d | 1733 | /* Sync existing breakpoints to record_full_breakpoints. */ |
d02ed0bb MM |
1734 | |
1735 | static void | |
88d1aa9d | 1736 | record_full_init_record_breakpoints (void) |
d02ed0bb | 1737 | { |
88d1aa9d | 1738 | VEC_free (record_full_breakpoint_p, record_full_breakpoints); |
d02ed0bb | 1739 | |
88d1aa9d | 1740 | iterate_over_bp_locations (record_full_sync_record_breakpoints); |
d02ed0bb MM |
1741 | } |
1742 | ||
88d1aa9d | 1743 | /* Behavior is conditional on RECORD_FULL_IS_REPLAY. We will not actually |
d02ed0bb MM |
1744 | insert or remove breakpoints in the real target when replaying, nor |
1745 | when recording. */ | |
1746 | ||
1747 | static int | |
88d1aa9d MM |
1748 | record_full_insert_breakpoint (struct gdbarch *gdbarch, |
1749 | struct bp_target_info *bp_tgt) | |
d02ed0bb | 1750 | { |
88d1aa9d | 1751 | struct record_full_breakpoint *bp; |
d02ed0bb MM |
1752 | int in_target_beneath = 0; |
1753 | ||
88d1aa9d | 1754 | if (!RECORD_FULL_IS_REPLAY) |
d02ed0bb MM |
1755 | { |
1756 | /* When recording, we currently always single-step, so we don't | |
1757 | really need to install regular breakpoints in the inferior. | |
1758 | However, we do have to insert software single-step | |
1759 | breakpoints, in case the target can't hardware step. To keep | |
1760 | things single, we always insert. */ | |
1761 | struct cleanup *old_cleanups; | |
1762 | int ret; | |
1763 | ||
25ea693b | 1764 | old_cleanups = record_full_gdb_operation_disable_set (); |
88d1aa9d | 1765 | ret = record_full_beneath_to_insert_breakpoint (gdbarch, bp_tgt); |
d02ed0bb MM |
1766 | do_cleanups (old_cleanups); |
1767 | ||
1768 | if (ret != 0) | |
1769 | return ret; | |
1770 | ||
1771 | in_target_beneath = 1; | |
1772 | } | |
1773 | ||
88d1aa9d | 1774 | bp = XNEW (struct record_full_breakpoint); |
d02ed0bb MM |
1775 | bp->addr = bp_tgt->placed_address; |
1776 | bp->address_space = bp_tgt->placed_address_space; | |
1777 | bp->in_target_beneath = in_target_beneath; | |
88d1aa9d | 1778 | VEC_safe_push (record_full_breakpoint_p, record_full_breakpoints, bp); |
d02ed0bb MM |
1779 | return 0; |
1780 | } | |
1781 | ||
1782 | /* "to_remove_breakpoint" method for process record target. */ | |
1783 | ||
1784 | static int | |
88d1aa9d MM |
1785 | record_full_remove_breakpoint (struct gdbarch *gdbarch, |
1786 | struct bp_target_info *bp_tgt) | |
d02ed0bb | 1787 | { |
88d1aa9d | 1788 | struct record_full_breakpoint *bp; |
d02ed0bb MM |
1789 | int ix; |
1790 | ||
1791 | for (ix = 0; | |
88d1aa9d MM |
1792 | VEC_iterate (record_full_breakpoint_p, |
1793 | record_full_breakpoints, ix, bp); | |
d02ed0bb MM |
1794 | ++ix) |
1795 | { | |
1796 | if (bp->addr == bp_tgt->placed_address | |
1797 | && bp->address_space == bp_tgt->placed_address_space) | |
1798 | { | |
1799 | if (bp->in_target_beneath) | |
1800 | { | |
1801 | struct cleanup *old_cleanups; | |
1802 | int ret; | |
1803 | ||
25ea693b | 1804 | old_cleanups = record_full_gdb_operation_disable_set (); |
88d1aa9d | 1805 | ret = record_full_beneath_to_remove_breakpoint (gdbarch, bp_tgt); |
d02ed0bb MM |
1806 | do_cleanups (old_cleanups); |
1807 | ||
1808 | if (ret != 0) | |
1809 | return ret; | |
1810 | } | |
1811 | ||
88d1aa9d MM |
1812 | VEC_unordered_remove (record_full_breakpoint_p, |
1813 | record_full_breakpoints, ix); | |
d02ed0bb MM |
1814 | return 0; |
1815 | } | |
1816 | } | |
1817 | ||
1818 | gdb_assert_not_reached ("removing unknown breakpoint"); | |
1819 | } | |
1820 | ||
1821 | /* "to_can_execute_reverse" method for process record target. */ | |
1822 | ||
1823 | static int | |
88d1aa9d | 1824 | record_full_can_execute_reverse (void) |
d02ed0bb MM |
1825 | { |
1826 | return 1; | |
1827 | } | |
1828 | ||
1829 | /* "to_get_bookmark" method for process record and prec over core. */ | |
1830 | ||
1831 | static gdb_byte * | |
88d1aa9d | 1832 | record_full_get_bookmark (char *args, int from_tty) |
d02ed0bb | 1833 | { |
0f928d68 | 1834 | char *ret = NULL; |
d02ed0bb MM |
1835 | |
1836 | /* Return stringified form of instruction count. */ | |
88d1aa9d MM |
1837 | if (record_full_list && record_full_list->type == record_full_end) |
1838 | ret = xstrdup (pulongest (record_full_list->u.end.insn_num)); | |
d02ed0bb MM |
1839 | |
1840 | if (record_debug) | |
1841 | { | |
1842 | if (ret) | |
1843 | fprintf_unfiltered (gdb_stdlog, | |
88d1aa9d | 1844 | "record_full_get_bookmark returns %s\n", ret); |
d02ed0bb MM |
1845 | else |
1846 | fprintf_unfiltered (gdb_stdlog, | |
88d1aa9d | 1847 | "record_full_get_bookmark returns NULL\n"); |
d02ed0bb | 1848 | } |
0f928d68 | 1849 | return (gdb_byte *) ret; |
d02ed0bb MM |
1850 | } |
1851 | ||
1852 | /* "to_goto_bookmark" method for process record and prec over core. */ | |
1853 | ||
1854 | static void | |
0f928d68 | 1855 | record_full_goto_bookmark (gdb_byte *raw_bookmark, int from_tty) |
d02ed0bb | 1856 | { |
0f928d68 PA |
1857 | char *bookmark = (char *) raw_bookmark; |
1858 | ||
d02ed0bb MM |
1859 | if (record_debug) |
1860 | fprintf_unfiltered (gdb_stdlog, | |
88d1aa9d | 1861 | "record_full_goto_bookmark receives %s\n", bookmark); |
d02ed0bb MM |
1862 | |
1863 | if (bookmark[0] == '\'' || bookmark[0] == '\"') | |
1864 | { | |
1865 | if (bookmark[strlen (bookmark) - 1] != bookmark[0]) | |
1866 | error (_("Unbalanced quotes: %s"), bookmark); | |
1867 | ||
1868 | /* Strip trailing quote. */ | |
1869 | bookmark[strlen (bookmark) - 1] = '\0'; | |
1870 | /* Strip leading quote. */ | |
1871 | bookmark++; | |
88d1aa9d | 1872 | /* Pass along to cmd_record_full_goto. */ |
d02ed0bb MM |
1873 | } |
1874 | ||
0f928d68 | 1875 | cmd_record_goto (bookmark, from_tty); |
d02ed0bb MM |
1876 | return; |
1877 | } | |
1878 | ||
1879 | static void | |
88d1aa9d MM |
1880 | record_full_async (void (*callback) (enum inferior_event_type event_type, |
1881 | void *context), void *context) | |
d02ed0bb MM |
1882 | { |
1883 | /* If we're on top of a line target (e.g., linux-nat, remote), then | |
1884 | set it to async mode as well. Will be NULL if we're sitting on | |
1885 | top of the core target, for "record restore". */ | |
88d1aa9d MM |
1886 | if (record_full_beneath_to_async != NULL) |
1887 | record_full_beneath_to_async (callback, context); | |
d02ed0bb MM |
1888 | } |
1889 | ||
1890 | static int | |
88d1aa9d | 1891 | record_full_can_async_p (void) |
d02ed0bb MM |
1892 | { |
1893 | /* We only enable async when the user specifically asks for it. */ | |
1894 | return target_async_permitted; | |
1895 | } | |
1896 | ||
1897 | static int | |
88d1aa9d | 1898 | record_full_is_async_p (void) |
d02ed0bb MM |
1899 | { |
1900 | /* We only enable async when the user specifically asks for it. */ | |
1901 | return target_async_permitted; | |
1902 | } | |
1903 | ||
1904 | static enum exec_direction_kind | |
88d1aa9d | 1905 | record_full_execution_direction (void) |
d02ed0bb | 1906 | { |
88d1aa9d | 1907 | return record_full_execution_dir; |
d02ed0bb MM |
1908 | } |
1909 | ||
1910 | static void | |
88d1aa9d | 1911 | record_full_info (void) |
d02ed0bb | 1912 | { |
88d1aa9d | 1913 | struct record_full_entry *p; |
d02ed0bb | 1914 | |
88d1aa9d | 1915 | if (RECORD_FULL_IS_REPLAY) |
d02ed0bb MM |
1916 | printf_filtered (_("Replay mode:\n")); |
1917 | else | |
1918 | printf_filtered (_("Record mode:\n")); | |
1919 | ||
1920 | /* Find entry for first actual instruction in the log. */ | |
88d1aa9d MM |
1921 | for (p = record_full_first.next; |
1922 | p != NULL && p->type != record_full_end; | |
d02ed0bb MM |
1923 | p = p->next) |
1924 | ; | |
1925 | ||
1926 | /* Do we have a log at all? */ | |
88d1aa9d | 1927 | if (p != NULL && p->type == record_full_end) |
d02ed0bb MM |
1928 | { |
1929 | /* Display instruction number for first instruction in the log. */ | |
1930 | printf_filtered (_("Lowest recorded instruction number is %s.\n"), | |
1931 | pulongest (p->u.end.insn_num)); | |
1932 | ||
1933 | /* If in replay mode, display where we are in the log. */ | |
88d1aa9d | 1934 | if (RECORD_FULL_IS_REPLAY) |
d02ed0bb | 1935 | printf_filtered (_("Current instruction number is %s.\n"), |
88d1aa9d | 1936 | pulongest (record_full_list->u.end.insn_num)); |
d02ed0bb MM |
1937 | |
1938 | /* Display instruction number for last instruction in the log. */ | |
1939 | printf_filtered (_("Highest recorded instruction number is %s.\n"), | |
88d1aa9d | 1940 | pulongest (record_full_insn_count)); |
d02ed0bb MM |
1941 | |
1942 | /* Display log count. */ | |
7ee70bf5 | 1943 | printf_filtered (_("Log contains %u instructions.\n"), |
88d1aa9d | 1944 | record_full_insn_num); |
d02ed0bb MM |
1945 | } |
1946 | else | |
1947 | printf_filtered (_("No instructions have been logged.\n")); | |
1948 | ||
1949 | /* Display max log size. */ | |
7ee70bf5 | 1950 | printf_filtered (_("Max logged instructions is %u.\n"), |
88d1aa9d | 1951 | record_full_insn_max_num); |
d02ed0bb MM |
1952 | } |
1953 | ||
1954 | /* The "to_record_delete" target method. */ | |
1955 | ||
1956 | static void | |
88d1aa9d | 1957 | record_full_delete (void) |
d02ed0bb | 1958 | { |
88d1aa9d | 1959 | record_full_list_release_following (record_full_list); |
d02ed0bb MM |
1960 | } |
1961 | ||
1962 | /* The "to_record_is_replaying" target method. */ | |
1963 | ||
1964 | static int | |
88d1aa9d | 1965 | record_full_is_replaying (void) |
d02ed0bb | 1966 | { |
88d1aa9d | 1967 | return RECORD_FULL_IS_REPLAY; |
d02ed0bb MM |
1968 | } |
1969 | ||
1970 | /* Go to a specific entry. */ | |
1971 | ||
1972 | static void | |
88d1aa9d | 1973 | record_full_goto_entry (struct record_full_entry *p) |
d02ed0bb MM |
1974 | { |
1975 | if (p == NULL) | |
1976 | error (_("Target insn not found.")); | |
88d1aa9d | 1977 | else if (p == record_full_list) |
d02ed0bb | 1978 | error (_("Already at target insn.")); |
88d1aa9d | 1979 | else if (p->u.end.insn_num > record_full_list->u.end.insn_num) |
d02ed0bb MM |
1980 | { |
1981 | printf_filtered (_("Go forward to insn number %s\n"), | |
1982 | pulongest (p->u.end.insn_num)); | |
88d1aa9d | 1983 | record_full_goto_insn (p, EXEC_FORWARD); |
d02ed0bb MM |
1984 | } |
1985 | else | |
1986 | { | |
1987 | printf_filtered (_("Go backward to insn number %s\n"), | |
1988 | pulongest (p->u.end.insn_num)); | |
88d1aa9d | 1989 | record_full_goto_insn (p, EXEC_REVERSE); |
d02ed0bb MM |
1990 | } |
1991 | ||
1992 | registers_changed (); | |
1993 | reinit_frame_cache (); | |
08d72866 | 1994 | print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1); |
d02ed0bb MM |
1995 | } |
1996 | ||
1997 | /* The "to_goto_record_begin" target method. */ | |
1998 | ||
1999 | static void | |
88d1aa9d | 2000 | record_full_goto_begin (void) |
d02ed0bb | 2001 | { |
88d1aa9d | 2002 | struct record_full_entry *p = NULL; |
d02ed0bb | 2003 | |
88d1aa9d MM |
2004 | for (p = &record_full_first; p != NULL; p = p->next) |
2005 | if (p->type == record_full_end) | |
d02ed0bb MM |
2006 | break; |
2007 | ||
88d1aa9d | 2008 | record_full_goto_entry (p); |
d02ed0bb MM |
2009 | } |
2010 | ||
2011 | /* The "to_goto_record_end" target method. */ | |
2012 | ||
2013 | static void | |
88d1aa9d | 2014 | record_full_goto_end (void) |
d02ed0bb | 2015 | { |
88d1aa9d | 2016 | struct record_full_entry *p = NULL; |
d02ed0bb | 2017 | |
88d1aa9d | 2018 | for (p = record_full_list; p->next != NULL; p = p->next) |
d02ed0bb MM |
2019 | ; |
2020 | for (; p!= NULL; p = p->prev) | |
88d1aa9d | 2021 | if (p->type == record_full_end) |
d02ed0bb MM |
2022 | break; |
2023 | ||
88d1aa9d | 2024 | record_full_goto_entry (p); |
d02ed0bb MM |
2025 | } |
2026 | ||
2027 | /* The "to_goto_record" target method. */ | |
2028 | ||
2029 | static void | |
88d1aa9d | 2030 | record_full_goto (ULONGEST target_insn) |
d02ed0bb | 2031 | { |
88d1aa9d | 2032 | struct record_full_entry *p = NULL; |
d02ed0bb | 2033 | |
88d1aa9d MM |
2034 | for (p = &record_full_first; p != NULL; p = p->next) |
2035 | if (p->type == record_full_end && p->u.end.insn_num == target_insn) | |
d02ed0bb MM |
2036 | break; |
2037 | ||
88d1aa9d | 2038 | record_full_goto_entry (p); |
d02ed0bb MM |
2039 | } |
2040 | ||
2041 | static void | |
88d1aa9d | 2042 | init_record_full_ops (void) |
d02ed0bb | 2043 | { |
88d1aa9d MM |
2044 | record_full_ops.to_shortname = "record-full"; |
2045 | record_full_ops.to_longname = "Process record and replay target"; | |
2046 | record_full_ops.to_doc = | |
d02ed0bb | 2047 | "Log program while executing and replay execution from log."; |
88d1aa9d MM |
2048 | record_full_ops.to_open = record_full_open; |
2049 | record_full_ops.to_close = record_full_close; | |
2050 | record_full_ops.to_resume = record_full_resume; | |
2051 | record_full_ops.to_wait = record_full_wait; | |
7c1687a9 MM |
2052 | record_full_ops.to_disconnect = record_disconnect; |
2053 | record_full_ops.to_detach = record_detach; | |
2054 | record_full_ops.to_mourn_inferior = record_mourn_inferior; | |
2055 | record_full_ops.to_kill = record_kill; | |
88d1aa9d MM |
2056 | record_full_ops.to_create_inferior = find_default_create_inferior; |
2057 | record_full_ops.to_store_registers = record_full_store_registers; | |
2058 | record_full_ops.to_xfer_partial = record_full_xfer_partial; | |
2059 | record_full_ops.to_insert_breakpoint = record_full_insert_breakpoint; | |
2060 | record_full_ops.to_remove_breakpoint = record_full_remove_breakpoint; | |
2061 | record_full_ops.to_stopped_by_watchpoint = record_full_stopped_by_watchpoint; | |
2062 | record_full_ops.to_stopped_data_address = record_full_stopped_data_address; | |
2063 | record_full_ops.to_can_execute_reverse = record_full_can_execute_reverse; | |
2064 | record_full_ops.to_stratum = record_stratum; | |
d02ed0bb | 2065 | /* Add bookmark target methods. */ |
88d1aa9d MM |
2066 | record_full_ops.to_get_bookmark = record_full_get_bookmark; |
2067 | record_full_ops.to_goto_bookmark = record_full_goto_bookmark; | |
2068 | record_full_ops.to_async = record_full_async; | |
2069 | record_full_ops.to_can_async_p = record_full_can_async_p; | |
2070 | record_full_ops.to_is_async_p = record_full_is_async_p; | |
2071 | record_full_ops.to_execution_direction = record_full_execution_direction; | |
2072 | record_full_ops.to_info_record = record_full_info; | |
2073 | record_full_ops.to_save_record = record_full_save; | |
2074 | record_full_ops.to_delete_record = record_full_delete; | |
2075 | record_full_ops.to_record_is_replaying = record_full_is_replaying; | |
2076 | record_full_ops.to_goto_record_begin = record_full_goto_begin; | |
2077 | record_full_ops.to_goto_record_end = record_full_goto_end; | |
2078 | record_full_ops.to_goto_record = record_full_goto; | |
2079 | record_full_ops.to_magic = OPS_MAGIC; | |
d02ed0bb MM |
2080 | } |
2081 | ||
2082 | /* "to_resume" method for prec over corefile. */ | |
2083 | ||
2084 | static void | |
88d1aa9d MM |
2085 | record_full_core_resume (struct target_ops *ops, ptid_t ptid, int step, |
2086 | enum gdb_signal signal) | |
d02ed0bb | 2087 | { |
88d1aa9d MM |
2088 | record_full_resume_step = step; |
2089 | record_full_resumed = 1; | |
2090 | record_full_execution_dir = execution_direction; | |
d02ed0bb MM |
2091 | |
2092 | /* We are about to start executing the inferior (or simulate it), | |
2093 | let's register it with the event loop. */ | |
2094 | if (target_can_async_p ()) | |
2095 | { | |
2096 | target_async (inferior_event_handler, 0); | |
2097 | ||
2098 | /* Notify the event loop there's an event to wait for. */ | |
88d1aa9d | 2099 | mark_async_event_handler (record_full_async_inferior_event_token); |
d02ed0bb MM |
2100 | } |
2101 | } | |
2102 | ||
2103 | /* "to_kill" method for prec over corefile. */ | |
2104 | ||
2105 | static void | |
88d1aa9d | 2106 | record_full_core_kill (struct target_ops *ops) |
d02ed0bb MM |
2107 | { |
2108 | if (record_debug) | |
88d1aa9d | 2109 | fprintf_unfiltered (gdb_stdlog, "Process record: record_full_core_kill\n"); |
d02ed0bb | 2110 | |
88d1aa9d | 2111 | unpush_target (&record_full_core_ops); |
d02ed0bb MM |
2112 | } |
2113 | ||
2114 | /* "to_fetch_registers" method for prec over corefile. */ | |
2115 | ||
2116 | static void | |
88d1aa9d MM |
2117 | record_full_core_fetch_registers (struct target_ops *ops, |
2118 | struct regcache *regcache, | |
2119 | int regno) | |
d02ed0bb MM |
2120 | { |
2121 | if (regno < 0) | |
2122 | { | |
2123 | int num = gdbarch_num_regs (get_regcache_arch (regcache)); | |
2124 | int i; | |
2125 | ||
2126 | for (i = 0; i < num; i ++) | |
2127 | regcache_raw_supply (regcache, i, | |
88d1aa9d | 2128 | record_full_core_regbuf + MAX_REGISTER_SIZE * i); |
d02ed0bb MM |
2129 | } |
2130 | else | |
2131 | regcache_raw_supply (regcache, regno, | |
88d1aa9d | 2132 | record_full_core_regbuf + MAX_REGISTER_SIZE * regno); |
d02ed0bb MM |
2133 | } |
2134 | ||
2135 | /* "to_prepare_to_store" method for prec over corefile. */ | |
2136 | ||
2137 | static void | |
88d1aa9d | 2138 | record_full_core_prepare_to_store (struct regcache *regcache) |
d02ed0bb MM |
2139 | { |
2140 | } | |
2141 | ||
2142 | /* "to_store_registers" method for prec over corefile. */ | |
2143 | ||
2144 | static void | |
88d1aa9d | 2145 | record_full_core_store_registers (struct target_ops *ops, |
d02ed0bb MM |
2146 | struct regcache *regcache, |
2147 | int regno) | |
2148 | { | |
88d1aa9d | 2149 | if (record_full_gdb_operation_disable) |
d02ed0bb | 2150 | regcache_raw_collect (regcache, regno, |
88d1aa9d | 2151 | record_full_core_regbuf + MAX_REGISTER_SIZE * regno); |
d02ed0bb MM |
2152 | else |
2153 | error (_("You can't do that without a process to debug.")); | |
2154 | } | |
2155 | ||
2156 | /* "to_xfer_partial" method for prec over corefile. */ | |
2157 | ||
2158 | static LONGEST | |
88d1aa9d MM |
2159 | record_full_core_xfer_partial (struct target_ops *ops, |
2160 | enum target_object object, | |
2161 | const char *annex, gdb_byte *readbuf, | |
2162 | const gdb_byte *writebuf, ULONGEST offset, | |
2163 | LONGEST len) | |
d02ed0bb MM |
2164 | { |
2165 | if (object == TARGET_OBJECT_MEMORY) | |
2166 | { | |
88d1aa9d | 2167 | if (record_full_gdb_operation_disable || !writebuf) |
d02ed0bb MM |
2168 | { |
2169 | struct target_section *p; | |
2170 | ||
88d1aa9d | 2171 | for (p = record_full_core_start; p < record_full_core_end; p++) |
d02ed0bb MM |
2172 | { |
2173 | if (offset >= p->addr) | |
2174 | { | |
88d1aa9d | 2175 | struct record_full_core_buf_entry *entry; |
d02ed0bb MM |
2176 | ULONGEST sec_offset; |
2177 | ||
2178 | if (offset >= p->endaddr) | |
2179 | continue; | |
2180 | ||
2181 | if (offset + len > p->endaddr) | |
2182 | len = p->endaddr - offset; | |
2183 | ||
2184 | sec_offset = offset - p->addr; | |
2185 | ||
2186 | /* Read readbuf or write writebuf p, offset, len. */ | |
2187 | /* Check flags. */ | |
2188 | if (p->the_bfd_section->flags & SEC_CONSTRUCTOR | |
2189 | || (p->the_bfd_section->flags & SEC_HAS_CONTENTS) == 0) | |
2190 | { | |
2191 | if (readbuf) | |
2192 | memset (readbuf, 0, len); | |
2193 | return len; | |
2194 | } | |
88d1aa9d MM |
2195 | /* Get record_full_core_buf_entry. */ |
2196 | for (entry = record_full_core_buf_list; entry; | |
d02ed0bb MM |
2197 | entry = entry->prev) |
2198 | if (entry->p == p) | |
2199 | break; | |
2200 | if (writebuf) | |
2201 | { | |
2202 | if (!entry) | |
2203 | { | |
2204 | /* Add a new entry. */ | |
88d1aa9d MM |
2205 | entry = (struct record_full_core_buf_entry *) |
2206 | xmalloc | |
2207 | (sizeof (struct record_full_core_buf_entry)); | |
d02ed0bb | 2208 | entry->p = p; |
2b2848e2 DE |
2209 | if (!bfd_malloc_and_get_section |
2210 | (p->the_bfd_section->owner, | |
2211 | p->the_bfd_section, | |
2212 | &entry->buf)) | |
d02ed0bb MM |
2213 | { |
2214 | xfree (entry); | |
2215 | return 0; | |
2216 | } | |
88d1aa9d MM |
2217 | entry->prev = record_full_core_buf_list; |
2218 | record_full_core_buf_list = entry; | |
d02ed0bb MM |
2219 | } |
2220 | ||
2221 | memcpy (entry->buf + sec_offset, writebuf, | |
2222 | (size_t) len); | |
2223 | } | |
2224 | else | |
2225 | { | |
2226 | if (!entry) | |
88d1aa9d MM |
2227 | return record_full_beneath_to_xfer_partial |
2228 | (record_full_beneath_to_xfer_partial_ops, | |
d02ed0bb MM |
2229 | object, annex, readbuf, writebuf, |
2230 | offset, len); | |
2231 | ||
2232 | memcpy (readbuf, entry->buf + sec_offset, | |
2233 | (size_t) len); | |
2234 | } | |
2235 | ||
2236 | return len; | |
2237 | } | |
2238 | } | |
2239 | ||
2240 | return -1; | |
2241 | } | |
2242 | else | |
2243 | error (_("You can't do that without a process to debug.")); | |
2244 | } | |
2245 | ||
88d1aa9d MM |
2246 | return record_full_beneath_to_xfer_partial |
2247 | (record_full_beneath_to_xfer_partial_ops, object, annex, | |
2248 | readbuf, writebuf, offset, len); | |
d02ed0bb MM |
2249 | } |
2250 | ||
2251 | /* "to_insert_breakpoint" method for prec over corefile. */ | |
2252 | ||
2253 | static int | |
88d1aa9d MM |
2254 | record_full_core_insert_breakpoint (struct gdbarch *gdbarch, |
2255 | struct bp_target_info *bp_tgt) | |
d02ed0bb MM |
2256 | { |
2257 | return 0; | |
2258 | } | |
2259 | ||
2260 | /* "to_remove_breakpoint" method for prec over corefile. */ | |
2261 | ||
2262 | static int | |
88d1aa9d MM |
2263 | record_full_core_remove_breakpoint (struct gdbarch *gdbarch, |
2264 | struct bp_target_info *bp_tgt) | |
d02ed0bb MM |
2265 | { |
2266 | return 0; | |
2267 | } | |
2268 | ||
2269 | /* "to_has_execution" method for prec over corefile. */ | |
2270 | ||
2271 | static int | |
88d1aa9d | 2272 | record_full_core_has_execution (struct target_ops *ops, ptid_t the_ptid) |
d02ed0bb MM |
2273 | { |
2274 | return 1; | |
2275 | } | |
2276 | ||
2277 | static void | |
88d1aa9d | 2278 | init_record_full_core_ops (void) |
d02ed0bb | 2279 | { |
88d1aa9d MM |
2280 | record_full_core_ops.to_shortname = "record-core"; |
2281 | record_full_core_ops.to_longname = "Process record and replay target"; | |
2282 | record_full_core_ops.to_doc = | |
d02ed0bb | 2283 | "Log program while executing and replay execution from log."; |
88d1aa9d MM |
2284 | record_full_core_ops.to_open = record_full_open; |
2285 | record_full_core_ops.to_close = record_full_close; | |
2286 | record_full_core_ops.to_resume = record_full_core_resume; | |
2287 | record_full_core_ops.to_wait = record_full_wait; | |
2288 | record_full_core_ops.to_kill = record_full_core_kill; | |
2289 | record_full_core_ops.to_fetch_registers = record_full_core_fetch_registers; | |
2290 | record_full_core_ops.to_prepare_to_store = record_full_core_prepare_to_store; | |
2291 | record_full_core_ops.to_store_registers = record_full_core_store_registers; | |
2292 | record_full_core_ops.to_xfer_partial = record_full_core_xfer_partial; | |
2293 | record_full_core_ops.to_insert_breakpoint | |
2294 | = record_full_core_insert_breakpoint; | |
2295 | record_full_core_ops.to_remove_breakpoint | |
2296 | = record_full_core_remove_breakpoint; | |
2297 | record_full_core_ops.to_stopped_by_watchpoint | |
2298 | = record_full_stopped_by_watchpoint; | |
2299 | record_full_core_ops.to_stopped_data_address | |
2300 | = record_full_stopped_data_address; | |
2301 | record_full_core_ops.to_can_execute_reverse | |
2302 | = record_full_can_execute_reverse; | |
2303 | record_full_core_ops.to_has_execution = record_full_core_has_execution; | |
2304 | record_full_core_ops.to_stratum = record_stratum; | |
d02ed0bb | 2305 | /* Add bookmark target methods. */ |
88d1aa9d MM |
2306 | record_full_core_ops.to_get_bookmark = record_full_get_bookmark; |
2307 | record_full_core_ops.to_goto_bookmark = record_full_goto_bookmark; | |
2308 | record_full_core_ops.to_async = record_full_async; | |
2309 | record_full_core_ops.to_can_async_p = record_full_can_async_p; | |
2310 | record_full_core_ops.to_is_async_p = record_full_is_async_p; | |
2311 | record_full_core_ops.to_execution_direction | |
2312 | = record_full_execution_direction; | |
2313 | record_full_core_ops.to_info_record = record_full_info; | |
2314 | record_full_core_ops.to_delete_record = record_full_delete; | |
2315 | record_full_core_ops.to_record_is_replaying = record_full_is_replaying; | |
2316 | record_full_core_ops.to_goto_record_begin = record_full_goto_begin; | |
2317 | record_full_core_ops.to_goto_record_end = record_full_goto_end; | |
2318 | record_full_core_ops.to_goto_record = record_full_goto; | |
2319 | record_full_core_ops.to_magic = OPS_MAGIC; | |
d02ed0bb MM |
2320 | } |
2321 | ||
2322 | /* Record log save-file format | |
2323 | Version 1 (never released) | |
2324 | ||
2325 | Header: | |
2326 | 4 bytes: magic number htonl(0x20090829). | |
2327 | NOTE: be sure to change whenever this file format changes! | |
2328 | ||
2329 | Records: | |
88d1aa9d MM |
2330 | record_full_end: |
2331 | 1 byte: record type (record_full_end, see enum record_full_type). | |
2332 | record_full_reg: | |
2333 | 1 byte: record type (record_full_reg, see enum record_full_type). | |
d02ed0bb MM |
2334 | 8 bytes: register id (network byte order). |
2335 | MAX_REGISTER_SIZE bytes: register value. | |
88d1aa9d MM |
2336 | record_full_mem: |
2337 | 1 byte: record type (record_full_mem, see enum record_full_type). | |
d02ed0bb MM |
2338 | 8 bytes: memory length (network byte order). |
2339 | 8 bytes: memory address (network byte order). | |
2340 | n bytes: memory value (n == memory length). | |
2341 | ||
2342 | Version 2 | |
2343 | 4 bytes: magic number netorder32(0x20091016). | |
2344 | NOTE: be sure to change whenever this file format changes! | |
2345 | ||
2346 | Records: | |
88d1aa9d MM |
2347 | record_full_end: |
2348 | 1 byte: record type (record_full_end, see enum record_full_type). | |
d02ed0bb MM |
2349 | 4 bytes: signal |
2350 | 4 bytes: instruction count | |
88d1aa9d MM |
2351 | record_full_reg: |
2352 | 1 byte: record type (record_full_reg, see enum record_full_type). | |
d02ed0bb MM |
2353 | 4 bytes: register id (network byte order). |
2354 | n bytes: register value (n == actual register size). | |
2355 | (eg. 4 bytes for x86 general registers). | |
88d1aa9d MM |
2356 | record_full_mem: |
2357 | 1 byte: record type (record_full_mem, see enum record_full_type). | |
d02ed0bb MM |
2358 | 4 bytes: memory length (network byte order). |
2359 | 8 bytes: memory address (network byte order). | |
2360 | n bytes: memory value (n == memory length). | |
2361 | ||
2362 | */ | |
2363 | ||
2364 | /* bfdcore_read -- read bytes from a core file section. */ | |
2365 | ||
2366 | static inline void | |
2367 | bfdcore_read (bfd *obfd, asection *osec, void *buf, int len, int *offset) | |
2368 | { | |
2369 | int ret = bfd_get_section_contents (obfd, osec, buf, *offset, len); | |
2370 | ||
2371 | if (ret) | |
2372 | *offset += len; | |
2373 | else | |
2374 | error (_("Failed to read %d bytes from core file %s ('%s')."), | |
2375 | len, bfd_get_filename (obfd), | |
2376 | bfd_errmsg (bfd_get_error ())); | |
2377 | } | |
2378 | ||
2379 | static inline uint64_t | |
2380 | netorder64 (uint64_t input) | |
2381 | { | |
2382 | uint64_t ret; | |
2383 | ||
2384 | store_unsigned_integer ((gdb_byte *) &ret, sizeof (ret), | |
2385 | BFD_ENDIAN_BIG, input); | |
2386 | return ret; | |
2387 | } | |
2388 | ||
2389 | static inline uint32_t | |
2390 | netorder32 (uint32_t input) | |
2391 | { | |
2392 | uint32_t ret; | |
2393 | ||
2394 | store_unsigned_integer ((gdb_byte *) &ret, sizeof (ret), | |
2395 | BFD_ENDIAN_BIG, input); | |
2396 | return ret; | |
2397 | } | |
2398 | ||
2399 | static inline uint16_t | |
2400 | netorder16 (uint16_t input) | |
2401 | { | |
2402 | uint16_t ret; | |
2403 | ||
2404 | store_unsigned_integer ((gdb_byte *) &ret, sizeof (ret), | |
2405 | BFD_ENDIAN_BIG, input); | |
2406 | return ret; | |
2407 | } | |
2408 | ||
2409 | /* Restore the execution log from a core_bfd file. */ | |
2410 | static void | |
88d1aa9d | 2411 | record_full_restore (void) |
d02ed0bb MM |
2412 | { |
2413 | uint32_t magic; | |
2414 | struct cleanup *old_cleanups; | |
88d1aa9d | 2415 | struct record_full_entry *rec; |
d02ed0bb MM |
2416 | asection *osec; |
2417 | uint32_t osec_size; | |
2418 | int bfd_offset = 0; | |
2419 | struct regcache *regcache; | |
2420 | ||
2421 | /* We restore the execution log from the open core bfd, | |
2422 | if there is one. */ | |
2423 | if (core_bfd == NULL) | |
2424 | return; | |
2425 | ||
88d1aa9d MM |
2426 | /* "record_full_restore" can only be called when record list is empty. */ |
2427 | gdb_assert (record_full_first.next == NULL); | |
d02ed0bb MM |
2428 | |
2429 | if (record_debug) | |
2430 | fprintf_unfiltered (gdb_stdlog, "Restoring recording from core file.\n"); | |
2431 | ||
2432 | /* Now need to find our special note section. */ | |
2433 | osec = bfd_get_section_by_name (core_bfd, "null0"); | |
2434 | if (record_debug) | |
2435 | fprintf_unfiltered (gdb_stdlog, "Find precord section %s.\n", | |
2436 | osec ? "succeeded" : "failed"); | |
2437 | if (osec == NULL) | |
2438 | return; | |
2439 | osec_size = bfd_section_size (core_bfd, osec); | |
2440 | if (record_debug) | |
2441 | fprintf_unfiltered (gdb_stdlog, "%s", bfd_section_name (core_bfd, osec)); | |
2442 | ||
2443 | /* Check the magic code. */ | |
2444 | bfdcore_read (core_bfd, osec, &magic, sizeof (magic), &bfd_offset); | |
88d1aa9d | 2445 | if (magic != RECORD_FULL_FILE_MAGIC) |
d02ed0bb MM |
2446 | error (_("Version mis-match or file format error in core file %s."), |
2447 | bfd_get_filename (core_bfd)); | |
2448 | if (record_debug) | |
2449 | fprintf_unfiltered (gdb_stdlog, | |
2450 | " Reading 4-byte magic cookie " | |
88d1aa9d | 2451 | "RECORD_FULL_FILE_MAGIC (0x%s)\n", |
d02ed0bb MM |
2452 | phex_nz (netorder32 (magic), 4)); |
2453 | ||
88d1aa9d MM |
2454 | /* Restore the entries in recfd into record_full_arch_list_head and |
2455 | record_full_arch_list_tail. */ | |
2456 | record_full_arch_list_head = NULL; | |
2457 | record_full_arch_list_tail = NULL; | |
2458 | record_full_insn_num = 0; | |
2459 | old_cleanups = make_cleanup (record_full_arch_list_cleanups, 0); | |
d02ed0bb MM |
2460 | regcache = get_current_regcache (); |
2461 | ||
2462 | while (1) | |
2463 | { | |
2464 | uint8_t rectype; | |
2465 | uint32_t regnum, len, signal, count; | |
2466 | uint64_t addr; | |
2467 | ||
2468 | /* We are finished when offset reaches osec_size. */ | |
2469 | if (bfd_offset >= osec_size) | |
2470 | break; | |
2471 | bfdcore_read (core_bfd, osec, &rectype, sizeof (rectype), &bfd_offset); | |
2472 | ||
2473 | switch (rectype) | |
2474 | { | |
88d1aa9d | 2475 | case record_full_reg: /* reg */ |
d02ed0bb MM |
2476 | /* Get register number to regnum. */ |
2477 | bfdcore_read (core_bfd, osec, ®num, | |
2478 | sizeof (regnum), &bfd_offset); | |
2479 | regnum = netorder32 (regnum); | |
2480 | ||
88d1aa9d | 2481 | rec = record_full_reg_alloc (regcache, regnum); |
d02ed0bb MM |
2482 | |
2483 | /* Get val. */ | |
88d1aa9d | 2484 | bfdcore_read (core_bfd, osec, record_full_get_loc (rec), |
d02ed0bb MM |
2485 | rec->u.reg.len, &bfd_offset); |
2486 | ||
2487 | if (record_debug) | |
2488 | fprintf_unfiltered (gdb_stdlog, | |
2489 | " Reading register %d (1 " | |
2490 | "plus %lu plus %d bytes)\n", | |
2491 | rec->u.reg.num, | |
2492 | (unsigned long) sizeof (regnum), | |
2493 | rec->u.reg.len); | |
2494 | break; | |
2495 | ||
88d1aa9d | 2496 | case record_full_mem: /* mem */ |
d02ed0bb MM |
2497 | /* Get len. */ |
2498 | bfdcore_read (core_bfd, osec, &len, | |
2499 | sizeof (len), &bfd_offset); | |
2500 | len = netorder32 (len); | |
2501 | ||
2502 | /* Get addr. */ | |
2503 | bfdcore_read (core_bfd, osec, &addr, | |
2504 | sizeof (addr), &bfd_offset); | |
2505 | addr = netorder64 (addr); | |
2506 | ||
88d1aa9d | 2507 | rec = record_full_mem_alloc (addr, len); |
d02ed0bb MM |
2508 | |
2509 | /* Get val. */ | |
88d1aa9d | 2510 | bfdcore_read (core_bfd, osec, record_full_get_loc (rec), |
d02ed0bb MM |
2511 | rec->u.mem.len, &bfd_offset); |
2512 | ||
2513 | if (record_debug) | |
2514 | fprintf_unfiltered (gdb_stdlog, | |
2515 | " Reading memory %s (1 plus " | |
2516 | "%lu plus %lu plus %d bytes)\n", | |
2517 | paddress (get_current_arch (), | |
2518 | rec->u.mem.addr), | |
2519 | (unsigned long) sizeof (addr), | |
2520 | (unsigned long) sizeof (len), | |
2521 | rec->u.mem.len); | |
2522 | break; | |
2523 | ||
88d1aa9d MM |
2524 | case record_full_end: /* end */ |
2525 | rec = record_full_end_alloc (); | |
2526 | record_full_insn_num ++; | |
d02ed0bb MM |
2527 | |
2528 | /* Get signal value. */ | |
2529 | bfdcore_read (core_bfd, osec, &signal, | |
2530 | sizeof (signal), &bfd_offset); | |
2531 | signal = netorder32 (signal); | |
2532 | rec->u.end.sigval = signal; | |
2533 | ||
2534 | /* Get insn count. */ | |
2535 | bfdcore_read (core_bfd, osec, &count, | |
2536 | sizeof (count), &bfd_offset); | |
2537 | count = netorder32 (count); | |
2538 | rec->u.end.insn_num = count; | |
88d1aa9d | 2539 | record_full_insn_count = count + 1; |
d02ed0bb MM |
2540 | if (record_debug) |
2541 | fprintf_unfiltered (gdb_stdlog, | |
88d1aa9d | 2542 | " Reading record_full_end (1 + " |
d02ed0bb MM |
2543 | "%lu + %lu bytes), offset == %s\n", |
2544 | (unsigned long) sizeof (signal), | |
2545 | (unsigned long) sizeof (count), | |
2546 | paddress (get_current_arch (), | |
2547 | bfd_offset)); | |
2548 | break; | |
2549 | ||
2550 | default: | |
2551 | error (_("Bad entry type in core file %s."), | |
2552 | bfd_get_filename (core_bfd)); | |
2553 | break; | |
2554 | } | |
2555 | ||
2556 | /* Add rec to record arch list. */ | |
88d1aa9d | 2557 | record_full_arch_list_add (rec); |
d02ed0bb MM |
2558 | } |
2559 | ||
2560 | discard_cleanups (old_cleanups); | |
2561 | ||
88d1aa9d MM |
2562 | /* Add record_full_arch_list_head to the end of record list. */ |
2563 | record_full_first.next = record_full_arch_list_head; | |
2564 | record_full_arch_list_head->prev = &record_full_first; | |
2565 | record_full_arch_list_tail->next = NULL; | |
2566 | record_full_list = &record_full_first; | |
d02ed0bb | 2567 | |
88d1aa9d MM |
2568 | /* Update record_full_insn_max_num. */ |
2569 | if (record_full_insn_num > record_full_insn_max_num) | |
d02ed0bb | 2570 | { |
88d1aa9d | 2571 | record_full_insn_max_num = record_full_insn_num; |
7ee70bf5 | 2572 | warning (_("Auto increase record/replay buffer limit to %u."), |
88d1aa9d | 2573 | record_full_insn_max_num); |
d02ed0bb MM |
2574 | } |
2575 | ||
2576 | /* Succeeded. */ | |
2577 | printf_filtered (_("Restored records from core file %s.\n"), | |
2578 | bfd_get_filename (core_bfd)); | |
2579 | ||
08d72866 | 2580 | print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1); |
d02ed0bb MM |
2581 | } |
2582 | ||
2583 | /* bfdcore_write -- write bytes into a core file section. */ | |
2584 | ||
2585 | static inline void | |
2586 | bfdcore_write (bfd *obfd, asection *osec, void *buf, int len, int *offset) | |
2587 | { | |
2588 | int ret = bfd_set_section_contents (obfd, osec, buf, *offset, len); | |
2589 | ||
2590 | if (ret) | |
2591 | *offset += len; | |
2592 | else | |
2593 | error (_("Failed to write %d bytes to core file %s ('%s')."), | |
2594 | len, bfd_get_filename (obfd), | |
2595 | bfd_errmsg (bfd_get_error ())); | |
2596 | } | |
2597 | ||
2598 | /* Restore the execution log from a file. We use a modified elf | |
2599 | corefile format, with an extra section for our data. */ | |
2600 | ||
2601 | static void | |
88d1aa9d | 2602 | cmd_record_full_restore (char *args, int from_tty) |
d02ed0bb MM |
2603 | { |
2604 | core_file_command (args, from_tty); | |
88d1aa9d | 2605 | record_full_open (args, from_tty); |
d02ed0bb MM |
2606 | } |
2607 | ||
2608 | static void | |
88d1aa9d | 2609 | record_full_save_cleanups (void *data) |
d02ed0bb MM |
2610 | { |
2611 | bfd *obfd = data; | |
2612 | char *pathname = xstrdup (bfd_get_filename (obfd)); | |
2613 | ||
2614 | gdb_bfd_unref (obfd); | |
2615 | unlink (pathname); | |
2616 | xfree (pathname); | |
2617 | } | |
2618 | ||
2619 | /* Save the execution log to a file. We use a modified elf corefile | |
2620 | format, with an extra section for our data. */ | |
2621 | ||
2622 | static void | |
85e1311a | 2623 | record_full_save (const char *recfilename) |
d02ed0bb | 2624 | { |
88d1aa9d | 2625 | struct record_full_entry *cur_record_full_list; |
d02ed0bb MM |
2626 | uint32_t magic; |
2627 | struct regcache *regcache; | |
2628 | struct gdbarch *gdbarch; | |
2629 | struct cleanup *old_cleanups; | |
2630 | struct cleanup *set_cleanups; | |
2631 | bfd *obfd; | |
2632 | int save_size = 0; | |
2633 | asection *osec = NULL; | |
2634 | int bfd_offset = 0; | |
2635 | ||
2636 | /* Open the save file. */ | |
2637 | if (record_debug) | |
2638 | fprintf_unfiltered (gdb_stdlog, "Saving execution log to core file '%s'\n", | |
2639 | recfilename); | |
2640 | ||
2641 | /* Open the output file. */ | |
2642 | obfd = create_gcore_bfd (recfilename); | |
88d1aa9d | 2643 | old_cleanups = make_cleanup (record_full_save_cleanups, obfd); |
d02ed0bb | 2644 | |
88d1aa9d MM |
2645 | /* Save the current record entry to "cur_record_full_list". */ |
2646 | cur_record_full_list = record_full_list; | |
d02ed0bb MM |
2647 | |
2648 | /* Get the values of regcache and gdbarch. */ | |
2649 | regcache = get_current_regcache (); | |
2650 | gdbarch = get_regcache_arch (regcache); | |
2651 | ||
2652 | /* Disable the GDB operation record. */ | |
25ea693b | 2653 | set_cleanups = record_full_gdb_operation_disable_set (); |
d02ed0bb MM |
2654 | |
2655 | /* Reverse execute to the begin of record list. */ | |
2656 | while (1) | |
2657 | { | |
2658 | /* Check for beginning and end of log. */ | |
88d1aa9d | 2659 | if (record_full_list == &record_full_first) |
d02ed0bb MM |
2660 | break; |
2661 | ||
88d1aa9d | 2662 | record_full_exec_insn (regcache, gdbarch, record_full_list); |
d02ed0bb | 2663 | |
88d1aa9d MM |
2664 | if (record_full_list->prev) |
2665 | record_full_list = record_full_list->prev; | |
d02ed0bb MM |
2666 | } |
2667 | ||
2668 | /* Compute the size needed for the extra bfd section. */ | |
2669 | save_size = 4; /* magic cookie */ | |
88d1aa9d MM |
2670 | for (record_full_list = record_full_first.next; record_full_list; |
2671 | record_full_list = record_full_list->next) | |
2672 | switch (record_full_list->type) | |
d02ed0bb | 2673 | { |
88d1aa9d | 2674 | case record_full_end: |
d02ed0bb MM |
2675 | save_size += 1 + 4 + 4; |
2676 | break; | |
88d1aa9d MM |
2677 | case record_full_reg: |
2678 | save_size += 1 + 4 + record_full_list->u.reg.len; | |
d02ed0bb | 2679 | break; |
88d1aa9d MM |
2680 | case record_full_mem: |
2681 | save_size += 1 + 4 + 8 + record_full_list->u.mem.len; | |
d02ed0bb MM |
2682 | break; |
2683 | } | |
2684 | ||
2685 | /* Make the new bfd section. */ | |
2686 | osec = bfd_make_section_anyway_with_flags (obfd, "precord", | |
2687 | SEC_HAS_CONTENTS | |
2688 | | SEC_READONLY); | |
2689 | if (osec == NULL) | |
2690 | error (_("Failed to create 'precord' section for corefile %s: %s"), | |
2691 | recfilename, | |
2692 | bfd_errmsg (bfd_get_error ())); | |
2693 | bfd_set_section_size (obfd, osec, save_size); | |
2694 | bfd_set_section_vma (obfd, osec, 0); | |
2695 | bfd_set_section_alignment (obfd, osec, 0); | |
2696 | bfd_section_lma (obfd, osec) = 0; | |
2697 | ||
2698 | /* Save corefile state. */ | |
2699 | write_gcore_file (obfd); | |
2700 | ||
2701 | /* Write out the record log. */ | |
2702 | /* Write the magic code. */ | |
88d1aa9d | 2703 | magic = RECORD_FULL_FILE_MAGIC; |
d02ed0bb MM |
2704 | if (record_debug) |
2705 | fprintf_unfiltered (gdb_stdlog, | |
2706 | " Writing 4-byte magic cookie " | |
88d1aa9d | 2707 | "RECORD_FULL_FILE_MAGIC (0x%s)\n", |
d02ed0bb MM |
2708 | phex_nz (magic, 4)); |
2709 | bfdcore_write (obfd, osec, &magic, sizeof (magic), &bfd_offset); | |
2710 | ||
2711 | /* Save the entries to recfd and forward execute to the end of | |
2712 | record list. */ | |
88d1aa9d | 2713 | record_full_list = &record_full_first; |
d02ed0bb MM |
2714 | while (1) |
2715 | { | |
2716 | /* Save entry. */ | |
88d1aa9d | 2717 | if (record_full_list != &record_full_first) |
d02ed0bb MM |
2718 | { |
2719 | uint8_t type; | |
2720 | uint32_t regnum, len, signal, count; | |
2721 | uint64_t addr; | |
2722 | ||
88d1aa9d | 2723 | type = record_full_list->type; |
d02ed0bb MM |
2724 | bfdcore_write (obfd, osec, &type, sizeof (type), &bfd_offset); |
2725 | ||
88d1aa9d | 2726 | switch (record_full_list->type) |
d02ed0bb | 2727 | { |
88d1aa9d | 2728 | case record_full_reg: /* reg */ |
d02ed0bb MM |
2729 | if (record_debug) |
2730 | fprintf_unfiltered (gdb_stdlog, | |
2731 | " Writing register %d (1 " | |
2732 | "plus %lu plus %d bytes)\n", | |
88d1aa9d | 2733 | record_full_list->u.reg.num, |
d02ed0bb | 2734 | (unsigned long) sizeof (regnum), |
88d1aa9d | 2735 | record_full_list->u.reg.len); |
d02ed0bb MM |
2736 | |
2737 | /* Write regnum. */ | |
88d1aa9d | 2738 | regnum = netorder32 (record_full_list->u.reg.num); |
d02ed0bb MM |
2739 | bfdcore_write (obfd, osec, ®num, |
2740 | sizeof (regnum), &bfd_offset); | |
2741 | ||
2742 | /* Write regval. */ | |
88d1aa9d MM |
2743 | bfdcore_write (obfd, osec, |
2744 | record_full_get_loc (record_full_list), | |
2745 | record_full_list->u.reg.len, &bfd_offset); | |
d02ed0bb MM |
2746 | break; |
2747 | ||
88d1aa9d | 2748 | case record_full_mem: /* mem */ |
d02ed0bb MM |
2749 | if (record_debug) |
2750 | fprintf_unfiltered (gdb_stdlog, | |
2751 | " Writing memory %s (1 plus " | |
2752 | "%lu plus %lu plus %d bytes)\n", | |
2753 | paddress (gdbarch, | |
88d1aa9d | 2754 | record_full_list->u.mem.addr), |
d02ed0bb MM |
2755 | (unsigned long) sizeof (addr), |
2756 | (unsigned long) sizeof (len), | |
88d1aa9d | 2757 | record_full_list->u.mem.len); |
d02ed0bb MM |
2758 | |
2759 | /* Write memlen. */ | |
88d1aa9d | 2760 | len = netorder32 (record_full_list->u.mem.len); |
d02ed0bb MM |
2761 | bfdcore_write (obfd, osec, &len, sizeof (len), &bfd_offset); |
2762 | ||
2763 | /* Write memaddr. */ | |
88d1aa9d | 2764 | addr = netorder64 (record_full_list->u.mem.addr); |
d02ed0bb MM |
2765 | bfdcore_write (obfd, osec, &addr, |
2766 | sizeof (addr), &bfd_offset); | |
2767 | ||
2768 | /* Write memval. */ | |
88d1aa9d MM |
2769 | bfdcore_write (obfd, osec, |
2770 | record_full_get_loc (record_full_list), | |
2771 | record_full_list->u.mem.len, &bfd_offset); | |
d02ed0bb MM |
2772 | break; |
2773 | ||
88d1aa9d | 2774 | case record_full_end: |
d02ed0bb MM |
2775 | if (record_debug) |
2776 | fprintf_unfiltered (gdb_stdlog, | |
88d1aa9d | 2777 | " Writing record_full_end (1 + " |
d02ed0bb MM |
2778 | "%lu + %lu bytes)\n", |
2779 | (unsigned long) sizeof (signal), | |
2780 | (unsigned long) sizeof (count)); | |
2781 | /* Write signal value. */ | |
88d1aa9d | 2782 | signal = netorder32 (record_full_list->u.end.sigval); |
d02ed0bb MM |
2783 | bfdcore_write (obfd, osec, &signal, |
2784 | sizeof (signal), &bfd_offset); | |
2785 | ||
2786 | /* Write insn count. */ | |
88d1aa9d | 2787 | count = netorder32 (record_full_list->u.end.insn_num); |
d02ed0bb MM |
2788 | bfdcore_write (obfd, osec, &count, |
2789 | sizeof (count), &bfd_offset); | |
2790 | break; | |
2791 | } | |
2792 | } | |
2793 | ||
2794 | /* Execute entry. */ | |
88d1aa9d | 2795 | record_full_exec_insn (regcache, gdbarch, record_full_list); |
d02ed0bb | 2796 | |
88d1aa9d MM |
2797 | if (record_full_list->next) |
2798 | record_full_list = record_full_list->next; | |
d02ed0bb MM |
2799 | else |
2800 | break; | |
2801 | } | |
2802 | ||
88d1aa9d | 2803 | /* Reverse execute to cur_record_full_list. */ |
d02ed0bb MM |
2804 | while (1) |
2805 | { | |
2806 | /* Check for beginning and end of log. */ | |
88d1aa9d | 2807 | if (record_full_list == cur_record_full_list) |
d02ed0bb MM |
2808 | break; |
2809 | ||
88d1aa9d | 2810 | record_full_exec_insn (regcache, gdbarch, record_full_list); |
d02ed0bb | 2811 | |
88d1aa9d MM |
2812 | if (record_full_list->prev) |
2813 | record_full_list = record_full_list->prev; | |
d02ed0bb MM |
2814 | } |
2815 | ||
2816 | do_cleanups (set_cleanups); | |
2817 | gdb_bfd_unref (obfd); | |
2818 | discard_cleanups (old_cleanups); | |
2819 | ||
2820 | /* Succeeded. */ | |
2821 | printf_filtered (_("Saved core file %s with execution log.\n"), | |
2822 | recfilename); | |
2823 | } | |
2824 | ||
88d1aa9d | 2825 | /* record_full_goto_insn -- rewind the record log (forward or backward, |
d02ed0bb MM |
2826 | depending on DIR) to the given entry, changing the program state |
2827 | correspondingly. */ | |
2828 | ||
2829 | static void | |
88d1aa9d MM |
2830 | record_full_goto_insn (struct record_full_entry *entry, |
2831 | enum exec_direction_kind dir) | |
d02ed0bb | 2832 | { |
25ea693b | 2833 | struct cleanup *set_cleanups = record_full_gdb_operation_disable_set (); |
d02ed0bb MM |
2834 | struct regcache *regcache = get_current_regcache (); |
2835 | struct gdbarch *gdbarch = get_regcache_arch (regcache); | |
2836 | ||
2837 | /* Assume everything is valid: we will hit the entry, | |
2838 | and we will not hit the end of the recording. */ | |
2839 | ||
2840 | if (dir == EXEC_FORWARD) | |
88d1aa9d | 2841 | record_full_list = record_full_list->next; |
d02ed0bb MM |
2842 | |
2843 | do | |
2844 | { | |
88d1aa9d | 2845 | record_full_exec_insn (regcache, gdbarch, record_full_list); |
d02ed0bb | 2846 | if (dir == EXEC_REVERSE) |
88d1aa9d | 2847 | record_full_list = record_full_list->prev; |
d02ed0bb | 2848 | else |
88d1aa9d MM |
2849 | record_full_list = record_full_list->next; |
2850 | } while (record_full_list != entry); | |
d02ed0bb MM |
2851 | do_cleanups (set_cleanups); |
2852 | } | |
2853 | ||
2854 | /* Alias for "target record-full". */ | |
2855 | ||
2856 | static void | |
88d1aa9d | 2857 | cmd_record_full_start (char *args, int from_tty) |
d02ed0bb MM |
2858 | { |
2859 | execute_command ("target record-full", from_tty); | |
2860 | } | |
2861 | ||
2862 | static void | |
88d1aa9d MM |
2863 | set_record_full_insn_max_num (char *args, int from_tty, |
2864 | struct cmd_list_element *c) | |
d02ed0bb | 2865 | { |
7ee70bf5 | 2866 | if (record_full_insn_num > record_full_insn_max_num) |
d02ed0bb | 2867 | { |
88d1aa9d MM |
2868 | /* Count down record_full_insn_num while releasing records from list. */ |
2869 | while (record_full_insn_num > record_full_insn_max_num) | |
d02ed0bb | 2870 | { |
88d1aa9d MM |
2871 | record_full_list_release_first (); |
2872 | record_full_insn_num--; | |
d02ed0bb MM |
2873 | } |
2874 | } | |
2875 | } | |
2876 | ||
2877 | /* The "set record full" command. */ | |
2878 | ||
2879 | static void | |
2880 | set_record_full_command (char *args, int from_tty) | |
2881 | { | |
2882 | printf_unfiltered (_("\"set record full\" must be followed " | |
2883 | "by an apporpriate subcommand.\n")); | |
2884 | help_list (set_record_full_cmdlist, "set record full ", all_commands, | |
2885 | gdb_stdout); | |
2886 | } | |
2887 | ||
2888 | /* The "show record full" command. */ | |
2889 | ||
2890 | static void | |
2891 | show_record_full_command (char *args, int from_tty) | |
2892 | { | |
2893 | cmd_show_list (show_record_full_cmdlist, from_tty, ""); | |
2894 | } | |
2895 | ||
2896 | /* Provide a prototype to silence -Wmissing-prototypes. */ | |
2897 | extern initialize_file_ftype _initialize_record_full; | |
2898 | ||
2899 | void | |
2900 | _initialize_record_full (void) | |
2901 | { | |
2902 | struct cmd_list_element *c; | |
2903 | ||
88d1aa9d MM |
2904 | /* Init record_full_first. */ |
2905 | record_full_first.prev = NULL; | |
2906 | record_full_first.next = NULL; | |
2907 | record_full_first.type = record_full_end; | |
d02ed0bb | 2908 | |
88d1aa9d MM |
2909 | init_record_full_ops (); |
2910 | add_target (&record_full_ops); | |
2911 | add_deprecated_target_alias (&record_full_ops, "record"); | |
2912 | init_record_full_core_ops (); | |
2913 | add_target (&record_full_core_ops); | |
d02ed0bb | 2914 | |
88d1aa9d | 2915 | add_prefix_cmd ("full", class_obscure, cmd_record_full_start, |
d02ed0bb MM |
2916 | _("Start full execution recording."), &record_full_cmdlist, |
2917 | "record full ", 0, &record_cmdlist); | |
2918 | ||
88d1aa9d | 2919 | c = add_cmd ("restore", class_obscure, cmd_record_full_restore, |
d02ed0bb MM |
2920 | _("Restore the execution log from a file.\n\ |
2921 | Argument is filename. File must be created with 'record save'."), | |
2922 | &record_full_cmdlist); | |
2923 | set_cmd_completer (c, filename_completer); | |
2924 | ||
2925 | /* Deprecate the old version without "full" prefix. */ | |
2926 | c = add_alias_cmd ("restore", "full restore", class_obscure, 1, | |
2927 | &record_cmdlist); | |
2928 | set_cmd_completer (c, filename_completer); | |
2929 | deprecate_cmd (c, "record full restore"); | |
2930 | ||
2931 | add_prefix_cmd ("full", class_support, set_record_full_command, | |
2932 | _("Set record options"), &set_record_full_cmdlist, | |
2933 | "set record full ", 0, &set_record_cmdlist); | |
2934 | ||
2935 | add_prefix_cmd ("full", class_support, show_record_full_command, | |
2936 | _("Show record options"), &show_record_full_cmdlist, | |
2937 | "show record full ", 0, &show_record_cmdlist); | |
2938 | ||
2939 | /* Record instructions number limit command. */ | |
2940 | add_setshow_boolean_cmd ("stop-at-limit", no_class, | |
88d1aa9d | 2941 | &record_full_stop_at_limit, _("\ |
d02ed0bb MM |
2942 | Set whether record/replay stops when record/replay buffer becomes full."), _("\ |
2943 | Show whether record/replay stops when record/replay buffer becomes full."), | |
2944 | _("Default is ON.\n\ | |
2945 | When ON, if the record/replay buffer becomes full, ask user what to do.\n\ | |
2946 | When OFF, if the record/replay buffer becomes full,\n\ | |
2947 | delete the oldest recorded instruction to make room for each new one."), | |
2948 | NULL, NULL, | |
2949 | &set_record_full_cmdlist, &show_record_full_cmdlist); | |
2950 | ||
2951 | c = add_alias_cmd ("stop-at-limit", "full stop-at-limit", no_class, 1, | |
2952 | &set_record_cmdlist); | |
2953 | deprecate_cmd (c, "set record full stop-at-limit"); | |
2954 | ||
2955 | c = add_alias_cmd ("stop-at-limit", "full stop-at-limit", no_class, 1, | |
2956 | &show_record_cmdlist); | |
2957 | deprecate_cmd (c, "show record full stop-at-limit"); | |
2958 | ||
88d1aa9d MM |
2959 | add_setshow_uinteger_cmd ("insn-number-max", no_class, |
2960 | &record_full_insn_max_num, | |
d02ed0bb MM |
2961 | _("Set record/replay buffer limit."), |
2962 | _("Show record/replay buffer limit."), _("\ | |
2963 | Set the maximum number of instructions to be stored in the\n\ | |
f81d1120 PA |
2964 | record/replay buffer. A value of either \"unlimited\" or zero means no\n\ |
2965 | limit. Default is 200000."), | |
88d1aa9d | 2966 | set_record_full_insn_max_num, |
d02ed0bb MM |
2967 | NULL, &set_record_full_cmdlist, |
2968 | &show_record_full_cmdlist); | |
2969 | ||
2970 | c = add_alias_cmd ("insn-number-max", "full insn-number-max", no_class, 1, | |
2971 | &set_record_cmdlist); | |
2972 | deprecate_cmd (c, "set record full insn-number-max"); | |
2973 | ||
2974 | c = add_alias_cmd ("insn-number-max", "full insn-number-max", no_class, 1, | |
2975 | &show_record_cmdlist); | |
2976 | deprecate_cmd (c, "show record full insn-number-max"); | |
2977 | ||
88d1aa9d | 2978 | add_setshow_boolean_cmd ("memory-query", no_class, |
25ea693b | 2979 | &record_full_memory_query, _("\ |
d02ed0bb MM |
2980 | Set whether query if PREC cannot record memory change of next instruction."), |
2981 | _("\ | |
2982 | Show whether query if PREC cannot record memory change of next instruction."), | |
2983 | _("\ | |
2984 | Default is OFF.\n\ | |
2985 | When ON, query if PREC cannot record memory change of next instruction."), | |
2986 | NULL, NULL, | |
88d1aa9d MM |
2987 | &set_record_full_cmdlist, |
2988 | &show_record_full_cmdlist); | |
d02ed0bb MM |
2989 | |
2990 | c = add_alias_cmd ("memory-query", "full memory-query", no_class, 1, | |
2991 | &set_record_cmdlist); | |
2992 | deprecate_cmd (c, "set record full memory-query"); | |
2993 | ||
2994 | c = add_alias_cmd ("memory-query", "full memory-query", no_class, 1, | |
2995 | &show_record_cmdlist); | |
2996 | deprecate_cmd (c, "show record full memory-query"); | |
2997 | } |