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