Rename _const functions to use overloading instead
[deliverable/binutils-gdb.git] / gdb / record.c
CommitLineData
69d05d38
HZ
1/* Process record and replay target for GDB, the GNU debugger.
2
61baf725 3 Copyright (C) 2008-2017 Free Software Foundation, Inc.
69d05d38
HZ
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"
0156b218 22#include "completer.h"
69d05d38 23#include "record.h"
82a90ccf 24#include "observer.h"
d02ed0bb
MM
25#include "inferior.h"
26#include "common/common-utils.h"
67c86d06
MM
27#include "cli/cli-utils.h"
28#include "disasm.h"
29
30#include <ctype.h>
69d05d38 31
d02ed0bb
MM
32/* This is the debug switch for process record. */
33unsigned int record_debug = 0;
27699eea 34
67c86d06
MM
35/* The number of instructions to print in "record instruction-history". */
36static unsigned int record_insn_history_size = 10;
37
42c634cb
PA
38/* The variable registered as control variable in the "record
39 instruction-history" command. Necessary for extra input
40 validation. */
41static unsigned int record_insn_history_size_setshow_var;
42
15984c13
MM
43/* The number of functions to print in "record function-call-history". */
44static unsigned int record_call_history_size = 10;
45
42c634cb
PA
46/* The variable registered as control variable in the "record
47 call-history" command. Necessary for extra input validation. */
48static unsigned int record_call_history_size_setshow_var;
49
d02ed0bb 50struct cmd_list_element *record_cmdlist = NULL;
742ce053 51struct cmd_list_element *record_goto_cmdlist = NULL;
d02ed0bb
MM
52struct cmd_list_element *set_record_cmdlist = NULL;
53struct cmd_list_element *show_record_cmdlist = NULL;
54struct cmd_list_element *info_record_cmdlist = NULL;
27699eea 55
7c1687a9
MM
56#define DEBUG(msg, args...) \
57 if (record_debug) \
58 fprintf_unfiltered (gdb_stdlog, "record: " msg "\n", ##args)
59
8213266a 60/* See record.h. */
27699eea 61
8213266a 62struct target_ops *
d02ed0bb 63find_record_target (void)
27699eea 64{
8b06beed 65 return find_target_at (record_stratum);
27699eea
MS
66}
67
d02ed0bb 68/* Check that recording is active. Throw an error, if it isn't. */
27699eea 69
d02ed0bb
MM
70static struct target_ops *
71require_record_target (void)
27699eea 72{
d02ed0bb 73 struct target_ops *t;
27699eea 74
d02ed0bb
MM
75 t = find_record_target ();
76 if (t == NULL)
77 error (_("No record target is currently active.\n"
78 "Use one of the \"target record-<tab><tab>\" commands first."));
27699eea 79
d02ed0bb 80 return t;
27699eea
MS
81}
82
d02ed0bb 83/* See record.h. */
27699eea 84
8213266a
PA
85void
86record_preopen (void)
87{
88 /* Check if a record target is already running. */
89 if (find_record_target () != NULL)
90 error (_("The process is already being recorded. Use \"record stop\" to "
91 "stop recording first."));
92}
93
94/* See record.h. */
95
45b196c5
TW
96void
97record_start (const char *method, const char *format, int from_tty)
98{
99 if (method == NULL)
100 {
101 if (format == NULL)
9b2eba3d 102 execute_command_to_string ((char *) "record", from_tty);
45b196c5
TW
103 else
104 error (_("Invalid format."));
105 }
106 else if (strcmp (method, "full") == 0)
107 {
108 if (format == NULL)
9b2eba3d 109 execute_command_to_string ((char *) "record full", from_tty);
45b196c5
TW
110 else
111 error (_("Invalid format."));
112 }
113 else if (strcmp (method, "btrace") == 0)
114 {
115 if (format == NULL)
9b2eba3d 116 execute_command_to_string ((char *) "record btrace", from_tty);
45b196c5 117 else if (strcmp (format, "bts") == 0)
9b2eba3d 118 execute_command_to_string ((char *) "record btrace bts", from_tty);
45b196c5 119 else if (strcmp (format, "pt") == 0)
9b2eba3d 120 execute_command_to_string ((char *) "record btrace pt", from_tty);
45b196c5
TW
121 else
122 error (_("Invalid format."));
123 }
124 else
125 error (_("Invalid method."));
126}
127
128/* See record.h. */
129
130void
131record_stop (int from_tty)
132{
9b2eba3d 133 execute_command_to_string ((char *) "record stop", from_tty);
45b196c5
TW
134}
135
136/* See record.h. */
137
d02ed0bb
MM
138int
139record_read_memory (struct gdbarch *gdbarch,
140 CORE_ADDR memaddr, gdb_byte *myaddr,
141 ssize_t len)
27699eea 142{
d02ed0bb 143 int ret = target_read_memory (memaddr, myaddr, len);
27699eea 144
7c1687a9
MM
145 if (ret != 0)
146 DEBUG ("error reading memory at addr %s len = %ld.\n",
147 paddress (gdbarch, memaddr), (long) len);
148
d02ed0bb 149 return ret;
27699eea
MS
150}
151
7c1687a9
MM
152/* Stop recording. */
153
154static void
155record_stop (struct target_ops *t)
156{
157 DEBUG ("stop %s", t->to_shortname);
158
ee97f592 159 t->to_stop_recording (t);
7c1687a9
MM
160}
161
162/* Unpush the record target. */
163
164static void
165record_unpush (struct target_ops *t)
166{
167 DEBUG ("unpush %s", t->to_shortname);
168
169 unpush_target (t);
170}
171
172/* See record.h. */
173
174void
fee354ee 175record_disconnect (struct target_ops *t, const char *args, int from_tty)
7c1687a9
MM
176{
177 gdb_assert (t->to_stratum == record_stratum);
178
179 DEBUG ("disconnect %s", t->to_shortname);
180
181 record_stop (t);
182 record_unpush (t);
183
184 target_disconnect (args, from_tty);
185}
186
187/* See record.h. */
188
189void
52554a0e 190record_detach (struct target_ops *t, const char *args, int from_tty)
7c1687a9
MM
191{
192 gdb_assert (t->to_stratum == record_stratum);
193
194 DEBUG ("detach %s", t->to_shortname);
195
196 record_stop (t);
197 record_unpush (t);
198
199 target_detach (args, from_tty);
200}
201
202/* See record.h. */
203
204void
205record_mourn_inferior (struct target_ops *t)
206{
207 gdb_assert (t->to_stratum == record_stratum);
208
209 DEBUG ("mourn inferior %s", t->to_shortname);
210
211 /* It is safer to not stop recording. Resources will be freed when
212 threads are discarded. */
213 record_unpush (t);
214
bc1e6c81 215 target_mourn_inferior (inferior_ptid);
7c1687a9
MM
216}
217
218/* See record.h. */
219
220void
221record_kill (struct target_ops *t)
222{
223 gdb_assert (t->to_stratum == record_stratum);
224
225 DEBUG ("kill %s", t->to_shortname);
226
227 /* It is safer to not stop recording. Resources will be freed when
228 threads are discarded. */
229 record_unpush (t);
230
231 target_kill ();
232}
233
9e8915c6
PA
234/* See record.h. */
235
236int
237record_check_stopped_by_breakpoint (struct address_space *aspace, CORE_ADDR pc,
238 enum target_stop_reason *reason)
239{
240 if (breakpoint_inserted_here_p (aspace, pc))
241 {
242 if (hardware_breakpoint_inserted_here_p (aspace, pc))
243 *reason = TARGET_STOPPED_BY_HW_BREAKPOINT;
244 else
245 *reason = TARGET_STOPPED_BY_SW_BREAKPOINT;
246 return 1;
247 }
248
249 *reason = TARGET_STOPPED_BY_NO_REASON;
250 return 0;
251}
252
6df67667
MS
253/* Implement "show record debug" command. */
254
69d05d38
HZ
255static void
256show_record_debug (struct ui_file *file, int from_tty,
257 struct cmd_list_element *c, const char *value)
258{
259 fprintf_filtered (file, _("Debugging of process record target is %s.\n"),
260 value);
261}
262
263/* Alias for "target record". */
264
265static void
266cmd_record_start (char *args, int from_tty)
267{
9b2eba3d 268 execute_command ((char *) "target record-full", from_tty);
69d05d38
HZ
269}
270
271/* Truncate the record log from the present point
272 of replay until the end. */
273
274static void
275cmd_record_delete (char *args, int from_tty)
276{
d02ed0bb
MM
277 require_record_target ();
278
a52eab48 279 if (!target_record_is_replaying (inferior_ptid))
69d05d38 280 {
d02ed0bb
MM
281 printf_unfiltered (_("Already at end of record list.\n"));
282 return;
283 }
69d05d38 284
d02ed0bb
MM
285 if (!target_supports_delete_record ())
286 {
287 printf_unfiltered (_("The current record target does not support "
288 "this operation.\n"));
289 return;
69d05d38 290 }
d02ed0bb
MM
291
292 if (!from_tty || query (_("Delete the log from this point forward "
293 "and begin to record the running message "
294 "at current PC?")))
295 target_delete_record ();
69d05d38
HZ
296}
297
6df67667 298/* Implement the "stoprecord" or "record stop" command. */
69d05d38
HZ
299
300static void
301cmd_record_stop (char *args, int from_tty)
302{
d02ed0bb 303 struct target_ops *t;
82a90ccf 304
d02ed0bb 305 t = require_record_target ();
7c1687a9
MM
306
307 record_stop (t);
308 record_unpush (t);
69d05d38 309
d02ed0bb
MM
310 printf_unfiltered (_("Process record is stopped and all execution "
311 "logs are deleted.\n"));
69d05d38 312
38b022b4 313 observer_notify_record_changed (current_inferior (), 0, NULL, NULL);
69d05d38
HZ
314}
315
d02ed0bb 316/* The "set record" command. */
69d05d38
HZ
317
318static void
319set_record_command (char *args, int from_tty)
320{
3e43a32a
MS
321 printf_unfiltered (_("\"set record\" must be followed "
322 "by an apporpriate subcommand.\n"));
69d05d38
HZ
323 help_list (set_record_cmdlist, "set record ", all_commands, gdb_stdout);
324}
325
d02ed0bb
MM
326/* The "show record" command. */
327
69d05d38
HZ
328static void
329show_record_command (char *args, int from_tty)
330{
331 cmd_show_list (show_record_cmdlist, from_tty, "");
332}
333
d02ed0bb 334/* The "info record" command. */
b54295a7 335
69d05d38
HZ
336static void
337info_record_command (char *args, int from_tty)
338{
d02ed0bb 339 struct target_ops *t;
0156b218 340
d02ed0bb
MM
341 t = find_record_target ();
342 if (t == NULL)
0156b218 343 {
d02ed0bb
MM
344 printf_filtered (_("No record target is currently active.\n"));
345 return;
0156b218
MS
346 }
347
d02ed0bb 348 printf_filtered (_("Active record target: %s\n"), t->to_shortname);
38e229b2 349 t->to_info_record (t);
0156b218
MS
350}
351
d02ed0bb 352/* The "record save" command. */
0156b218
MS
353
354static void
355cmd_record_save (char *args, int from_tty)
356{
357 char *recfilename, recfilename_buffer[40];
0156b218 358
d02ed0bb 359 require_record_target ();
0156b218 360
d02ed0bb 361 if (args != NULL && *args != 0)
0156b218
MS
362 recfilename = args;
363 else
364 {
365 /* Default recfile name is "gdb_record.PID". */
d02ed0bb 366 xsnprintf (recfilename_buffer, sizeof (recfilename_buffer),
dfd4cc63 367 "gdb_record.%d", ptid_get_pid (inferior_ptid));
0156b218
MS
368 recfilename = recfilename_buffer;
369 }
370
d02ed0bb 371 target_save_record (recfilename);
6b04bdb7
MS
372}
373
c2bcbb1d 374/* See record.h. */
6b04bdb7 375
d02ed0bb 376void
c2bcbb1d 377record_goto (const char *arg)
6b04bdb7 378{
742ce053 379 ULONGEST insn;
6b04bdb7
MS
380
381 if (arg == NULL || *arg == '\0')
382 error (_("Command requires an argument (insn number to go to)."));
383
742ce053 384 insn = parse_and_eval_long (arg);
6b04bdb7 385
742ce053
MM
386 require_record_target ();
387 target_goto_record (insn);
388}
389
c2bcbb1d
TT
390/* "record goto" command. Argument is an instruction number,
391 as given by "info record".
392
393 Rewinds the recording (forward or backward) to the given instruction. */
394
395static void
396cmd_record_goto (char *arg, int from_tty)
397{
398 record_goto (arg);
399}
400
742ce053
MM
401/* The "record goto begin" command. */
402
403static void
404cmd_record_goto_begin (char *arg, int from_tty)
405{
406 if (arg != NULL && *arg != '\0')
407 error (_("Junk after argument: %s."), arg);
408
409 require_record_target ();
410 target_goto_record_begin ();
411}
412
413/* The "record goto end" command. */
414
415static void
416cmd_record_goto_end (char *arg, int from_tty)
417{
418 if (arg != NULL && *arg != '\0')
419 error (_("Junk after argument: %s."), arg);
420
421 require_record_target ();
422 target_goto_record_end ();
6b04bdb7
MS
423}
424
67c86d06
MM
425/* Read an instruction number from an argument string. */
426
427static ULONGEST
428get_insn_number (char **arg)
429{
430 ULONGEST number;
431 const char *begin, *end, *pos;
432
433 begin = *arg;
f1735a53 434 pos = skip_spaces (begin);
67c86d06
MM
435
436 if (!isdigit (*pos))
437 error (_("Expected positive number, got: %s."), pos);
438
439 number = strtoulst (pos, &end, 10);
440
441 *arg += (end - begin);
442
443 return number;
444}
445
446/* Read a context size from an argument string. */
447
448static int
449get_context_size (char **arg)
450{
451 char *pos;
452 int number;
453
454 pos = skip_spaces (*arg);
455
456 if (!isdigit (*pos))
457 error (_("Expected positive number, got: %s."), pos);
458
459 return strtol (pos, arg, 10);
460}
461
462/* Complain about junk at the end of an argument string. */
463
464static void
465no_chunk (char *arg)
466{
467 if (*arg != 0)
468 error (_("Junk after argument: %s."), arg);
469}
470
471/* Read instruction-history modifiers from an argument string. */
472
9a24775b 473static gdb_disassembly_flags
67c86d06
MM
474get_insn_history_modifiers (char **arg)
475{
9a24775b 476 gdb_disassembly_flags modifiers;
67c86d06
MM
477 char *args;
478
479 modifiers = 0;
480 args = *arg;
481
482 if (args == NULL)
483 return modifiers;
484
485 while (*args == '/')
486 {
487 ++args;
488
489 if (*args == '\0')
490 error (_("Missing modifier."));
491
492 for (; *args; ++args)
493 {
494 if (isspace (*args))
495 break;
496
497 if (*args == '/')
498 continue;
499
500 switch (*args)
501 {
502 case 'm':
0c532a29
MM
503 case 's':
504 modifiers |= DISASSEMBLY_SOURCE;
67c86d06
MM
505 modifiers |= DISASSEMBLY_FILENAME;
506 break;
507 case 'r':
508 modifiers |= DISASSEMBLY_RAW_INSN;
509 break;
510 case 'f':
511 modifiers |= DISASSEMBLY_OMIT_FNAME;
512 break;
946287b7
MM
513 case 'p':
514 modifiers |= DISASSEMBLY_OMIT_PC;
515 break;
67c86d06
MM
516 default:
517 error (_("Invalid modifier: %c."), *args);
518 }
519 }
520
521 args = skip_spaces (args);
522 }
523
524 /* Update the argument string. */
525 *arg = args;
526
527 return modifiers;
528}
529
42c634cb
PA
530/* The "set record instruction-history-size / set record
531 function-call-history-size" commands are unsigned, with UINT_MAX
532 meaning unlimited. The target interfaces works with signed int
533 though, to indicate direction, so map "unlimited" to INT_MAX, which
534 is about the same as unlimited in practice. If the user does have
0ccfeeae
MM
535 a log that huge, she can fetch it in chunks across several requests,
536 but she'll likely have other problems first... */
42c634cb
PA
537
538static int
0ccfeeae 539command_size_to_target_size (unsigned int size)
42c634cb 540{
0ccfeeae 541 gdb_assert (size <= INT_MAX || size == UINT_MAX);
42c634cb 542
0ccfeeae 543 if (size == UINT_MAX)
42c634cb
PA
544 return INT_MAX;
545 else
0ccfeeae 546 return size;
42c634cb
PA
547}
548
67c86d06
MM
549/* The "record instruction-history" command. */
550
551static void
552cmd_record_insn_history (char *arg, int from_tty)
553{
67c86d06
MM
554 require_record_target ();
555
9a24775b 556 gdb_disassembly_flags flags = get_insn_history_modifiers (&arg);
67c86d06 557
9a24775b 558 int size = command_size_to_target_size (record_insn_history_size);
67c86d06
MM
559
560 if (arg == NULL || *arg == 0 || strcmp (arg, "+") == 0)
561 target_insn_history (size, flags);
562 else if (strcmp (arg, "-") == 0)
563 target_insn_history (-size, flags);
564 else
565 {
566 ULONGEST begin, end;
567
568 begin = get_insn_number (&arg);
569
570 if (*arg == ',')
571 {
572 arg = skip_spaces (++arg);
573
574 if (*arg == '+')
575 {
576 arg += 1;
577 size = get_context_size (&arg);
578
579 no_chunk (arg);
580
581 target_insn_history_from (begin, size, flags);
582 }
583 else if (*arg == '-')
584 {
585 arg += 1;
586 size = get_context_size (&arg);
587
588 no_chunk (arg);
589
590 target_insn_history_from (begin, -size, flags);
591 }
592 else
593 {
594 end = get_insn_number (&arg);
595
596 no_chunk (arg);
597
598 target_insn_history_range (begin, end, flags);
599 }
600 }
601 else
602 {
603 no_chunk (arg);
604
605 target_insn_history_from (begin, size, flags);
606 }
607
608 dont_repeat ();
609 }
610}
611
15984c13
MM
612/* Read function-call-history modifiers from an argument string. */
613
614static int
615get_call_history_modifiers (char **arg)
616{
617 int modifiers;
618 char *args;
619
620 modifiers = 0;
621 args = *arg;
622
623 if (args == NULL)
624 return modifiers;
625
626 while (*args == '/')
627 {
628 ++args;
629
630 if (*args == '\0')
631 error (_("Missing modifier."));
632
633 for (; *args; ++args)
634 {
635 if (isspace (*args))
636 break;
637
638 if (*args == '/')
639 continue;
640
641 switch (*args)
642 {
643 case 'l':
1e038f67 644 modifiers |= RECORD_PRINT_SRC_LINE;
15984c13
MM
645 break;
646 case 'i':
1e038f67 647 modifiers |= RECORD_PRINT_INSN_RANGE;
15984c13 648 break;
8710b709
MM
649 case 'c':
650 modifiers |= RECORD_PRINT_INDENT_CALLS;
651 break;
15984c13
MM
652 default:
653 error (_("Invalid modifier: %c."), *args);
654 }
655 }
656
657 args = skip_spaces (args);
658 }
659
660 /* Update the argument string. */
661 *arg = args;
662
663 return modifiers;
664}
665
666/* The "record function-call-history" command. */
667
668static void
669cmd_record_call_history (char *arg, int from_tty)
670{
671 int flags, size;
672
673 require_record_target ();
674
675 flags = get_call_history_modifiers (&arg);
676
0ccfeeae 677 size = command_size_to_target_size (record_call_history_size);
15984c13
MM
678
679 if (arg == NULL || *arg == 0 || strcmp (arg, "+") == 0)
680 target_call_history (size, flags);
681 else if (strcmp (arg, "-") == 0)
682 target_call_history (-size, flags);
683 else
684 {
685 ULONGEST begin, end;
686
687 begin = get_insn_number (&arg);
688
689 if (*arg == ',')
690 {
691 arg = skip_spaces (++arg);
692
693 if (*arg == '+')
694 {
695 arg += 1;
696 size = get_context_size (&arg);
697
698 no_chunk (arg);
699
700 target_call_history_from (begin, size, flags);
701 }
702 else if (*arg == '-')
703 {
704 arg += 1;
705 size = get_context_size (&arg);
706
707 no_chunk (arg);
708
709 target_call_history_from (begin, -size, flags);
710 }
711 else
712 {
713 end = get_insn_number (&arg);
714
715 no_chunk (arg);
716
717 target_call_history_range (begin, end, flags);
718 }
719 }
720 else
721 {
722 no_chunk (arg);
723
724 target_call_history_from (begin, size, flags);
725 }
726
727 dont_repeat ();
728 }
729}
730
42c634cb
PA
731/* Helper for "set record instruction-history-size" and "set record
732 function-call-history-size" input validation. COMMAND_VAR is the
733 variable registered in the command as control variable. *SETTING
734 is the real setting the command allows changing. */
735
736static void
9c37696b 737validate_history_size (unsigned int *command_var, unsigned int *setting)
42c634cb
PA
738{
739 if (*command_var != UINT_MAX && *command_var > INT_MAX)
740 {
741 unsigned int new_value = *command_var;
742
743 /* Restore previous value. */
744 *command_var = *setting;
745 error (_("integer %u out of range"), new_value);
746 }
747
748 /* Commit new value. */
749 *setting = *command_var;
750}
751
752/* Called by do_setshow_command. We only want values in the
753 [0..INT_MAX] range, while the command's machinery accepts
754 [0..UINT_MAX]. See command_size_to_target_size. */
755
756static void
757set_record_insn_history_size (char *args, int from_tty,
758 struct cmd_list_element *c)
759{
760 validate_history_size (&record_insn_history_size_setshow_var,
761 &record_insn_history_size);
762}
763
764/* Called by do_setshow_command. We only want values in the
765 [0..INT_MAX] range, while the command's machinery accepts
766 [0..UINT_MAX]. See command_size_to_target_size. */
767
768static void
769set_record_call_history_size (char *args, int from_tty,
770 struct cmd_list_element *c)
771{
772 validate_history_size (&record_call_history_size_setshow_var,
773 &record_call_history_size);
774}
775
69d05d38
HZ
776void
777_initialize_record (void)
778{
0156b218
MS
779 struct cmd_list_element *c;
780
ccce17b0
YQ
781 add_setshow_zuinteger_cmd ("record", no_class, &record_debug,
782 _("Set debugging of record/replay feature."),
783 _("Show debugging of record/replay feature."),
784 _("When enabled, debugging output for "
785 "record/replay feature is displayed."),
786 NULL, show_record_debug, &setdebuglist,
787 &showdebuglist);
69d05d38 788
67c86d06 789 add_setshow_uinteger_cmd ("instruction-history-size", no_class,
42c634cb 790 &record_insn_history_size_setshow_var, _("\
67c86d06 791Set number of instructions to print in \"record instruction-history\"."), _("\
f81d1120
PA
792Show number of instructions to print in \"record instruction-history\"."), _("\
793A size of \"unlimited\" means unlimited instructions. The default is 10."),
42c634cb
PA
794 set_record_insn_history_size, NULL,
795 &set_record_cmdlist, &show_record_cmdlist);
67c86d06 796
15984c13 797 add_setshow_uinteger_cmd ("function-call-history-size", no_class,
42c634cb 798 &record_call_history_size_setshow_var, _("\
15984c13 799Set number of function to print in \"record function-call-history\"."), _("\
f81d1120
PA
800Show number of functions to print in \"record function-call-history\"."), _("\
801A size of \"unlimited\" means unlimited lines. The default is 10."),
42c634cb
PA
802 set_record_call_history_size, NULL,
803 &set_record_cmdlist, &show_record_cmdlist);
15984c13 804
0156b218 805 c = add_prefix_cmd ("record", class_obscure, cmd_record_start,
d02ed0bb 806 _("Start recording."),
0156b218
MS
807 &record_cmdlist, "record ", 0, &cmdlist);
808 set_cmd_completer (c, filename_completer);
809
69d05d38
HZ
810 add_com_alias ("rec", "record", class_obscure, 1);
811 add_prefix_cmd ("record", class_support, set_record_command,
812 _("Set record options"), &set_record_cmdlist,
813 "set record ", 0, &setlist);
814 add_alias_cmd ("rec", "record", class_obscure, 1, &setlist);
815 add_prefix_cmd ("record", class_support, show_record_command,
816 _("Show record options"), &show_record_cmdlist,
817 "show record ", 0, &showlist);
818 add_alias_cmd ("rec", "record", class_obscure, 1, &showlist);
819 add_prefix_cmd ("record", class_support, info_record_command,
820 _("Info record options"), &info_record_cmdlist,
821 "info record ", 0, &infolist);
822 add_alias_cmd ("rec", "record", class_obscure, 1, &infolist);
823
0156b218
MS
824 c = add_cmd ("save", class_obscure, cmd_record_save,
825 _("Save the execution log to a file.\n\
826Argument is optional filename.\n\
827Default filename is 'gdb_record.<process_id>'."),
828 &record_cmdlist);
829 set_cmd_completer (c, filename_completer);
830
69d05d38
HZ
831 add_cmd ("delete", class_obscure, cmd_record_delete,
832 _("Delete the rest of execution log and start recording it anew."),
833 &record_cmdlist);
834 add_alias_cmd ("d", "delete", class_obscure, 1, &record_cmdlist);
835 add_alias_cmd ("del", "delete", class_obscure, 1, &record_cmdlist);
836
837 add_cmd ("stop", class_obscure, cmd_record_stop,
838 _("Stop the record/replay target."),
839 &record_cmdlist);
840 add_alias_cmd ("s", "stop", class_obscure, 1, &record_cmdlist);
841
742ce053 842 add_prefix_cmd ("goto", class_obscure, cmd_record_goto, _("\
6b04bdb7
MS
843Restore the program to its state at instruction number N.\n\
844Argument is instruction number, as shown by 'info record'."),
742ce053
MM
845 &record_goto_cmdlist, "record goto ", 1, &record_cmdlist);
846
847 add_cmd ("begin", class_obscure, cmd_record_goto_begin,
848 _("Go to the beginning of the execution log."),
849 &record_goto_cmdlist);
850 add_alias_cmd ("start", "begin", class_obscure, 1, &record_goto_cmdlist);
851
852 add_cmd ("end", class_obscure, cmd_record_goto_end,
853 _("Go to the end of the execution log."),
854 &record_goto_cmdlist);
67c86d06
MM
855
856 add_cmd ("instruction-history", class_obscure, cmd_record_insn_history, _("\
857Print disassembled instructions stored in the execution log.\n\
0c532a29 858With a /m or /s modifier, source lines are included (if available).\n\
67c86d06
MM
859With a /r modifier, raw instructions in hex are included.\n\
860With a /f modifier, function names are omitted.\n\
946287b7 861With a /p modifier, current position markers are omitted.\n\
67c86d06
MM
862With no argument, disassembles ten more instructions after the previous \
863disassembly.\n\
864\"record instruction-history -\" disassembles ten instructions before a \
865previous disassembly.\n\
866One argument specifies an instruction number as shown by 'info record', and \
867ten instructions are disassembled after that instruction.\n\
868Two arguments with comma between them specify starting and ending instruction \
869numbers to disassemble.\n\
870If the second argument is preceded by '+' or '-', it specifies the distance \
871from the first argument.\n\
872The number of instructions to disassemble can be defined with \"set record \
873instruction-history-size\"."),
874 &record_cmdlist);
15984c13
MM
875
876 add_cmd ("function-call-history", class_obscure, cmd_record_call_history, _("\
877Prints the execution history at function granularity.\n\
878It prints one line for each sequence of instructions that belong to the same \
879function.\n\
880Without modifiers, it prints the function name.\n\
881With a /l modifier, the source file and line number range is included.\n\
882With a /i modifier, the instruction number range is included.\n\
8710b709 883With a /c modifier, the output is indented based on the call stack depth.\n\
15984c13
MM
884With no argument, prints ten more lines after the previous ten-line print.\n\
885\"record function-call-history -\" prints ten lines before a previous ten-line \
886print.\n\
887One argument specifies a function number as shown by 'info record', and \
888ten lines are printed after that function.\n\
889Two arguments with comma between them specify a range of functions to print.\n\
890If the second argument is preceded by '+' or '-', it specifies the distance \
891from the first argument.\n\
892The number of functions to print can be defined with \"set record \
893function-call-history-size\"."),
894 &record_cmdlist);
42c634cb
PA
895
896 /* Sync command control variables. */
897 record_insn_history_size_setshow_var = record_insn_history_size;
898 record_call_history_size_setshow_var = record_call_history_size;
69d05d38 899}
This page took 0.892759 seconds and 4 git commands to generate.