Commit | Line | Data |
---|---|---|
69d05d38 HZ |
1 | /* Process record and replay target for GDB, the GNU debugger. |
2 | ||
28e7fd62 | 3 | Copyright (C) 2008-2013 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. */ |
33 | unsigned int record_debug = 0; | |
27699eea | 34 | |
67c86d06 MM |
35 | /* The number of instructions to print in "record instruction-history". */ |
36 | static unsigned int record_insn_history_size = 10; | |
37 | ||
15984c13 MM |
38 | /* The number of functions to print in "record function-call-history". */ |
39 | static unsigned int record_call_history_size = 10; | |
40 | ||
d02ed0bb MM |
41 | struct cmd_list_element *record_cmdlist = NULL; |
42 | struct cmd_list_element *set_record_cmdlist = NULL; | |
43 | struct cmd_list_element *show_record_cmdlist = NULL; | |
44 | struct cmd_list_element *info_record_cmdlist = NULL; | |
27699eea | 45 | |
7c1687a9 MM |
46 | #define DEBUG(msg, args...) \ |
47 | if (record_debug) \ | |
48 | fprintf_unfiltered (gdb_stdlog, "record: " msg "\n", ##args) | |
49 | ||
d02ed0bb | 50 | /* Find the record target in the target stack. */ |
27699eea | 51 | |
d02ed0bb MM |
52 | static struct target_ops * |
53 | find_record_target (void) | |
27699eea | 54 | { |
d02ed0bb | 55 | struct target_ops *t; |
123f5f96 | 56 | |
d02ed0bb MM |
57 | for (t = current_target.beneath; t != NULL; t = t->beneath) |
58 | if (t->to_stratum == record_stratum) | |
59 | return t; | |
27699eea | 60 | |
d02ed0bb | 61 | return NULL; |
27699eea MS |
62 | } |
63 | ||
d02ed0bb | 64 | /* Check that recording is active. Throw an error, if it isn't. */ |
27699eea | 65 | |
d02ed0bb MM |
66 | static struct target_ops * |
67 | require_record_target (void) | |
27699eea | 68 | { |
d02ed0bb | 69 | struct target_ops *t; |
27699eea | 70 | |
d02ed0bb MM |
71 | t = find_record_target (); |
72 | if (t == NULL) | |
73 | error (_("No record target is currently active.\n" | |
74 | "Use one of the \"target record-<tab><tab>\" commands first.")); | |
27699eea | 75 | |
d02ed0bb | 76 | return t; |
27699eea MS |
77 | } |
78 | ||
d02ed0bb | 79 | /* See record.h. */ |
27699eea | 80 | |
d02ed0bb MM |
81 | int |
82 | record_read_memory (struct gdbarch *gdbarch, | |
83 | CORE_ADDR memaddr, gdb_byte *myaddr, | |
84 | ssize_t len) | |
27699eea | 85 | { |
d02ed0bb | 86 | int ret = target_read_memory (memaddr, myaddr, len); |
27699eea | 87 | |
7c1687a9 MM |
88 | if (ret != 0) |
89 | DEBUG ("error reading memory at addr %s len = %ld.\n", | |
90 | paddress (gdbarch, memaddr), (long) len); | |
91 | ||
d02ed0bb | 92 | return ret; |
27699eea MS |
93 | } |
94 | ||
7c1687a9 MM |
95 | /* Stop recording. */ |
96 | ||
97 | static void | |
98 | record_stop (struct target_ops *t) | |
99 | { | |
100 | DEBUG ("stop %s", t->to_shortname); | |
101 | ||
102 | if (t->to_stop_recording != NULL) | |
103 | t->to_stop_recording (); | |
104 | } | |
105 | ||
106 | /* Unpush the record target. */ | |
107 | ||
108 | static void | |
109 | record_unpush (struct target_ops *t) | |
110 | { | |
111 | DEBUG ("unpush %s", t->to_shortname); | |
112 | ||
113 | unpush_target (t); | |
114 | } | |
115 | ||
116 | /* See record.h. */ | |
117 | ||
118 | void | |
119 | record_disconnect (struct target_ops *t, char *args, int from_tty) | |
120 | { | |
121 | gdb_assert (t->to_stratum == record_stratum); | |
122 | ||
123 | DEBUG ("disconnect %s", t->to_shortname); | |
124 | ||
125 | record_stop (t); | |
126 | record_unpush (t); | |
127 | ||
128 | target_disconnect (args, from_tty); | |
129 | } | |
130 | ||
131 | /* See record.h. */ | |
132 | ||
133 | void | |
134 | record_detach (struct target_ops *t, char *args, int from_tty) | |
135 | { | |
136 | gdb_assert (t->to_stratum == record_stratum); | |
137 | ||
138 | DEBUG ("detach %s", t->to_shortname); | |
139 | ||
140 | record_stop (t); | |
141 | record_unpush (t); | |
142 | ||
143 | target_detach (args, from_tty); | |
144 | } | |
145 | ||
146 | /* See record.h. */ | |
147 | ||
148 | void | |
149 | record_mourn_inferior (struct target_ops *t) | |
150 | { | |
151 | gdb_assert (t->to_stratum == record_stratum); | |
152 | ||
153 | DEBUG ("mourn inferior %s", t->to_shortname); | |
154 | ||
155 | /* It is safer to not stop recording. Resources will be freed when | |
156 | threads are discarded. */ | |
157 | record_unpush (t); | |
158 | ||
159 | target_mourn_inferior (); | |
160 | } | |
161 | ||
162 | /* See record.h. */ | |
163 | ||
164 | void | |
165 | record_kill (struct target_ops *t) | |
166 | { | |
167 | gdb_assert (t->to_stratum == record_stratum); | |
168 | ||
169 | DEBUG ("kill %s", t->to_shortname); | |
170 | ||
171 | /* It is safer to not stop recording. Resources will be freed when | |
172 | threads are discarded. */ | |
173 | record_unpush (t); | |
174 | ||
175 | target_kill (); | |
176 | } | |
177 | ||
6df67667 MS |
178 | /* Implement "show record debug" command. */ |
179 | ||
69d05d38 HZ |
180 | static void |
181 | show_record_debug (struct ui_file *file, int from_tty, | |
182 | struct cmd_list_element *c, const char *value) | |
183 | { | |
184 | fprintf_filtered (file, _("Debugging of process record target is %s.\n"), | |
185 | value); | |
186 | } | |
187 | ||
188 | /* Alias for "target record". */ | |
189 | ||
190 | static void | |
191 | cmd_record_start (char *args, int from_tty) | |
192 | { | |
d02ed0bb | 193 | execute_command ("target record-full", from_tty); |
69d05d38 HZ |
194 | } |
195 | ||
196 | /* Truncate the record log from the present point | |
197 | of replay until the end. */ | |
198 | ||
199 | static void | |
200 | cmd_record_delete (char *args, int from_tty) | |
201 | { | |
d02ed0bb MM |
202 | require_record_target (); |
203 | ||
204 | if (!target_record_is_replaying ()) | |
69d05d38 | 205 | { |
d02ed0bb MM |
206 | printf_unfiltered (_("Already at end of record list.\n")); |
207 | return; | |
208 | } | |
69d05d38 | 209 | |
d02ed0bb MM |
210 | if (!target_supports_delete_record ()) |
211 | { | |
212 | printf_unfiltered (_("The current record target does not support " | |
213 | "this operation.\n")); | |
214 | return; | |
69d05d38 | 215 | } |
d02ed0bb MM |
216 | |
217 | if (!from_tty || query (_("Delete the log from this point forward " | |
218 | "and begin to record the running message " | |
219 | "at current PC?"))) | |
220 | target_delete_record (); | |
69d05d38 HZ |
221 | } |
222 | ||
6df67667 | 223 | /* Implement the "stoprecord" or "record stop" command. */ |
69d05d38 HZ |
224 | |
225 | static void | |
226 | cmd_record_stop (char *args, int from_tty) | |
227 | { | |
d02ed0bb | 228 | struct target_ops *t; |
82a90ccf | 229 | |
d02ed0bb | 230 | t = require_record_target (); |
7c1687a9 MM |
231 | |
232 | record_stop (t); | |
233 | record_unpush (t); | |
69d05d38 | 234 | |
d02ed0bb MM |
235 | printf_unfiltered (_("Process record is stopped and all execution " |
236 | "logs are deleted.\n")); | |
69d05d38 | 237 | |
d02ed0bb | 238 | observer_notify_record_changed (current_inferior (), 0); |
69d05d38 HZ |
239 | } |
240 | ||
d02ed0bb | 241 | /* The "set record" command. */ |
69d05d38 HZ |
242 | |
243 | static void | |
244 | set_record_command (char *args, int from_tty) | |
245 | { | |
3e43a32a MS |
246 | printf_unfiltered (_("\"set record\" must be followed " |
247 | "by an apporpriate subcommand.\n")); | |
69d05d38 HZ |
248 | help_list (set_record_cmdlist, "set record ", all_commands, gdb_stdout); |
249 | } | |
250 | ||
d02ed0bb MM |
251 | /* The "show record" command. */ |
252 | ||
69d05d38 HZ |
253 | static void |
254 | show_record_command (char *args, int from_tty) | |
255 | { | |
256 | cmd_show_list (show_record_cmdlist, from_tty, ""); | |
257 | } | |
258 | ||
d02ed0bb | 259 | /* The "info record" command. */ |
b54295a7 | 260 | |
69d05d38 HZ |
261 | static void |
262 | info_record_command (char *args, int from_tty) | |
263 | { | |
d02ed0bb | 264 | struct target_ops *t; |
0156b218 | 265 | |
d02ed0bb MM |
266 | t = find_record_target (); |
267 | if (t == NULL) | |
0156b218 | 268 | { |
d02ed0bb MM |
269 | printf_filtered (_("No record target is currently active.\n")); |
270 | return; | |
0156b218 MS |
271 | } |
272 | ||
d02ed0bb MM |
273 | printf_filtered (_("Active record target: %s\n"), t->to_shortname); |
274 | if (t->to_info_record != NULL) | |
275 | t->to_info_record (); | |
0156b218 MS |
276 | } |
277 | ||
d02ed0bb | 278 | /* The "record save" command. */ |
0156b218 MS |
279 | |
280 | static void | |
281 | cmd_record_save (char *args, int from_tty) | |
282 | { | |
283 | char *recfilename, recfilename_buffer[40]; | |
0156b218 | 284 | |
d02ed0bb | 285 | require_record_target (); |
0156b218 | 286 | |
d02ed0bb | 287 | if (args != NULL && *args != 0) |
0156b218 MS |
288 | recfilename = args; |
289 | else | |
290 | { | |
291 | /* Default recfile name is "gdb_record.PID". */ | |
d02ed0bb | 292 | xsnprintf (recfilename_buffer, sizeof (recfilename_buffer), |
0156b218 MS |
293 | "gdb_record.%d", PIDGET (inferior_ptid)); |
294 | recfilename = recfilename_buffer; | |
295 | } | |
296 | ||
d02ed0bb | 297 | target_save_record (recfilename); |
6b04bdb7 MS |
298 | } |
299 | ||
300 | /* "record goto" command. Argument is an instruction number, | |
301 | as given by "info record". | |
302 | ||
303 | Rewinds the recording (forward or backward) to the given instruction. */ | |
304 | ||
d02ed0bb | 305 | void |
6b04bdb7 MS |
306 | cmd_record_goto (char *arg, int from_tty) |
307 | { | |
d02ed0bb | 308 | require_record_target (); |
6b04bdb7 MS |
309 | |
310 | if (arg == NULL || *arg == '\0') | |
311 | error (_("Command requires an argument (insn number to go to).")); | |
312 | ||
313 | if (strncmp (arg, "start", strlen ("start")) == 0 | |
314 | || strncmp (arg, "begin", strlen ("begin")) == 0) | |
d02ed0bb | 315 | target_goto_record_begin (); |
6b04bdb7 | 316 | else if (strncmp (arg, "end", strlen ("end")) == 0) |
d02ed0bb | 317 | target_goto_record_end (); |
6b04bdb7 MS |
318 | else |
319 | { | |
d02ed0bb | 320 | ULONGEST insn; |
6b04bdb7 | 321 | |
d02ed0bb MM |
322 | insn = parse_and_eval_long (arg); |
323 | target_goto_record (insn); | |
6b04bdb7 | 324 | } |
6b04bdb7 MS |
325 | } |
326 | ||
67c86d06 MM |
327 | /* Read an instruction number from an argument string. */ |
328 | ||
329 | static ULONGEST | |
330 | get_insn_number (char **arg) | |
331 | { | |
332 | ULONGEST number; | |
333 | const char *begin, *end, *pos; | |
334 | ||
335 | begin = *arg; | |
336 | pos = skip_spaces_const (begin); | |
337 | ||
338 | if (!isdigit (*pos)) | |
339 | error (_("Expected positive number, got: %s."), pos); | |
340 | ||
341 | number = strtoulst (pos, &end, 10); | |
342 | ||
343 | *arg += (end - begin); | |
344 | ||
345 | return number; | |
346 | } | |
347 | ||
348 | /* Read a context size from an argument string. */ | |
349 | ||
350 | static int | |
351 | get_context_size (char **arg) | |
352 | { | |
353 | char *pos; | |
354 | int number; | |
355 | ||
356 | pos = skip_spaces (*arg); | |
357 | ||
358 | if (!isdigit (*pos)) | |
359 | error (_("Expected positive number, got: %s."), pos); | |
360 | ||
361 | return strtol (pos, arg, 10); | |
362 | } | |
363 | ||
364 | /* Complain about junk at the end of an argument string. */ | |
365 | ||
366 | static void | |
367 | no_chunk (char *arg) | |
368 | { | |
369 | if (*arg != 0) | |
370 | error (_("Junk after argument: %s."), arg); | |
371 | } | |
372 | ||
373 | /* Read instruction-history modifiers from an argument string. */ | |
374 | ||
375 | static int | |
376 | get_insn_history_modifiers (char **arg) | |
377 | { | |
378 | int modifiers; | |
379 | char *args; | |
380 | ||
381 | modifiers = 0; | |
382 | args = *arg; | |
383 | ||
384 | if (args == NULL) | |
385 | return modifiers; | |
386 | ||
387 | while (*args == '/') | |
388 | { | |
389 | ++args; | |
390 | ||
391 | if (*args == '\0') | |
392 | error (_("Missing modifier.")); | |
393 | ||
394 | for (; *args; ++args) | |
395 | { | |
396 | if (isspace (*args)) | |
397 | break; | |
398 | ||
399 | if (*args == '/') | |
400 | continue; | |
401 | ||
402 | switch (*args) | |
403 | { | |
404 | case 'm': | |
405 | modifiers |= DISASSEMBLY_SOURCE; | |
406 | modifiers |= DISASSEMBLY_FILENAME; | |
407 | break; | |
408 | case 'r': | |
409 | modifiers |= DISASSEMBLY_RAW_INSN; | |
410 | break; | |
411 | case 'f': | |
412 | modifiers |= DISASSEMBLY_OMIT_FNAME; | |
413 | break; | |
414 | default: | |
415 | error (_("Invalid modifier: %c."), *args); | |
416 | } | |
417 | } | |
418 | ||
419 | args = skip_spaces (args); | |
420 | } | |
421 | ||
422 | /* Update the argument string. */ | |
423 | *arg = args; | |
424 | ||
425 | return modifiers; | |
426 | } | |
427 | ||
428 | /* The "record instruction-history" command. */ | |
429 | ||
430 | static void | |
431 | cmd_record_insn_history (char *arg, int from_tty) | |
432 | { | |
433 | int flags, size; | |
434 | ||
435 | require_record_target (); | |
436 | ||
437 | flags = get_insn_history_modifiers (&arg); | |
438 | ||
439 | /* We use a signed size to also indicate the direction. Make sure that | |
440 | unlimited remains unlimited. */ | |
441 | size = (int) record_insn_history_size; | |
442 | if (size < 0) | |
443 | size = INT_MAX; | |
444 | ||
445 | if (arg == NULL || *arg == 0 || strcmp (arg, "+") == 0) | |
446 | target_insn_history (size, flags); | |
447 | else if (strcmp (arg, "-") == 0) | |
448 | target_insn_history (-size, flags); | |
449 | else | |
450 | { | |
451 | ULONGEST begin, end; | |
452 | ||
453 | begin = get_insn_number (&arg); | |
454 | ||
455 | if (*arg == ',') | |
456 | { | |
457 | arg = skip_spaces (++arg); | |
458 | ||
459 | if (*arg == '+') | |
460 | { | |
461 | arg += 1; | |
462 | size = get_context_size (&arg); | |
463 | ||
464 | no_chunk (arg); | |
465 | ||
466 | target_insn_history_from (begin, size, flags); | |
467 | } | |
468 | else if (*arg == '-') | |
469 | { | |
470 | arg += 1; | |
471 | size = get_context_size (&arg); | |
472 | ||
473 | no_chunk (arg); | |
474 | ||
475 | target_insn_history_from (begin, -size, flags); | |
476 | } | |
477 | else | |
478 | { | |
479 | end = get_insn_number (&arg); | |
480 | ||
481 | no_chunk (arg); | |
482 | ||
483 | target_insn_history_range (begin, end, flags); | |
484 | } | |
485 | } | |
486 | else | |
487 | { | |
488 | no_chunk (arg); | |
489 | ||
490 | target_insn_history_from (begin, size, flags); | |
491 | } | |
492 | ||
493 | dont_repeat (); | |
494 | } | |
495 | } | |
496 | ||
15984c13 MM |
497 | /* Read function-call-history modifiers from an argument string. */ |
498 | ||
499 | static int | |
500 | get_call_history_modifiers (char **arg) | |
501 | { | |
502 | int modifiers; | |
503 | char *args; | |
504 | ||
505 | modifiers = 0; | |
506 | args = *arg; | |
507 | ||
508 | if (args == NULL) | |
509 | return modifiers; | |
510 | ||
511 | while (*args == '/') | |
512 | { | |
513 | ++args; | |
514 | ||
515 | if (*args == '\0') | |
516 | error (_("Missing modifier.")); | |
517 | ||
518 | for (; *args; ++args) | |
519 | { | |
520 | if (isspace (*args)) | |
521 | break; | |
522 | ||
523 | if (*args == '/') | |
524 | continue; | |
525 | ||
526 | switch (*args) | |
527 | { | |
528 | case 'l': | |
529 | modifiers |= record_print_src_line; | |
530 | break; | |
531 | case 'i': | |
532 | modifiers |= record_print_insn_range; | |
533 | break; | |
534 | default: | |
535 | error (_("Invalid modifier: %c."), *args); | |
536 | } | |
537 | } | |
538 | ||
539 | args = skip_spaces (args); | |
540 | } | |
541 | ||
542 | /* Update the argument string. */ | |
543 | *arg = args; | |
544 | ||
545 | return modifiers; | |
546 | } | |
547 | ||
548 | /* The "record function-call-history" command. */ | |
549 | ||
550 | static void | |
551 | cmd_record_call_history (char *arg, int from_tty) | |
552 | { | |
553 | int flags, size; | |
554 | ||
555 | require_record_target (); | |
556 | ||
557 | flags = get_call_history_modifiers (&arg); | |
558 | ||
559 | /* We use a signed size to also indicate the direction. Make sure that | |
560 | unlimited remains unlimited. */ | |
561 | size = (int) record_call_history_size; | |
562 | if (size < 0) | |
563 | size = INT_MAX; | |
564 | ||
565 | if (arg == NULL || *arg == 0 || strcmp (arg, "+") == 0) | |
566 | target_call_history (size, flags); | |
567 | else if (strcmp (arg, "-") == 0) | |
568 | target_call_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_call_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_call_history_from (begin, -size, flags); | |
596 | } | |
597 | else | |
598 | { | |
599 | end = get_insn_number (&arg); | |
600 | ||
601 | no_chunk (arg); | |
602 | ||
603 | target_call_history_range (begin, end, flags); | |
604 | } | |
605 | } | |
606 | else | |
607 | { | |
608 | no_chunk (arg); | |
609 | ||
610 | target_call_history_from (begin, size, flags); | |
611 | } | |
612 | ||
613 | dont_repeat (); | |
614 | } | |
615 | } | |
616 | ||
70221824 PA |
617 | /* Provide a prototype to silence -Wmissing-prototypes. */ |
618 | extern initialize_file_ftype _initialize_record; | |
619 | ||
69d05d38 HZ |
620 | void |
621 | _initialize_record (void) | |
622 | { | |
0156b218 MS |
623 | struct cmd_list_element *c; |
624 | ||
ccce17b0 YQ |
625 | add_setshow_zuinteger_cmd ("record", no_class, &record_debug, |
626 | _("Set debugging of record/replay feature."), | |
627 | _("Show debugging of record/replay feature."), | |
628 | _("When enabled, debugging output for " | |
629 | "record/replay feature is displayed."), | |
630 | NULL, show_record_debug, &setdebuglist, | |
631 | &showdebuglist); | |
69d05d38 | 632 | |
67c86d06 MM |
633 | add_setshow_uinteger_cmd ("instruction-history-size", no_class, |
634 | &record_insn_history_size, _("\ | |
635 | Set number of instructions to print in \"record instruction-history\"."), _("\ | |
636 | Show number of instructions to print in \"record instruction-history\"."), | |
637 | NULL, NULL, NULL, &set_record_cmdlist, | |
638 | &show_record_cmdlist); | |
639 | ||
15984c13 MM |
640 | add_setshow_uinteger_cmd ("function-call-history-size", no_class, |
641 | &record_call_history_size, _("\ | |
642 | Set number of function to print in \"record function-call-history\"."), _("\ | |
643 | Show number of functions to print in \"record function-call-history\"."), | |
644 | NULL, NULL, NULL, &set_record_cmdlist, | |
645 | &show_record_cmdlist); | |
646 | ||
0156b218 | 647 | c = add_prefix_cmd ("record", class_obscure, cmd_record_start, |
d02ed0bb | 648 | _("Start recording."), |
0156b218 MS |
649 | &record_cmdlist, "record ", 0, &cmdlist); |
650 | set_cmd_completer (c, filename_completer); | |
651 | ||
69d05d38 HZ |
652 | add_com_alias ("rec", "record", class_obscure, 1); |
653 | add_prefix_cmd ("record", class_support, set_record_command, | |
654 | _("Set record options"), &set_record_cmdlist, | |
655 | "set record ", 0, &setlist); | |
656 | add_alias_cmd ("rec", "record", class_obscure, 1, &setlist); | |
657 | add_prefix_cmd ("record", class_support, show_record_command, | |
658 | _("Show record options"), &show_record_cmdlist, | |
659 | "show record ", 0, &showlist); | |
660 | add_alias_cmd ("rec", "record", class_obscure, 1, &showlist); | |
661 | add_prefix_cmd ("record", class_support, info_record_command, | |
662 | _("Info record options"), &info_record_cmdlist, | |
663 | "info record ", 0, &infolist); | |
664 | add_alias_cmd ("rec", "record", class_obscure, 1, &infolist); | |
665 | ||
0156b218 MS |
666 | c = add_cmd ("save", class_obscure, cmd_record_save, |
667 | _("Save the execution log to a file.\n\ | |
668 | Argument is optional filename.\n\ | |
669 | Default filename is 'gdb_record.<process_id>'."), | |
670 | &record_cmdlist); | |
671 | set_cmd_completer (c, filename_completer); | |
672 | ||
69d05d38 HZ |
673 | add_cmd ("delete", class_obscure, cmd_record_delete, |
674 | _("Delete the rest of execution log and start recording it anew."), | |
675 | &record_cmdlist); | |
676 | add_alias_cmd ("d", "delete", class_obscure, 1, &record_cmdlist); | |
677 | add_alias_cmd ("del", "delete", class_obscure, 1, &record_cmdlist); | |
678 | ||
679 | add_cmd ("stop", class_obscure, cmd_record_stop, | |
680 | _("Stop the record/replay target."), | |
681 | &record_cmdlist); | |
682 | add_alias_cmd ("s", "stop", class_obscure, 1, &record_cmdlist); | |
683 | ||
6b04bdb7 MS |
684 | add_cmd ("goto", class_obscure, cmd_record_goto, _("\ |
685 | Restore the program to its state at instruction number N.\n\ | |
686 | Argument is instruction number, as shown by 'info record'."), | |
687 | &record_cmdlist); | |
67c86d06 MM |
688 | |
689 | add_cmd ("instruction-history", class_obscure, cmd_record_insn_history, _("\ | |
690 | Print disassembled instructions stored in the execution log.\n\ | |
691 | With a /m modifier, source lines are included (if available).\n\ | |
692 | With a /r modifier, raw instructions in hex are included.\n\ | |
693 | With a /f modifier, function names are omitted.\n\ | |
694 | With no argument, disassembles ten more instructions after the previous \ | |
695 | disassembly.\n\ | |
696 | \"record instruction-history -\" disassembles ten instructions before a \ | |
697 | previous disassembly.\n\ | |
698 | One argument specifies an instruction number as shown by 'info record', and \ | |
699 | ten instructions are disassembled after that instruction.\n\ | |
700 | Two arguments with comma between them specify starting and ending instruction \ | |
701 | numbers to disassemble.\n\ | |
702 | If the second argument is preceded by '+' or '-', it specifies the distance \ | |
703 | from the first argument.\n\ | |
704 | The number of instructions to disassemble can be defined with \"set record \ | |
705 | instruction-history-size\"."), | |
706 | &record_cmdlist); | |
15984c13 MM |
707 | |
708 | add_cmd ("function-call-history", class_obscure, cmd_record_call_history, _("\ | |
709 | Prints the execution history at function granularity.\n\ | |
710 | It prints one line for each sequence of instructions that belong to the same \ | |
711 | function.\n\ | |
712 | Without modifiers, it prints the function name.\n\ | |
713 | With a /l modifier, the source file and line number range is included.\n\ | |
714 | With a /i modifier, the instruction number range is included.\n\ | |
715 | With no argument, prints ten more lines after the previous ten-line print.\n\ | |
716 | \"record function-call-history -\" prints ten lines before a previous ten-line \ | |
717 | print.\n\ | |
718 | One argument specifies a function number as shown by 'info record', and \ | |
719 | ten lines are printed after that function.\n\ | |
720 | Two arguments with comma between them specify a range of functions to print.\n\ | |
721 | If the second argument is preceded by '+' or '-', it specifies the distance \ | |
722 | from the first argument.\n\ | |
723 | The number of functions to print can be defined with \"set record \ | |
724 | function-call-history-size\"."), | |
725 | &record_cmdlist); | |
69d05d38 | 726 | } |