Constify add_prefix_cmd
[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
981a3fb3 266cmd_record_start (const char *args, int from_tty)
69d05d38 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
8c2f95f4 275cmd_record_delete (const char *args, int from_tty)
69d05d38 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
8c2f95f4 301cmd_record_stop (const char *args, int from_tty)
69d05d38 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
981a3fb3 319set_record_command (const char *args, int from_tty)
69d05d38 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 328static void
981a3fb3 329show_record_command (const char *args, int from_tty)
69d05d38
HZ
330{
331 cmd_show_list (show_record_cmdlist, from_tty, "");
332}
333
d02ed0bb 334/* The "info record" command. */
b54295a7 335
69d05d38 336static void
981a3fb3 337info_record_command (const char *args, int from_tty)
69d05d38 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
8c2f95f4 355cmd_record_save (const char *args, int from_tty)
0156b218 356{
8c2f95f4
TT
357 const char *recfilename;
358 char recfilename_buffer[40];
0156b218 359
d02ed0bb 360 require_record_target ();
0156b218 361
d02ed0bb 362 if (args != NULL && *args != 0)
0156b218
MS
363 recfilename = args;
364 else
365 {
366 /* Default recfile name is "gdb_record.PID". */
d02ed0bb 367 xsnprintf (recfilename_buffer, sizeof (recfilename_buffer),
dfd4cc63 368 "gdb_record.%d", ptid_get_pid (inferior_ptid));
0156b218
MS
369 recfilename = recfilename_buffer;
370 }
371
d02ed0bb 372 target_save_record (recfilename);
6b04bdb7
MS
373}
374
c2bcbb1d 375/* See record.h. */
6b04bdb7 376
d02ed0bb 377void
c2bcbb1d 378record_goto (const char *arg)
6b04bdb7 379{
742ce053 380 ULONGEST insn;
6b04bdb7
MS
381
382 if (arg == NULL || *arg == '\0')
383 error (_("Command requires an argument (insn number to go to)."));
384
742ce053 385 insn = parse_and_eval_long (arg);
6b04bdb7 386
742ce053
MM
387 require_record_target ();
388 target_goto_record (insn);
389}
390
c2bcbb1d
TT
391/* "record goto" command. Argument is an instruction number,
392 as given by "info record".
393
394 Rewinds the recording (forward or backward) to the given instruction. */
395
396static void
981a3fb3 397cmd_record_goto (const char *arg, int from_tty)
c2bcbb1d
TT
398{
399 record_goto (arg);
400}
401
742ce053
MM
402/* The "record goto begin" command. */
403
404static void
8c2f95f4 405cmd_record_goto_begin (const char *arg, int from_tty)
742ce053
MM
406{
407 if (arg != NULL && *arg != '\0')
408 error (_("Junk after argument: %s."), arg);
409
410 require_record_target ();
411 target_goto_record_begin ();
412}
413
414/* The "record goto end" command. */
415
416static void
8c2f95f4 417cmd_record_goto_end (const char *arg, int from_tty)
742ce053
MM
418{
419 if (arg != NULL && *arg != '\0')
420 error (_("Junk after argument: %s."), arg);
421
422 require_record_target ();
423 target_goto_record_end ();
6b04bdb7
MS
424}
425
67c86d06
MM
426/* Read an instruction number from an argument string. */
427
428static ULONGEST
8c2f95f4 429get_insn_number (const char **arg)
67c86d06
MM
430{
431 ULONGEST number;
432 const char *begin, *end, *pos;
433
434 begin = *arg;
f1735a53 435 pos = skip_spaces (begin);
67c86d06
MM
436
437 if (!isdigit (*pos))
438 error (_("Expected positive number, got: %s."), pos);
439
440 number = strtoulst (pos, &end, 10);
441
442 *arg += (end - begin);
443
444 return number;
445}
446
447/* Read a context size from an argument string. */
448
449static int
8c2f95f4 450get_context_size (const char **arg)
67c86d06 451{
8c2f95f4
TT
452 const char *pos;
453 char *end;
67c86d06
MM
454 int number;
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
618static int
8c2f95f4 619get_call_history_modifiers (const char **arg)
15984c13
MM
620{
621 int modifiers;
8c2f95f4 622 const char *args;
15984c13
MM
623
624 modifiers = 0;
625 args = *arg;
626
627 if (args == NULL)
628 return modifiers;
629
630 while (*args == '/')
631 {
632 ++args;
633
634 if (*args == '\0')
635 error (_("Missing modifier."));
636
637 for (; *args; ++args)
638 {
639 if (isspace (*args))
640 break;
641
642 if (*args == '/')
643 continue;
644
645 switch (*args)
646 {
647 case 'l':
1e038f67 648 modifiers |= RECORD_PRINT_SRC_LINE;
15984c13
MM
649 break;
650 case 'i':
1e038f67 651 modifiers |= RECORD_PRINT_INSN_RANGE;
15984c13 652 break;
8710b709
MM
653 case 'c':
654 modifiers |= RECORD_PRINT_INDENT_CALLS;
655 break;
15984c13
MM
656 default:
657 error (_("Invalid modifier: %c."), *args);
658 }
659 }
660
661 args = skip_spaces (args);
662 }
663
664 /* Update the argument string. */
665 *arg = args;
666
667 return modifiers;
668}
669
670/* The "record function-call-history" command. */
671
672static void
8c2f95f4 673cmd_record_call_history (const char *arg, int from_tty)
15984c13
MM
674{
675 int flags, size;
676
677 require_record_target ();
678
679 flags = get_call_history_modifiers (&arg);
680
0ccfeeae 681 size = command_size_to_target_size (record_call_history_size);
15984c13
MM
682
683 if (arg == NULL || *arg == 0 || strcmp (arg, "+") == 0)
684 target_call_history (size, flags);
685 else if (strcmp (arg, "-") == 0)
686 target_call_history (-size, flags);
687 else
688 {
689 ULONGEST begin, end;
690
691 begin = get_insn_number (&arg);
692
693 if (*arg == ',')
694 {
695 arg = skip_spaces (++arg);
696
697 if (*arg == '+')
698 {
699 arg += 1;
700 size = get_context_size (&arg);
701
702 no_chunk (arg);
703
704 target_call_history_from (begin, size, flags);
705 }
706 else if (*arg == '-')
707 {
708 arg += 1;
709 size = get_context_size (&arg);
710
711 no_chunk (arg);
712
713 target_call_history_from (begin, -size, flags);
714 }
715 else
716 {
717 end = get_insn_number (&arg);
718
719 no_chunk (arg);
720
721 target_call_history_range (begin, end, flags);
722 }
723 }
724 else
725 {
726 no_chunk (arg);
727
728 target_call_history_from (begin, size, flags);
729 }
730
731 dont_repeat ();
732 }
733}
734
42c634cb
PA
735/* Helper for "set record instruction-history-size" and "set record
736 function-call-history-size" input validation. COMMAND_VAR is the
737 variable registered in the command as control variable. *SETTING
738 is the real setting the command allows changing. */
739
740static void
9c37696b 741validate_history_size (unsigned int *command_var, unsigned int *setting)
42c634cb
PA
742{
743 if (*command_var != UINT_MAX && *command_var > INT_MAX)
744 {
745 unsigned int new_value = *command_var;
746
747 /* Restore previous value. */
748 *command_var = *setting;
749 error (_("integer %u out of range"), new_value);
750 }
751
752 /* Commit new value. */
753 *setting = *command_var;
754}
755
756/* Called by do_setshow_command. We only want values in the
757 [0..INT_MAX] range, while the command's machinery accepts
758 [0..UINT_MAX]. See command_size_to_target_size. */
759
760static void
761set_record_insn_history_size (char *args, int from_tty,
762 struct cmd_list_element *c)
763{
764 validate_history_size (&record_insn_history_size_setshow_var,
765 &record_insn_history_size);
766}
767
768/* Called by do_setshow_command. We only want values in the
769 [0..INT_MAX] range, while the command's machinery accepts
770 [0..UINT_MAX]. See command_size_to_target_size. */
771
772static void
773set_record_call_history_size (char *args, int from_tty,
774 struct cmd_list_element *c)
775{
776 validate_history_size (&record_call_history_size_setshow_var,
777 &record_call_history_size);
778}
779
69d05d38
HZ
780void
781_initialize_record (void)
782{
0156b218
MS
783 struct cmd_list_element *c;
784
ccce17b0
YQ
785 add_setshow_zuinteger_cmd ("record", no_class, &record_debug,
786 _("Set debugging of record/replay feature."),
787 _("Show debugging of record/replay feature."),
788 _("When enabled, debugging output for "
789 "record/replay feature is displayed."),
790 NULL, show_record_debug, &setdebuglist,
791 &showdebuglist);
69d05d38 792
67c86d06 793 add_setshow_uinteger_cmd ("instruction-history-size", no_class,
42c634cb 794 &record_insn_history_size_setshow_var, _("\
67c86d06 795Set number of instructions to print in \"record instruction-history\"."), _("\
f81d1120
PA
796Show number of instructions to print in \"record instruction-history\"."), _("\
797A size of \"unlimited\" means unlimited instructions. The default is 10."),
42c634cb
PA
798 set_record_insn_history_size, NULL,
799 &set_record_cmdlist, &show_record_cmdlist);
67c86d06 800
15984c13 801 add_setshow_uinteger_cmd ("function-call-history-size", no_class,
42c634cb 802 &record_call_history_size_setshow_var, _("\
15984c13 803Set number of function to print in \"record function-call-history\"."), _("\
f81d1120
PA
804Show number of functions to print in \"record function-call-history\"."), _("\
805A size of \"unlimited\" means unlimited lines. The default is 10."),
42c634cb
PA
806 set_record_call_history_size, NULL,
807 &set_record_cmdlist, &show_record_cmdlist);
15984c13 808
0156b218 809 c = add_prefix_cmd ("record", class_obscure, cmd_record_start,
d02ed0bb 810 _("Start recording."),
0156b218
MS
811 &record_cmdlist, "record ", 0, &cmdlist);
812 set_cmd_completer (c, filename_completer);
813
69d05d38
HZ
814 add_com_alias ("rec", "record", class_obscure, 1);
815 add_prefix_cmd ("record", class_support, set_record_command,
816 _("Set record options"), &set_record_cmdlist,
817 "set record ", 0, &setlist);
818 add_alias_cmd ("rec", "record", class_obscure, 1, &setlist);
819 add_prefix_cmd ("record", class_support, show_record_command,
820 _("Show record options"), &show_record_cmdlist,
821 "show record ", 0, &showlist);
822 add_alias_cmd ("rec", "record", class_obscure, 1, &showlist);
823 add_prefix_cmd ("record", class_support, info_record_command,
824 _("Info record options"), &info_record_cmdlist,
825 "info record ", 0, &infolist);
826 add_alias_cmd ("rec", "record", class_obscure, 1, &infolist);
827
0156b218
MS
828 c = add_cmd ("save", class_obscure, cmd_record_save,
829 _("Save the execution log to a file.\n\
830Argument is optional filename.\n\
831Default filename is 'gdb_record.<process_id>'."),
832 &record_cmdlist);
833 set_cmd_completer (c, filename_completer);
834
69d05d38
HZ
835 add_cmd ("delete", class_obscure, cmd_record_delete,
836 _("Delete the rest of execution log and start recording it anew."),
837 &record_cmdlist);
838 add_alias_cmd ("d", "delete", class_obscure, 1, &record_cmdlist);
839 add_alias_cmd ("del", "delete", class_obscure, 1, &record_cmdlist);
840
841 add_cmd ("stop", class_obscure, cmd_record_stop,
842 _("Stop the record/replay target."),
843 &record_cmdlist);
844 add_alias_cmd ("s", "stop", class_obscure, 1, &record_cmdlist);
845
742ce053 846 add_prefix_cmd ("goto", class_obscure, cmd_record_goto, _("\
6b04bdb7
MS
847Restore the program to its state at instruction number N.\n\
848Argument is instruction number, as shown by 'info record'."),
742ce053
MM
849 &record_goto_cmdlist, "record goto ", 1, &record_cmdlist);
850
851 add_cmd ("begin", class_obscure, cmd_record_goto_begin,
852 _("Go to the beginning of the execution log."),
853 &record_goto_cmdlist);
854 add_alias_cmd ("start", "begin", class_obscure, 1, &record_goto_cmdlist);
855
856 add_cmd ("end", class_obscure, cmd_record_goto_end,
857 _("Go to the end of the execution log."),
858 &record_goto_cmdlist);
67c86d06
MM
859
860 add_cmd ("instruction-history", class_obscure, cmd_record_insn_history, _("\
861Print disassembled instructions stored in the execution log.\n\
0c532a29 862With a /m or /s modifier, source lines are included (if available).\n\
67c86d06
MM
863With a /r modifier, raw instructions in hex are included.\n\
864With a /f modifier, function names are omitted.\n\
946287b7 865With a /p modifier, current position markers are omitted.\n\
67c86d06
MM
866With no argument, disassembles ten more instructions after the previous \
867disassembly.\n\
868\"record instruction-history -\" disassembles ten instructions before a \
869previous disassembly.\n\
870One argument specifies an instruction number as shown by 'info record', and \
871ten instructions are disassembled after that instruction.\n\
872Two arguments with comma between them specify starting and ending instruction \
873numbers to disassemble.\n\
874If the second argument is preceded by '+' or '-', it specifies the distance \
875from the first argument.\n\
876The number of instructions to disassemble can be defined with \"set record \
877instruction-history-size\"."),
878 &record_cmdlist);
15984c13
MM
879
880 add_cmd ("function-call-history", class_obscure, cmd_record_call_history, _("\
881Prints the execution history at function granularity.\n\
882It prints one line for each sequence of instructions that belong to the same \
883function.\n\
884Without modifiers, it prints the function name.\n\
885With a /l modifier, the source file and line number range is included.\n\
886With a /i modifier, the instruction number range is included.\n\
8710b709 887With a /c modifier, the output is indented based on the call stack depth.\n\
15984c13
MM
888With no argument, prints ten more lines after the previous ten-line print.\n\
889\"record function-call-history -\" prints ten lines before a previous ten-line \
890print.\n\
891One argument specifies a function number as shown by 'info record', and \
892ten lines are printed after that function.\n\
893Two arguments with comma between them specify a range of functions to print.\n\
894If the second argument is preceded by '+' or '-', it specifies the distance \
895from the first argument.\n\
896The number of functions to print can be defined with \"set record \
897function-call-history-size\"."),
898 &record_cmdlist);
42c634cb
PA
899
900 /* Sync command control variables. */
901 record_insn_history_size_setshow_var = record_insn_history_size;
902 record_call_history_size_setshow_var = record_call_history_size;
69d05d38 903}
This page took 0.8789 seconds and 4 git commands to generate.