1 /* Process record and replay target for GDB, the GNU debugger.
3 Copyright (C) 2008, 2009 Free Software Foundation, Inc.
5 This file is part of GDB.
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.
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.
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/>. */
23 #include "gdbthread.h"
24 #include "event-top.h"
25 #include "exceptions.h"
32 /* This module implements "target record", also known as "process
33 record and replay". This target sits on top of a "normal" target
34 (a target that "has execution"), and provides a record and replay
35 functionality, including reverse debugging.
37 Target record has two modes: recording, and replaying.
39 In record mode, we intercept the to_resume and to_wait methods.
40 Whenever gdb resumes the target, we run the target in single step
41 mode, and we build up an execution log in which, for each executed
42 instruction, we record all changes in memory and register state.
43 This is invisible to the user, to whom it just looks like an
44 ordinary debugging session (except for performance degredation).
46 In replay mode, instead of actually letting the inferior run as a
47 process, we simulate its execution by playing back the recorded
48 execution log. For each instruction in the log, we simulate the
49 instruction's side effects by duplicating the changes that it would
50 have made on memory and registers. */
52 #define DEFAULT_RECORD_INSN_MAX_NUM 200000
54 #define RECORD_IS_REPLAY \
55 (record_list->next || execution_direction == EXEC_REVERSE)
57 /* These are the core structs of the process record functionality.
59 A record_entry is a record of the value change of a register
60 ("record_reg") or a part of memory ("record_mem"). And each
61 instruction must have a struct record_entry ("record_end") that
62 indicates that this is the last struct record_entry of this
65 Each struct record_entry is linked to "record_list" by "prev" and
68 struct record_mem_entry
72 /* Set this flag if target memory for this entry
73 can no longer be accessed. */
74 int mem_entry_not_accessible;
78 gdb_byte buf[sizeof (gdb_byte *)];
82 struct record_reg_entry
89 gdb_byte buf[2 * sizeof (gdb_byte *)];
93 struct record_end_entry
95 enum target_signal sigval;
106 /* This is the data structure that makes up the execution log.
108 The execution log consists of a single linked list of entries
109 of type "struct record_entry". It is doubly linked so that it
110 can be traversed in either direction.
112 The start of the list is anchored by a struct called
113 "record_first". The pointer "record_list" either points to the
114 last entry that was added to the list (in record mode), or to the
115 next entry in the list that will be executed (in replay mode).
117 Each list element (struct record_entry), in addition to next and
118 prev pointers, consists of a union of three entry types: mem, reg,
119 and end. A field called "type" determines which entry type is
120 represented by a given list element.
122 Each instruction that is added to the execution log is represented
123 by a variable number of list elements ('entries'). The instruction
124 will have one "reg" entry for each register that is changed by
125 executing the instruction (including the PC in every case). It
126 will also have one "mem" entry for each memory change. Finally,
127 each instruction will have an "end" entry that separates it from
128 the changes associated with the next instruction. */
132 struct record_entry *prev;
133 struct record_entry *next;
134 enum record_type type;
138 struct record_reg_entry reg;
140 struct record_mem_entry mem;
142 struct record_end_entry end;
146 /* This is the debug switch for process record. */
147 int record_debug = 0;
149 struct record_core_buf_entry
151 struct record_core_buf_entry *prev;
152 struct target_section *p;
156 /* Record buf with core target. */
157 static gdb_byte *record_core_regbuf = NULL;
158 static struct target_section *record_core_start;
159 static struct target_section *record_core_end;
160 static struct record_core_buf_entry *record_core_buf_list = NULL;
162 /* The following variables are used for managing the linked list that
163 represents the execution log.
165 record_first is the anchor that holds down the beginning of the list.
167 record_list serves two functions:
168 1) In record mode, it anchors the end of the list.
169 2) In replay mode, it traverses the list and points to
170 the next instruction that must be emulated.
172 record_arch_list_head and record_arch_list_tail are used to manage
173 a separate list, which is used to build up the change elements of
174 the currently executing instruction during record mode. When this
175 instruction has been completely annotated in the "arch list", it
176 will be appended to the main execution log. */
178 static struct record_entry record_first;
179 static struct record_entry *record_list = &record_first;
180 static struct record_entry *record_arch_list_head = NULL;
181 static struct record_entry *record_arch_list_tail = NULL;
183 /* 1 ask user. 0 auto delete the last struct record_entry. */
184 static int record_stop_at_limit = 1;
185 /* Maximum allowed number of insns in execution log. */
186 static unsigned int record_insn_max_num = DEFAULT_RECORD_INSN_MAX_NUM;
187 /* Actual count of insns presently in execution log. */
188 static int record_insn_num = 0;
189 /* Count of insns logged so far (may be larger
190 than count of insns presently in execution log). */
191 static ULONGEST record_insn_count;
193 /* The target_ops of process record. */
194 static struct target_ops record_ops;
195 static struct target_ops record_core_ops;
197 /* The beneath function pointers. */
198 static struct target_ops *record_beneath_to_resume_ops;
199 static void (*record_beneath_to_resume) (struct target_ops *, ptid_t, int,
201 static struct target_ops *record_beneath_to_wait_ops;
202 static ptid_t (*record_beneath_to_wait) (struct target_ops *, ptid_t,
203 struct target_waitstatus *,
205 static struct target_ops *record_beneath_to_store_registers_ops;
206 static void (*record_beneath_to_store_registers) (struct target_ops *,
209 static struct target_ops *record_beneath_to_xfer_partial_ops;
210 static LONGEST (*record_beneath_to_xfer_partial) (struct target_ops *ops,
211 enum target_object object,
214 const gdb_byte *writebuf,
217 static int (*record_beneath_to_insert_breakpoint) (struct gdbarch *,
218 struct bp_target_info *);
219 static int (*record_beneath_to_remove_breakpoint) (struct gdbarch *,
220 struct bp_target_info *);
222 /* Alloc and free functions for record_reg, record_mem, and record_end
225 /* Alloc a record_reg record entry. */
227 static inline struct record_entry *
228 record_reg_alloc (struct regcache *regcache, int regnum)
230 struct record_entry *rec;
231 struct gdbarch *gdbarch = get_regcache_arch (regcache);
233 rec = (struct record_entry *) xcalloc (1, sizeof (struct record_entry));
234 rec->type = record_reg;
235 rec->u.reg.num = regnum;
236 rec->u.reg.len = register_size (gdbarch, regnum);
237 if (rec->u.reg.len > sizeof (rec->u.reg.u.buf))
238 rec->u.reg.u.ptr = (gdb_byte *) xmalloc (rec->u.reg.len);
243 /* Free a record_reg record entry. */
246 record_reg_release (struct record_entry *rec)
248 gdb_assert (rec->type == record_reg);
249 if (rec->u.reg.len > sizeof (rec->u.reg.u.buf))
250 xfree (rec->u.reg.u.ptr);
254 /* Alloc a record_mem record entry. */
256 static inline struct record_entry *
257 record_mem_alloc (CORE_ADDR addr, int len)
259 struct record_entry *rec;
261 rec = (struct record_entry *) xcalloc (1, sizeof (struct record_entry));
262 rec->type = record_mem;
263 rec->u.mem.addr = addr;
264 rec->u.mem.len = len;
265 if (rec->u.mem.len > sizeof (rec->u.mem.u.buf))
266 rec->u.mem.u.ptr = (gdb_byte *) xmalloc (len);
271 /* Free a record_mem record entry. */
274 record_mem_release (struct record_entry *rec)
276 gdb_assert (rec->type == record_mem);
277 if (rec->u.mem.len > sizeof (rec->u.mem.u.buf))
278 xfree (rec->u.mem.u.ptr);
282 /* Alloc a record_end record entry. */
284 static inline struct record_entry *
285 record_end_alloc (void)
287 struct record_entry *rec;
289 rec = (struct record_entry *) xcalloc (1, sizeof (struct record_entry));
290 rec->type = record_end;
295 /* Free a record_end record entry. */
298 record_end_release (struct record_entry *rec)
303 /* Free one record entry, any type.
304 Return entry->type, in case caller wants to know. */
306 static inline enum record_type
307 record_entry_release (struct record_entry *rec)
309 enum record_type type = rec->type;
313 record_reg_release (rec);
316 record_mem_release (rec);
319 record_end_release (rec);
325 /* Free all record entries in list pointed to by REC. */
328 record_list_release (struct record_entry *rec)
339 record_entry_release (rec->next);
342 if (rec == &record_first)
345 record_first.next = NULL;
348 record_entry_release (rec);
351 /* Free all record entries forward of the given list position. */
354 record_list_release_following (struct record_entry *rec)
356 struct record_entry *tmp = rec->next;
362 if (record_entry_release (tmp) == record_end)
371 /* Delete the first instruction from the beginning of the log, to make
372 room for adding a new instruction at the end of the log.
374 Note -- this function does not modify record_insn_num. */
377 record_list_release_first (void)
379 struct record_entry *tmp;
381 if (!record_first.next)
384 /* Loop until a record_end. */
387 /* Cut record_first.next out of the linked list. */
388 tmp = record_first.next;
389 record_first.next = tmp->next;
390 tmp->next->prev = &record_first;
392 /* tmp is now isolated, and can be deleted. */
393 if (record_entry_release (tmp) == record_end)
394 break; /* End loop at first record_end. */
396 if (!record_first.next)
398 gdb_assert (record_insn_num == 1);
399 break; /* End loop when list is empty. */
404 /* Add a struct record_entry to record_arch_list. */
407 record_arch_list_add (struct record_entry *rec)
409 if (record_debug > 1)
410 fprintf_unfiltered (gdb_stdlog,
411 "Process record: record_arch_list_add %s.\n",
412 host_address_to_string (rec));
414 if (record_arch_list_tail)
416 record_arch_list_tail->next = rec;
417 rec->prev = record_arch_list_tail;
418 record_arch_list_tail = rec;
422 record_arch_list_head = rec;
423 record_arch_list_tail = rec;
427 /* Return the value storage location of a record entry. */
428 static inline gdb_byte *
429 record_get_loc (struct record_entry *rec)
433 if (rec->u.mem.len > sizeof (rec->u.mem.u.buf))
434 return rec->u.mem.u.ptr;
436 return rec->u.mem.u.buf;
438 if (rec->u.reg.len > sizeof (rec->u.reg.u.buf))
439 return rec->u.reg.u.ptr;
441 return rec->u.reg.u.buf;
449 /* Record the value of a register NUM to record_arch_list. */
452 record_arch_list_add_reg (struct regcache *regcache, int regnum)
454 struct record_entry *rec;
456 if (record_debug > 1)
457 fprintf_unfiltered (gdb_stdlog,
458 "Process record: add register num = %d to "
462 rec = record_reg_alloc (regcache, regnum);
464 regcache_raw_read (regcache, regnum, record_get_loc (rec));
466 record_arch_list_add (rec);
471 /* Record the value of a region of memory whose address is ADDR and
472 length is LEN to record_arch_list. */
475 record_arch_list_add_mem (CORE_ADDR addr, int len)
477 struct record_entry *rec;
479 if (record_debug > 1)
480 fprintf_unfiltered (gdb_stdlog,
481 "Process record: add mem addr = %s len = %d to "
483 paddress (target_gdbarch, addr), len);
485 if (!addr) /* FIXME: Why? Some arch must permit it... */
488 rec = record_mem_alloc (addr, len);
490 if (target_read_memory (addr, record_get_loc (rec), len))
493 fprintf_unfiltered (gdb_stdlog,
494 "Process record: error reading memory at "
495 "addr = %s len = %d.\n",
496 paddress (target_gdbarch, addr), len);
497 record_mem_release (rec);
501 record_arch_list_add (rec);
506 /* Add a record_end type struct record_entry to record_arch_list. */
509 record_arch_list_add_end (void)
511 struct record_entry *rec;
513 if (record_debug > 1)
514 fprintf_unfiltered (gdb_stdlog,
515 "Process record: add end to arch list.\n");
517 rec = record_end_alloc ();
518 rec->u.end.sigval = TARGET_SIGNAL_0;
519 rec->u.end.insn_num = ++record_insn_count;
521 record_arch_list_add (rec);
527 record_check_insn_num (int set_terminal)
529 if (record_insn_max_num)
531 gdb_assert (record_insn_num <= record_insn_max_num);
532 if (record_insn_num == record_insn_max_num)
534 /* Ask user what to do. */
535 if (record_stop_at_limit)
539 target_terminal_ours ();
540 q = yquery (_("Do you want to auto delete previous execution "
541 "log entries when record/replay buffer becomes "
542 "full (record stop-at-limit)?"));
544 target_terminal_inferior ();
546 record_stop_at_limit = 0;
548 error (_("Process record: inferior program stopped."));
554 /* Before inferior step (when GDB record the running message, inferior
555 only can step), GDB will call this function to record the values to
556 record_list. This function will call gdbarch_process_record to
557 record the running message of inferior and set them to
558 record_arch_list, and add it to record_list. */
561 record_message_cleanups (void *ignore)
563 record_list_release (record_arch_list_tail);
566 struct record_message_args {
567 struct regcache *regcache;
568 enum target_signal signal;
572 record_message (void *args)
575 struct record_message_args *myargs = args;
576 struct gdbarch *gdbarch = get_regcache_arch (myargs->regcache);
577 struct cleanup *old_cleanups = make_cleanup (record_message_cleanups, 0);
579 record_arch_list_head = NULL;
580 record_arch_list_tail = NULL;
582 /* Check record_insn_num. */
583 record_check_insn_num (1);
585 /* If gdb sends a signal value to target_resume,
586 save it in the 'end' field of the previous instruction.
588 Maybe process record should record what really happened,
589 rather than what gdb pretends has happened.
591 So if Linux delivered the signal to the child process during
592 the record mode, we will record it and deliver it again in
595 If user says "ignore this signal" during the record mode, then
596 it will be ignored again during the replay mode (no matter if
597 the user says something different, like "deliver this signal"
598 during the replay mode).
600 User should understand that nothing he does during the replay
601 mode will change the behavior of the child. If he tries,
602 then that is a user error.
604 But we should still deliver the signal to gdb during the replay,
605 if we delivered it during the recording. Therefore we should
606 record the signal during record_wait, not record_resume. */
607 if (record_list != &record_first) /* FIXME better way to check */
609 gdb_assert (record_list->type == record_end);
610 record_list->u.end.sigval = myargs->signal;
613 if (myargs->signal == TARGET_SIGNAL_0
614 || !gdbarch_process_record_signal_p (gdbarch))
615 ret = gdbarch_process_record (gdbarch,
617 regcache_read_pc (myargs->regcache));
619 ret = gdbarch_process_record_signal (gdbarch,
624 error (_("Process record: inferior program stopped."));
626 error (_("Process record: failed to record execution log."));
628 discard_cleanups (old_cleanups);
630 record_list->next = record_arch_list_head;
631 record_arch_list_head->prev = record_list;
632 record_list = record_arch_list_tail;
634 if (record_insn_num == record_insn_max_num && record_insn_max_num)
635 record_list_release_first ();
643 do_record_message (struct regcache *regcache,
644 enum target_signal signal)
646 struct record_message_args args;
648 args.regcache = regcache;
649 args.signal = signal;
650 return catch_errors (record_message, &args, NULL, RETURN_MASK_ALL);
653 /* Set to 1 if record_store_registers and record_xfer_partial
654 doesn't need record. */
656 static int record_gdb_operation_disable = 0;
659 record_gdb_operation_disable_set (void)
661 struct cleanup *old_cleanups = NULL;
664 make_cleanup_restore_integer (&record_gdb_operation_disable);
665 record_gdb_operation_disable = 1;
670 /* Execute one instruction from the record log. Each instruction in
671 the log will be represented by an arbitrary sequence of register
672 entries and memory entries, followed by an 'end' entry. */
675 record_exec_insn (struct regcache *regcache, struct gdbarch *gdbarch,
676 struct record_entry *entry)
680 case record_reg: /* reg */
682 gdb_byte reg[MAX_REGISTER_SIZE];
684 if (record_debug > 1)
685 fprintf_unfiltered (gdb_stdlog,
686 "Process record: record_reg %s to "
687 "inferior num = %d.\n",
688 host_address_to_string (entry),
691 regcache_cooked_read (regcache, entry->u.reg.num, reg);
692 regcache_cooked_write (regcache, entry->u.reg.num,
693 record_get_loc (entry));
694 memcpy (record_get_loc (entry), reg, entry->u.reg.len);
698 case record_mem: /* mem */
700 /* Nothing to do if the entry is flagged not_accessible. */
701 if (!entry->u.mem.mem_entry_not_accessible)
703 gdb_byte *mem = alloca (entry->u.mem.len);
705 if (record_debug > 1)
706 fprintf_unfiltered (gdb_stdlog,
707 "Process record: record_mem %s to "
708 "inferior addr = %s len = %d.\n",
709 host_address_to_string (entry),
710 paddress (gdbarch, entry->u.mem.addr),
713 if (target_read_memory (entry->u.mem.addr, mem, entry->u.mem.len))
715 entry->u.mem.mem_entry_not_accessible = 1;
717 warning (_("Process record: error reading memory at "
718 "addr = %s len = %d."),
719 paddress (gdbarch, entry->u.mem.addr),
724 if (target_write_memory (entry->u.mem.addr,
725 record_get_loc (entry),
728 entry->u.mem.mem_entry_not_accessible = 1;
730 warning (_("Process record: error writing memory at "
731 "addr = %s len = %d."),
732 paddress (gdbarch, entry->u.mem.addr),
736 memcpy (record_get_loc (entry), mem, entry->u.mem.len);
744 static struct target_ops *tmp_to_resume_ops;
745 static void (*tmp_to_resume) (struct target_ops *, ptid_t, int,
747 static struct target_ops *tmp_to_wait_ops;
748 static ptid_t (*tmp_to_wait) (struct target_ops *, ptid_t,
749 struct target_waitstatus *,
751 static struct target_ops *tmp_to_store_registers_ops;
752 static void (*tmp_to_store_registers) (struct target_ops *,
755 static struct target_ops *tmp_to_xfer_partial_ops;
756 static LONGEST (*tmp_to_xfer_partial) (struct target_ops *ops,
757 enum target_object object,
760 const gdb_byte *writebuf,
763 static int (*tmp_to_insert_breakpoint) (struct gdbarch *,
764 struct bp_target_info *);
765 static int (*tmp_to_remove_breakpoint) (struct gdbarch *,
766 struct bp_target_info *);
768 /* Open the process record target. */
771 record_core_open_1 (char *name, int from_tty)
773 struct regcache *regcache = get_current_regcache ();
774 int regnum = gdbarch_num_regs (get_regcache_arch (regcache));
777 /* Get record_core_regbuf. */
778 target_fetch_registers (regcache, -1);
779 record_core_regbuf = xmalloc (MAX_REGISTER_SIZE * regnum);
780 for (i = 0; i < regnum; i ++)
781 regcache_raw_collect (regcache, i,
782 record_core_regbuf + MAX_REGISTER_SIZE * i);
784 /* Get record_core_start and record_core_end. */
785 if (build_section_table (core_bfd, &record_core_start, &record_core_end))
787 xfree (record_core_regbuf);
788 record_core_regbuf = NULL;
789 error (_("\"%s\": Can't find sections: %s"),
790 bfd_get_filename (core_bfd), bfd_errmsg (bfd_get_error ()));
793 push_target (&record_core_ops);
796 /* "to_open" target method for 'live' processes. */
799 record_open_1 (char *name, int from_tty)
801 struct target_ops *t;
804 fprintf_unfiltered (gdb_stdlog, "Process record: record_open\n");
807 if (!target_has_execution)
808 error (_("Process record: the program is not being run."));
810 error (_("Process record target can't debug inferior in non-stop mode "
812 if (target_async_permitted)
813 error (_("Process record target can't debug inferior in asynchronous "
814 "mode (target-async)."));
816 if (!gdbarch_process_record_p (target_gdbarch))
817 error (_("Process record: the current architecture doesn't support "
818 "record function."));
821 error (_("Could not find 'to_resume' method on the target stack."));
823 error (_("Could not find 'to_wait' method on the target stack."));
824 if (!tmp_to_store_registers)
825 error (_("Could not find 'to_store_registers' method on the target stack."));
826 if (!tmp_to_insert_breakpoint)
827 error (_("Could not find 'to_insert_breakpoint' method on the target stack."));
828 if (!tmp_to_remove_breakpoint)
829 error (_("Could not find 'to_remove_breakpoint' method on the target stack."));
831 push_target (&record_ops);
834 /* "to_open" target method. Open the process record target. */
837 record_open (char *name, int from_tty)
839 struct target_ops *t;
842 fprintf_unfiltered (gdb_stdlog, "Process record: record_open\n");
844 /* Check if record target is already running. */
845 if (current_target.to_stratum == record_stratum)
846 error (_("Process record target already running. Use \"record stop\" to "
847 "stop record target first."));
849 /* Reset the tmp beneath pointers. */
850 tmp_to_resume_ops = NULL;
851 tmp_to_resume = NULL;
852 tmp_to_wait_ops = NULL;
854 tmp_to_store_registers_ops = NULL;
855 tmp_to_store_registers = NULL;
856 tmp_to_xfer_partial_ops = NULL;
857 tmp_to_xfer_partial = NULL;
858 tmp_to_insert_breakpoint = NULL;
859 tmp_to_remove_breakpoint = NULL;
861 /* Set the beneath function pointers. */
862 for (t = current_target.beneath; t != NULL; t = t->beneath)
866 tmp_to_resume = t->to_resume;
867 tmp_to_resume_ops = t;
871 tmp_to_wait = t->to_wait;
874 if (!tmp_to_store_registers)
876 tmp_to_store_registers = t->to_store_registers;
877 tmp_to_store_registers_ops = t;
879 if (!tmp_to_xfer_partial)
881 tmp_to_xfer_partial = t->to_xfer_partial;
882 tmp_to_xfer_partial_ops = t;
884 if (!tmp_to_insert_breakpoint)
885 tmp_to_insert_breakpoint = t->to_insert_breakpoint;
886 if (!tmp_to_remove_breakpoint)
887 tmp_to_remove_breakpoint = t->to_remove_breakpoint;
889 if (!tmp_to_xfer_partial)
890 error (_("Could not find 'to_xfer_partial' method on the target stack."));
894 record_insn_count = 0;
895 record_list = &record_first;
896 record_list->next = NULL;
898 /* Set the tmp beneath pointers to beneath pointers. */
899 record_beneath_to_resume_ops = tmp_to_resume_ops;
900 record_beneath_to_resume = tmp_to_resume;
901 record_beneath_to_wait_ops = tmp_to_wait_ops;
902 record_beneath_to_wait = tmp_to_wait;
903 record_beneath_to_store_registers_ops = tmp_to_store_registers_ops;
904 record_beneath_to_store_registers = tmp_to_store_registers;
905 record_beneath_to_xfer_partial_ops = tmp_to_xfer_partial_ops;
906 record_beneath_to_xfer_partial = tmp_to_xfer_partial;
907 record_beneath_to_insert_breakpoint = tmp_to_insert_breakpoint;
908 record_beneath_to_remove_breakpoint = tmp_to_remove_breakpoint;
910 if (current_target.to_stratum == core_stratum)
911 record_core_open_1 (name, from_tty);
913 record_open_1 (name, from_tty);
916 /* "to_close" target method. Close the process record target. */
919 record_close (int quitting)
921 struct record_core_buf_entry *entry;
924 fprintf_unfiltered (gdb_stdlog, "Process record: record_close\n");
926 record_list_release (record_list);
928 /* Release record_core_regbuf. */
929 if (record_core_regbuf)
931 xfree (record_core_regbuf);
932 record_core_regbuf = NULL;
935 /* Release record_core_buf_list. */
936 if (record_core_buf_list)
938 for (entry = record_core_buf_list->prev; entry; entry = entry->prev)
940 xfree (record_core_buf_list);
941 record_core_buf_list = entry;
943 record_core_buf_list = NULL;
947 static int record_resume_step = 0;
948 static int record_resume_error;
950 /* "to_resume" target method. Resume the process record target. */
953 record_resume (struct target_ops *ops, ptid_t ptid, int step,
954 enum target_signal signal)
956 record_resume_step = step;
958 if (!RECORD_IS_REPLAY)
960 if (do_record_message (get_current_regcache (), signal))
962 record_resume_error = 0;
966 record_resume_error = 1;
969 record_beneath_to_resume (record_beneath_to_resume_ops, ptid, 1,
974 static int record_get_sig = 0;
976 /* SIGINT signal handler, registered by "to_wait" method. */
979 record_sig_handler (int signo)
982 fprintf_unfiltered (gdb_stdlog, "Process record: get a signal\n");
984 /* It will break the running inferior in replay mode. */
985 record_resume_step = 1;
987 /* It will let record_wait set inferior status to get the signal
993 record_wait_cleanups (void *ignore)
995 if (execution_direction == EXEC_REVERSE)
997 if (record_list->next)
998 record_list = record_list->next;
1001 record_list = record_list->prev;
1004 /* "to_wait" target method for process record target.
1006 In record mode, the target is always run in singlestep mode
1007 (even when gdb says to continue). The to_wait method intercepts
1008 the stop events and determines which ones are to be passed on to
1009 gdb. Most stop events are just singlestep events that gdb is not
1010 to know about, so the to_wait method just records them and keeps
1013 In replay mode, this function emulates the recorded execution log,
1014 one instruction at a time (forward or backward), and determines
1018 record_wait (struct target_ops *ops,
1019 ptid_t ptid, struct target_waitstatus *status,
1022 struct cleanup *set_cleanups = record_gdb_operation_disable_set ();
1025 fprintf_unfiltered (gdb_stdlog,
1026 "Process record: record_wait "
1027 "record_resume_step = %d\n",
1028 record_resume_step);
1030 if (!RECORD_IS_REPLAY && ops != &record_core_ops)
1032 if (record_resume_error)
1034 /* If record_resume get error, return directly. */
1035 status->kind = TARGET_WAITKIND_STOPPED;
1036 status->value.sig = TARGET_SIGNAL_ABRT;
1037 return inferior_ptid;
1040 if (record_resume_step)
1042 /* This is a single step. */
1043 return record_beneath_to_wait (record_beneath_to_wait_ops,
1044 ptid, status, options);
1048 /* This is not a single step. */
1054 ret = record_beneath_to_wait (record_beneath_to_wait_ops,
1055 ptid, status, options);
1057 /* Is this a SIGTRAP? */
1058 if (status->kind == TARGET_WAITKIND_STOPPED
1059 && status->value.sig == TARGET_SIGNAL_TRAP)
1061 struct regcache *regcache;
1063 /* Yes -- check if there is a breakpoint. */
1064 registers_changed ();
1065 regcache = get_current_regcache ();
1066 tmp_pc = regcache_read_pc (regcache);
1067 if (breakpoint_inserted_here_p (get_regcache_aspace (regcache),
1070 /* There is a breakpoint. GDB will want to stop. */
1071 struct gdbarch *gdbarch = get_regcache_arch (regcache);
1072 CORE_ADDR decr_pc_after_break
1073 = gdbarch_decr_pc_after_break (gdbarch);
1074 if (decr_pc_after_break)
1075 regcache_write_pc (regcache,
1076 tmp_pc + decr_pc_after_break);
1080 /* There is not a breakpoint, and gdb is not
1081 stepping, therefore gdb will not stop.
1082 Therefore we will not return to gdb.
1083 Record the insn and resume. */
1084 if (!do_record_message (regcache, TARGET_SIGNAL_0))
1087 record_beneath_to_resume (record_beneath_to_resume_ops,
1094 /* The inferior is broken by a breakpoint or a signal. */
1103 struct regcache *regcache = get_current_regcache ();
1104 struct gdbarch *gdbarch = get_regcache_arch (regcache);
1105 int continue_flag = 1;
1106 int first_record_end = 1;
1107 struct cleanup *old_cleanups = make_cleanup (record_wait_cleanups, 0);
1110 status->kind = TARGET_WAITKIND_STOPPED;
1112 /* Check breakpoint when forward execute. */
1113 if (execution_direction == EXEC_FORWARD)
1115 tmp_pc = regcache_read_pc (regcache);
1116 if (breakpoint_inserted_here_p (get_regcache_aspace (regcache),
1120 fprintf_unfiltered (gdb_stdlog,
1121 "Process record: break at %s.\n",
1122 paddress (gdbarch, tmp_pc));
1123 if (gdbarch_decr_pc_after_break (gdbarch)
1124 && !record_resume_step)
1125 regcache_write_pc (regcache,
1127 gdbarch_decr_pc_after_break (gdbarch));
1133 signal (SIGINT, record_sig_handler);
1134 /* If GDB is in terminal_inferior mode, it will not get the signal.
1135 And in GDB replay mode, GDB doesn't need to be in terminal_inferior
1136 mode, because inferior will not executed.
1137 Then set it to terminal_ours to make GDB get the signal. */
1138 target_terminal_ours ();
1140 /* In EXEC_FORWARD mode, record_list points to the tail of prev
1142 if (execution_direction == EXEC_FORWARD && record_list->next)
1143 record_list = record_list->next;
1145 /* Loop over the record_list, looking for the next place to
1149 /* Check for beginning and end of log. */
1150 if (execution_direction == EXEC_REVERSE
1151 && record_list == &record_first)
1153 /* Hit beginning of record log in reverse. */
1154 status->kind = TARGET_WAITKIND_NO_HISTORY;
1157 if (execution_direction != EXEC_REVERSE && !record_list->next)
1159 /* Hit end of record log going forward. */
1160 status->kind = TARGET_WAITKIND_NO_HISTORY;
1164 record_exec_insn (regcache, gdbarch, record_list);
1166 if (record_list->type == record_end)
1168 if (record_debug > 1)
1169 fprintf_unfiltered (gdb_stdlog,
1170 "Process record: record_end %s to "
1172 host_address_to_string (record_list));
1174 if (first_record_end && execution_direction == EXEC_REVERSE)
1176 /* When reverse excute, the first record_end is the part of
1177 current instruction. */
1178 first_record_end = 0;
1182 /* In EXEC_REVERSE mode, this is the record_end of prev
1184 In EXEC_FORWARD mode, this is the record_end of current
1187 if (record_resume_step)
1189 if (record_debug > 1)
1190 fprintf_unfiltered (gdb_stdlog,
1191 "Process record: step.\n");
1195 /* check breakpoint */
1196 tmp_pc = regcache_read_pc (regcache);
1197 if (breakpoint_inserted_here_p (get_regcache_aspace (regcache),
1201 fprintf_unfiltered (gdb_stdlog,
1202 "Process record: break "
1204 paddress (gdbarch, tmp_pc));
1205 if (gdbarch_decr_pc_after_break (gdbarch)
1206 && execution_direction == EXEC_FORWARD
1207 && !record_resume_step)
1208 regcache_write_pc (regcache,
1210 gdbarch_decr_pc_after_break (gdbarch));
1213 /* Check target signal */
1214 if (record_list->u.end.sigval != TARGET_SIGNAL_0)
1215 /* FIXME: better way to check */
1222 if (execution_direction == EXEC_REVERSE)
1224 if (record_list->prev)
1225 record_list = record_list->prev;
1229 if (record_list->next)
1230 record_list = record_list->next;
1234 while (continue_flag);
1236 signal (SIGINT, handle_sigint);
1240 status->value.sig = TARGET_SIGNAL_INT;
1241 else if (record_list->u.end.sigval != TARGET_SIGNAL_0)
1242 /* FIXME: better way to check */
1243 status->value.sig = record_list->u.end.sigval;
1245 status->value.sig = TARGET_SIGNAL_TRAP;
1247 discard_cleanups (old_cleanups);
1250 do_cleanups (set_cleanups);
1251 return inferior_ptid;
1254 /* "to_disconnect" method for process record target. */
1257 record_disconnect (struct target_ops *target, char *args, int from_tty)
1260 fprintf_unfiltered (gdb_stdlog, "Process record: record_disconnect\n");
1262 unpush_target (&record_ops);
1263 target_disconnect (args, from_tty);
1266 /* "to_detach" method for process record target. */
1269 record_detach (struct target_ops *ops, char *args, int from_tty)
1272 fprintf_unfiltered (gdb_stdlog, "Process record: record_detach\n");
1274 unpush_target (&record_ops);
1275 target_detach (args, from_tty);
1278 /* "to_mourn_inferior" method for process record target. */
1281 record_mourn_inferior (struct target_ops *ops)
1284 fprintf_unfiltered (gdb_stdlog, "Process record: "
1285 "record_mourn_inferior\n");
1287 unpush_target (&record_ops);
1288 target_mourn_inferior ();
1291 /* Close process record target before killing the inferior process. */
1294 record_kill (struct target_ops *ops)
1297 fprintf_unfiltered (gdb_stdlog, "Process record: record_kill\n");
1299 unpush_target (&record_ops);
1303 /* Record registers change (by user or by GDB) to list as an instruction. */
1306 record_registers_change (struct regcache *regcache, int regnum)
1308 /* Check record_insn_num. */
1309 record_check_insn_num (0);
1311 record_arch_list_head = NULL;
1312 record_arch_list_tail = NULL;
1317 for (i = 0; i < gdbarch_num_regs (get_regcache_arch (regcache)); i++)
1319 if (record_arch_list_add_reg (regcache, i))
1321 record_list_release (record_arch_list_tail);
1322 error (_("Process record: failed to record execution log."));
1328 if (record_arch_list_add_reg (regcache, regnum))
1330 record_list_release (record_arch_list_tail);
1331 error (_("Process record: failed to record execution log."));
1334 if (record_arch_list_add_end ())
1336 record_list_release (record_arch_list_tail);
1337 error (_("Process record: failed to record execution log."));
1339 record_list->next = record_arch_list_head;
1340 record_arch_list_head->prev = record_list;
1341 record_list = record_arch_list_tail;
1343 if (record_insn_num == record_insn_max_num && record_insn_max_num)
1344 record_list_release_first ();
1349 /* "to_store_registers" method for process record target. */
1352 record_store_registers (struct target_ops *ops, struct regcache *regcache,
1355 if (!record_gdb_operation_disable)
1357 if (RECORD_IS_REPLAY)
1361 /* Let user choose if he wants to write register or not. */
1364 query (_("Because GDB is in replay mode, changing the "
1365 "value of a register will make the execution "
1366 "log unusable from this point onward. "
1367 "Change all registers?"));
1370 query (_("Because GDB is in replay mode, changing the value "
1371 "of a register will make the execution log unusable "
1372 "from this point onward. Change register %s?"),
1373 gdbarch_register_name (get_regcache_arch (regcache),
1378 /* Invalidate the value of regcache that was set in function
1379 "regcache_raw_write". */
1384 i < gdbarch_num_regs (get_regcache_arch (regcache));
1386 regcache_invalidate (regcache, i);
1389 regcache_invalidate (regcache, regno);
1391 error (_("Process record canceled the operation."));
1394 /* Destroy the record from here forward. */
1395 record_list_release_following (record_list);
1398 record_registers_change (regcache, regno);
1400 record_beneath_to_store_registers (record_beneath_to_store_registers_ops,
1404 /* "to_xfer_partial" method. Behavior is conditional on RECORD_IS_REPLAY.
1405 In replay mode, we cannot write memory unles we are willing to
1406 invalidate the record/replay log from this point forward. */
1409 record_xfer_partial (struct target_ops *ops, enum target_object object,
1410 const char *annex, gdb_byte *readbuf,
1411 const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
1413 if (!record_gdb_operation_disable
1414 && (object == TARGET_OBJECT_MEMORY
1415 || object == TARGET_OBJECT_RAW_MEMORY) && writebuf)
1417 if (RECORD_IS_REPLAY)
1419 /* Let user choose if he wants to write memory or not. */
1420 if (!query (_("Because GDB is in replay mode, writing to memory "
1421 "will make the execution log unusable from this "
1422 "point onward. Write memory at address %s?"),
1423 paddress (target_gdbarch, offset)))
1424 error (_("Process record canceled the operation."));
1426 /* Destroy the record from here forward. */
1427 record_list_release_following (record_list);
1430 /* Check record_insn_num */
1431 record_check_insn_num (0);
1433 /* Record registers change to list as an instruction. */
1434 record_arch_list_head = NULL;
1435 record_arch_list_tail = NULL;
1436 if (record_arch_list_add_mem (offset, len))
1438 record_list_release (record_arch_list_tail);
1440 fprintf_unfiltered (gdb_stdlog,
1441 _("Process record: failed to record "
1445 if (record_arch_list_add_end ())
1447 record_list_release (record_arch_list_tail);
1449 fprintf_unfiltered (gdb_stdlog,
1450 _("Process record: failed to record "
1454 record_list->next = record_arch_list_head;
1455 record_arch_list_head->prev = record_list;
1456 record_list = record_arch_list_tail;
1458 if (record_insn_num == record_insn_max_num && record_insn_max_num)
1459 record_list_release_first ();
1464 return record_beneath_to_xfer_partial (record_beneath_to_xfer_partial_ops,
1465 object, annex, readbuf, writebuf,
1469 /* Behavior is conditional on RECORD_IS_REPLAY.
1470 We will not actually insert or remove breakpoints when replaying,
1471 nor when recording. */
1474 record_insert_breakpoint (struct gdbarch *gdbarch,
1475 struct bp_target_info *bp_tgt)
1477 if (!RECORD_IS_REPLAY)
1479 struct cleanup *old_cleanups = record_gdb_operation_disable_set ();
1480 int ret = record_beneath_to_insert_breakpoint (gdbarch, bp_tgt);
1482 do_cleanups (old_cleanups);
1490 /* "to_remove_breakpoint" method for process record target. */
1493 record_remove_breakpoint (struct gdbarch *gdbarch,
1494 struct bp_target_info *bp_tgt)
1496 if (!RECORD_IS_REPLAY)
1498 struct cleanup *old_cleanups = record_gdb_operation_disable_set ();
1499 int ret = record_beneath_to_remove_breakpoint (gdbarch, bp_tgt);
1501 do_cleanups (old_cleanups);
1509 /* "to_can_execute_reverse" method for process record target. */
1512 record_can_execute_reverse (void)
1518 init_record_ops (void)
1520 record_ops.to_shortname = "record";
1521 record_ops.to_longname = "Process record and replay target";
1523 "Log program while executing and replay execution from log.";
1524 record_ops.to_open = record_open;
1525 record_ops.to_close = record_close;
1526 record_ops.to_resume = record_resume;
1527 record_ops.to_wait = record_wait;
1528 record_ops.to_disconnect = record_disconnect;
1529 record_ops.to_detach = record_detach;
1530 record_ops.to_mourn_inferior = record_mourn_inferior;
1531 record_ops.to_kill = record_kill;
1532 record_ops.to_create_inferior = find_default_create_inferior;
1533 record_ops.to_store_registers = record_store_registers;
1534 record_ops.to_xfer_partial = record_xfer_partial;
1535 record_ops.to_insert_breakpoint = record_insert_breakpoint;
1536 record_ops.to_remove_breakpoint = record_remove_breakpoint;
1537 record_ops.to_can_execute_reverse = record_can_execute_reverse;
1538 record_ops.to_stratum = record_stratum;
1539 record_ops.to_magic = OPS_MAGIC;
1542 /* "to_resume" method for prec over corefile. */
1545 record_core_resume (struct target_ops *ops, ptid_t ptid, int step,
1546 enum target_signal signal)
1548 record_resume_step = step;
1551 /* "to_kill" method for prec over corefile. */
1554 record_core_kill (struct target_ops *ops)
1557 fprintf_unfiltered (gdb_stdlog, "Process record: record_core_kill\n");
1559 unpush_target (&record_core_ops);
1562 /* "to_fetch_registers" method for prec over corefile. */
1565 record_core_fetch_registers (struct target_ops *ops,
1566 struct regcache *regcache,
1571 int num = gdbarch_num_regs (get_regcache_arch (regcache));
1574 for (i = 0; i < num; i ++)
1575 regcache_raw_supply (regcache, i,
1576 record_core_regbuf + MAX_REGISTER_SIZE * i);
1579 regcache_raw_supply (regcache, regno,
1580 record_core_regbuf + MAX_REGISTER_SIZE * regno);
1583 /* "to_prepare_to_store" method for prec over corefile. */
1586 record_core_prepare_to_store (struct regcache *regcache)
1590 /* "to_store_registers" method for prec over corefile. */
1593 record_core_store_registers (struct target_ops *ops,
1594 struct regcache *regcache,
1597 if (record_gdb_operation_disable)
1598 regcache_raw_collect (regcache, regno,
1599 record_core_regbuf + MAX_REGISTER_SIZE * regno);
1601 error (_("You can't do that without a process to debug."));
1604 /* "to_xfer_partial" method for prec over corefile. */
1607 record_core_xfer_partial (struct target_ops *ops, enum target_object object,
1608 const char *annex, gdb_byte *readbuf,
1609 const gdb_byte *writebuf, ULONGEST offset,
1612 if (object == TARGET_OBJECT_MEMORY)
1614 if (record_gdb_operation_disable || !writebuf)
1616 struct target_section *p;
1617 for (p = record_core_start; p < record_core_end; p++)
1619 if (offset >= p->addr)
1621 struct record_core_buf_entry *entry;
1623 if (offset >= p->endaddr)
1626 if (offset + len > p->endaddr)
1627 len = p->endaddr - offset;
1631 /* Read readbuf or write writebuf p, offset, len. */
1633 if (p->the_bfd_section->flags & SEC_CONSTRUCTOR
1634 || (p->the_bfd_section->flags & SEC_HAS_CONTENTS) == 0)
1637 memset (readbuf, 0, len);
1640 /* Get record_core_buf_entry. */
1641 for (entry = record_core_buf_list; entry;
1642 entry = entry->prev)
1649 /* Add a new entry. */
1651 = (struct record_core_buf_entry *)
1653 (sizeof (struct record_core_buf_entry));
1655 if (!bfd_malloc_and_get_section (p->bfd,
1662 entry->prev = record_core_buf_list;
1663 record_core_buf_list = entry;
1666 memcpy (entry->buf + offset, writebuf, (size_t) len);
1671 return record_beneath_to_xfer_partial
1672 (record_beneath_to_xfer_partial_ops,
1673 object, annex, readbuf, writebuf,
1676 memcpy (readbuf, entry->buf + offset, (size_t) len);
1686 error (_("You can't do that without a process to debug."));
1689 return record_beneath_to_xfer_partial (record_beneath_to_xfer_partial_ops,
1690 object, annex, readbuf, writebuf,
1694 /* "to_insert_breakpoint" method for prec over corefile. */
1697 record_core_insert_breakpoint (struct gdbarch *gdbarch,
1698 struct bp_target_info *bp_tgt)
1703 /* "to_remove_breakpoint" method for prec over corefile. */
1706 record_core_remove_breakpoint (struct gdbarch *gdbarch,
1707 struct bp_target_info *bp_tgt)
1712 /* "to_has_execution" method for prec over corefile. */
1715 record_core_has_execution (struct target_ops *ops)
1721 init_record_core_ops (void)
1723 record_core_ops.to_shortname = "record_core";
1724 record_core_ops.to_longname = "Process record and replay target";
1725 record_core_ops.to_doc =
1726 "Log program while executing and replay execution from log.";
1727 record_core_ops.to_open = record_open;
1728 record_core_ops.to_close = record_close;
1729 record_core_ops.to_resume = record_core_resume;
1730 record_core_ops.to_wait = record_wait;
1731 record_core_ops.to_kill = record_core_kill;
1732 record_core_ops.to_fetch_registers = record_core_fetch_registers;
1733 record_core_ops.to_prepare_to_store = record_core_prepare_to_store;
1734 record_core_ops.to_store_registers = record_core_store_registers;
1735 record_core_ops.to_xfer_partial = record_core_xfer_partial;
1736 record_core_ops.to_insert_breakpoint = record_core_insert_breakpoint;
1737 record_core_ops.to_remove_breakpoint = record_core_remove_breakpoint;
1738 record_core_ops.to_can_execute_reverse = record_can_execute_reverse;
1739 record_core_ops.to_has_execution = record_core_has_execution;
1740 record_core_ops.to_stratum = record_stratum;
1741 record_core_ops.to_magic = OPS_MAGIC;
1744 /* Implement "show record debug" command. */
1747 show_record_debug (struct ui_file *file, int from_tty,
1748 struct cmd_list_element *c, const char *value)
1750 fprintf_filtered (file, _("Debugging of process record target is %s.\n"),
1754 /* Alias for "target record". */
1757 cmd_record_start (char *args, int from_tty)
1759 execute_command ("target record", from_tty);
1762 /* Truncate the record log from the present point
1763 of replay until the end. */
1766 cmd_record_delete (char *args, int from_tty)
1768 if (current_target.to_stratum == record_stratum)
1770 if (RECORD_IS_REPLAY)
1772 if (!from_tty || query (_("Delete the log from this point forward "
1773 "and begin to record the running message "
1775 record_list_release_following (record_list);
1778 printf_unfiltered (_("Already at end of record list.\n"));
1782 printf_unfiltered (_("Process record is not started.\n"));
1785 /* Implement the "stoprecord" or "record stop" command. */
1788 cmd_record_stop (char *args, int from_tty)
1790 if (current_target.to_stratum == record_stratum)
1792 unpush_target (&record_ops);
1793 printf_unfiltered (_("Process record is stopped and all execution "
1794 "logs are deleted.\n"));
1797 printf_unfiltered (_("Process record is not started.\n"));
1800 /* Set upper limit of record log size. */
1803 set_record_insn_max_num (char *args, int from_tty, struct cmd_list_element *c)
1805 if (record_insn_num > record_insn_max_num && record_insn_max_num)
1807 /* Count down record_insn_num while releasing records from list. */
1808 while (record_insn_num > record_insn_max_num)
1810 record_list_release_first ();
1816 static struct cmd_list_element *record_cmdlist, *set_record_cmdlist,
1817 *show_record_cmdlist, *info_record_cmdlist;
1820 set_record_command (char *args, int from_tty)
1822 printf_unfiltered (_("\
1823 \"set record\" must be followed by an apporpriate subcommand.\n"));
1824 help_list (set_record_cmdlist, "set record ", all_commands, gdb_stdout);
1828 show_record_command (char *args, int from_tty)
1830 cmd_show_list (show_record_cmdlist, from_tty, "");
1833 /* Display some statistics about the execution log. */
1836 info_record_command (char *args, int from_tty)
1838 struct record_entry *p;
1840 if (current_target.to_stratum == record_stratum)
1842 if (RECORD_IS_REPLAY)
1843 printf_filtered (_("Replay mode:\n"));
1845 printf_filtered (_("Record mode:\n"));
1847 /* Find entry for first actual instruction in the log. */
1848 for (p = record_first.next;
1849 p != NULL && p->type != record_end;
1853 /* Do we have a log at all? */
1854 if (p != NULL && p->type == record_end)
1856 /* Display instruction number for first instruction in the log. */
1857 printf_filtered (_("Lowest recorded instruction number is %s.\n"),
1858 pulongest (p->u.end.insn_num));
1860 /* If in replay mode, display where we are in the log. */
1861 if (RECORD_IS_REPLAY)
1862 printf_filtered (_("Current instruction number is %s.\n"),
1863 pulongest (record_list->u.end.insn_num));
1865 /* Display instruction number for last instruction in the log. */
1866 printf_filtered (_("Highest recorded instruction number is %s.\n"),
1867 pulongest (record_insn_count));
1869 /* Display log count. */
1870 printf_filtered (_("Log contains %d instructions.\n"),
1875 printf_filtered (_("No instructions have been logged.\n"));
1880 printf_filtered (_("target record is not active.\n"));
1883 /* Display max log size. */
1884 printf_filtered (_("Max logged instructions is %d.\n"),
1885 record_insn_max_num);
1889 _initialize_record (void)
1891 /* Init record_first. */
1892 record_first.prev = NULL;
1893 record_first.next = NULL;
1894 record_first.type = record_end;
1897 add_target (&record_ops);
1898 init_record_core_ops ();
1899 add_target (&record_core_ops);
1901 add_setshow_zinteger_cmd ("record", no_class, &record_debug,
1902 _("Set debugging of record/replay feature."),
1903 _("Show debugging of record/replay feature."),
1904 _("When enabled, debugging output for "
1905 "record/replay feature is displayed."),
1906 NULL, show_record_debug, &setdebuglist,
1909 add_prefix_cmd ("record", class_obscure, cmd_record_start,
1910 _("Abbreviated form of \"target record\" command."),
1911 &record_cmdlist, "record ", 0, &cmdlist);
1912 add_com_alias ("rec", "record", class_obscure, 1);
1913 add_prefix_cmd ("record", class_support, set_record_command,
1914 _("Set record options"), &set_record_cmdlist,
1915 "set record ", 0, &setlist);
1916 add_alias_cmd ("rec", "record", class_obscure, 1, &setlist);
1917 add_prefix_cmd ("record", class_support, show_record_command,
1918 _("Show record options"), &show_record_cmdlist,
1919 "show record ", 0, &showlist);
1920 add_alias_cmd ("rec", "record", class_obscure, 1, &showlist);
1921 add_prefix_cmd ("record", class_support, info_record_command,
1922 _("Info record options"), &info_record_cmdlist,
1923 "info record ", 0, &infolist);
1924 add_alias_cmd ("rec", "record", class_obscure, 1, &infolist);
1927 add_cmd ("delete", class_obscure, cmd_record_delete,
1928 _("Delete the rest of execution log and start recording it anew."),
1930 add_alias_cmd ("d", "delete", class_obscure, 1, &record_cmdlist);
1931 add_alias_cmd ("del", "delete", class_obscure, 1, &record_cmdlist);
1933 add_cmd ("stop", class_obscure, cmd_record_stop,
1934 _("Stop the record/replay target."),
1936 add_alias_cmd ("s", "stop", class_obscure, 1, &record_cmdlist);
1938 /* Record instructions number limit command. */
1939 add_setshow_boolean_cmd ("stop-at-limit", no_class,
1940 &record_stop_at_limit, _("\
1941 Set whether record/replay stops when record/replay buffer becomes full."), _("\
1942 Show whether record/replay stops when record/replay buffer becomes full."), _("\
1944 When ON, if the record/replay buffer becomes full, ask user what to do.\n\
1945 When OFF, if the record/replay buffer becomes full,\n\
1946 delete the oldest recorded instruction to make room for each new one."),
1948 &set_record_cmdlist, &show_record_cmdlist);
1949 add_setshow_uinteger_cmd ("insn-number-max", no_class,
1950 &record_insn_max_num,
1951 _("Set record/replay buffer limit."),
1952 _("Show record/replay buffer limit."), _("\
1953 Set the maximum number of instructions to be stored in the\n\
1954 record/replay buffer. Zero means unlimited. Default is 200000."),
1955 set_record_insn_max_num,
1956 NULL, &set_record_cmdlist, &show_record_cmdlist);