GDB (xrefs)

/tmp/gdb-8.1/gdb/record.c
Go to the documentation of this file.
1 /* Process record and replay target for GDB, the GNU debugger.
2
3 Copyright (C) 2008-2018 Free Software Foundation, Inc.
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"
22 #include "completer.h"
23 #include "record.h"
24 #include "observer.h"
25 #include "inferior.h"
26 #include "common/common-utils.h"
27 #include "cli/cli-utils.h"
28 #include "disasm.h"
29
30 #include <ctype.h>
31
32 /* This is the debug switch for process record. */
33 unsigned int record_debug = 0;
34
35 /* The number of instructions to print in "record instruction-history". */
36 static unsigned int record_insn_history_size = 10;
37
38 /* The variable registered as control variable in the "record
39 instruction-history" command. Necessary for extra input
40 validation. */
41 static unsigned int record_insn_history_size_setshow_var;
42
43 /* The number of functions to print in "record function-call-history". */
44 static unsigned int record_call_history_size = 10;
45
46 /* The variable registered as control variable in the "record
47 call-history" command. Necessary for extra input validation. */
48 static unsigned int record_call_history_size_setshow_var;
49
50 struct cmd_list_element *record_cmdlist = NULL;
51 struct cmd_list_element *record_goto_cmdlist = NULL;
52 struct cmd_list_element *set_record_cmdlist = NULL;
53 struct cmd_list_element *show_record_cmdlist = NULL;
54 struct cmd_list_element *info_record_cmdlist = NULL;
55
56 #define DEBUG(msg, args...) \
57 if (record_debug) \
58 fprintf_unfiltered (gdb_stdlog, "record: " msg "\n", ##args)
59
60 /* See record.h. */
61
62 struct target_ops *
63 find_record_target (void)
64 {
65 return find_target_at (record_stratum);
66 }
67
68 /* Check that recording is active. Throw an error, if it isn't. */
69
70 static struct target_ops *
71 require_record_target (void)
72 {
73 struct target_ops *t;
74
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."));
79
80 return t;
81 }
82
83 /* See record.h. */
84
85 void
86 record_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
96 void
97 record_start (const char *method, const char *format, int from_tty)
98 {
99 if (method == NULL)
100 {
101 if (format == NULL)
102 execute_command_to_string ("record", from_tty);
103 else
104 error (_("Invalid format."));
105 }
106 else if (strcmp (method, "full") == 0)
107 {
108 if (format == NULL)
109 execute_command_to_string ("record full", from_tty);
110 else
111 error (_("Invalid format."));
112 }
113 else if (strcmp (method, "btrace") == 0)
114 {
115 if (format == NULL)
116 execute_command_to_string ("record btrace", from_tty);
117 else if (strcmp (format, "bts") == 0)
118 execute_command_to_string ("record btrace bts", from_tty);
119 else if (strcmp (format, "pt") == 0)
120 execute_command_to_string ("record btrace pt", from_tty);
121 else
122 error (_("Invalid format."));
123 }
124 else
125 error (_("Invalid method."));
126 }
127
128 /* See record.h. */
129
130 void
131 record_stop (int from_tty)
132 {
133 execute_command_to_string ("record stop", from_tty);
134 }
135
136 /* See record.h. */
137
138 int
139 record_read_memory (struct gdbarch *gdbarch,
140 CORE_ADDR memaddr, gdb_byte *myaddr,
141 ssize_t len)
142 {
143 int ret = target_read_memory (memaddr, myaddr, len);
144
145 if (ret != 0)
146 DEBUG ("error reading memory at addr %s len = %ld.\n",
147 paddress (gdbarch, memaddr), (long) len);
148
149 return ret;
150 }
151
152 /* Stop recording. */
153
154 static void
155 record_stop (struct target_ops *t)
156 {
157 DEBUG ("stop %s", t->to_shortname);
158
159 t->to_stop_recording (t);
160 }
161
162 /* Unpush the record target. */
163
164 static void
165 record_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
174 void
175 record_disconnect (struct target_ops *t, const char *args, int from_tty)
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
189 void
190 record_detach (struct target_ops *t, const char *args, int from_tty)
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
204 void
205 record_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
215 target_mourn_inferior (inferior_ptid);
216 }
217
218 /* See record.h. */
219
220 void
221 record_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
234 /* See record.h. */
235
236 int
237 record_check_stopped_by_breakpoint (const address_space *aspace,
238 CORE_ADDR pc,
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
254 /* Implement "show record debug" command. */
255
256 static void
257 show_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
266 static void
267 cmd_record_start (const char *args, int from_tty)
268 {
269 execute_command ("target record-full", from_tty);
270 }
271
272 /* Truncate the record log from the present point
273 of replay until the end. */
274
275 static void
276 cmd_record_delete (const char *args, int from_tty)
277 {
278 require_record_target ();
279
280 if (!target_record_is_replaying (inferior_ptid))
281 {
282 printf_unfiltered (_("Already at end of record list.\n"));
283 return;
284 }
285
286 if (!target_supports_delete_record ())
287 {
288 printf_unfiltered (_("The current record target does not support "
289 "this operation.\n"));
290 return;
291 }
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 ();
297 }
298
299 /* Implement the "stoprecord" or "record stop" command. */
300
301 static void
302 cmd_record_stop (const char *args, int from_tty)
303 {
304 struct target_ops *t;
305
306 t = require_record_target ();
307
308 record_stop (t);
309 record_unpush (t);
310
311 printf_unfiltered (_("Process record is stopped and all execution "
312 "logs are deleted.\n"));
313
314 observer_notify_record_changed (current_inferior (), 0, NULL, NULL);
315 }
316
317 /* The "set record" command. */
318
319 static void
320 set_record_command (const char *args, int from_tty)
321 {
322 printf_unfiltered (_("\"set record\" must be followed "
323 "by an apporpriate subcommand.\n"));
324 help_list (set_record_cmdlist, "set record ", all_commands, gdb_stdout);
325 }
326
327 /* The "show record" command. */
328
329 static void
330 show_record_command (const char *args, int from_tty)
331 {
332 cmd_show_list (show_record_cmdlist, from_tty, "");
333 }
334
335 /* The "info record" command. */
336
337 static void
338 info_record_command (const char *args, int from_tty)
339 {
340 struct target_ops *t;
341
342 t = find_record_target ();
343 if (t == NULL)
344 {
345 printf_filtered (_("No record target is currently active.\n"));
346 return;
347 }
348
349 printf_filtered (_("Active record target: %s\n"), t->to_shortname);
350 t->to_info_record (t);
351 }
352
353 /* The "record save" command. */
354
355 static void
356 cmd_record_save (const char *args, int from_tty)
357 {
358 const char *recfilename;
359 char recfilename_buffer[40];
360
361 require_record_target ();
362
363 if (args != NULL && *args != 0)
364 recfilename = args;
365 else
366 {
367 /* Default recfile name is "gdb_record.PID". */
368 xsnprintf (recfilename_buffer, sizeof (recfilename_buffer),
369 "gdb_record.%d", ptid_get_pid (inferior_ptid));
370 recfilename = recfilename_buffer;
371 }
372
373 target_save_record (recfilename);
374 }
375
376 /* See record.h. */
377
378 void
379 record_goto (const char *arg)
380 {
381 ULONGEST insn;
382
383 if (arg == NULL || *arg == '\0')
384 error (_("Command requires an argument (insn number to go to)."));
385
386 insn = parse_and_eval_long (arg);
387
388 require_record_target ();
389 target_goto_record (insn);
390 }
391
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
397 static void
398 cmd_record_goto (const char *arg, int from_tty)
399 {
400 record_goto (arg);
401 }
402
403 /* The "record goto begin" command. */
404
405 static void
406 cmd_record_goto_begin (const char *arg, int from_tty)
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
417 static void
418 cmd_record_goto_end (const char *arg, int from_tty)
419 {
420 if (arg != NULL && *arg != '\0')
421 error (_("Junk after argument: %s."), arg);
422
423 require_record_target ();
424 target_goto_record_end ();
425 }
426
427 /* Read an instruction number from an argument string. */
428
429 static ULONGEST
430 get_insn_number (const char **arg)
431 {
432 ULONGEST number;
433 const char *begin, *end, *pos;
434
435 begin = *arg;
436 pos = skip_spaces (begin);
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
450 static int
451 get_context_size (const char **arg)
452 {
453 const char *pos;
454 char *end;
455
456 pos = skip_spaces (*arg);
457
458 if (!isdigit (*pos))
459 error (_("Expected positive number, got: %s."), pos);
460
461 long result = strtol (pos, &end, 10);
462 *arg = end;
463 return result;
464 }
465
466 /* Complain about junk at the end of an argument string. */
467
468 static void
469 no_chunk (const char *arg)
470 {
471 if (*arg != 0)
472 error (_("Junk after argument: %s."), arg);
473 }
474
475 /* Read instruction-history modifiers from an argument string. */
476
477 static gdb_disassembly_flags
478 get_insn_history_modifiers (const char **arg)
479 {
480 gdb_disassembly_flags modifiers;
481 const char *args;
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':
507 case 's':
508 modifiers |= DISASSEMBLY_SOURCE;
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;
517 case 'p':
518 modifiers |= DISASSEMBLY_OMIT_PC;
519 break;
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
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
539 a log that huge, she can fetch it in chunks across several requests,
540 but she'll likely have other problems first... */
541
542 static int
543 command_size_to_target_size (unsigned int size)
544 {
545 gdb_assert (size <= INT_MAX || size == UINT_MAX);
546
547 if (size == UINT_MAX)
548 return INT_MAX;
549 else
550 return size;
551 }
552
553 /* The "record instruction-history" command. */
554
555 static void
556 cmd_record_insn_history (const char *arg, int from_tty)
557 {
558 require_record_target ();
559
560 gdb_disassembly_flags flags = get_insn_history_modifiers (&arg);
561
562 int size = command_size_to_target_size (record_insn_history_size);
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
616 /* Read function-call-history modifiers from an argument string. */
617
618 static int
619 get_call_history_modifiers (const char **arg)
620 {
621 int modifiers;
622 const char *args;
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':
648 modifiers |= RECORD_PRINT_SRC_LINE;
649 break;
650 case 'i':
651 modifiers |= RECORD_PRINT_INSN_RANGE;
652 break;
653 case 'c':
654 modifiers |= RECORD_PRINT_INDENT_CALLS;
655 break;
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
672 static void
673 cmd_record_call_history (const char *arg, int from_tty)
674 {
675 int flags, size;
676
677 require_record_target ();
678
679 flags = get_call_history_modifiers (&arg);
680
681 size = command_size_to_target_size (record_call_history_size);
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
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
740 static void
741 validate_history_size (unsigned int *command_var, unsigned int *setting)
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
760 static void
761 set_record_insn_history_size (const 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
772 static void
773 set_record_call_history_size (const 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
780 void
781 _initialize_record (void)
782 {
783 struct cmd_list_element *c;
784
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);
792
793 add_setshow_uinteger_cmd ("instruction-history-size", no_class,
794 &record_insn_history_size_setshow_var, _("\
795 Set number of instructions to print in \"record instruction-history\"."), _("\
796 Show number of instructions to print in \"record instruction-history\"."), _("\
797 A size of \"unlimited\" means unlimited instructions. The default is 10."),
798 set_record_insn_history_size, NULL,
799 &set_record_cmdlist, &show_record_cmdlist);
800
801 add_setshow_uinteger_cmd ("function-call-history-size", no_class,
802 &record_call_history_size_setshow_var, _("\
803 Set number of function to print in \"record function-call-history\"."), _("\
804 Show number of functions to print in \"record function-call-history\"."), _("\
805 A size of \"unlimited\" means unlimited lines. The default is 10."),
806 set_record_call_history_size, NULL,
807 &set_record_cmdlist, &show_record_cmdlist);
808
809 c = add_prefix_cmd ("record", class_obscure, cmd_record_start,
810 _("Start recording."),
811 &record_cmdlist, "record ", 0, &cmdlist);
812 set_cmd_completer (c, filename_completer);
813
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
828 c = add_cmd ("save", class_obscure, cmd_record_save,
829 _("Save the execution log to a file.\n\
830 Argument is optional filename.\n\
831 Default filename is 'gdb_record.<process_id>'."),
832 &record_cmdlist);
833 set_cmd_completer (c, filename_completer);
834
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
846 add_prefix_cmd ("goto", class_obscure, cmd_record_goto, _("\
847 Restore the program to its state at instruction number N.\n\
848 Argument is instruction number, as shown by 'info record'."),
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);
859
860 add_cmd ("instruction-history", class_obscure, cmd_record_insn_history, _("\
861 Print disassembled instructions stored in the execution log.\n\
862 With a /m or /s modifier, source lines are included (if available).\n\
863 With a /r modifier, raw instructions in hex are included.\n\
864 With a /f modifier, function names are omitted.\n\
865 With a /p modifier, current position markers are omitted.\n\
866 With no argument, disassembles ten more instructions after the previous \
867 disassembly.\n\
868 \"record instruction-history -\" disassembles ten instructions before a \
869 previous disassembly.\n\
870 One argument specifies an instruction number as shown by 'info record', and \
871 ten instructions are disassembled after that instruction.\n\
872 Two arguments with comma between them specify starting and ending instruction \
873 numbers to disassemble.\n\
874 If the second argument is preceded by '+' or '-', it specifies the distance \
875 from the first argument.\n\
876 The number of instructions to disassemble can be defined with \"set record \
877 instruction-history-size\"."),
878 &record_cmdlist);
879
880 add_cmd ("function-call-history", class_obscure, cmd_record_call_history, _("\
881 Prints the execution history at function granularity.\n\
882 It prints one line for each sequence of instructions that belong to the same \
883 function.\n\
884 Without modifiers, it prints the function name.\n\
885 With a /l modifier, the source file and line number range is included.\n\
886 With a /i modifier, the instruction number range is included.\n\
887 With a /c modifier, the output is indented based on the call stack depth.\n\
888 With 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 \
890 print.\n\
891 One argument specifies a function number as shown by 'info record', and \
892 ten lines are printed after that function.\n\
893 Two arguments with comma between them specify a range of functions to print.\n\
894 If the second argument is preceded by '+' or '-', it specifies the distance \
895 from the first argument.\n\
896 The number of functions to print can be defined with \"set record \
897 function-call-history-size\"."),
898 &record_cmdlist);
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;
903 }
gdbarch
Definition: gdbarch.c:127
target_goto_record_begin
void target_goto_record_begin(void)
Definition: target.c:3674
show_record_cmdlist
struct cmd_list_element * show_record_cmdlist
Definition: record.c:53
breakpoint_inserted_here_p
int breakpoint_inserted_here_p(const address_space *aspace, CORE_ADDR pc)
Definition: breakpoint.c:4092
completer.h
get_insn_history_modifiers
static gdb_disassembly_flags get_insn_history_modifiers(const char **arg)
Definition: record.c:478
CORE_ADDR
bfd_vma CORE_ADDR
Definition: common-types.h:41
target_insn_history_from
void target_insn_history_from(ULONGEST from, int size, gdb_disassembly_flags flags)
Definition: target.c:3706
ptid_get_pid
int ptid_get_pid(const ptid_t &ptid)
Definition: ptid.c:47
record_goto_cmdlist
struct cmd_list_element * record_goto_cmdlist
Definition: record.c:51
info_record_cmdlist
struct cmd_list_element * info_record_cmdlist
Definition: record.c:54
TARGET_STOPPED_BY_NO_REASON
Definition: waitstatus.h:131
no_class
Definition: command.h:41
cmd_record_goto_end
static void cmd_record_goto_end(const char *arg, int from_tty)
Definition: record.c:418
class_support
Definition: command.h:42
no_chunk
static void no_chunk(const char *arg)
Definition: record.c:469
cmd_list_element
Definition: cli-decode.h:46
INT_MAX
#define INT_MAX
Definition: defs.h:477
record_goto
void record_goto(const char *arg)
Definition: record.c:379
query
int query(const char *ctlstr,...)
Definition: utils.c:1063
target_ops::to_stop_recording
void(* to_stop_recording)(struct target_ops *) TARGET_DEFAULT_IGNORE()
Definition: target.h:1154
set_record_cmdlist
struct cmd_list_element * set_record_cmdlist
Definition: record.c:52
set_record_call_history_size
static void set_record_call_history_size(const char *args, int from_tty, struct cmd_list_element *c)
Definition: record.c:773
record_preopen
void record_preopen(void)
Definition: record.c:86
target_detach
void target_detach(const char *args, int from_tty)
Definition: target.c:2147
record_disconnect
void record_disconnect(struct target_ops *t, const char *args, int from_tty)
Definition: record.c:175
unpush_target
int unpush_target(struct target_ops *t)
Definition: target.c:689
target_supports_delete_record
int target_supports_delete_record(void)
Definition: target.c:3619
record_debug
unsigned int record_debug
Definition: record.c:33
disasm.h
add_cmd
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
Definition: cli-decode.c:262
filename_completer
void filename_completer(struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word)
Definition: completer.c:152
RECORD_PRINT_INSN_RANGE
Definition: record.h:60
cmdlist
struct cmd_list_element * cmdlist
Definition: cli-cmds.c:79
cmd_record_insn_history
static void cmd_record_insn_history(const char *arg, int from_tty)
Definition: record.c:556
target_kill
void target_kill(void)
Definition: target.c:420
target_ops::to_info_record
void(* to_info_record)(struct target_ops *) TARGET_DEFAULT_IGNORE()
Definition: target.h:1158
target_call_history_from
void target_call_history_from(ULONGEST begin, int size, int flags)
Definition: target.c:3732
skip_spaces
char * skip_spaces(char *chp)
Definition: common-utils.c:337
_
#define _(String)
Definition: gdb_locale.h:35
ui_file
Definition: ui-file.h:26
common-utils.h
defs.h
target_insn_history_range
void target_insn_history_range(ULONGEST begin, ULONGEST end, gdb_disassembly_flags flags)
Definition: target.c:3715
command_size_to_target_size
static int command_size_to_target_size(unsigned int size)
Definition: record.c:543
target_insn_history
void target_insn_history(int size, gdb_disassembly_flags flags)
Definition: target.c:3698
printf_filtered
void printf_filtered(const char *format,...)
Definition: utils.c:2045
info_record_command
static void info_record_command(const char *args, int from_tty)
Definition: record.c:338
paddress
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
Definition: utils.c:2745
record_start
void record_start(const char *method, const char *format, int from_tty)
Definition: record.c:97
cmd_record_save
static void cmd_record_save(const char *args, int from_tty)
Definition: record.c:356
execute_command
void execute_command(const char *, int)
Definition: top.c:540
observer.h
add_prefix_cmd
struct cmd_list_element * add_prefix_cmd(const char *name, enum command_class theclass, cmd_const_cfunc_ftype *fun, const char *doc, struct cmd_list_element **prefixlist, const char *prefixname, int allow_unknown, struct cmd_list_element **list)
Definition: cli-decode.c:367
add_setshow_zuinteger_cmd
void add_setshow_zuinteger_cmd(const char *name, enum command_class theclass, unsigned int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
Definition: cli-decode.c:792
flags
mach_port_t kern_return_t mach_port_t msgports mach_port_t kern_return_t pid_t pid mach_port_t kern_return_t mach_port_t task mach_port_t kern_return_t int flags
Definition: gnu-nat.c:1891
cmd_record_start
static void cmd_record_start(const char *args, int from_tty)
Definition: record.c:267
infolist
struct cmd_list_element * infolist
Definition: cli-cmds.c:83
setlist
struct cmd_list_element * setlist
Definition: cli-cmds.c:111
add_setshow_uinteger_cmd
void add_setshow_uinteger_cmd(const char *name, enum command_class theclass, unsigned int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
Definition: cli-decode.c:723
cmd_record_goto
static void cmd_record_goto(const char *arg, int from_tty)
Definition: record.c:398
observer_notify_record_changed
void observer_notify_record_changed(struct inferior *inferior, int started, const char *method, const char *format)
DEBUG
#define DEBUG(msg, args...)
Definition: record.c:56
record_stop
void record_stop(int from_tty)
Definition: record.c:131
UINT_MAX
#define UINT_MAX
Definition: defs.h:473
record_read_memory
int record_read_memory(struct gdbarch *gdbarch, CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
Definition: record.c:139
target_ops
Definition: target.h:412
fprintf_filtered
void fprintf_filtered(struct ui_file *stream, const char *format,...)
Definition: utils.c:2008
execute_command_to_string
std::string execute_command_to_string(const char *p, int from_tty)
Definition: top.c:655
record_call_history_size
static unsigned int record_call_history_size
Definition: record.c:44
set_cmd_completer
void set_cmd_completer(struct cmd_list_element *cmd, completer_ftype *completer)
Definition: cli-decode.c:160
showlist
struct cmd_list_element * showlist
Definition: cli-cmds.c:119
add_com_alias
struct cmd_list_element * add_com_alias(const char *name, const char *oldname, enum command_class theclass, int abbrev_flag)
Definition: cli-decode.c:912
cli-utils.h
set_record_insn_history_size
static void set_record_insn_history_size(const char *args, int from_tty, struct cmd_list_element *c)
Definition: record.c:761
record_unpush
static void record_unpush(struct target_ops *t)
Definition: record.c:165
show_record_command
static void show_record_command(const char *args, int from_tty)
Definition: record.c:330
inferior.h
record_insn_history_size_setshow_var
static unsigned int record_insn_history_size_setshow_var
Definition: record.c:41
require_record_target
static struct target_ops * require_record_target(void)
Definition: record.c:71
find_record_target
struct target_ops * find_record_target(void)
Definition: record.c:63
_initialize_record
void _initialize_record(void)
Definition: record.c:781
cmd_record_stop
static void cmd_record_stop(const char *args, int from_tty)
Definition: record.c:302
target_mourn_inferior
void target_mourn_inferior(ptid_t ptid)
Definition: target.c:2298
record_detach
void record_detach(struct target_ops *t, const char *args, int from_tty)
Definition: record.c:190
target_goto_record_end
void target_goto_record_end(void)
Definition: target.c:3682
cmd_record_call_history
static void cmd_record_call_history(const char *arg, int from_tty)
Definition: record.c:673
strtoulst
ULONGEST strtoulst(const char *num, const char **trailer, int base)
Definition: common-utils.c:266
target_goto_record
void target_goto_record(ULONGEST insn)
Definition: target.c:3690
printf_unfiltered
void printf_unfiltered(const char *format,...)
Definition: utils.c:2056
target_record_is_replaying
int target_record_is_replaying(ptid_t ptid)
Definition: target.c:3650
setdebuglist
struct cmd_list_element * setdebuglist
Definition: cli-cmds.c:153
DISASSEMBLY_RAW_INSN
Definition: disasm.h:28
target_save_record
void target_save_record(const char *filename)
Definition: target.c:3611
DISASSEMBLY_OMIT_PC
Definition: disasm.h:31
record_check_stopped_by_breakpoint
int record_check_stopped_by_breakpoint(const address_space *aspace, CORE_ADDR pc, enum target_stop_reason *reason)
Definition: record.c:237
cmd_show_list
void cmd_show_list(struct cmd_list_element *list, int from_tty, const char *prefix)
Definition: cli-setshow.c:657
get_context_size
static int get_context_size(const char **arg)
Definition: record.c:451
add_alias_cmd
struct cmd_list_element * add_alias_cmd(const char *name, cmd_list_element *old, enum command_class theclass, int abbrev_flag, struct cmd_list_element **list)
Definition: cli-decode.c:306
record_call_history_size_setshow_var
static unsigned int record_call_history_size_setshow_var
Definition: record.c:48
record_mourn_inferior
void record_mourn_inferior(struct target_ops *t)
Definition: record.c:205
gdb_assert
#define gdb_assert(expr)
Definition: gdb_assert.h:32
value
Definition: value.c:169
target_call_history_range
void target_call_history_range(ULONGEST begin, ULONGEST end, int flags)
Definition: target.c:3740
DISASSEMBLY_FILENAME
Definition: disasm.h:30
record_kill
void record_kill(struct target_ops *t)
Definition: record.c:221
TARGET_STOPPED_BY_HW_BREAKPOINT
Definition: waitstatus.h:137
record_cmdlist
struct cmd_list_element * record_cmdlist
Definition: record.c:50
gdb_byte
bfd_byte gdb_byte
Definition: common-types.h:38
help_list
void help_list(struct cmd_list_element *list, const char *cmdtype, enum command_class theclass, struct ui_file *stream)
Definition: cli-decode.c:1071
record.h
get_call_history_modifiers
static int get_call_history_modifiers(const char **arg)
Definition: record.c:619
TARGET_STOPPED_BY_SW_BREAKPOINT
Definition: waitstatus.h:134
address_space
Definition: progspace.h:216
xsnprintf
int xsnprintf(char *str, size_t size, const char *format,...)
Definition: common-utils.c:134
target_read_memory
int target_read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
Definition: target.c:1370
inferior_ptid
ptid_t inferior_ptid
Definition: infcmd.c:94
target_ops::to_stratum
enum strata to_stratum
Definition: target.h:656
cmd_record_delete
static void cmd_record_delete(const char *args, int from_tty)
Definition: record.c:276
hardware_breakpoint_inserted_here_p
int hardware_breakpoint_inserted_here_p(const address_space *aspace, CORE_ADDR pc)
Definition: breakpoint.c:4136
set_record_command
static void set_record_command(const char *args, int from_tty)
Definition: record.c:320
target_call_history
void target_call_history(int size, int flags)
Definition: target.c:3724
cmd_record_goto_begin
static void cmd_record_goto_begin(const char *arg, int from_tty)
Definition: record.c:406
DISASSEMBLY_OMIT_FNAME
Definition: disasm.h:29
DISASSEMBLY_SOURCE
Definition: disasm.h:32
RECORD_PRINT_SRC_LINE
Definition: record.h:57
current_inferior
struct inferior * current_inferior(void)
Definition: inferior.c:58
target_ops::to_shortname
const char * to_shortname
Definition: target.h:415
target_delete_record
void target_delete_record(void)
Definition: target.c:3634
ULONGEST
unsigned long long ULONGEST
Definition: common-types.h:53
target_disconnect
void target_disconnect(const char *args, int from_tty)
Definition: target.c:2164
all_commands
Definition: command.h:39
showdebuglist
struct cmd_list_element * showdebuglist
Definition: cli-cmds.c:155
show_record_debug
static void show_record_debug(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition: record.c:257
get_insn_number
static ULONGEST get_insn_number(const char **arg)
Definition: record.c:430
RECORD_PRINT_INDENT_CALLS
Definition: record.h:63
dont_repeat
void dont_repeat(void)
Definition: top.c:695
class_obscure
Definition: command.h:43
record_insn_history_size
static unsigned int record_insn_history_size
Definition: record.c:36
gdbcmd.h
target_stop_reason
target_stop_reason
Definition: waitstatus.h:127
error
void error(const char *fmt,...)
Definition: errors.c:38
size
size_t size
Definition: go32-nat.c:242
record_stratum
Definition: target.h:89
gdb_stdout
#define gdb_stdout
Definition: utils.h:340
validate_history_size
static void validate_history_size(unsigned int *command_var, unsigned int *setting)
Definition: record.c:741
find_target_at
struct target_ops * find_target_at(enum strata stratum)
Definition: target.c:3161
parse_and_eval_long
LONGEST parse_and_eval_long(const char *exp)
Definition: eval.c:111