fix typos in ada-lang.c comment
[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)
95a6b0a1 102 execute_command_to_string ("record", from_tty);
45b196c5
TW
103 else
104 error (_("Invalid format."));
105 }
106 else if (strcmp (method, "full") == 0)
107 {
108 if (format == NULL)
95a6b0a1 109 execute_command_to_string ("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)
95a6b0a1 116 execute_command_to_string ("record btrace", from_tty);
45b196c5 117 else if (strcmp (format, "bts") == 0)
95a6b0a1 118 execute_command_to_string ("record btrace bts", from_tty);
45b196c5 119 else if (strcmp (format, "pt") == 0)
95a6b0a1 120 execute_command_to_string ("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{
95a6b0a1 133 execute_command_to_string ("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
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
38b022b4 314 observer_notify_record_changed (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
MS
322 printf_unfiltered (_("\"set record\" must be followed "
323 "by an apporpriate 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
d02ed0bb 349 printf_filtered (_("Active record target: %s\n"), t->to_shortname);
38e229b2 350 t->to_info_record (t);
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),
dfd4cc63 369 "gdb_record.%d", ptid_get_pid (inferior_ptid));
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 int number;
456
457 pos = skip_spaces (*arg);
458
459 if (!isdigit (*pos))
460 error (_("Expected positive number, got: %s."), pos);
461
8c2f95f4
TT
462 long result = strtol (pos, &end, 10);
463 *arg = end;
464 return result;
67c86d06
MM
465}
466
467/* Complain about junk at the end of an argument string. */
468
469static void
8c2f95f4 470no_chunk (const char *arg)
67c86d06
MM
471{
472 if (*arg != 0)
473 error (_("Junk after argument: %s."), arg);
474}
475
476/* Read instruction-history modifiers from an argument string. */
477
9a24775b 478static gdb_disassembly_flags
8c2f95f4 479get_insn_history_modifiers (const char **arg)
67c86d06 480{
9a24775b 481 gdb_disassembly_flags modifiers;
8c2f95f4 482 const char *args;
67c86d06
MM
483
484 modifiers = 0;
485 args = *arg;
486
487 if (args == NULL)
488 return modifiers;
489
490 while (*args == '/')
491 {
492 ++args;
493
494 if (*args == '\0')
495 error (_("Missing modifier."));
496
497 for (; *args; ++args)
498 {
499 if (isspace (*args))
500 break;
501
502 if (*args == '/')
503 continue;
504
505 switch (*args)
506 {
507 case 'm':
0c532a29
MM
508 case 's':
509 modifiers |= DISASSEMBLY_SOURCE;
67c86d06
MM
510 modifiers |= DISASSEMBLY_FILENAME;
511 break;
512 case 'r':
513 modifiers |= DISASSEMBLY_RAW_INSN;
514 break;
515 case 'f':
516 modifiers |= DISASSEMBLY_OMIT_FNAME;
517 break;
946287b7
MM
518 case 'p':
519 modifiers |= DISASSEMBLY_OMIT_PC;
520 break;
67c86d06
MM
521 default:
522 error (_("Invalid modifier: %c."), *args);
523 }
524 }
525
526 args = skip_spaces (args);
527 }
528
529 /* Update the argument string. */
530 *arg = args;
531
532 return modifiers;
533}
534
42c634cb
PA
535/* The "set record instruction-history-size / set record
536 function-call-history-size" commands are unsigned, with UINT_MAX
537 meaning unlimited. The target interfaces works with signed int
538 though, to indicate direction, so map "unlimited" to INT_MAX, which
539 is about the same as unlimited in practice. If the user does have
0ccfeeae
MM
540 a log that huge, she can fetch it in chunks across several requests,
541 but she'll likely have other problems first... */
42c634cb
PA
542
543static int
0ccfeeae 544command_size_to_target_size (unsigned int size)
42c634cb 545{
0ccfeeae 546 gdb_assert (size <= INT_MAX || size == UINT_MAX);
42c634cb 547
0ccfeeae 548 if (size == UINT_MAX)
42c634cb
PA
549 return INT_MAX;
550 else
0ccfeeae 551 return size;
42c634cb
PA
552}
553
67c86d06
MM
554/* The "record instruction-history" command. */
555
556static void
8c2f95f4 557cmd_record_insn_history (const char *arg, int from_tty)
67c86d06 558{
67c86d06
MM
559 require_record_target ();
560
9a24775b 561 gdb_disassembly_flags flags = get_insn_history_modifiers (&arg);
67c86d06 562
9a24775b 563 int size = command_size_to_target_size (record_insn_history_size);
67c86d06
MM
564
565 if (arg == NULL || *arg == 0 || strcmp (arg, "+") == 0)
566 target_insn_history (size, flags);
567 else if (strcmp (arg, "-") == 0)
568 target_insn_history (-size, flags);
569 else
570 {
571 ULONGEST begin, end;
572
573 begin = get_insn_number (&arg);
574
575 if (*arg == ',')
576 {
577 arg = skip_spaces (++arg);
578
579 if (*arg == '+')
580 {
581 arg += 1;
582 size = get_context_size (&arg);
583
584 no_chunk (arg);
585
586 target_insn_history_from (begin, size, flags);
587 }
588 else if (*arg == '-')
589 {
590 arg += 1;
591 size = get_context_size (&arg);
592
593 no_chunk (arg);
594
595 target_insn_history_from (begin, -size, flags);
596 }
597 else
598 {
599 end = get_insn_number (&arg);
600
601 no_chunk (arg);
602
603 target_insn_history_range (begin, end, flags);
604 }
605 }
606 else
607 {
608 no_chunk (arg);
609
610 target_insn_history_from (begin, size, flags);
611 }
612
613 dont_repeat ();
614 }
615}
616
15984c13
MM
617/* Read function-call-history modifiers from an argument string. */
618
619static int
8c2f95f4 620get_call_history_modifiers (const char **arg)
15984c13
MM
621{
622 int modifiers;
8c2f95f4 623 const char *args;
15984c13
MM
624
625 modifiers = 0;
626 args = *arg;
627
628 if (args == NULL)
629 return modifiers;
630
631 while (*args == '/')
632 {
633 ++args;
634
635 if (*args == '\0')
636 error (_("Missing modifier."));
637
638 for (; *args; ++args)
639 {
640 if (isspace (*args))
641 break;
642
643 if (*args == '/')
644 continue;
645
646 switch (*args)
647 {
648 case 'l':
1e038f67 649 modifiers |= RECORD_PRINT_SRC_LINE;
15984c13
MM
650 break;
651 case 'i':
1e038f67 652 modifiers |= RECORD_PRINT_INSN_RANGE;
15984c13 653 break;
8710b709
MM
654 case 'c':
655 modifiers |= RECORD_PRINT_INDENT_CALLS;
656 break;
15984c13
MM
657 default:
658 error (_("Invalid modifier: %c."), *args);
659 }
660 }
661
662 args = skip_spaces (args);
663 }
664
665 /* Update the argument string. */
666 *arg = args;
667
668 return modifiers;
669}
670
671/* The "record function-call-history" command. */
672
673static void
8c2f95f4 674cmd_record_call_history (const char *arg, int from_tty)
15984c13
MM
675{
676 int flags, size;
677
678 require_record_target ();
679
680 flags = get_call_history_modifiers (&arg);
681
0ccfeeae 682 size = command_size_to_target_size (record_call_history_size);
15984c13
MM
683
684 if (arg == NULL || *arg == 0 || strcmp (arg, "+") == 0)
685 target_call_history (size, flags);
686 else if (strcmp (arg, "-") == 0)
687 target_call_history (-size, flags);
688 else
689 {
690 ULONGEST begin, end;
691
692 begin = get_insn_number (&arg);
693
694 if (*arg == ',')
695 {
696 arg = skip_spaces (++arg);
697
698 if (*arg == '+')
699 {
700 arg += 1;
701 size = get_context_size (&arg);
702
703 no_chunk (arg);
704
705 target_call_history_from (begin, size, flags);
706 }
707 else if (*arg == '-')
708 {
709 arg += 1;
710 size = get_context_size (&arg);
711
712 no_chunk (arg);
713
714 target_call_history_from (begin, -size, flags);
715 }
716 else
717 {
718 end = get_insn_number (&arg);
719
720 no_chunk (arg);
721
722 target_call_history_range (begin, end, flags);
723 }
724 }
725 else
726 {
727 no_chunk (arg);
728
729 target_call_history_from (begin, size, flags);
730 }
731
732 dont_repeat ();
733 }
734}
735
42c634cb
PA
736/* Helper for "set record instruction-history-size" and "set record
737 function-call-history-size" input validation. COMMAND_VAR is the
738 variable registered in the command as control variable. *SETTING
739 is the real setting the command allows changing. */
740
741static void
9c37696b 742validate_history_size (unsigned int *command_var, unsigned int *setting)
42c634cb
PA
743{
744 if (*command_var != UINT_MAX && *command_var > INT_MAX)
745 {
746 unsigned int new_value = *command_var;
747
748 /* Restore previous value. */
749 *command_var = *setting;
750 error (_("integer %u out of range"), new_value);
751 }
752
753 /* Commit new value. */
754 *setting = *command_var;
755}
756
757/* Called by do_setshow_command. We only want values in the
758 [0..INT_MAX] range, while the command's machinery accepts
759 [0..UINT_MAX]. See command_size_to_target_size. */
760
761static void
eb4c3f4a 762set_record_insn_history_size (const char *args, int from_tty,
42c634cb
PA
763 struct cmd_list_element *c)
764{
765 validate_history_size (&record_insn_history_size_setshow_var,
766 &record_insn_history_size);
767}
768
769/* Called by do_setshow_command. We only want values in the
770 [0..INT_MAX] range, while the command's machinery accepts
771 [0..UINT_MAX]. See command_size_to_target_size. */
772
773static void
eb4c3f4a 774set_record_call_history_size (const char *args, int from_tty,
42c634cb
PA
775 struct cmd_list_element *c)
776{
777 validate_history_size (&record_call_history_size_setshow_var,
778 &record_call_history_size);
779}
780
69d05d38
HZ
781void
782_initialize_record (void)
783{
0156b218
MS
784 struct cmd_list_element *c;
785
ccce17b0
YQ
786 add_setshow_zuinteger_cmd ("record", no_class, &record_debug,
787 _("Set debugging of record/replay feature."),
788 _("Show debugging of record/replay feature."),
789 _("When enabled, debugging output for "
790 "record/replay feature is displayed."),
791 NULL, show_record_debug, &setdebuglist,
792 &showdebuglist);
69d05d38 793
67c86d06 794 add_setshow_uinteger_cmd ("instruction-history-size", no_class,
42c634cb 795 &record_insn_history_size_setshow_var, _("\
67c86d06 796Set number of instructions to print in \"record instruction-history\"."), _("\
f81d1120
PA
797Show number of instructions to print in \"record instruction-history\"."), _("\
798A size of \"unlimited\" means unlimited instructions. The default is 10."),
42c634cb
PA
799 set_record_insn_history_size, NULL,
800 &set_record_cmdlist, &show_record_cmdlist);
67c86d06 801
15984c13 802 add_setshow_uinteger_cmd ("function-call-history-size", no_class,
42c634cb 803 &record_call_history_size_setshow_var, _("\
15984c13 804Set number of function to print in \"record function-call-history\"."), _("\
f81d1120
PA
805Show number of functions to print in \"record function-call-history\"."), _("\
806A size of \"unlimited\" means unlimited lines. The default is 10."),
42c634cb
PA
807 set_record_call_history_size, NULL,
808 &set_record_cmdlist, &show_record_cmdlist);
15984c13 809
0156b218 810 c = add_prefix_cmd ("record", class_obscure, cmd_record_start,
d02ed0bb 811 _("Start recording."),
0156b218
MS
812 &record_cmdlist, "record ", 0, &cmdlist);
813 set_cmd_completer (c, filename_completer);
814
69d05d38
HZ
815 add_com_alias ("rec", "record", class_obscure, 1);
816 add_prefix_cmd ("record", class_support, set_record_command,
817 _("Set record options"), &set_record_cmdlist,
818 "set record ", 0, &setlist);
819 add_alias_cmd ("rec", "record", class_obscure, 1, &setlist);
820 add_prefix_cmd ("record", class_support, show_record_command,
821 _("Show record options"), &show_record_cmdlist,
822 "show record ", 0, &showlist);
823 add_alias_cmd ("rec", "record", class_obscure, 1, &showlist);
824 add_prefix_cmd ("record", class_support, info_record_command,
825 _("Info record options"), &info_record_cmdlist,
826 "info record ", 0, &infolist);
827 add_alias_cmd ("rec", "record", class_obscure, 1, &infolist);
828
0156b218
MS
829 c = add_cmd ("save", class_obscure, cmd_record_save,
830 _("Save the execution log to a file.\n\
831Argument is optional filename.\n\
832Default filename is 'gdb_record.<process_id>'."),
833 &record_cmdlist);
834 set_cmd_completer (c, filename_completer);
835
69d05d38
HZ
836 add_cmd ("delete", class_obscure, cmd_record_delete,
837 _("Delete the rest of execution log and start recording it anew."),
838 &record_cmdlist);
839 add_alias_cmd ("d", "delete", class_obscure, 1, &record_cmdlist);
840 add_alias_cmd ("del", "delete", class_obscure, 1, &record_cmdlist);
841
842 add_cmd ("stop", class_obscure, cmd_record_stop,
843 _("Stop the record/replay target."),
844 &record_cmdlist);
845 add_alias_cmd ("s", "stop", class_obscure, 1, &record_cmdlist);
846
742ce053 847 add_prefix_cmd ("goto", class_obscure, cmd_record_goto, _("\
6b04bdb7
MS
848Restore the program to its state at instruction number N.\n\
849Argument is instruction number, as shown by 'info record'."),
742ce053
MM
850 &record_goto_cmdlist, "record goto ", 1, &record_cmdlist);
851
852 add_cmd ("begin", class_obscure, cmd_record_goto_begin,
853 _("Go to the beginning of the execution log."),
854 &record_goto_cmdlist);
855 add_alias_cmd ("start", "begin", class_obscure, 1, &record_goto_cmdlist);
856
857 add_cmd ("end", class_obscure, cmd_record_goto_end,
858 _("Go to the end of the execution log."),
859 &record_goto_cmdlist);
67c86d06
MM
860
861 add_cmd ("instruction-history", class_obscure, cmd_record_insn_history, _("\
862Print disassembled instructions stored in the execution log.\n\
0c532a29 863With a /m or /s modifier, source lines are included (if available).\n\
67c86d06
MM
864With a /r modifier, raw instructions in hex are included.\n\
865With a /f modifier, function names are omitted.\n\
946287b7 866With a /p modifier, current position markers are omitted.\n\
67c86d06
MM
867With no argument, disassembles ten more instructions after the previous \
868disassembly.\n\
869\"record instruction-history -\" disassembles ten instructions before a \
870previous disassembly.\n\
871One argument specifies an instruction number as shown by 'info record', and \
872ten instructions are disassembled after that instruction.\n\
873Two arguments with comma between them specify starting and ending instruction \
874numbers to disassemble.\n\
875If the second argument is preceded by '+' or '-', it specifies the distance \
876from the first argument.\n\
877The number of instructions to disassemble can be defined with \"set record \
878instruction-history-size\"."),
879 &record_cmdlist);
15984c13
MM
880
881 add_cmd ("function-call-history", class_obscure, cmd_record_call_history, _("\
882Prints the execution history at function granularity.\n\
883It prints one line for each sequence of instructions that belong to the same \
884function.\n\
885Without modifiers, it prints the function name.\n\
886With a /l modifier, the source file and line number range is included.\n\
887With a /i modifier, the instruction number range is included.\n\
8710b709 888With a /c modifier, the output is indented based on the call stack depth.\n\
15984c13
MM
889With no argument, prints ten more lines after the previous ten-line print.\n\
890\"record function-call-history -\" prints ten lines before a previous ten-line \
891print.\n\
892One argument specifies a function number as shown by 'info record', and \
893ten lines are printed after that function.\n\
894Two arguments with comma between them specify a range of functions to print.\n\
895If the second argument is preceded by '+' or '-', it specifies the distance \
896from the first argument.\n\
897The number of functions to print can be defined with \"set record \
898function-call-history-size\"."),
899 &record_cmdlist);
42c634cb
PA
900
901 /* Sync command control variables. */
902 record_insn_history_size_setshow_var = record_insn_history_size;
903 record_call_history_size_setshow_var = record_call_history_size;
69d05d38 904}
This page took 0.928856 seconds and 4 git commands to generate.