]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/record.c
2009-10-19 Pedro Alves <pedro@codesourcery.com>
[thirdparty/binutils-gdb.git] / gdb / record.c
CommitLineData
69d05d38
HZ
1/* Process record and replay target for GDB, the GNU debugger.
2
3 Copyright (C) 2008, 2009 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20#include "defs.h"
21#include "gdbcmd.h"
22#include "regcache.h"
23#include "gdbthread.h"
24#include "event-top.h"
25#include "exceptions.h"
26#include "record.h"
27
28#include <signal.h>
29
30#define DEFAULT_RECORD_INSN_MAX_NUM 200000
31
32#define RECORD_IS_REPLAY \
33 (record_list->next || execution_direction == EXEC_REVERSE)
34
fda458ee 35/* These are the core structs of the process record functionality.
69d05d38 36
fda458ee 37 A record_entry is a record of the value change of a register
69d05d38 38 ("record_reg") or a part of memory ("record_mem"). And each
fda458ee
MS
39 instruction must have a struct record_entry ("record_end") that
40 indicates that this is the last struct record_entry of this
41 instruction.
69d05d38 42
fda458ee
MS
43 Each struct record_entry is linked to "record_list" by "prev" and
44 "next" pointers. */
69d05d38 45
69d05d38
HZ
46struct record_mem_entry
47{
48 CORE_ADDR addr;
49 int len;
afd0cd3f
MS
50 /* Set this flag if target memory for this entry
51 can no longer be accessed. */
52 int mem_entry_not_accessible;
44389f9b
MS
53 union
54 {
55 gdb_byte *ptr;
56 gdb_byte buf[sizeof (gdb_byte *)];
57 } u;
58};
59
60struct record_reg_entry
61{
62 unsigned short num;
63 unsigned short len;
64 union
65 {
66 gdb_byte *ptr;
67 gdb_byte buf[2 * sizeof (gdb_byte *)];
68 } u;
69d05d38
HZ
69};
70
8b739a96
HZ
71struct record_end_entry
72{
73 enum target_signal sigval;
74};
75
69d05d38
HZ
76enum record_type
77{
78 record_end = 0,
79 record_reg,
80 record_mem
81};
82
83struct record_entry
84{
85 struct record_entry *prev;
86 struct record_entry *next;
87 enum record_type type;
88 union
89 {
90 /* reg */
91 struct record_reg_entry reg;
92 /* mem */
93 struct record_mem_entry mem;
8b739a96
HZ
94 /* end */
95 struct record_end_entry end;
69d05d38
HZ
96 } u;
97};
98
99/* This is the debug switch for process record. */
100int record_debug = 0;
101
102/* These list is for execution log. */
103static struct record_entry record_first;
104static struct record_entry *record_list = &record_first;
105static struct record_entry *record_arch_list_head = NULL;
106static struct record_entry *record_arch_list_tail = NULL;
107
108/* 1 ask user. 0 auto delete the last struct record_entry. */
109static int record_stop_at_limit = 1;
191e1813 110static unsigned int record_insn_max_num = DEFAULT_RECORD_INSN_MAX_NUM;
69d05d38
HZ
111static int record_insn_num = 0;
112
113/* The target_ops of process record. */
114static struct target_ops record_ops;
115
116/* The beneath function pointers. */
117static struct target_ops *record_beneath_to_resume_ops;
118static void (*record_beneath_to_resume) (struct target_ops *, ptid_t, int,
119 enum target_signal);
120static struct target_ops *record_beneath_to_wait_ops;
121static ptid_t (*record_beneath_to_wait) (struct target_ops *, ptid_t,
47608cb1
PA
122 struct target_waitstatus *,
123 int);
69d05d38
HZ
124static struct target_ops *record_beneath_to_store_registers_ops;
125static void (*record_beneath_to_store_registers) (struct target_ops *,
126 struct regcache *,
127 int regno);
128static struct target_ops *record_beneath_to_xfer_partial_ops;
129static LONGEST (*record_beneath_to_xfer_partial) (struct target_ops *ops,
130 enum target_object object,
131 const char *annex,
132 gdb_byte *readbuf,
133 const gdb_byte *writebuf,
134 ULONGEST offset,
135 LONGEST len);
a6d9a66e
UW
136static int (*record_beneath_to_insert_breakpoint) (struct gdbarch *,
137 struct bp_target_info *);
138static int (*record_beneath_to_remove_breakpoint) (struct gdbarch *,
139 struct bp_target_info *);
69d05d38 140
61f75dd8
MS
141/* Alloc and free functions for record_reg, record_mem, and record_end
142 entries. */
143
144/* Alloc a record_reg record entry. */
145
146static inline struct record_entry *
147record_reg_alloc (struct regcache *regcache, int regnum)
148{
149 struct record_entry *rec;
150 struct gdbarch *gdbarch = get_regcache_arch (regcache);
151
152 rec = (struct record_entry *) xcalloc (1, sizeof (struct record_entry));
153 rec->type = record_reg;
154 rec->u.reg.num = regnum;
44389f9b
MS
155 rec->u.reg.len = register_size (gdbarch, regnum);
156 if (rec->u.reg.len > sizeof (rec->u.reg.u.buf))
157 rec->u.reg.u.ptr = (gdb_byte *) xmalloc (rec->u.reg.len);
61f75dd8
MS
158
159 return rec;
160}
161
162/* Free a record_reg record entry. */
163
164static inline void
165record_reg_release (struct record_entry *rec)
166{
167 gdb_assert (rec->type == record_reg);
44389f9b
MS
168 if (rec->u.reg.len > sizeof (rec->u.reg.u.buf))
169 xfree (rec->u.reg.u.ptr);
61f75dd8
MS
170 xfree (rec);
171}
172
173/* Alloc a record_mem record entry. */
174
175static inline struct record_entry *
176record_mem_alloc (CORE_ADDR addr, int len)
177{
178 struct record_entry *rec;
179
180 rec = (struct record_entry *) xcalloc (1, sizeof (struct record_entry));
181 rec->type = record_mem;
182 rec->u.mem.addr = addr;
183 rec->u.mem.len = len;
44389f9b
MS
184 if (rec->u.mem.len > sizeof (rec->u.mem.u.buf))
185 rec->u.mem.u.ptr = (gdb_byte *) xmalloc (len);
61f75dd8
MS
186
187 return rec;
188}
189
190/* Free a record_mem record entry. */
191
192static inline void
193record_mem_release (struct record_entry *rec)
194{
195 gdb_assert (rec->type == record_mem);
44389f9b
MS
196 if (rec->u.mem.len > sizeof (rec->u.mem.u.buf))
197 xfree (rec->u.mem.u.ptr);
61f75dd8
MS
198 xfree (rec);
199}
200
201/* Alloc a record_end record entry. */
202
203static inline struct record_entry *
204record_end_alloc (void)
205{
206 struct record_entry *rec;
207
208 rec = (struct record_entry *) xcalloc (1, sizeof (struct record_entry));
209 rec->type = record_end;
210
211 return rec;
212}
213
214/* Free a record_end record entry. */
215
216static inline void
217record_end_release (struct record_entry *rec)
218{
219 xfree (rec);
220}
221
222/* Free one record entry, any type.
223 Return entry->type, in case caller wants to know. */
224
225static inline enum record_type
226record_entry_release (struct record_entry *rec)
227{
228 enum record_type type = rec->type;
229
230 switch (type) {
231 case record_reg:
232 record_reg_release (rec);
233 break;
234 case record_mem:
235 record_mem_release (rec);
236 break;
237 case record_end:
238 record_end_release (rec);
239 break;
240 }
241 return type;
242}
243
244/* Free all record entries in list pointed to by REC. */
245
69d05d38
HZ
246static void
247record_list_release (struct record_entry *rec)
248{
69d05d38
HZ
249 if (!rec)
250 return;
251
252 while (rec->next)
61f75dd8 253 rec = rec->next;
69d05d38
HZ
254
255 while (rec->prev)
256 {
69d05d38 257 rec = rec->prev;
61f75dd8 258 record_entry_release (rec->next);
69d05d38
HZ
259 }
260
61f75dd8
MS
261 if (rec == &record_first)
262 {
263 record_insn_num = 0;
264 record_first.next = NULL;
265 }
266 else
267 record_entry_release (rec);
69d05d38
HZ
268}
269
61f75dd8
MS
270/* Free all record entries forward of the given list position. */
271
69d05d38 272static void
61f75dd8 273record_list_release_following (struct record_entry *rec)
69d05d38 274{
69d05d38 275 struct record_entry *tmp = rec->next;
61f75dd8 276
69d05d38
HZ
277 rec->next = NULL;
278 while (tmp)
279 {
280 rec = tmp->next;
61f75dd8 281 if (record_entry_release (tmp) == record_end)
69d05d38 282 record_insn_num--;
69d05d38
HZ
283 tmp = rec;
284 }
285}
286
265aad34
MS
287/* Delete the first instruction from the beginning of the log, to make
288 room for adding a new instruction at the end of the log.
289
290 Note -- this function does not modify record_insn_num. */
291
69d05d38
HZ
292static void
293record_list_release_first (void)
294{
61f75dd8 295 struct record_entry *tmp;
69d05d38
HZ
296
297 if (!record_first.next)
298 return;
299
61f75dd8 300 /* Loop until a record_end. */
69d05d38
HZ
301 while (1)
302 {
61f75dd8 303 /* Cut record_first.next out of the linked list. */
69d05d38
HZ
304 tmp = record_first.next;
305 record_first.next = tmp->next;
61f75dd8
MS
306 tmp->next->prev = &record_first;
307
308 /* tmp is now isolated, and can be deleted. */
309 if (record_entry_release (tmp) == record_end)
310 {
311 record_insn_num--;
312 break; /* End loop at first record_end. */
313 }
69d05d38
HZ
314
315 if (!record_first.next)
316 {
317 gdb_assert (record_insn_num == 1);
61f75dd8 318 break; /* End loop when list is empty. */
69d05d38 319 }
69d05d38 320 }
69d05d38
HZ
321}
322
323/* Add a struct record_entry to record_arch_list. */
324
325static void
326record_arch_list_add (struct record_entry *rec)
327{
328 if (record_debug > 1)
329 fprintf_unfiltered (gdb_stdlog,
330 "Process record: record_arch_list_add %s.\n",
331 host_address_to_string (rec));
332
333 if (record_arch_list_tail)
334 {
335 record_arch_list_tail->next = rec;
336 rec->prev = record_arch_list_tail;
337 record_arch_list_tail = rec;
338 }
339 else
340 {
341 record_arch_list_head = rec;
342 record_arch_list_tail = rec;
343 }
344}
345
44389f9b
MS
346/* Return the value storage location of a record entry. */
347static inline gdb_byte *
348record_get_loc (struct record_entry *rec)
349{
350 switch (rec->type) {
351 case record_mem:
352 if (rec->u.mem.len > sizeof (rec->u.mem.u.buf))
353 return rec->u.mem.u.ptr;
354 else
355 return rec->u.mem.u.buf;
356 case record_reg:
357 if (rec->u.reg.len > sizeof (rec->u.reg.u.buf))
358 return rec->u.reg.u.ptr;
359 else
360 return rec->u.reg.u.buf;
361 case record_end:
362 default:
363 gdb_assert (0);
364 return NULL;
365 }
366}
367
368/* Record the value of a register NUM to record_arch_list. */
69d05d38
HZ
369
370int
61f75dd8 371record_arch_list_add_reg (struct regcache *regcache, int regnum)
69d05d38
HZ
372{
373 struct record_entry *rec;
374
375 if (record_debug > 1)
376 fprintf_unfiltered (gdb_stdlog,
377 "Process record: add register num = %d to "
378 "record list.\n",
61f75dd8 379 regnum);
69d05d38 380
61f75dd8 381 rec = record_reg_alloc (regcache, regnum);
69d05d38 382
44389f9b 383 regcache_raw_read (regcache, regnum, record_get_loc (rec));
69d05d38
HZ
384
385 record_arch_list_add (rec);
386
387 return 0;
388}
389
390/* Record the value of a region of memory whose address is ADDR and
391 length is LEN to record_arch_list. */
392
393int
394record_arch_list_add_mem (CORE_ADDR addr, int len)
395{
396 struct record_entry *rec;
397
398 if (record_debug > 1)
399 fprintf_unfiltered (gdb_stdlog,
5af949e3 400 "Process record: add mem addr = %s len = %d to "
69d05d38 401 "record list.\n",
5af949e3 402 paddress (target_gdbarch, addr), len);
69d05d38 403
61f75dd8 404 if (!addr) /* FIXME: Why? Some arch must permit it... */
69d05d38
HZ
405 return 0;
406
61f75dd8 407 rec = record_mem_alloc (addr, len);
69d05d38 408
44389f9b 409 if (target_read_memory (addr, record_get_loc (rec), len))
69d05d38
HZ
410 {
411 if (record_debug)
412 fprintf_unfiltered (gdb_stdlog,
413 "Process record: error reading memory at "
5af949e3
UW
414 "addr = %s len = %d.\n",
415 paddress (target_gdbarch, addr), len);
61f75dd8 416 record_mem_release (rec);
69d05d38
HZ
417 return -1;
418 }
419
420 record_arch_list_add (rec);
421
422 return 0;
423}
424
425/* Add a record_end type struct record_entry to record_arch_list. */
426
427int
428record_arch_list_add_end (void)
429{
430 struct record_entry *rec;
431
432 if (record_debug > 1)
433 fprintf_unfiltered (gdb_stdlog,
434 "Process record: add end to arch list.\n");
435
61f75dd8 436 rec = record_end_alloc ();
8b739a96 437 rec->u.end.sigval = TARGET_SIGNAL_0;
69d05d38
HZ
438
439 record_arch_list_add (rec);
440
441 return 0;
442}
443
444static void
445record_check_insn_num (int set_terminal)
446{
447 if (record_insn_max_num)
448 {
449 gdb_assert (record_insn_num <= record_insn_max_num);
450 if (record_insn_num == record_insn_max_num)
451 {
452 /* Ask user what to do. */
453 if (record_stop_at_limit)
454 {
455 int q;
456 if (set_terminal)
457 target_terminal_ours ();
458 q = yquery (_("Do you want to auto delete previous execution "
459 "log entries when record/replay buffer becomes "
460 "full (record stop-at-limit)?"));
461 if (set_terminal)
462 target_terminal_inferior ();
463 if (q)
464 record_stop_at_limit = 0;
465 else
466 error (_("Process record: inferior program stopped."));
467 }
468 }
469 }
470}
471
472/* Before inferior step (when GDB record the running message, inferior
473 only can step), GDB will call this function to record the values to
474 record_list. This function will call gdbarch_process_record to
475 record the running message of inferior and set them to
476 record_arch_list, and add it to record_list. */
477
478static void
479record_message_cleanups (void *ignore)
480{
481 record_list_release (record_arch_list_tail);
482}
483
8b739a96
HZ
484struct record_message_args {
485 struct regcache *regcache;
486 enum target_signal signal;
487};
488
69d05d38
HZ
489static int
490record_message (void *args)
491{
492 int ret;
8b739a96
HZ
493 struct record_message_args *myargs = args;
494 struct gdbarch *gdbarch = get_regcache_arch (myargs->regcache);
69d05d38
HZ
495 struct cleanup *old_cleanups = make_cleanup (record_message_cleanups, 0);
496
497 record_arch_list_head = NULL;
498 record_arch_list_tail = NULL;
499
500 /* Check record_insn_num. */
501 record_check_insn_num (1);
502
8b739a96
HZ
503 /* If gdb sends a signal value to target_resume,
504 save it in the 'end' field of the previous instruction.
505
506 Maybe process record should record what really happened,
507 rather than what gdb pretends has happened.
508
509 So if Linux delivered the signal to the child process during
510 the record mode, we will record it and deliver it again in
511 the replay mode.
512
513 If user says "ignore this signal" during the record mode, then
514 it will be ignored again during the replay mode (no matter if
515 the user says something different, like "deliver this signal"
516 during the replay mode).
517
518 User should understand that nothing he does during the replay
519 mode will change the behavior of the child. If he tries,
520 then that is a user error.
521
522 But we should still deliver the signal to gdb during the replay,
523 if we delivered it during the recording. Therefore we should
524 record the signal during record_wait, not record_resume. */
525 if (record_list != &record_first) /* FIXME better way to check */
526 {
527 gdb_assert (record_list->type == record_end);
528 record_list->u.end.sigval = myargs->signal;
529 }
530
531 if (myargs->signal == TARGET_SIGNAL_0
532 || !gdbarch_process_record_signal_p (gdbarch))
533 ret = gdbarch_process_record (gdbarch,
534 myargs->regcache,
535 regcache_read_pc (myargs->regcache));
536 else
537 ret = gdbarch_process_record_signal (gdbarch,
538 myargs->regcache,
539 myargs->signal);
540
69d05d38
HZ
541 if (ret > 0)
542 error (_("Process record: inferior program stopped."));
543 if (ret < 0)
544 error (_("Process record: failed to record execution log."));
545
546 discard_cleanups (old_cleanups);
547
548 record_list->next = record_arch_list_head;
549 record_arch_list_head->prev = record_list;
550 record_list = record_arch_list_tail;
551
552 if (record_insn_num == record_insn_max_num && record_insn_max_num)
553 record_list_release_first ();
554 else
555 record_insn_num++;
556
557 return 1;
558}
559
560static int
8b739a96
HZ
561do_record_message (struct regcache *regcache,
562 enum target_signal signal)
69d05d38 563{
8b739a96
HZ
564 struct record_message_args args;
565
566 args.regcache = regcache;
567 args.signal = signal;
568 return catch_errors (record_message, &args, NULL, RETURN_MASK_ALL);
69d05d38
HZ
569}
570
571/* Set to 1 if record_store_registers and record_xfer_partial
572 doesn't need record. */
573
574static int record_gdb_operation_disable = 0;
575
576struct cleanup *
577record_gdb_operation_disable_set (void)
578{
579 struct cleanup *old_cleanups = NULL;
580
581 old_cleanups =
582 make_cleanup_restore_integer (&record_gdb_operation_disable);
583 record_gdb_operation_disable = 1;
584
585 return old_cleanups;
586}
587
588static void
589record_open (char *name, int from_tty)
590{
591 struct target_ops *t;
592
593 if (record_debug)
594 fprintf_unfiltered (gdb_stdlog, "Process record: record_open\n");
595
596 /* check exec */
597 if (!target_has_execution)
598 error (_("Process record: the program is not being run."));
599 if (non_stop)
600 error (_("Process record target can't debug inferior in non-stop mode "
601 "(non-stop)."));
602 if (target_async_permitted)
603 error (_("Process record target can't debug inferior in asynchronous "
604 "mode (target-async)."));
605
a97b0ac8 606 if (!gdbarch_process_record_p (target_gdbarch))
69d05d38
HZ
607 error (_("Process record: the current architecture doesn't support "
608 "record function."));
609
610 /* Check if record target is already running. */
611 if (current_target.to_stratum == record_stratum)
5d40bb85
HZ
612 error (_("Process record target already running. Use \"record stop\" to "
613 "stop record target first."));
69d05d38
HZ
614
615 /*Reset the beneath function pointers. */
616 record_beneath_to_resume = NULL;
617 record_beneath_to_wait = NULL;
618 record_beneath_to_store_registers = NULL;
619 record_beneath_to_xfer_partial = NULL;
620 record_beneath_to_insert_breakpoint = NULL;
621 record_beneath_to_remove_breakpoint = NULL;
622
623 /* Set the beneath function pointers. */
624 for (t = current_target.beneath; t != NULL; t = t->beneath)
625 {
626 if (!record_beneath_to_resume)
627 {
628 record_beneath_to_resume = t->to_resume;
629 record_beneath_to_resume_ops = t;
630 }
631 if (!record_beneath_to_wait)
632 {
633 record_beneath_to_wait = t->to_wait;
634 record_beneath_to_wait_ops = t;
635 }
636 if (!record_beneath_to_store_registers)
637 {
638 record_beneath_to_store_registers = t->to_store_registers;
639 record_beneath_to_store_registers_ops = t;
640 }
641 if (!record_beneath_to_xfer_partial)
642 {
643 record_beneath_to_xfer_partial = t->to_xfer_partial;
644 record_beneath_to_xfer_partial_ops = t;
645 }
646 if (!record_beneath_to_insert_breakpoint)
647 record_beneath_to_insert_breakpoint = t->to_insert_breakpoint;
648 if (!record_beneath_to_remove_breakpoint)
649 record_beneath_to_remove_breakpoint = t->to_remove_breakpoint;
650 }
651 if (!record_beneath_to_resume)
652 error (_("Process record can't get to_resume."));
653 if (!record_beneath_to_wait)
654 error (_("Process record can't get to_wait."));
655 if (!record_beneath_to_store_registers)
656 error (_("Process record can't get to_store_registers."));
657 if (!record_beneath_to_xfer_partial)
658 error (_("Process record can't get to_xfer_partial."));
659 if (!record_beneath_to_insert_breakpoint)
660 error (_("Process record can't get to_insert_breakpoint."));
661 if (!record_beneath_to_remove_breakpoint)
662 error (_("Process record can't get to_remove_breakpoint."));
663
664 push_target (&record_ops);
665
666 /* Reset */
667 record_insn_num = 0;
668 record_list = &record_first;
669 record_list->next = NULL;
670}
671
672static void
673record_close (int quitting)
674{
675 if (record_debug)
676 fprintf_unfiltered (gdb_stdlog, "Process record: record_close\n");
677
678 record_list_release (record_list);
679}
680
681static int record_resume_step = 0;
69d05d38
HZ
682static int record_resume_error;
683
684static void
685record_resume (struct target_ops *ops, ptid_t ptid, int step,
8b739a96 686 enum target_signal signal)
69d05d38
HZ
687{
688 record_resume_step = step;
69d05d38
HZ
689
690 if (!RECORD_IS_REPLAY)
691 {
8b739a96 692 if (do_record_message (get_current_regcache (), signal))
69d05d38
HZ
693 {
694 record_resume_error = 0;
695 }
696 else
697 {
698 record_resume_error = 1;
699 return;
700 }
701 record_beneath_to_resume (record_beneath_to_resume_ops, ptid, 1,
8b739a96 702 signal);
69d05d38
HZ
703 }
704}
705
706static int record_get_sig = 0;
707
708static void
709record_sig_handler (int signo)
710{
711 if (record_debug)
712 fprintf_unfiltered (gdb_stdlog, "Process record: get a signal\n");
713
714 /* It will break the running inferior in replay mode. */
715 record_resume_step = 1;
716
717 /* It will let record_wait set inferior status to get the signal
718 SIGINT. */
719 record_get_sig = 1;
720}
721
722static void
723record_wait_cleanups (void *ignore)
724{
725 if (execution_direction == EXEC_REVERSE)
726 {
727 if (record_list->next)
728 record_list = record_list->next;
729 }
730 else
731 record_list = record_list->prev;
732}
733
734/* In replay mode, this function examines the recorded log and
735 determines where to stop. */
736
737static ptid_t
738record_wait (struct target_ops *ops,
47608cb1
PA
739 ptid_t ptid, struct target_waitstatus *status,
740 int options)
69d05d38
HZ
741{
742 struct cleanup *set_cleanups = record_gdb_operation_disable_set ();
743
744 if (record_debug)
745 fprintf_unfiltered (gdb_stdlog,
746 "Process record: record_wait "
747 "record_resume_step = %d\n",
748 record_resume_step);
749
750 if (!RECORD_IS_REPLAY)
751 {
752 if (record_resume_error)
753 {
754 /* If record_resume get error, return directly. */
755 status->kind = TARGET_WAITKIND_STOPPED;
756 status->value.sig = TARGET_SIGNAL_ABRT;
757 return inferior_ptid;
758 }
759
760 if (record_resume_step)
761 {
762 /* This is a single step. */
763 return record_beneath_to_wait (record_beneath_to_wait_ops,
90092760 764 ptid, status, options);
69d05d38
HZ
765 }
766 else
767 {
768 /* This is not a single step. */
769 ptid_t ret;
770 CORE_ADDR tmp_pc;
771
772 while (1)
773 {
774 ret = record_beneath_to_wait (record_beneath_to_wait_ops,
90092760 775 ptid, status, options);
69d05d38 776
8b739a96 777 /* Is this a SIGTRAP? */
69d05d38
HZ
778 if (status->kind == TARGET_WAITKIND_STOPPED
779 && status->value.sig == TARGET_SIGNAL_TRAP)
780 {
6c95b8df
PA
781 struct regcache *regcache;
782
8b739a96 783 /* Yes -- check if there is a breakpoint. */
69d05d38 784 registers_changed ();
6c95b8df
PA
785 regcache = get_current_regcache ();
786 tmp_pc = regcache_read_pc (regcache);
787 if (breakpoint_inserted_here_p (get_regcache_aspace (regcache),
788 tmp_pc))
69d05d38 789 {
8b739a96 790 /* There is a breakpoint. GDB will want to stop. */
6c95b8df
PA
791 struct gdbarch *gdbarch = get_regcache_arch (regcache);
792 CORE_ADDR decr_pc_after_break
793 = gdbarch_decr_pc_after_break (gdbarch);
69d05d38 794 if (decr_pc_after_break)
6c95b8df
PA
795 regcache_write_pc (regcache,
796 tmp_pc + decr_pc_after_break);
69d05d38
HZ
797 }
798 else
799 {
8b739a96
HZ
800 /* There is not a breakpoint, and gdb is not
801 stepping, therefore gdb will not stop.
802 Therefore we will not return to gdb.
803 Record the insn and resume. */
6c95b8df
PA
804 if (!do_record_message (regcache, TARGET_SIGNAL_0))
805 break;
806
69d05d38
HZ
807 record_beneath_to_resume (record_beneath_to_resume_ops,
808 ptid, 1,
88fef440 809 TARGET_SIGNAL_0);
69d05d38
HZ
810 continue;
811 }
812 }
813
814 /* The inferior is broken by a breakpoint or a signal. */
815 break;
816 }
817
818 return ret;
819 }
820 }
821 else
822 {
823 struct regcache *regcache = get_current_regcache ();
5af949e3 824 struct gdbarch *gdbarch = get_regcache_arch (regcache);
69d05d38
HZ
825 int continue_flag = 1;
826 int first_record_end = 1;
827 struct cleanup *old_cleanups = make_cleanup (record_wait_cleanups, 0);
828 CORE_ADDR tmp_pc;
829
830 status->kind = TARGET_WAITKIND_STOPPED;
831
832 /* Check breakpoint when forward execute. */
833 if (execution_direction == EXEC_FORWARD)
834 {
835 tmp_pc = regcache_read_pc (regcache);
6c95b8df
PA
836 if (breakpoint_inserted_here_p (get_regcache_aspace (regcache),
837 tmp_pc))
69d05d38
HZ
838 {
839 if (record_debug)
840 fprintf_unfiltered (gdb_stdlog,
5af949e3
UW
841 "Process record: break at %s.\n",
842 paddress (gdbarch, tmp_pc));
843 if (gdbarch_decr_pc_after_break (gdbarch)
69d05d38
HZ
844 && !record_resume_step)
845 regcache_write_pc (regcache,
846 tmp_pc +
5af949e3 847 gdbarch_decr_pc_after_break (gdbarch));
69d05d38
HZ
848 goto replay_out;
849 }
850 }
851
852 record_get_sig = 0;
853 signal (SIGINT, record_sig_handler);
854 /* If GDB is in terminal_inferior mode, it will not get the signal.
855 And in GDB replay mode, GDB doesn't need to be in terminal_inferior
856 mode, because inferior will not executed.
857 Then set it to terminal_ours to make GDB get the signal. */
858 target_terminal_ours ();
859
860 /* In EXEC_FORWARD mode, record_list points to the tail of prev
861 instruction. */
862 if (execution_direction == EXEC_FORWARD && record_list->next)
863 record_list = record_list->next;
864
865 /* Loop over the record_list, looking for the next place to
866 stop. */
867 do
868 {
869 /* Check for beginning and end of log. */
870 if (execution_direction == EXEC_REVERSE
871 && record_list == &record_first)
872 {
873 /* Hit beginning of record log in reverse. */
874 status->kind = TARGET_WAITKIND_NO_HISTORY;
875 break;
876 }
877 if (execution_direction != EXEC_REVERSE && !record_list->next)
878 {
879 /* Hit end of record log going forward. */
880 status->kind = TARGET_WAITKIND_NO_HISTORY;
881 break;
882 }
883
884 /* Set ptid, register and memory according to record_list. */
885 if (record_list->type == record_reg)
886 {
887 /* reg */
888 gdb_byte reg[MAX_REGISTER_SIZE];
889 if (record_debug > 1)
890 fprintf_unfiltered (gdb_stdlog,
891 "Process record: record_reg %s to "
892 "inferior num = %d.\n",
893 host_address_to_string (record_list),
894 record_list->u.reg.num);
895 regcache_cooked_read (regcache, record_list->u.reg.num, reg);
896 regcache_cooked_write (regcache, record_list->u.reg.num,
44389f9b
MS
897 record_get_loc (record_list));
898 memcpy (record_get_loc (record_list), reg,
899 record_list->u.reg.len);
69d05d38
HZ
900 }
901 else if (record_list->type == record_mem)
902 {
903 /* mem */
afd0cd3f
MS
904 /* Nothing to do if the entry is flagged not_accessible. */
905 if (!record_list->u.mem.mem_entry_not_accessible)
906 {
907 gdb_byte *mem = alloca (record_list->u.mem.len);
908 if (record_debug > 1)
909 fprintf_unfiltered (gdb_stdlog,
910 "Process record: record_mem %s to "
911 "inferior addr = %s len = %d.\n",
912 host_address_to_string (record_list),
913 paddress (gdbarch,
914 record_list->u.mem.addr),
915 record_list->u.mem.len);
916
917 if (target_read_memory (record_list->u.mem.addr, mem,
918 record_list->u.mem.len))
919 {
920 if (execution_direction != EXEC_REVERSE)
921 error (_("Process record: error reading memory at "
922 "addr = %s len = %d."),
923 paddress (gdbarch, record_list->u.mem.addr),
924 record_list->u.mem.len);
925 else
926 /* Read failed --
927 flag entry as not_accessible. */
928 record_list->u.mem.mem_entry_not_accessible = 1;
929 }
930 else
931 {
932 if (target_write_memory (record_list->u.mem.addr,
44389f9b 933 record_get_loc (record_list),
afd0cd3f
MS
934 record_list->u.mem.len))
935 {
936 if (execution_direction != EXEC_REVERSE)
937 error (_("Process record: error writing memory at "
938 "addr = %s len = %d."),
939 paddress (gdbarch, record_list->u.mem.addr),
940 record_list->u.mem.len);
941 else
942 /* Write failed --
943 flag entry as not_accessible. */
944 record_list->u.mem.mem_entry_not_accessible = 1;
945 }
946 else
947 {
44389f9b 948 memcpy (record_get_loc (record_list), mem,
afd0cd3f
MS
949 record_list->u.mem.len);
950 }
951 }
952 }
69d05d38
HZ
953 }
954 else
955 {
956 if (record_debug > 1)
957 fprintf_unfiltered (gdb_stdlog,
958 "Process record: record_end %s to "
959 "inferior.\n",
960 host_address_to_string (record_list));
961
962 if (first_record_end && execution_direction == EXEC_REVERSE)
963 {
964 /* When reverse excute, the first record_end is the part of
965 current instruction. */
966 first_record_end = 0;
967 }
968 else
969 {
970 /* In EXEC_REVERSE mode, this is the record_end of prev
971 instruction.
972 In EXEC_FORWARD mode, this is the record_end of current
973 instruction. */
974 /* step */
975 if (record_resume_step)
976 {
977 if (record_debug > 1)
978 fprintf_unfiltered (gdb_stdlog,
979 "Process record: step.\n");
980 continue_flag = 0;
981 }
982
983 /* check breakpoint */
984 tmp_pc = regcache_read_pc (regcache);
6c95b8df
PA
985 if (breakpoint_inserted_here_p (get_regcache_aspace (regcache),
986 tmp_pc))
69d05d38
HZ
987 {
988 if (record_debug)
989 fprintf_unfiltered (gdb_stdlog,
990 "Process record: break "
5af949e3
UW
991 "at %s.\n",
992 paddress (gdbarch, tmp_pc));
993 if (gdbarch_decr_pc_after_break (gdbarch)
69d05d38
HZ
994 && execution_direction == EXEC_FORWARD
995 && !record_resume_step)
996 regcache_write_pc (regcache,
997 tmp_pc +
5af949e3 998 gdbarch_decr_pc_after_break (gdbarch));
69d05d38
HZ
999 continue_flag = 0;
1000 }
8b739a96
HZ
1001 /* Check target signal */
1002 if (record_list->u.end.sigval != TARGET_SIGNAL_0)
1003 /* FIXME: better way to check */
1004 continue_flag = 0;
69d05d38
HZ
1005 }
1006 }
1007
1008 if (continue_flag)
1009 {
1010 if (execution_direction == EXEC_REVERSE)
1011 {
1012 if (record_list->prev)
1013 record_list = record_list->prev;
1014 }
1015 else
1016 {
1017 if (record_list->next)
1018 record_list = record_list->next;
1019 }
1020 }
1021 }
1022 while (continue_flag);
1023
1024 signal (SIGINT, handle_sigint);
1025
1026replay_out:
1027 if (record_get_sig)
1028 status->value.sig = TARGET_SIGNAL_INT;
8b739a96
HZ
1029 else if (record_list->u.end.sigval != TARGET_SIGNAL_0)
1030 /* FIXME: better way to check */
1031 status->value.sig = record_list->u.end.sigval;
69d05d38
HZ
1032 else
1033 status->value.sig = TARGET_SIGNAL_TRAP;
1034
1035 discard_cleanups (old_cleanups);
1036 }
1037
1038 do_cleanups (set_cleanups);
1039 return inferior_ptid;
1040}
1041
1042static void
1043record_disconnect (struct target_ops *target, char *args, int from_tty)
1044{
1045 if (record_debug)
1046 fprintf_unfiltered (gdb_stdlog, "Process record: record_disconnect\n");
1047
1048 unpush_target (&record_ops);
1049 target_disconnect (args, from_tty);
1050}
1051
1052static void
1053record_detach (struct target_ops *ops, char *args, int from_tty)
1054{
1055 if (record_debug)
1056 fprintf_unfiltered (gdb_stdlog, "Process record: record_detach\n");
1057
1058 unpush_target (&record_ops);
1059 target_detach (args, from_tty);
1060}
1061
1062static void
1063record_mourn_inferior (struct target_ops *ops)
1064{
1065 if (record_debug)
1066 fprintf_unfiltered (gdb_stdlog, "Process record: "
1067 "record_mourn_inferior\n");
1068
1069 unpush_target (&record_ops);
1070 target_mourn_inferior ();
1071}
1072
1073/* Close process record target before killing the inferior process. */
1074
1075static void
1076record_kill (struct target_ops *ops)
1077{
1078 if (record_debug)
1079 fprintf_unfiltered (gdb_stdlog, "Process record: record_kill\n");
1080
1081 unpush_target (&record_ops);
1082 target_kill ();
1083}
1084
1085/* Record registers change (by user or by GDB) to list as an instruction. */
1086
1087static void
1088record_registers_change (struct regcache *regcache, int regnum)
1089{
1090 /* Check record_insn_num. */
1091 record_check_insn_num (0);
1092
1093 record_arch_list_head = NULL;
1094 record_arch_list_tail = NULL;
1095
1096 if (regnum < 0)
1097 {
1098 int i;
1099 for (i = 0; i < gdbarch_num_regs (get_regcache_arch (regcache)); i++)
1100 {
1101 if (record_arch_list_add_reg (regcache, i))
1102 {
1103 record_list_release (record_arch_list_tail);
1104 error (_("Process record: failed to record execution log."));
1105 }
1106 }
1107 }
1108 else
1109 {
1110 if (record_arch_list_add_reg (regcache, regnum))
1111 {
1112 record_list_release (record_arch_list_tail);
1113 error (_("Process record: failed to record execution log."));
1114 }
1115 }
1116 if (record_arch_list_add_end ())
1117 {
1118 record_list_release (record_arch_list_tail);
1119 error (_("Process record: failed to record execution log."));
1120 }
1121 record_list->next = record_arch_list_head;
1122 record_arch_list_head->prev = record_list;
1123 record_list = record_arch_list_tail;
1124
1125 if (record_insn_num == record_insn_max_num && record_insn_max_num)
1126 record_list_release_first ();
1127 else
1128 record_insn_num++;
1129}
1130
1131static void
1132record_store_registers (struct target_ops *ops, struct regcache *regcache,
1133 int regno)
1134{
1135 if (!record_gdb_operation_disable)
1136 {
1137 if (RECORD_IS_REPLAY)
1138 {
1139 int n;
69d05d38
HZ
1140
1141 /* Let user choose if he wants to write register or not. */
1142 if (regno < 0)
1143 n =
604ad007
JB
1144 query (_("Because GDB is in replay mode, changing the "
1145 "value of a register will make the execution "
1146 "log unusable from this point onward. "
1147 "Change all registers?"));
69d05d38
HZ
1148 else
1149 n =
604ad007
JB
1150 query (_("Because GDB is in replay mode, changing the value "
1151 "of a register will make the execution log unusable "
1152 "from this point onward. Change register %s?"),
69d05d38
HZ
1153 gdbarch_register_name (get_regcache_arch (regcache),
1154 regno));
1155
1156 if (!n)
1157 {
1158 /* Invalidate the value of regcache that was set in function
1159 "regcache_raw_write". */
1160 if (regno < 0)
1161 {
1162 int i;
1163 for (i = 0;
1164 i < gdbarch_num_regs (get_regcache_arch (regcache));
1165 i++)
1166 regcache_invalidate (regcache, i);
1167 }
1168 else
1169 regcache_invalidate (regcache, regno);
1170
1171 error (_("Process record canceled the operation."));
1172 }
1173
1174 /* Destroy the record from here forward. */
61f75dd8 1175 record_list_release_following (record_list);
69d05d38
HZ
1176 }
1177
1178 record_registers_change (regcache, regno);
1179 }
1180 record_beneath_to_store_registers (record_beneath_to_store_registers_ops,
1181 regcache, regno);
1182}
1183
1184/* Behavior is conditional on RECORD_IS_REPLAY.
1185 In replay mode, we cannot write memory unles we are willing to
1186 invalidate the record/replay log from this point forward. */
1187
1188static LONGEST
1189record_xfer_partial (struct target_ops *ops, enum target_object object,
1190 const char *annex, gdb_byte *readbuf,
1191 const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
1192{
1193 if (!record_gdb_operation_disable
1194 && (object == TARGET_OBJECT_MEMORY
1195 || object == TARGET_OBJECT_RAW_MEMORY) && writebuf)
1196 {
1197 if (RECORD_IS_REPLAY)
1198 {
1199 /* Let user choose if he wants to write memory or not. */
604ad007
JB
1200 if (!query (_("Because GDB is in replay mode, writing to memory "
1201 "will make the execution log unusable from this "
1202 "point onward. Write memory at address %s?"),
5af949e3 1203 paddress (target_gdbarch, offset)))
9a9dc473 1204 error (_("Process record canceled the operation."));
69d05d38
HZ
1205
1206 /* Destroy the record from here forward. */
61f75dd8 1207 record_list_release_following (record_list);
69d05d38
HZ
1208 }
1209
1210 /* Check record_insn_num */
1211 record_check_insn_num (0);
1212
1213 /* Record registers change to list as an instruction. */
1214 record_arch_list_head = NULL;
1215 record_arch_list_tail = NULL;
1216 if (record_arch_list_add_mem (offset, len))
1217 {
1218 record_list_release (record_arch_list_tail);
1219 if (record_debug)
1220 fprintf_unfiltered (gdb_stdlog,
1221 _("Process record: failed to record "
1222 "execution log."));
1223 return -1;
1224 }
1225 if (record_arch_list_add_end ())
1226 {
1227 record_list_release (record_arch_list_tail);
1228 if (record_debug)
1229 fprintf_unfiltered (gdb_stdlog,
1230 _("Process record: failed to record "
1231 "execution log."));
1232 return -1;
1233 }
1234 record_list->next = record_arch_list_head;
1235 record_arch_list_head->prev = record_list;
1236 record_list = record_arch_list_tail;
1237
1238 if (record_insn_num == record_insn_max_num && record_insn_max_num)
1239 record_list_release_first ();
1240 else
1241 record_insn_num++;
1242 }
1243
1244 return record_beneath_to_xfer_partial (record_beneath_to_xfer_partial_ops,
1245 object, annex, readbuf, writebuf,
1246 offset, len);
1247}
1248
1249/* Behavior is conditional on RECORD_IS_REPLAY.
1250 We will not actually insert or remove breakpoints when replaying,
1251 nor when recording. */
1252
1253static int
a6d9a66e
UW
1254record_insert_breakpoint (struct gdbarch *gdbarch,
1255 struct bp_target_info *bp_tgt)
69d05d38
HZ
1256{
1257 if (!RECORD_IS_REPLAY)
1258 {
1259 struct cleanup *old_cleanups = record_gdb_operation_disable_set ();
a6d9a66e 1260 int ret = record_beneath_to_insert_breakpoint (gdbarch, bp_tgt);
69d05d38
HZ
1261
1262 do_cleanups (old_cleanups);
1263
1264 return ret;
1265 }
1266
1267 return 0;
1268}
1269
1270static int
a6d9a66e
UW
1271record_remove_breakpoint (struct gdbarch *gdbarch,
1272 struct bp_target_info *bp_tgt)
69d05d38
HZ
1273{
1274 if (!RECORD_IS_REPLAY)
1275 {
1276 struct cleanup *old_cleanups = record_gdb_operation_disable_set ();
a6d9a66e 1277 int ret = record_beneath_to_remove_breakpoint (gdbarch, bp_tgt);
69d05d38
HZ
1278
1279 do_cleanups (old_cleanups);
1280
1281 return ret;
1282 }
1283
1284 return 0;
1285}
1286
1287static int
1288record_can_execute_reverse (void)
1289{
1290 return 1;
1291}
1292
1293static void
1294init_record_ops (void)
1295{
1296 record_ops.to_shortname = "record";
1297 record_ops.to_longname = "Process record and replay target";
1298 record_ops.to_doc =
1299 "Log program while executing and replay execution from log.";
1300 record_ops.to_open = record_open;
1301 record_ops.to_close = record_close;
1302 record_ops.to_resume = record_resume;
1303 record_ops.to_wait = record_wait;
1304 record_ops.to_disconnect = record_disconnect;
1305 record_ops.to_detach = record_detach;
1306 record_ops.to_mourn_inferior = record_mourn_inferior;
1307 record_ops.to_kill = record_kill;
1308 record_ops.to_create_inferior = find_default_create_inferior;
1309 record_ops.to_store_registers = record_store_registers;
1310 record_ops.to_xfer_partial = record_xfer_partial;
1311 record_ops.to_insert_breakpoint = record_insert_breakpoint;
1312 record_ops.to_remove_breakpoint = record_remove_breakpoint;
1313 record_ops.to_can_execute_reverse = record_can_execute_reverse;
1314 record_ops.to_stratum = record_stratum;
1315 record_ops.to_magic = OPS_MAGIC;
1316}
1317
1318static void
1319show_record_debug (struct ui_file *file, int from_tty,
1320 struct cmd_list_element *c, const char *value)
1321{
1322 fprintf_filtered (file, _("Debugging of process record target is %s.\n"),
1323 value);
1324}
1325
1326/* Alias for "target record". */
1327
1328static void
1329cmd_record_start (char *args, int from_tty)
1330{
1331 execute_command ("target record", from_tty);
1332}
1333
1334/* Truncate the record log from the present point
1335 of replay until the end. */
1336
1337static void
1338cmd_record_delete (char *args, int from_tty)
1339{
1340 if (current_target.to_stratum == record_stratum)
1341 {
1342 if (RECORD_IS_REPLAY)
1343 {
1344 if (!from_tty || query (_("Delete the log from this point forward "
1345 "and begin to record the running message "
1346 "at current PC?")))
61f75dd8 1347 record_list_release_following (record_list);
69d05d38
HZ
1348 }
1349 else
1350 printf_unfiltered (_("Already at end of record list.\n"));
1351
1352 }
1353 else
1354 printf_unfiltered (_("Process record is not started.\n"));
1355}
1356
1357/* Implement the "stoprecord" command. */
1358
1359static void
1360cmd_record_stop (char *args, int from_tty)
1361{
1362 if (current_target.to_stratum == record_stratum)
1363 {
5d40bb85
HZ
1364 unpush_target (&record_ops);
1365 printf_unfiltered (_("Process record is stoped and all execution "
1366 "log is deleted.\n"));
69d05d38
HZ
1367 }
1368 else
1369 printf_unfiltered (_("Process record is not started.\n"));
1370}
1371
1372/* Set upper limit of record log size. */
1373
1374static void
1375set_record_insn_max_num (char *args, int from_tty, struct cmd_list_element *c)
1376{
1377 if (record_insn_num > record_insn_max_num && record_insn_max_num)
1378 {
265aad34 1379 /* Count down record_insn_num while releasing records from list. */
69d05d38 1380 while (record_insn_num > record_insn_max_num)
265aad34
MS
1381 {
1382 record_list_release_first ();
1383 record_insn_num--;
1384 }
69d05d38
HZ
1385 }
1386}
1387
1388/* Print the current index into the record log (number of insns recorded
1389 so far). */
1390
1391static void
1392show_record_insn_number (char *ignore, int from_tty)
1393{
1394 printf_unfiltered (_("Record instruction number is %d.\n"),
1395 record_insn_num);
1396}
1397
1398static struct cmd_list_element *record_cmdlist, *set_record_cmdlist,
1399 *show_record_cmdlist, *info_record_cmdlist;
1400
1401static void
1402set_record_command (char *args, int from_tty)
1403{
1404 printf_unfiltered (_("\
1405\"set record\" must be followed by an apporpriate subcommand.\n"));
1406 help_list (set_record_cmdlist, "set record ", all_commands, gdb_stdout);
1407}
1408
1409static void
1410show_record_command (char *args, int from_tty)
1411{
1412 cmd_show_list (show_record_cmdlist, from_tty, "");
1413}
1414
1415static void
1416info_record_command (char *args, int from_tty)
1417{
1418 cmd_show_list (info_record_cmdlist, from_tty, "");
1419}
1420
1421void
1422_initialize_record (void)
1423{
1424 /* Init record_first. */
1425 record_first.prev = NULL;
1426 record_first.next = NULL;
1427 record_first.type = record_end;
1428
1429 init_record_ops ();
1430 add_target (&record_ops);
1431
1432 add_setshow_zinteger_cmd ("record", no_class, &record_debug,
1433 _("Set debugging of record/replay feature."),
1434 _("Show debugging of record/replay feature."),
1435 _("When enabled, debugging output for "
1436 "record/replay feature is displayed."),
1437 NULL, show_record_debug, &setdebuglist,
1438 &showdebuglist);
1439
1440 add_prefix_cmd ("record", class_obscure, cmd_record_start,
1441 _("Abbreviated form of \"target record\" command."),
1442 &record_cmdlist, "record ", 0, &cmdlist);
1443 add_com_alias ("rec", "record", class_obscure, 1);
1444 add_prefix_cmd ("record", class_support, set_record_command,
1445 _("Set record options"), &set_record_cmdlist,
1446 "set record ", 0, &setlist);
1447 add_alias_cmd ("rec", "record", class_obscure, 1, &setlist);
1448 add_prefix_cmd ("record", class_support, show_record_command,
1449 _("Show record options"), &show_record_cmdlist,
1450 "show record ", 0, &showlist);
1451 add_alias_cmd ("rec", "record", class_obscure, 1, &showlist);
1452 add_prefix_cmd ("record", class_support, info_record_command,
1453 _("Info record options"), &info_record_cmdlist,
1454 "info record ", 0, &infolist);
1455 add_alias_cmd ("rec", "record", class_obscure, 1, &infolist);
1456
1457
1458 add_cmd ("delete", class_obscure, cmd_record_delete,
1459 _("Delete the rest of execution log and start recording it anew."),
1460 &record_cmdlist);
1461 add_alias_cmd ("d", "delete", class_obscure, 1, &record_cmdlist);
1462 add_alias_cmd ("del", "delete", class_obscure, 1, &record_cmdlist);
1463
1464 add_cmd ("stop", class_obscure, cmd_record_stop,
1465 _("Stop the record/replay target."),
1466 &record_cmdlist);
1467 add_alias_cmd ("s", "stop", class_obscure, 1, &record_cmdlist);
1468
1469 /* Record instructions number limit command. */
1470 add_setshow_boolean_cmd ("stop-at-limit", no_class,
fda458ee 1471 &record_stop_at_limit, _("\
299a410e
EZ
1472Set whether record/replay stops when record/replay buffer becomes full."), _("\
1473Show whether record/replay stops when record/replay buffer becomes full."), _("\
1474Default is ON.\n\
1475When ON, if the record/replay buffer becomes full, ask user what to do.\n\
1476When OFF, if the record/replay buffer becomes full,\n\
1477delete the oldest recorded instruction to make room for each new one."),
fda458ee
MS
1478 NULL, NULL,
1479 &set_record_cmdlist, &show_record_cmdlist);
191e1813 1480 add_setshow_uinteger_cmd ("insn-number-max", no_class,
69d05d38
HZ
1481 &record_insn_max_num,
1482 _("Set record/replay buffer limit."),
299a410e
EZ
1483 _("Show record/replay buffer limit."), _("\
1484Set the maximum number of instructions to be stored in the\n\
1485record/replay buffer. Zero means unlimited. Default is 200000."),
69d05d38
HZ
1486 set_record_insn_max_num,
1487 NULL, &set_record_cmdlist, &show_record_cmdlist);
1488 add_cmd ("insn-number", class_obscure, show_record_insn_number,
fda458ee
MS
1489 _("Show the current number of instructions in the "
1490 "record/replay buffer."), &info_record_cmdlist);
69d05d38 1491}