Remove dwarf2_per_cu_data::objfile ()
[deliverable/binutils-gdb.git] / gdb / record.c
CommitLineData
69d05d38
HZ
1/* Process record and replay target for GDB, the GNU debugger.
2
b811d2c2 3 Copyright (C) 2008-2020 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
69d05d38 317
d02ed0bb 318/* The "info record" command. */
b54295a7 319
69d05d38 320static void
981a3fb3 321info_record_command (const char *args, int from_tty)
69d05d38 322{
d02ed0bb 323 struct target_ops *t;
0156b218 324
d02ed0bb
MM
325 t = find_record_target ();
326 if (t == NULL)
0156b218 327 {
d02ed0bb
MM
328 printf_filtered (_("No record target is currently active.\n"));
329 return;
0156b218
MS
330 }
331
f6ac5f3d
PA
332 printf_filtered (_("Active record target: %s\n"), t->shortname ());
333 t->info_record ();
0156b218
MS
334}
335
d02ed0bb 336/* The "record save" command. */
0156b218
MS
337
338static void
8c2f95f4 339cmd_record_save (const char *args, int from_tty)
0156b218 340{
8c2f95f4
TT
341 const char *recfilename;
342 char recfilename_buffer[40];
0156b218 343
d02ed0bb 344 require_record_target ();
0156b218 345
d02ed0bb 346 if (args != NULL && *args != 0)
0156b218
MS
347 recfilename = args;
348 else
349 {
350 /* Default recfile name is "gdb_record.PID". */
d02ed0bb 351 xsnprintf (recfilename_buffer, sizeof (recfilename_buffer),
e99b03dc 352 "gdb_record.%d", inferior_ptid.pid ());
0156b218
MS
353 recfilename = recfilename_buffer;
354 }
355
d02ed0bb 356 target_save_record (recfilename);
6b04bdb7
MS
357}
358
c2bcbb1d 359/* See record.h. */
6b04bdb7 360
d02ed0bb 361void
c2bcbb1d 362record_goto (const char *arg)
6b04bdb7 363{
742ce053 364 ULONGEST insn;
6b04bdb7
MS
365
366 if (arg == NULL || *arg == '\0')
367 error (_("Command requires an argument (insn number to go to)."));
368
742ce053 369 insn = parse_and_eval_long (arg);
6b04bdb7 370
742ce053
MM
371 require_record_target ();
372 target_goto_record (insn);
373}
374
c2bcbb1d
TT
375/* "record goto" command. Argument is an instruction number,
376 as given by "info record".
377
378 Rewinds the recording (forward or backward) to the given instruction. */
379
380static void
981a3fb3 381cmd_record_goto (const char *arg, int from_tty)
c2bcbb1d
TT
382{
383 record_goto (arg);
384}
385
742ce053
MM
386/* The "record goto begin" command. */
387
388static void
8c2f95f4 389cmd_record_goto_begin (const char *arg, int from_tty)
742ce053
MM
390{
391 if (arg != NULL && *arg != '\0')
392 error (_("Junk after argument: %s."), arg);
393
394 require_record_target ();
395 target_goto_record_begin ();
396}
397
398/* The "record goto end" command. */
399
400static void
8c2f95f4 401cmd_record_goto_end (const char *arg, int from_tty)
742ce053
MM
402{
403 if (arg != NULL && *arg != '\0')
404 error (_("Junk after argument: %s."), arg);
405
406 require_record_target ();
407 target_goto_record_end ();
6b04bdb7
MS
408}
409
67c86d06
MM
410/* Read an instruction number from an argument string. */
411
412static ULONGEST
8c2f95f4 413get_insn_number (const char **arg)
67c86d06
MM
414{
415 ULONGEST number;
416 const char *begin, *end, *pos;
417
418 begin = *arg;
f1735a53 419 pos = skip_spaces (begin);
67c86d06
MM
420
421 if (!isdigit (*pos))
422 error (_("Expected positive number, got: %s."), pos);
423
424 number = strtoulst (pos, &end, 10);
425
426 *arg += (end - begin);
427
428 return number;
429}
430
431/* Read a context size from an argument string. */
432
433static int
8c2f95f4 434get_context_size (const char **arg)
67c86d06 435{
8c2f95f4
TT
436 const char *pos;
437 char *end;
67c86d06
MM
438
439 pos = skip_spaces (*arg);
440
441 if (!isdigit (*pos))
442 error (_("Expected positive number, got: %s."), pos);
443
8c2f95f4
TT
444 long result = strtol (pos, &end, 10);
445 *arg = end;
446 return result;
67c86d06
MM
447}
448
449/* Complain about junk at the end of an argument string. */
450
451static void
8c2f95f4 452no_chunk (const char *arg)
67c86d06
MM
453{
454 if (*arg != 0)
455 error (_("Junk after argument: %s."), arg);
456}
457
458/* Read instruction-history modifiers from an argument string. */
459
9a24775b 460static gdb_disassembly_flags
8c2f95f4 461get_insn_history_modifiers (const char **arg)
67c86d06 462{
9a24775b 463 gdb_disassembly_flags modifiers;
8c2f95f4 464 const char *args;
67c86d06
MM
465
466 modifiers = 0;
467 args = *arg;
468
469 if (args == NULL)
470 return modifiers;
471
472 while (*args == '/')
473 {
474 ++args;
475
476 if (*args == '\0')
477 error (_("Missing modifier."));
478
479 for (; *args; ++args)
480 {
481 if (isspace (*args))
482 break;
483
484 if (*args == '/')
485 continue;
486
487 switch (*args)
488 {
489 case 'm':
0c532a29
MM
490 case 's':
491 modifiers |= DISASSEMBLY_SOURCE;
67c86d06
MM
492 modifiers |= DISASSEMBLY_FILENAME;
493 break;
494 case 'r':
495 modifiers |= DISASSEMBLY_RAW_INSN;
496 break;
497 case 'f':
498 modifiers |= DISASSEMBLY_OMIT_FNAME;
499 break;
946287b7
MM
500 case 'p':
501 modifiers |= DISASSEMBLY_OMIT_PC;
502 break;
67c86d06
MM
503 default:
504 error (_("Invalid modifier: %c."), *args);
505 }
506 }
507
508 args = skip_spaces (args);
509 }
510
511 /* Update the argument string. */
512 *arg = args;
513
514 return modifiers;
515}
516
42c634cb
PA
517/* The "set record instruction-history-size / set record
518 function-call-history-size" commands are unsigned, with UINT_MAX
519 meaning unlimited. The target interfaces works with signed int
520 though, to indicate direction, so map "unlimited" to INT_MAX, which
521 is about the same as unlimited in practice. If the user does have
0ccfeeae
MM
522 a log that huge, she can fetch it in chunks across several requests,
523 but she'll likely have other problems first... */
42c634cb
PA
524
525static int
0ccfeeae 526command_size_to_target_size (unsigned int size)
42c634cb 527{
0ccfeeae 528 gdb_assert (size <= INT_MAX || size == UINT_MAX);
42c634cb 529
0ccfeeae 530 if (size == UINT_MAX)
42c634cb
PA
531 return INT_MAX;
532 else
0ccfeeae 533 return size;
42c634cb
PA
534}
535
67c86d06
MM
536/* The "record instruction-history" command. */
537
538static void
8c2f95f4 539cmd_record_insn_history (const char *arg, int from_tty)
67c86d06 540{
67c86d06
MM
541 require_record_target ();
542
9a24775b 543 gdb_disassembly_flags flags = get_insn_history_modifiers (&arg);
67c86d06 544
9a24775b 545 int size = command_size_to_target_size (record_insn_history_size);
67c86d06
MM
546
547 if (arg == NULL || *arg == 0 || strcmp (arg, "+") == 0)
548 target_insn_history (size, flags);
549 else if (strcmp (arg, "-") == 0)
550 target_insn_history (-size, flags);
551 else
552 {
553 ULONGEST begin, end;
554
555 begin = get_insn_number (&arg);
556
557 if (*arg == ',')
558 {
559 arg = skip_spaces (++arg);
560
561 if (*arg == '+')
562 {
563 arg += 1;
564 size = get_context_size (&arg);
565
566 no_chunk (arg);
567
568 target_insn_history_from (begin, size, flags);
569 }
570 else if (*arg == '-')
571 {
572 arg += 1;
573 size = get_context_size (&arg);
574
575 no_chunk (arg);
576
577 target_insn_history_from (begin, -size, flags);
578 }
579 else
580 {
581 end = get_insn_number (&arg);
582
583 no_chunk (arg);
584
585 target_insn_history_range (begin, end, flags);
586 }
587 }
588 else
589 {
590 no_chunk (arg);
591
592 target_insn_history_from (begin, size, flags);
593 }
594
595 dont_repeat ();
596 }
597}
598
15984c13
MM
599/* Read function-call-history modifiers from an argument string. */
600
0cb7c7b0 601static record_print_flags
8c2f95f4 602get_call_history_modifiers (const char **arg)
15984c13 603{
0cb7c7b0
SM
604 record_print_flags modifiers = 0;
605 const char *args = *arg;
15984c13
MM
606
607 if (args == NULL)
608 return modifiers;
609
610 while (*args == '/')
611 {
612 ++args;
613
614 if (*args == '\0')
615 error (_("Missing modifier."));
616
617 for (; *args; ++args)
618 {
619 if (isspace (*args))
620 break;
621
622 if (*args == '/')
623 continue;
624
625 switch (*args)
626 {
627 case 'l':
1e038f67 628 modifiers |= RECORD_PRINT_SRC_LINE;
15984c13
MM
629 break;
630 case 'i':
1e038f67 631 modifiers |= RECORD_PRINT_INSN_RANGE;
15984c13 632 break;
8710b709
MM
633 case 'c':
634 modifiers |= RECORD_PRINT_INDENT_CALLS;
635 break;
15984c13
MM
636 default:
637 error (_("Invalid modifier: %c."), *args);
638 }
639 }
640
641 args = skip_spaces (args);
642 }
643
644 /* Update the argument string. */
645 *arg = args;
646
647 return modifiers;
648}
649
650/* The "record function-call-history" command. */
651
652static void
8c2f95f4 653cmd_record_call_history (const char *arg, int from_tty)
15984c13 654{
15984c13
MM
655 require_record_target ();
656
0cb7c7b0 657 record_print_flags flags = get_call_history_modifiers (&arg);
15984c13 658
0cb7c7b0 659 int size = command_size_to_target_size (record_call_history_size);
15984c13
MM
660
661 if (arg == NULL || *arg == 0 || strcmp (arg, "+") == 0)
662 target_call_history (size, flags);
663 else if (strcmp (arg, "-") == 0)
664 target_call_history (-size, flags);
665 else
666 {
667 ULONGEST begin, end;
668
669 begin = get_insn_number (&arg);
670
671 if (*arg == ',')
672 {
673 arg = skip_spaces (++arg);
674
675 if (*arg == '+')
676 {
677 arg += 1;
678 size = get_context_size (&arg);
679
680 no_chunk (arg);
681
682 target_call_history_from (begin, size, flags);
683 }
684 else if (*arg == '-')
685 {
686 arg += 1;
687 size = get_context_size (&arg);
688
689 no_chunk (arg);
690
691 target_call_history_from (begin, -size, flags);
692 }
693 else
694 {
695 end = get_insn_number (&arg);
696
697 no_chunk (arg);
698
699 target_call_history_range (begin, end, flags);
700 }
701 }
702 else
703 {
704 no_chunk (arg);
705
706 target_call_history_from (begin, size, flags);
707 }
708
709 dont_repeat ();
710 }
711}
712
42c634cb
PA
713/* Helper for "set record instruction-history-size" and "set record
714 function-call-history-size" input validation. COMMAND_VAR is the
715 variable registered in the command as control variable. *SETTING
716 is the real setting the command allows changing. */
717
718static void
9c37696b 719validate_history_size (unsigned int *command_var, unsigned int *setting)
42c634cb
PA
720{
721 if (*command_var != UINT_MAX && *command_var > INT_MAX)
722 {
723 unsigned int new_value = *command_var;
724
725 /* Restore previous value. */
726 *command_var = *setting;
727 error (_("integer %u out of range"), new_value);
728 }
729
730 /* Commit new value. */
731 *setting = *command_var;
732}
733
734/* Called by do_setshow_command. We only want values in the
735 [0..INT_MAX] range, while the command's machinery accepts
736 [0..UINT_MAX]. See command_size_to_target_size. */
737
738static void
eb4c3f4a 739set_record_insn_history_size (const char *args, int from_tty,
42c634cb
PA
740 struct cmd_list_element *c)
741{
742 validate_history_size (&record_insn_history_size_setshow_var,
743 &record_insn_history_size);
744}
745
746/* Called by do_setshow_command. We only want values in the
747 [0..INT_MAX] range, while the command's machinery accepts
748 [0..UINT_MAX]. See command_size_to_target_size. */
749
750static void
eb4c3f4a 751set_record_call_history_size (const char *args, int from_tty,
42c634cb
PA
752 struct cmd_list_element *c)
753{
754 validate_history_size (&record_call_history_size_setshow_var,
755 &record_call_history_size);
756}
757
6c265988 758void _initialize_record ();
69d05d38 759void
6c265988 760_initialize_record ()
69d05d38 761{
0156b218
MS
762 struct cmd_list_element *c;
763
ccce17b0
YQ
764 add_setshow_zuinteger_cmd ("record", no_class, &record_debug,
765 _("Set debugging of record/replay feature."),
766 _("Show debugging of record/replay feature."),
767 _("When enabled, debugging output for "
768 "record/replay feature is displayed."),
769 NULL, show_record_debug, &setdebuglist,
770 &showdebuglist);
69d05d38 771
67c86d06 772 add_setshow_uinteger_cmd ("instruction-history-size", no_class,
42c634cb 773 &record_insn_history_size_setshow_var, _("\
67c86d06 774Set number of instructions to print in \"record instruction-history\"."), _("\
f81d1120
PA
775Show number of instructions to print in \"record instruction-history\"."), _("\
776A size of \"unlimited\" means unlimited instructions. The default is 10."),
42c634cb
PA
777 set_record_insn_history_size, NULL,
778 &set_record_cmdlist, &show_record_cmdlist);
67c86d06 779
15984c13 780 add_setshow_uinteger_cmd ("function-call-history-size", no_class,
42c634cb 781 &record_call_history_size_setshow_var, _("\
15984c13 782Set number of function to print in \"record function-call-history\"."), _("\
f81d1120
PA
783Show number of functions to print in \"record function-call-history\"."), _("\
784A size of \"unlimited\" means unlimited lines. The default is 10."),
42c634cb
PA
785 set_record_call_history_size, NULL,
786 &set_record_cmdlist, &show_record_cmdlist);
15984c13 787
0156b218 788 c = add_prefix_cmd ("record", class_obscure, cmd_record_start,
d02ed0bb 789 _("Start recording."),
0156b218
MS
790 &record_cmdlist, "record ", 0, &cmdlist);
791 set_cmd_completer (c, filename_completer);
792
69d05d38 793 add_com_alias ("rec", "record", class_obscure, 1);
0743fc83
TT
794 add_basic_prefix_cmd ("record", class_support,
795 _("Set record options."), &set_record_cmdlist,
796 "set record ", 0, &setlist);
69d05d38 797 add_alias_cmd ("rec", "record", class_obscure, 1, &setlist);
0743fc83
TT
798 add_show_prefix_cmd ("record", class_support,
799 _("Show record options."), &show_record_cmdlist,
800 "show record ", 0, &showlist);
69d05d38
HZ
801 add_alias_cmd ("rec", "record", class_obscure, 1, &showlist);
802 add_prefix_cmd ("record", class_support, info_record_command,
590042fc 803 _("Info record options."), &info_record_cmdlist,
69d05d38
HZ
804 "info record ", 0, &infolist);
805 add_alias_cmd ("rec", "record", class_obscure, 1, &infolist);
806
0156b218
MS
807 c = add_cmd ("save", class_obscure, cmd_record_save,
808 _("Save the execution log to a file.\n\
a974b5ec
TT
809Usage: record save [FILENAME]\n\
810Default filename is 'gdb_record.PROCESS_ID'."),
0156b218
MS
811 &record_cmdlist);
812 set_cmd_completer (c, filename_completer);
813
69d05d38
HZ
814 add_cmd ("delete", class_obscure, cmd_record_delete,
815 _("Delete the rest of execution log and start recording it anew."),
816 &record_cmdlist);
817 add_alias_cmd ("d", "delete", class_obscure, 1, &record_cmdlist);
818 add_alias_cmd ("del", "delete", class_obscure, 1, &record_cmdlist);
819
820 add_cmd ("stop", class_obscure, cmd_record_stop,
821 _("Stop the record/replay target."),
822 &record_cmdlist);
823 add_alias_cmd ("s", "stop", class_obscure, 1, &record_cmdlist);
824
742ce053 825 add_prefix_cmd ("goto", class_obscure, cmd_record_goto, _("\
6b04bdb7
MS
826Restore the program to its state at instruction number N.\n\
827Argument is instruction number, as shown by 'info record'."),
742ce053
MM
828 &record_goto_cmdlist, "record goto ", 1, &record_cmdlist);
829
830 add_cmd ("begin", class_obscure, cmd_record_goto_begin,
831 _("Go to the beginning of the execution log."),
832 &record_goto_cmdlist);
833 add_alias_cmd ("start", "begin", class_obscure, 1, &record_goto_cmdlist);
834
835 add_cmd ("end", class_obscure, cmd_record_goto_end,
836 _("Go to the end of the execution log."),
837 &record_goto_cmdlist);
67c86d06
MM
838
839 add_cmd ("instruction-history", class_obscure, cmd_record_insn_history, _("\
840Print disassembled instructions stored in the execution log.\n\
0c532a29 841With a /m or /s modifier, source lines are included (if available).\n\
67c86d06
MM
842With a /r modifier, raw instructions in hex are included.\n\
843With a /f modifier, function names are omitted.\n\
946287b7 844With a /p modifier, current position markers are omitted.\n\
67c86d06
MM
845With no argument, disassembles ten more instructions after the previous \
846disassembly.\n\
847\"record instruction-history -\" disassembles ten instructions before a \
848previous disassembly.\n\
849One argument specifies an instruction number as shown by 'info record', and \
850ten instructions are disassembled after that instruction.\n\
851Two arguments with comma between them specify starting and ending instruction \
852numbers to disassemble.\n\
853If the second argument is preceded by '+' or '-', it specifies the distance \
854from the first argument.\n\
855The number of instructions to disassemble can be defined with \"set record \
856instruction-history-size\"."),
857 &record_cmdlist);
15984c13
MM
858
859 add_cmd ("function-call-history", class_obscure, cmd_record_call_history, _("\
860Prints the execution history at function granularity.\n\
861It prints one line for each sequence of instructions that belong to the same \
862function.\n\
863Without modifiers, it prints the function name.\n\
864With a /l modifier, the source file and line number range is included.\n\
865With a /i modifier, the instruction number range is included.\n\
8710b709 866With a /c modifier, the output is indented based on the call stack depth.\n\
15984c13
MM
867With no argument, prints ten more lines after the previous ten-line print.\n\
868\"record function-call-history -\" prints ten lines before a previous ten-line \
869print.\n\
870One argument specifies a function number as shown by 'info record', and \
871ten lines are printed after that function.\n\
872Two arguments with comma between them specify a range of functions to print.\n\
873If the second argument is preceded by '+' or '-', it specifies the distance \
874from the first argument.\n\
875The number of functions to print can be defined with \"set record \
876function-call-history-size\"."),
877 &record_cmdlist);
42c634cb
PA
878
879 /* Sync command control variables. */
880 record_insn_history_size_setshow_var = record_insn_history_size;
881 record_call_history_size_setshow_var = record_call_history_size;
69d05d38 882}
This page took 1.17006 seconds and 4 git commands to generate.