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