This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GDB MI Reverse Commands added [1 of 3]


Cool!  Thanks for your work.  :)


Hui

On Wed, Aug 26, 2009 at 22:37, Jakob Engblom<jakob@virtutech.com> wrote:
> Here are the patches adding the MI commands for reverse execution to gdb.
>
> Changelog entry: "Added reverse debugging support to gdb MI"
>
> cvs diff: Diffing gdb/mi
> Index: gdb/mi/mi-main.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/mi/mi-main.c,v
> retrieving revision 1.156
> diff -c -p -r1.156 mi-main.c
> *** gdb/mi/mi-main.c??? 2 Jul 2009 17:25:59 -0000?????? 1.156
> --- gdb/mi/mi-main.c??? 25 Aug 2009 14:40:18 -0000
> *************** static void mi_cmd_execute (struct mi_pa
> *** 88,94 ****
>
> ? static void mi_execute_cli_command (const char *cmd, int args_p,
> ??????????????????????????????????? const char *args);
> ! static void mi_execute_async_cli_command (char *cli_command,
> ????????????? ??????????????????????????????????????????char **argv, int argc);
> ? static int register_changed_p (int regnum, struct regcache *,
> ?????????????????????????????? struct regcache *);
> --- 88,94 ----
>
> ? static void mi_execute_cli_command (const char *cmd, int args_p,
> ??????????????????????????????????? const char *args);
> ! static void mi_execute_async_cli_command (char *cli_command,
> ??????????????????????????????????????????????????????? char **argv, int argc);
> ? static int register_changed_p (int regnum, struct regcache *,
> ?????????????????????????????? struct regcache *);
> *************** void
> *** 119,153 ****
> ? mi_cmd_exec_next (char *command, char **argv, int argc)
> ? {
> ??? /* FIXME: Should call a libgdb function, not a cli wrapper.? */
> !?? mi_execute_async_cli_command ("next", argv, argc);
> ? }
>
> ? void
> ? mi_cmd_exec_next_instruction (char *command, char **argv, int argc)
> ? {
> ??? /* FIXME: Should call a libgdb function, not a cli wrapper.? */
> !?? mi_execute_async_cli_command ("nexti", argv, argc);
> ? }
>
> ? void
> ? mi_cmd_exec_step (char *command, char **argv, int argc)
> ? {
> ??? /* FIXME: Should call a libgdb function, not a cli wrapper.? */
> !?? mi_execute_async_cli_command ("step", argv, argc);
> ? }
>
> ? void
> ? mi_cmd_exec_step_instruction (char *command, char **argv, int argc)
> ? {
> ??? /* FIXME: Should call a libgdb function, not a cli wrapper.? */
> !?? mi_execute_async_cli_command ("stepi", argv, argc);
> ? }
>
> ? void
> ? mi_cmd_exec_finish (char *command, char **argv, int argc)
> ? {
> ??? /* FIXME: Should call a libgdb function, not a cli wrapper.? */
> !?? mi_execute_async_cli_command ("finish", argv, argc);
> ? }
>
> ? void
> --- 119,168 ----
> ? mi_cmd_exec_next (char *command, char **argv, int argc)
> ? {
> ??? /* FIXME: Should call a libgdb function, not a cli wrapper.? */
> !?? if (argc > 0 && strcmp(argv[0], "--reverse") == 0)
> !???? mi_execute_async_cli_command ("reverse-next", argv + 1, argc - 1);
> !?? else
> !???? mi_execute_async_cli_command ("next", argv, argc);
> ? }
>
> ? void
> ? mi_cmd_exec_next_instruction (char *command, char **argv, int argc)
> ? {
> ??? /* FIXME: Should call a libgdb function, not a cli wrapper.? */
> !?? if (argc > 0 && strcmp(argv[0], "--reverse") == 0)
> !???? mi_execute_async_cli_command ("reverse-nexti", argv + 1, argc - 1);
> !?? else
> ! ????mi_execute_async_cli_command ("nexti", argv, argc);
> ? }
>
> ? void
> ? mi_cmd_exec_step (char *command, char **argv, int argc)
> ? {
> ??? /* FIXME: Should call a libgdb function, not a cli wrapper.? */
> !?? if (argc > 0 && strcmp(argv[0], "--reverse") == 0)
> !? ???mi_execute_async_cli_command ("reverse-step", argv + 1, argc - 1);
> !?? else
> !???? mi_execute_async_cli_command ("step", argv, argc);
> ? }
>
> ? void
> ? mi_cmd_exec_step_instruction (char *command, char **argv, int argc)
> ? {
> ??? /* FIXME: Should call a libgdb function, not a cli wrapper.? */
> !?? if (argc > 0 && strcmp(argv[0], "--reverse") == 0)
> !???? mi_execute_async_cli_command ("reverse-stepi", argv + 1, argc - 1);
> !?? else
> !???? mi_execute_async_cli_command ("stepi", argv, argc);
> ? }
>
> ? void
> ? mi_cmd_exec_finish (char *command, char **argv, int argc)
> ? {
> ??? /* FIXME: Should call a libgdb function, not a cli wrapper.? */
> !?? if (argc > 0 && strcmp(argv[0], "--reverse") == 0)
> !???? mi_execute_async_cli_command ("reverse-finish", argv + 1, argc - 1);
> !?? else
> !???? mi_execute_async_cli_command ("finish", argv, argc);
> ? }
>
> ? void
> *************** mi_cmd_exec_jump (char *args, char **arg
> *** 175,181 ****
> ??? /* FIXME: Should call a libgdb function, not a cli wrapper.? */
> ??? return mi_execute_async_cli_command ("jump", argv, argc);
> ? }
> !
> ? static int
> ? proceed_thread_callback (struct thread_info *thread, void *arg)
> ? {
> --- 190,196 ----
> ??? /* FIXME: Should call a libgdb function, not a cli wrapper.? */
> ??? return mi_execute_async_cli_command ("jump", argv, argc);
> ? }
> !
> ? static int
> ? proceed_thread_callback (struct thread_info *thread, void *arg)
> ? {
> *************** proceed_thread_callback (struct thread_i
> *** 193,200 ****
> ??? return 0;
> ? }
>
> ! void
> ! mi_cmd_exec_continue (char *command, char **argv, int argc)
> ? {
> ??? if (argc == 0)
> ????? continue_1 (0);
> --- 208,215 ----
> ??? return 0;
> ? }
>
> ! static void
> ! exec_continue (char **argv, int argc)
> ? {
> ??? if (argc == 0)
> ????? continue_1 (0);
> *************** mi_cmd_exec_continue (char *command, cha
> *** 212,221 ****
>
> ????? ??old_chain = make_cleanup_restore_current_thread ();
> ??????? iterate_over_threads (proceed_thread_callback, &pid);
> !?????? do_cleanups (old_chain);
> ????? }
> ??? else
> !???? error ("Usage: -exec-continue [--all|--thread-group id]");
> ? }
>
> ? static int
> --- 227,276 ----
>
> ??????? old_chain = make_cleanup_restore_current_thread ();
> ??????? iterate_over_threads (proceed_thread_callback, &pid);
> !?????? do_cleanups (old_chain);
> ????? }
> ??? else
> !???? error ("Usage: -exec-continue [--reverse] [--all|--thread-group id]");
> ! }
> !
> ! /* continue in reverse direction:
> !??? XXX: code duplicated from reverse.c */
> !
> ! static void
> ! exec_direction_default (void *notused)
> ! {
> !?? /* Return execution direction to default state.? */
> !?? execution_direction = EXEC_FORWARD;
> ! }
> !
> ! static void
> ! exec_reverse_continue (char **argv, int argc)
> ! {
> !?? enum exec_direction_kind dir = execution_direction;
> !?? struct cleanup *old_chain;
> !
> !?? if (dir == EXEC_ERROR)
> !???? error (_("Target %s does not support this command."), target_shortname);
> !
> !?? if (dir == EXEC_REVERSE)
> !???? error (_("Already in reverse mode."));
> !
> !?? if (!target_can_execute_reverse)
> !???? error (_("Target %s does not support this command."), target_shortname);
> !
> !?? old_chain = make_cleanup (exec_direction_default, NULL);
> !?? execution_direction = EXEC_REVERSE;
> !?? exec_continue (argv, argc);
> !?? do_cleanups (old_chain);
> ! }
> !
> ! void
> ! mi_cmd_exec_continue (char *command, char **argv, int argc)
> ! {
> !?? if (argc > 0 && strcmp(argv[0], "--reverse") == 0)
> !???? exec_reverse_continue (argv + 1, argc - 1);
> !?? else
> !???? exec_continue (argv, argc);
> ? }
>
> ? static int
> *************** mi_cmd_exec_interrupt (char *command, ch
> *** 252,258 ****
> ????? {
> ??????? if (!any_running ())
> ??????? error ("Inferior not running.");
> !
> ??????? interrupt_target_1 (1);
> ????? }
> ??? else if (argc == 2 && strcmp (argv[0], "--thread-group") == 0)
> --- 307,313 ----
> ????? {
> ??????? if (!any_running ())
> ??????? error ("Inferior not running.");
> !
> ??????? interrupt_target_1 (1);
> ????? }
> ??? else if (argc == 2 && strcmp (argv[0], "--thread-group") == 0)
> *************** void
> *** 349,355 ****
> ? mi_cmd_thread_info (char *command, char **argv, int argc)
> ? {
> ??? int thread = -1;
> !
> ??? if (argc != 0 && argc != 1)
> ????? error ("Invalid MI command");
>
> --- 404,410 ----
> ? mi_cmd_thread_info (char *command, char **argv, int argc)
> ? {
> ??? int thread = -1;
> !
> ??? if (argc != 0 && argc != 1)
> ????? error ("Invalid MI command");
>
> *************** print_one_inferior (struct inferior *inf
> *** 367,373 ****
> ??? ui_out_field_fmt (uiout, "id", "%d", inferior->pid);
> ??? ui_out_field_string (uiout, "type", "process");
> ??? ui_out_field_int (uiout, "pid", inferior->pid);
> !
> ??? do_cleanups (back_to);
> ??? return 0;
> ? }
> --- 422,428 ----
> ??? ui_out_field_fmt (uiout, "id", "%d", inferior->pid);
> ??? ui_out_field_string (uiout, "type", "process");
> ??? ui_out_field_int (uiout, "pid", inferior->pid);
> !
> ??? do_cleanups (back_to);
> ??? return 0;
> ? }
> *************** mi_cmd_list_thread_groups (char *command
> *** 433,446 ****
> ??????? int pid = atoi (id);
> ??????? if (!in_inferior_list (pid))
> ??????? error ("Invalid thread group id '%s'", id);
> !?????? print_thread_info (uiout, -1, pid);
> ????? }
> ??? else
> ????? {
> ??????? make_cleanup_ui_out_list_begin_end (uiout, "groups");
> ??????? iterate_over_inferiors (print_one_inferior, NULL);
> ????? }
> !
> ??? do_cleanups (back_to);
> ? }
>
> --- 488,501 ----
> ??????? int pid = atoi (id);
> ??????? if (!in_inferior_list (pid))
> ??????? error ("Invalid thread group id '%s'", id);
> !?????? print_thread_info (uiout, -1, pid);
> ????? }
> ??? else
> ????? {
> ??????? make_cleanup_ui_out_list_begin_end (uiout, "groups");
> ??????? iterate_over_inferiors (print_one_inferior, NULL);
> ????? }
> !
> ??? do_cleanups (back_to);
> ? }
>
> *************** get_register (struct frame_info *frame,
> *** 713,719 ****
> ? }
>
> ? /* Write given values into registers. The registers and values are
> !??? given as pairs.? The corresponding MI command is
> ???? -data-write-register-values <format> [<regnum1> <value1>...<regnumN>
> <valueN>]*/
> ? void
> ? mi_cmd_data_write_register_values (char *command, char **argv, int argc)
> --- 768,774 ----
> ? }
>
> ? /* Write given values into registers. The registers and values are
> !??? given as pairs.? The corresponding MI command is
> ???? -data-write-register-values <format> [<regnum1> <value1>...<regnumN>
> <valueN>]*/
> ? void
> ? mi_cmd_data_write_register_values (char *command, char **argv, int argc)
> *************** mi_cmd_data_evaluate_expression (char *c
> *** 810,816 ****
> ? /* DATA-MEMORY-READ:
>
> ???? ADDR: start address of data to be dumped.
> !??? WORD-FORMAT: a char indicating format for the ``word''.? See
> ???? the ``x'' command.
> ???? WORD-SIZE: size of each ``word''; 1,2,4, or 8 bytes.
> ???? NR_ROW: Number of rows.
> --- 865,871 ----
> ? /* DATA-MEMORY-READ:
>
> ???? ADDR: start address of data to be dumped.
> !??? WORD-FORMAT: a char indicating format for the ``word''.? See
> ???? the ``x'' command.
> ???? WORD-SIZE: size of each ``word''; 1,2,4, or 8 bytes.
> ???? NR_ROW: Number of rows.
> *************** mi_cmd_data_evaluate_expression (char *c
> *** 823,829 ****
>
> ???? {addr="...",rowN={wordN="..." ,... [,ascii="..."]}, ...}
>
> !??? Returns:
> ???? The number of bytes read is SIZE*ROW*COL. */
>
> ? void
> --- 878,884 ----
>
> ???? {addr="...",rowN={wordN="..." ,... [,ascii="..."]}, ...}
>
> !??? Returns:
> ???? The number of bytes read is SIZE*ROW*COL. */
>
> ? void
> *************** mi_cmd_data_read_memory (char *command,
> *** 1019,1025 ****
> ???? ADDR: start address of the row in the memory grid where the memory
> ???? cell is, if OFFSET_COLUMN is specified.? Otherwise, the address of
> ???? the location to write to.
> !??? FORMAT: a char indicating format for the ``word''.? See
> ???? the ``x'' command.
> ???? WORD_SIZE: size of each ``word''; 1,2,4, or 8 bytes
> ???? VALUE: value to be written into the memory address.
> --- 1074,1080 ----
> ???? ADDR: start address of the row in the memory grid where the memory
> ???? cell is, if OFFSET_COLUMN is specified.? Otherwise, the address of
> ???? the location to write to.
> !??? FORMAT: a char indicating format for the ``word''.? See
> ???? the ``x'' command.
> ?? ??WORD_SIZE: size of each ``word''; 1,2,4, or 8 bytes
> ???? VALUE: value to be written into the memory address.
> *************** mi_cmd_enable_timings (char *command, ch
> *** 1112,1118 ****
> ????? }
> ??? else
> ????? goto usage_error;
> !
> ??? return;
>
> ?? usage_error:
> --- 1167,1173 ----
> ????? }
> ??? else
> ????? goto usage_error;
> !
> ??? return;
>
> ?? usage_error:
> *************** mi_cmd_list_features (char *command, cha
> *** 1125,1140 ****
> ??? if (argc == 0)
> ????? {
> ??????? struct cleanup *cleanup = NULL;
> !?????? cleanup = make_cleanup_ui_out_list_begin_end (uiout, "features");
>
> ??????? ui_out_field_string (uiout, NULL, "frozen-varobjs");
> ??????? ui_out_field_string (uiout, NULL, "pending-breakpoints");
> ??????? ui_out_field_string (uiout, NULL, "thread-info");
> !
> ? #if HAVE_PYTHON
> ??????? ui_out_field_string (uiout, NULL, "python");
> ? #endif
> !
> ??????? do_cleanups (cleanup);
> ??????? return;
> ????? }
> --- 1180,1195 ----
> ??? if (argc == 0)
> ????? {
> ??????? struct cleanup *cleanup = NULL;
> !?????? cleanup = make_cleanup_ui_out_list_begin_end (uiout, "features");
>
> ??????? ui_out_field_string (uiout, NULL, "frozen-varobjs");
> ??????? ui_out_field_string (uiout, NULL, "pending-breakpoints");
> ??????? ui_out_field_string (uiout, NULL, "thread-info");
> !
> ? #if HAVE_PYTHON
> ??????? ui_out_field_string (uiout, NULL, "python");
> ? #endif
> !
> ??????? do_cleanups (cleanup);
> ??????? return;
> ????? }
> *************** mi_cmd_list_target_features (char *comma
> *** 1148,1158 ****
> ??? if (argc == 0)
> ????? {
> ??????? struct cleanup *cleanup = NULL;
> ! ??????cleanup = make_cleanup_ui_out_list_begin_end (uiout, "features");
>
> ??????? if (target_can_async_p ())
> ??????? ui_out_field_string (uiout, NULL, "async");
> !
> ??????? do_cleanups (cleanup);
> ??????? return;
> ????? }
> --- 1203,1213 ----
> ??? if (argc == 0)
> ????? {
> ??????? struct cleanup *cleanup = NULL;
> !?????? cleanup = make_cleanup_ui_out_list_begin_end (uiout, "features");
>
> ??????? if (target_can_async_p ())
> ??????? ui_out_field_string (uiout, NULL, "async");
> !
> ??????? do_cleanups (cleanup);
> ??????? return;
> ????? }
> *************** captured_mi_execute_command (struct ui_o
> *** 1196,1203 ****
> ??????? /* Print the result if there were no errors.
>
> ???????? Remember that on the way out of executing a command, you have
> !??????? to directly use the mi_interp's uiout, since the command could
> !??????? have reset the interpreter, in which case the current uiout
> ???????? will most likely crash in the mi_out_* routines.? */
> ??????? if (!running_result_record_printed)
> ??????? {
> --- 1251,1258 ----
> ??????? /* Print the result if there were no errors.
>
> ???????? Remember that on the way out of executing a command, you have
> !??????? to directly use the mi_interp's uiout, since the command could
> !??????? have reset the interpreter, in which case the current uiout
> ???????? will most likely crash in the mi_out_* routines.? */
> ??????? if (!running_result_record_printed)
> ??????? {
> *************** captured_mi_execute_command (struct ui_o
> *** 1244,1250 ****
> ??????????????? mi_out_put (uiout, raw_stdout);
> ??????????????? mi_out_rewind (uiout);
> ??????????????? mi_print_timing_maybe ();
> !?????????????? fputs_unfiltered ("\n", raw_stdout);
> ????????????? }
> ??????????? else
> ????????????? mi_out_rewind (uiout);
> --- 1299,1305 ----
> ??????????????? mi_out_put (uiout, raw_stdout);
> ??????????????? mi_out_rewind (uiout);
> ??????????????? mi_print_timing_maybe ();
> !?????????????? fputs_unfiltered ("\n", raw_stdout);
> ????????????? }
> ??????????? else
> ????????????? mi_out_rewind (uiout);
> *************** mi_execute_command (char *cmd, int from_
> *** 1302,1310 ****
> ??????? }
>
> ??????? if (/* The notifications are only output when the top-level
> !??????????? interpreter (specified on the command line) is MI.? */
> ????????? ui_out_is_mi_like_p (interp_ui_out (top_level_interpreter ()))
> !???????? /* Don't try report anything if there are no threads --
> ???????????? the program is dead.? */
> ????????? && thread_count () != 0
> ????????? /* -thread-select explicitly changes thread. If frontend uses that
> --- 1357,1365 ----
> ??????? }
>
> ??????? if (/* The notifications are only output when the top-level
> !??????????? interpreter (specified on the command line) is MI.? */
> ????????? ui_out_is_mi_like_p (interp_ui_out (top_level_interpreter ()))
> !???????? /* Don't try report anything if there are no threads --
> ???? ????????the program is dead.? */
> ????????? && thread_count () != 0
> ????????? /* -thread-select explicitly changes thread. If frontend uses that
> *************** mi_execute_command (char *cmd, int from_
> *** 1328,1337 ****
> ??????????? }
>
> ????????? if (report_change)
> !?????????? {
> ????????????? struct thread_info *ti = inferior_thread ();
> ????????????? target_terminal_ours ();
> !???????????? fprintf_unfiltered (mi->event_channel,
> ????????????????????????????????? "thread-selected,id=\"%d\"",
> ??????????????????? ??????????????ti->num);
> ????????????? gdb_flush (mi->event_channel);
> --- 1383,1392 ----
> ??????????? }
>
> ????????? if (report_change)
> !?????????? {
> ????????????? struct thread_info *ti = inferior_thread ();
> ????????????? target_terminal_ours ();
> !?????????? ??fprintf_unfiltered (mi->event_channel,
> ????????????????????????????????? "thread-selected,id=\"%d\"",
> ????????????????????????????????? ti->num);
> ????????????? gdb_flush (mi->event_channel);
> *************** mi_execute_async_cli_command (char *cli_
> *** 1446,1452 ****
> ????? run = xstrprintf ("%s %s&", cli_command, argc ? *argv : "");
> ??? else
> ????? run = xstrprintf ("%s %s", cli_command, argc ? *argv : "");
> !?? old_cleanups = make_cleanup (xfree, run);
>
> ??? execute_command ( /*ui */ run, 0 /*from_tty */ );
>
> --- 1501,1507 ----
> ????? run = xstrprintf ("%s %s&", cli_command, argc ? *argv : "");
> ??? else
> ????? run = xstrprintf ("%s %s", cli_command, argc ? *argv : "");
> !?? old_cleanups = make_cleanup (xfree, run);
>
> ??? execute_command ( /*ui */ run, 0 /*from_tty */ );
>
> *************** mi_load_progress (const char *section_na
> *** 1551,1557 ****
> ??? uiout = saved_uiout;
> ? }
>
> ! static void
> ? timestamp (struct mi_timestamp *tv)
> ??? {
> ????? long usec;
> --- 1606,1612 ----
> ??? uiout = saved_uiout;
> ? }
>
> ! static void
> ? timestamp (struct mi_timestamp *tv)
> ??? {
> ????? long usec;
> *************** timestamp (struct mi_timestamp *tv)
> *** 1571,1577 ****
> ? #endif
> ??? }
>
> ! static void
> ? print_diff_now (struct mi_timestamp *start)
> ??? {
> ????? struct mi_timestamp now;
> --- 1626,1632 ----
> ? #endif
> ??? }
>
> ! static void
> ? print_diff_now (struct mi_timestamp *start)
> ??? {
> ????? struct mi_timestamp now;
> *************** mi_print_timing_maybe (void)
> *** 1588,1607 ****
> ????? print_diff_now (current_command_ts);
> ? }
>
> ! static long
> ? timeval_diff (struct timeval start, struct timeval end)
> ??? {
> ????? return ((end.tv_sec - start.tv_sec) * 1000000L)
> ??????? + (end.tv_usec - start.tv_usec);
> ??? }
>
> ! static void
> ? print_diff (struct mi_timestamp *start, struct mi_timestamp *end)
> ??? {
> ????? fprintf_unfiltered
> ??????? (raw_stdout,
> !??????? ",time={wallclock=\"%0.5f\",user=\"%0.5f\",system=\"%0.5f\"}",
> !??????? timeval_diff (start->wallclock, end->wallclock) / 1000000.0,
> !??????? timeval_diff (start->utime, end->utime) / 1000000.0,
> ???????? timeval_diff (start->stime, end->stime) / 1000000.0);
> ??? }
> --- 1643,1662 ----
> ????? print_diff_now (current_command_ts);
> ? }
>
> ! static long
> ? timeval_diff (struct timeval start, struct timeval end)
> ??? {
> ????? return ((end.tv_sec - start.tv_sec) * 1000000L)
> ??????? + (end.tv_usec - start.tv_usec);
> ??? }
>
> ! static void
> ? print_diff (struct mi_timestamp *start, struct mi_timestamp *end)
> ??? {
> ????? fprintf_unfiltered
> ??????? (raw_stdout,
> !??????? ",time={wallclock=\"%0.5f\",user=\"%0.5f\",system=\"%0.5f\"}",
> ! ???????timeval_diff (start->wallclock, end->wallclock) / 1000000.0,
> !??????? timeval_diff (start->utime, end->utime) / 1000000.0,
> ???????? timeval_diff (start->stime, end->stime) / 1000000.0);
> ??? }
>
>
> Best regards,
>
> /jakob
>
> _______________________________________________________
>
> Jakob Engblom, PhD, Technical Marketing Manager
>
> Virtutech?????????????????? Direct: +46 8 690 07 47
> Drottningholmsvägen 22????? Mobile: +46 709 242 646
> 11243 Stockholm???????????? Web:??? www.virtutech.com
> Sweden
> ________________________________________________________
>
>
>
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]