record.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893
  1. /* Process record and replay target for GDB, the GNU debugger.
  2. Copyright (C) 2008-2022 Free Software Foundation, Inc.
  3. This file is part of GDB.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  14. #include "defs.h"
  15. #include "gdbcmd.h"
  16. #include "completer.h"
  17. #include "record.h"
  18. #include "observable.h"
  19. #include "inferior.h"
  20. #include "gdbsupport/common-utils.h"
  21. #include "cli/cli-utils.h"
  22. #include "disasm.h"
  23. #include <ctype.h>
  24. /* This is the debug switch for process record. */
  25. unsigned int record_debug = 0;
  26. /* The number of instructions to print in "record instruction-history". */
  27. static unsigned int record_insn_history_size = 10;
  28. /* The variable registered as control variable in the "record
  29. instruction-history" command. Necessary for extra input
  30. validation. */
  31. static unsigned int record_insn_history_size_setshow_var;
  32. /* The number of functions to print in "record function-call-history". */
  33. static unsigned int record_call_history_size = 10;
  34. /* The variable registered as control variable in the "record
  35. call-history" command. Necessary for extra input validation. */
  36. static unsigned int record_call_history_size_setshow_var;
  37. struct cmd_list_element *record_cmdlist = NULL;
  38. static struct cmd_list_element *record_goto_cmdlist = NULL;
  39. struct cmd_list_element *set_record_cmdlist = NULL;
  40. struct cmd_list_element *show_record_cmdlist = NULL;
  41. struct cmd_list_element *info_record_cmdlist = NULL;
  42. #define DEBUG(msg, args...) \
  43. if (record_debug) \
  44. gdb_printf (gdb_stdlog, "record: " msg "\n", ##args)
  45. /* See record.h. */
  46. struct target_ops *
  47. find_record_target (void)
  48. {
  49. return find_target_at (record_stratum);
  50. }
  51. /* Check that recording is active. Throw an error, if it isn't. */
  52. static struct target_ops *
  53. require_record_target (void)
  54. {
  55. struct target_ops *t;
  56. t = find_record_target ();
  57. if (t == NULL)
  58. error (_("No recording is currently active.\n"
  59. "Use the \"record full\" or \"record btrace\" command first."));
  60. return t;
  61. }
  62. /* See record.h. */
  63. void
  64. record_preopen (void)
  65. {
  66. /* Check if a record target is already running. */
  67. if (find_record_target () != NULL)
  68. error (_("The process is already being recorded. Use \"record stop\" to "
  69. "stop recording first."));
  70. }
  71. /* See record.h. */
  72. void
  73. record_start (const char *method, const char *format, int from_tty)
  74. {
  75. if (method == NULL)
  76. {
  77. if (format == NULL)
  78. execute_command_to_string ("record", from_tty, false);
  79. else
  80. error (_("Invalid format."));
  81. }
  82. else if (strcmp (method, "full") == 0)
  83. {
  84. if (format == NULL)
  85. execute_command_to_string ("record full", from_tty, false);
  86. else
  87. error (_("Invalid format."));
  88. }
  89. else if (strcmp (method, "btrace") == 0)
  90. {
  91. if (format == NULL)
  92. execute_command_to_string ("record btrace", from_tty, false);
  93. else if (strcmp (format, "bts") == 0)
  94. execute_command_to_string ("record btrace bts", from_tty, false);
  95. else if (strcmp (format, "pt") == 0)
  96. execute_command_to_string ("record btrace pt", from_tty, false);
  97. else
  98. error (_("Invalid format."));
  99. }
  100. else
  101. error (_("Invalid method."));
  102. }
  103. /* See record.h. */
  104. void
  105. record_stop (int from_tty)
  106. {
  107. execute_command_to_string ("record stop", from_tty, false);
  108. }
  109. /* See record.h. */
  110. int
  111. record_read_memory (struct gdbarch *gdbarch,
  112. CORE_ADDR memaddr, gdb_byte *myaddr,
  113. ssize_t len)
  114. {
  115. int ret = target_read_memory (memaddr, myaddr, len);
  116. if (ret != 0)
  117. DEBUG ("error reading memory at addr %s len = %ld.\n",
  118. paddress (gdbarch, memaddr), (long) len);
  119. return ret;
  120. }
  121. /* Stop recording. */
  122. static void
  123. record_stop (struct target_ops *t)
  124. {
  125. DEBUG ("stop %s", t->shortname ());
  126. t->stop_recording ();
  127. }
  128. /* Unpush the record target. */
  129. static void
  130. record_unpush (struct target_ops *t)
  131. {
  132. DEBUG ("unpush %s", t->shortname ());
  133. current_inferior ()->unpush_target (t);
  134. }
  135. /* See record.h. */
  136. void
  137. record_disconnect (struct target_ops *t, const char *args, int from_tty)
  138. {
  139. gdb_assert (t->stratum () == record_stratum);
  140. DEBUG ("disconnect %s", t->shortname ());
  141. record_stop (t);
  142. record_unpush (t);
  143. target_disconnect (args, from_tty);
  144. }
  145. /* See record.h. */
  146. void
  147. record_detach (struct target_ops *t, inferior *inf, int from_tty)
  148. {
  149. gdb_assert (t->stratum () == record_stratum);
  150. DEBUG ("detach %s", t->shortname ());
  151. record_stop (t);
  152. record_unpush (t);
  153. target_detach (inf, from_tty);
  154. }
  155. /* See record.h. */
  156. void
  157. record_mourn_inferior (struct target_ops *t)
  158. {
  159. gdb_assert (t->stratum () == record_stratum);
  160. DEBUG ("mourn inferior %s", t->shortname ());
  161. /* It is safer to not stop recording. Resources will be freed when
  162. threads are discarded. */
  163. record_unpush (t);
  164. target_mourn_inferior (inferior_ptid);
  165. }
  166. /* See record.h. */
  167. void
  168. record_kill (struct target_ops *t)
  169. {
  170. gdb_assert (t->stratum () == record_stratum);
  171. DEBUG ("kill %s", t->shortname ());
  172. /* It is safer to not stop recording. Resources will be freed when
  173. threads are discarded. */
  174. record_unpush (t);
  175. target_kill ();
  176. }
  177. /* See record.h. */
  178. int
  179. record_check_stopped_by_breakpoint (const address_space *aspace,
  180. CORE_ADDR pc,
  181. enum target_stop_reason *reason)
  182. {
  183. if (breakpoint_inserted_here_p (aspace, pc))
  184. {
  185. if (hardware_breakpoint_inserted_here_p (aspace, pc))
  186. *reason = TARGET_STOPPED_BY_HW_BREAKPOINT;
  187. else
  188. *reason = TARGET_STOPPED_BY_SW_BREAKPOINT;
  189. return 1;
  190. }
  191. *reason = TARGET_STOPPED_BY_NO_REASON;
  192. return 0;
  193. }
  194. /* Implement "show record debug" command. */
  195. static void
  196. show_record_debug (struct ui_file *file, int from_tty,
  197. struct cmd_list_element *c, const char *value)
  198. {
  199. gdb_printf (file, _("Debugging of process record target is %s.\n"),
  200. value);
  201. }
  202. /* Alias for "target record". */
  203. static void
  204. cmd_record_start (const char *args, int from_tty)
  205. {
  206. execute_command ("target record-full", from_tty);
  207. }
  208. /* Truncate the record log from the present point
  209. of replay until the end. */
  210. static void
  211. cmd_record_delete (const char *args, int from_tty)
  212. {
  213. require_record_target ();
  214. if (!target_record_is_replaying (inferior_ptid))
  215. {
  216. gdb_printf (_("Already at end of record list.\n"));
  217. return;
  218. }
  219. if (!target_supports_delete_record ())
  220. {
  221. gdb_printf (_("The current record target does not support "
  222. "this operation.\n"));
  223. return;
  224. }
  225. if (!from_tty || query (_("Delete the log from this point forward "
  226. "and begin to record the running message "
  227. "at current PC?")))
  228. target_delete_record ();
  229. }
  230. /* Implement the "stoprecord" or "record stop" command. */
  231. static void
  232. cmd_record_stop (const char *args, int from_tty)
  233. {
  234. struct target_ops *t;
  235. t = require_record_target ();
  236. record_stop (t);
  237. record_unpush (t);
  238. gdb_printf (_("Process record is stopped and all execution "
  239. "logs are deleted.\n"));
  240. gdb::observers::record_changed.notify (current_inferior (), 0, NULL, NULL);
  241. }
  242. /* The "info record" command. */
  243. static void
  244. info_record_command (const char *args, int from_tty)
  245. {
  246. struct target_ops *t;
  247. t = find_record_target ();
  248. if (t == NULL)
  249. {
  250. gdb_printf (_("No recording is currently active.\n"));
  251. return;
  252. }
  253. gdb_printf (_("Active record target: %s\n"), t->shortname ());
  254. t->info_record ();
  255. }
  256. /* The "record save" command. */
  257. static void
  258. cmd_record_save (const char *args, int from_tty)
  259. {
  260. const char *recfilename;
  261. char recfilename_buffer[40];
  262. require_record_target ();
  263. if (args != NULL && *args != 0)
  264. recfilename = args;
  265. else
  266. {
  267. /* Default recfile name is "gdb_record.PID". */
  268. xsnprintf (recfilename_buffer, sizeof (recfilename_buffer),
  269. "gdb_record.%d", inferior_ptid.pid ());
  270. recfilename = recfilename_buffer;
  271. }
  272. target_save_record (recfilename);
  273. }
  274. /* See record.h. */
  275. void
  276. record_goto (const char *arg)
  277. {
  278. ULONGEST insn;
  279. if (arg == NULL || *arg == '\0')
  280. error (_("Command requires an argument (insn number to go to)."));
  281. insn = parse_and_eval_long (arg);
  282. require_record_target ();
  283. target_goto_record (insn);
  284. }
  285. /* "record goto" command. Argument is an instruction number,
  286. as given by "info record".
  287. Rewinds the recording (forward or backward) to the given instruction. */
  288. static void
  289. cmd_record_goto (const char *arg, int from_tty)
  290. {
  291. record_goto (arg);
  292. }
  293. /* The "record goto begin" command. */
  294. static void
  295. cmd_record_goto_begin (const char *arg, int from_tty)
  296. {
  297. if (arg != NULL && *arg != '\0')
  298. error (_("Junk after argument: %s."), arg);
  299. require_record_target ();
  300. target_goto_record_begin ();
  301. }
  302. /* The "record goto end" command. */
  303. static void
  304. cmd_record_goto_end (const char *arg, int from_tty)
  305. {
  306. if (arg != NULL && *arg != '\0')
  307. error (_("Junk after argument: %s."), arg);
  308. require_record_target ();
  309. target_goto_record_end ();
  310. }
  311. /* Read an instruction number from an argument string. */
  312. static ULONGEST
  313. get_insn_number (const char **arg)
  314. {
  315. ULONGEST number;
  316. const char *begin, *end, *pos;
  317. begin = *arg;
  318. pos = skip_spaces (begin);
  319. if (!isdigit (*pos))
  320. error (_("Expected positive number, got: %s."), pos);
  321. number = strtoulst (pos, &end, 10);
  322. *arg += (end - begin);
  323. return number;
  324. }
  325. /* Read a context size from an argument string. */
  326. static int
  327. get_context_size (const char **arg)
  328. {
  329. const char *pos;
  330. char *end;
  331. pos = skip_spaces (*arg);
  332. if (!isdigit (*pos))
  333. error (_("Expected positive number, got: %s."), pos);
  334. long result = strtol (pos, &end, 10);
  335. *arg = end;
  336. return result;
  337. }
  338. /* Complain about junk at the end of an argument string. */
  339. static void
  340. no_chunk (const char *arg)
  341. {
  342. if (*arg != 0)
  343. error (_("Junk after argument: %s."), arg);
  344. }
  345. /* Read instruction-history modifiers from an argument string. */
  346. static gdb_disassembly_flags
  347. get_insn_history_modifiers (const char **arg)
  348. {
  349. gdb_disassembly_flags modifiers;
  350. const char *args;
  351. modifiers = 0;
  352. args = *arg;
  353. if (args == NULL)
  354. return modifiers;
  355. while (*args == '/')
  356. {
  357. ++args;
  358. if (*args == '\0')
  359. error (_("Missing modifier."));
  360. for (; *args; ++args)
  361. {
  362. if (isspace (*args))
  363. break;
  364. if (*args == '/')
  365. continue;
  366. switch (*args)
  367. {
  368. case 'm':
  369. case 's':
  370. modifiers |= DISASSEMBLY_SOURCE;
  371. modifiers |= DISASSEMBLY_FILENAME;
  372. break;
  373. case 'r':
  374. modifiers |= DISASSEMBLY_RAW_INSN;
  375. break;
  376. case 'f':
  377. modifiers |= DISASSEMBLY_OMIT_FNAME;
  378. break;
  379. case 'p':
  380. modifiers |= DISASSEMBLY_OMIT_PC;
  381. break;
  382. default:
  383. error (_("Invalid modifier: %c."), *args);
  384. }
  385. }
  386. args = skip_spaces (args);
  387. }
  388. /* Update the argument string. */
  389. *arg = args;
  390. return modifiers;
  391. }
  392. /* The "set record instruction-history-size / set record
  393. function-call-history-size" commands are unsigned, with UINT_MAX
  394. meaning unlimited. The target interfaces works with signed int
  395. though, to indicate direction, so map "unlimited" to INT_MAX, which
  396. is about the same as unlimited in practice. If the user does have
  397. a log that huge, she can fetch it in chunks across several requests,
  398. but she'll likely have other problems first... */
  399. static int
  400. command_size_to_target_size (unsigned int size)
  401. {
  402. gdb_assert (size <= INT_MAX || size == UINT_MAX);
  403. if (size == UINT_MAX)
  404. return INT_MAX;
  405. else
  406. return size;
  407. }
  408. /* The "record instruction-history" command. */
  409. static void
  410. cmd_record_insn_history (const char *arg, int from_tty)
  411. {
  412. require_record_target ();
  413. gdb_disassembly_flags flags = get_insn_history_modifiers (&arg);
  414. int size = command_size_to_target_size (record_insn_history_size);
  415. if (arg == NULL || *arg == 0 || strcmp (arg, "+") == 0)
  416. target_insn_history (size, flags);
  417. else if (strcmp (arg, "-") == 0)
  418. target_insn_history (-size, flags);
  419. else
  420. {
  421. ULONGEST begin, end;
  422. begin = get_insn_number (&arg);
  423. if (*arg == ',')
  424. {
  425. arg = skip_spaces (++arg);
  426. if (*arg == '+')
  427. {
  428. arg += 1;
  429. size = get_context_size (&arg);
  430. no_chunk (arg);
  431. target_insn_history_from (begin, size, flags);
  432. }
  433. else if (*arg == '-')
  434. {
  435. arg += 1;
  436. size = get_context_size (&arg);
  437. no_chunk (arg);
  438. target_insn_history_from (begin, -size, flags);
  439. }
  440. else
  441. {
  442. end = get_insn_number (&arg);
  443. no_chunk (arg);
  444. target_insn_history_range (begin, end, flags);
  445. }
  446. }
  447. else
  448. {
  449. no_chunk (arg);
  450. target_insn_history_from (begin, size, flags);
  451. }
  452. dont_repeat ();
  453. }
  454. }
  455. /* Read function-call-history modifiers from an argument string. */
  456. static record_print_flags
  457. get_call_history_modifiers (const char **arg)
  458. {
  459. record_print_flags modifiers = 0;
  460. const char *args = *arg;
  461. if (args == NULL)
  462. return modifiers;
  463. while (*args == '/')
  464. {
  465. ++args;
  466. if (*args == '\0')
  467. error (_("Missing modifier."));
  468. for (; *args; ++args)
  469. {
  470. if (isspace (*args))
  471. break;
  472. if (*args == '/')
  473. continue;
  474. switch (*args)
  475. {
  476. case 'l':
  477. modifiers |= RECORD_PRINT_SRC_LINE;
  478. break;
  479. case 'i':
  480. modifiers |= RECORD_PRINT_INSN_RANGE;
  481. break;
  482. case 'c':
  483. modifiers |= RECORD_PRINT_INDENT_CALLS;
  484. break;
  485. default:
  486. error (_("Invalid modifier: %c."), *args);
  487. }
  488. }
  489. args = skip_spaces (args);
  490. }
  491. /* Update the argument string. */
  492. *arg = args;
  493. return modifiers;
  494. }
  495. /* The "record function-call-history" command. */
  496. static void
  497. cmd_record_call_history (const char *arg, int from_tty)
  498. {
  499. require_record_target ();
  500. record_print_flags flags = get_call_history_modifiers (&arg);
  501. int size = command_size_to_target_size (record_call_history_size);
  502. if (arg == NULL || *arg == 0 || strcmp (arg, "+") == 0)
  503. target_call_history (size, flags);
  504. else if (strcmp (arg, "-") == 0)
  505. target_call_history (-size, flags);
  506. else
  507. {
  508. ULONGEST begin, end;
  509. begin = get_insn_number (&arg);
  510. if (*arg == ',')
  511. {
  512. arg = skip_spaces (++arg);
  513. if (*arg == '+')
  514. {
  515. arg += 1;
  516. size = get_context_size (&arg);
  517. no_chunk (arg);
  518. target_call_history_from (begin, size, flags);
  519. }
  520. else if (*arg == '-')
  521. {
  522. arg += 1;
  523. size = get_context_size (&arg);
  524. no_chunk (arg);
  525. target_call_history_from (begin, -size, flags);
  526. }
  527. else
  528. {
  529. end = get_insn_number (&arg);
  530. no_chunk (arg);
  531. target_call_history_range (begin, end, flags);
  532. }
  533. }
  534. else
  535. {
  536. no_chunk (arg);
  537. target_call_history_from (begin, size, flags);
  538. }
  539. dont_repeat ();
  540. }
  541. }
  542. /* Helper for "set record instruction-history-size" and "set record
  543. function-call-history-size" input validation. COMMAND_VAR is the
  544. variable registered in the command as control variable. *SETTING
  545. is the real setting the command allows changing. */
  546. static void
  547. validate_history_size (unsigned int *command_var, unsigned int *setting)
  548. {
  549. if (*command_var != UINT_MAX && *command_var > INT_MAX)
  550. {
  551. unsigned int new_value = *command_var;
  552. /* Restore previous value. */
  553. *command_var = *setting;
  554. error (_("integer %u out of range"), new_value);
  555. }
  556. /* Commit new value. */
  557. *setting = *command_var;
  558. }
  559. /* Called by do_setshow_command. We only want values in the
  560. [0..INT_MAX] range, while the command's machinery accepts
  561. [0..UINT_MAX]. See command_size_to_target_size. */
  562. static void
  563. set_record_insn_history_size (const char *args, int from_tty,
  564. struct cmd_list_element *c)
  565. {
  566. validate_history_size (&record_insn_history_size_setshow_var,
  567. &record_insn_history_size);
  568. }
  569. /* Called by do_setshow_command. We only want values in the
  570. [0..INT_MAX] range, while the command's machinery accepts
  571. [0..UINT_MAX]. See command_size_to_target_size. */
  572. static void
  573. set_record_call_history_size (const char *args, int from_tty,
  574. struct cmd_list_element *c)
  575. {
  576. validate_history_size (&record_call_history_size_setshow_var,
  577. &record_call_history_size);
  578. }
  579. void _initialize_record ();
  580. void
  581. _initialize_record ()
  582. {
  583. struct cmd_list_element *c;
  584. add_setshow_zuinteger_cmd ("record", no_class, &record_debug,
  585. _("Set debugging of record/replay feature."),
  586. _("Show debugging of record/replay feature."),
  587. _("When enabled, debugging output for "
  588. "record/replay feature is displayed."),
  589. NULL, show_record_debug, &setdebuglist,
  590. &showdebuglist);
  591. add_setshow_uinteger_cmd ("instruction-history-size", no_class,
  592. &record_insn_history_size_setshow_var, _("\
  593. Set number of instructions to print in \"record instruction-history\"."), _("\
  594. Show number of instructions to print in \"record instruction-history\"."), _("\
  595. A size of \"unlimited\" means unlimited instructions. The default is 10."),
  596. set_record_insn_history_size, NULL,
  597. &set_record_cmdlist, &show_record_cmdlist);
  598. add_setshow_uinteger_cmd ("function-call-history-size", no_class,
  599. &record_call_history_size_setshow_var, _("\
  600. Set number of function to print in \"record function-call-history\"."), _("\
  601. Show number of functions to print in \"record function-call-history\"."), _("\
  602. A size of \"unlimited\" means unlimited lines. The default is 10."),
  603. set_record_call_history_size, NULL,
  604. &set_record_cmdlist, &show_record_cmdlist);
  605. cmd_list_element *record_cmd
  606. = add_prefix_cmd ("record", class_obscure, cmd_record_start,
  607. _("Start recording."),
  608. &record_cmdlist, 0, &cmdlist);
  609. set_cmd_completer (record_cmd, filename_completer);
  610. add_com_alias ("rec", record_cmd, class_obscure, 1);
  611. set_show_commands setshow_record_cmds
  612. = add_setshow_prefix_cmd ("record", class_support,
  613. _("Set record options."),
  614. _("Show record options."),
  615. &set_record_cmdlist, &show_record_cmdlist,
  616. &setlist, &showlist);
  617. add_alias_cmd ("rec", setshow_record_cmds.set, class_obscure, 1, &setlist);
  618. add_alias_cmd ("rec", setshow_record_cmds.show, class_obscure, 1, &showlist);
  619. cmd_list_element *info_record_cmd
  620. = add_prefix_cmd ("record", class_support, info_record_command,
  621. _("Info record options."), &info_record_cmdlist,
  622. 0, &infolist);
  623. add_alias_cmd ("rec", info_record_cmd, class_obscure, 1, &infolist);
  624. c = add_cmd ("save", class_obscure, cmd_record_save,
  625. _("Save the execution log to a file.\n\
  626. Usage: record save [FILENAME]\n\
  627. Default filename is 'gdb_record.PROCESS_ID'."),
  628. &record_cmdlist);
  629. set_cmd_completer (c, filename_completer);
  630. cmd_list_element *record_delete_cmd
  631. = add_cmd ("delete", class_obscure, cmd_record_delete,
  632. _("Delete the rest of execution log and start recording it \
  633. anew."),
  634. &record_cmdlist);
  635. add_alias_cmd ("d", record_delete_cmd, class_obscure, 1, &record_cmdlist);
  636. add_alias_cmd ("del", record_delete_cmd, class_obscure, 1, &record_cmdlist);
  637. cmd_list_element *record_stop_cmd
  638. = add_cmd ("stop", class_obscure, cmd_record_stop,
  639. _("Stop the record/replay target."),
  640. &record_cmdlist);
  641. add_alias_cmd ("s", record_stop_cmd, class_obscure, 1, &record_cmdlist);
  642. add_prefix_cmd ("goto", class_obscure, cmd_record_goto, _("\
  643. Restore the program to its state at instruction number N.\n\
  644. Argument is instruction number, as shown by 'info record'."),
  645. &record_goto_cmdlist, 1, &record_cmdlist);
  646. cmd_list_element *record_goto_begin_cmd
  647. = add_cmd ("begin", class_obscure, cmd_record_goto_begin,
  648. _("Go to the beginning of the execution log."),
  649. &record_goto_cmdlist);
  650. add_alias_cmd ("start", record_goto_begin_cmd, class_obscure, 1,
  651. &record_goto_cmdlist);
  652. add_cmd ("end", class_obscure, cmd_record_goto_end,
  653. _("Go to the end of the execution log."),
  654. &record_goto_cmdlist);
  655. add_cmd ("instruction-history", class_obscure, cmd_record_insn_history, _("\
  656. Print disassembled instructions stored in the execution log.\n\
  657. With a /m or /s modifier, source lines are included (if available).\n\
  658. With a /r modifier, raw instructions in hex are included.\n\
  659. With a /f modifier, function names are omitted.\n\
  660. With a /p modifier, current position markers are omitted.\n\
  661. With no argument, disassembles ten more instructions after the previous \
  662. disassembly.\n\
  663. \"record instruction-history -\" disassembles ten instructions before a \
  664. previous disassembly.\n\
  665. One argument specifies an instruction number as shown by 'info record', and \
  666. ten instructions are disassembled after that instruction.\n\
  667. Two arguments with comma between them specify starting and ending instruction \
  668. numbers to disassemble.\n\
  669. If the second argument is preceded by '+' or '-', it specifies the distance \
  670. from the first argument.\n\
  671. The number of instructions to disassemble can be defined with \"set record \
  672. instruction-history-size\"."),
  673. &record_cmdlist);
  674. add_cmd ("function-call-history", class_obscure, cmd_record_call_history, _("\
  675. Prints the execution history at function granularity.\n\
  676. It prints one line for each sequence of instructions that belong to the same \
  677. function.\n\
  678. Without modifiers, it prints the function name.\n\
  679. With a /l modifier, the source file and line number range is included.\n\
  680. With a /i modifier, the instruction number range is included.\n\
  681. With a /c modifier, the output is indented based on the call stack depth.\n\
  682. With no argument, prints ten more lines after the previous ten-line print.\n\
  683. \"record function-call-history -\" prints ten lines before a previous ten-line \
  684. print.\n\
  685. One argument specifies a function number as shown by 'info record', and \
  686. ten lines are printed after that function.\n\
  687. Two arguments with comma between them specify a range of functions to print.\n\
  688. If the second argument is preceded by '+' or '-', it specifies the distance \
  689. from the first argument.\n\
  690. The number of functions to print can be defined with \"set record \
  691. function-call-history-size\"."),
  692. &record_cmdlist);
  693. /* Sync command control variables. */
  694. record_insn_history_size_setshow_var = record_insn_history_size;
  695. record_call_history_size_setshow_var = record_call_history_size;
  696. }