From 0bd1ef2ac65a1b832a45b70437f84925f5218e8d Mon Sep 17 00:00:00 2001 From: Michael Snyder Date: Wed, 8 Oct 2008 00:26:49 +0000 Subject: 2008-10-07 Michael Snyder * target.h (to_set_exec_direction, to_get_exec_direction): Remove. (to_can_execute_reverse): New method. (enum exec_direction_kind): Move to inferior.h. * target.c (update_current_target): Inherit to_can_execute_reverse. Remove to_set_exec_direction, to_get_exec_direction. * inferior.h (enum exec_direction_kind): Move from target.h. * infrun.c (set_exec_direction_func): Move here from reverse.c. (show_exec_direction_func): Ditto. (proceed): Consult global execution_direction instead of target method. (handle_inferior_event): Ditto. * reverse.c (set_exec_direction_func): Move to infrun.c (show_exec_direction_func): Ditto. (exec_direction_default): Set infrun global variable. (exec_reverse_once): Consult infrun global direction variable. * infcmd.c (step_1): Consult infrun global direction variable. (step_once): Ditto. (until_next_command): Ditto. (finish_command): Ditto. * record.h (record_exec_direction): Delete. (RECORD_IS_REPLAY): Consult infrun global direction variable. * record.c: (record_wait_cleanups): Use infrun state variable. (record_wait): Ditto. (record_get_exec_direction, record_set_exec_direction): Remove. (record_can_execute_reverse): New target method. * remote.c (remote_resume): Use infrun state variable. (remote_get_exec_direction, remote_set_exec_direction): Remove. (remote_can_execute_reverse): New target method. --- gdb/ChangeLog | 37 ++++++++++++++++++++++++++ gdb/infcmd.c | 12 ++++----- gdb/inferior.h | 10 +++++++ gdb/infrun.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++--------- gdb/record.c | 45 ++++++++----------------------- gdb/record.h | 3 +-- gdb/remote.c | 35 +++++-------------------- gdb/reverse.c | 73 +++++---------------------------------------------- gdb/target.c | 3 +-- gdb/target.h | 29 +++++--------------- 10 files changed, 155 insertions(+), 175 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e5ea04e1ee9..a0520701a12 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,40 @@ +2008-10-07 Michael Snyder + + * target.h (to_set_exec_direction, to_get_exec_direction): Remove. + (to_can_execute_reverse): New method. + (enum exec_direction_kind): Move to inferior.h. + * target.c (update_current_target): Inherit to_can_execute_reverse. + Remove to_set_exec_direction, to_get_exec_direction. + * inferior.h (enum exec_direction_kind): Move from target.h. + + * infrun.c (set_exec_direction_func): Move here from reverse.c. + (show_exec_direction_func): Ditto. + (proceed): Consult global execution_direction instead of + target method. + (handle_inferior_event): Ditto. + + * reverse.c (set_exec_direction_func): Move to infrun.c + (show_exec_direction_func): Ditto. + (exec_direction_default): Set infrun global variable. + (exec_reverse_once): Consult infrun global direction variable. + + * infcmd.c (step_1): Consult infrun global direction variable. + (step_once): Ditto. + (until_next_command): Ditto. + (finish_command): Ditto. + + * record.h (record_exec_direction): Delete. + (RECORD_IS_REPLAY): Consult infrun global direction variable. + + * record.c: (record_wait_cleanups): Use infrun state variable. + (record_wait): Ditto. + (record_get_exec_direction, record_set_exec_direction): Remove. + (record_can_execute_reverse): New target method. + + * remote.c (remote_resume): Use infrun state variable. + (remote_get_exec_direction, remote_set_exec_direction): Remove. + (remote_can_execute_reverse): New target method. + 2008-10-07 Michael Snyder * infrun.c (stepped_into_function): Rename handle_step_into_function. diff --git a/gdb/infcmd.c b/gdb/infcmd.c index e0a4e02d31b..ba8367e42eb 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -824,7 +824,7 @@ step_1 (int skip_subroutines, int single_inst, char *count_string) error (_("No current frame")); step_frame_id = get_frame_id (frame); - if (target_get_execution_direction () == EXEC_REVERSE) + if (execution_direction == EXEC_REVERSE) { frame = get_prev_frame (frame); if (frame) @@ -942,7 +942,7 @@ step_once (int skip_subroutines, int single_inst, int count, int thread) error (_("No current frame")); step_frame_id = get_frame_id (frame); - if (target_get_execution_direction () == EXEC_REVERSE) + if (execution_direction == EXEC_REVERSE) { frame = get_prev_frame (frame); if (frame) @@ -1221,7 +1221,7 @@ until_next_command (int from_tty) step_over_calls = STEP_OVER_ALL; step_frame_id = get_frame_id (frame); - if (target_get_execution_direction () == EXEC_REVERSE) + if (execution_direction == EXEC_REVERSE) { frame = get_prev_frame (frame); if (frame) @@ -1501,7 +1501,7 @@ finish_command (char *arg, int from_tty) error (_("Asynchronous execution not supported on this target.")); /* Don't try to async in reverse. */ - if (async_exec && target_get_execution_direction () == EXEC_REVERSE) + if (async_exec && execution_direction == EXEC_REVERSE) error (_("Asynchronous 'finish' not supported in reverse.")); /* If we are not asked to run in the bg, then prepare to run in the @@ -1531,7 +1531,7 @@ finish_command (char *arg, int from_tty) source. */ if (from_tty) { - if (target_get_execution_direction () == EXEC_REVERSE) + if (execution_direction == EXEC_REVERSE) printf_filtered (_("Run back to call of ")); else printf_filtered (_("Run till exit from ")); @@ -1539,7 +1539,7 @@ finish_command (char *arg, int from_tty) print_stack_frame (get_selected_frame (NULL), 1, LOCATION); } - if (target_get_execution_direction () == EXEC_REVERSE) + if (execution_direction == EXEC_REVERSE) { /* Split off at this point. */ finish_backward (function); diff --git a/gdb/inferior.h b/gdb/inferior.h index 7347a21a8c3..eb1f4f08e35 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -386,6 +386,16 @@ enum stop_kind extern enum stop_kind stop_soon; +/* Reverse execution. */ +enum exec_direction_kind + { + EXEC_FORWARD, + EXEC_REVERSE, + EXEC_ERROR + }; + +extern enum exec_direction_kind execution_direction; + /* Nonzero if proceed is being used for a "finish" command or a similar situation when stop_registers should be saved. */ diff --git a/gdb/infrun.c b/gdb/infrun.c index 4bd620976f4..13887a0d15f 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -1223,7 +1223,7 @@ proceed (CORE_ADDR addr, enum target_signal siggnal, int step) if (addr == (CORE_ADDR) -1) { if (pc == stop_pc && breakpoint_here_p (pc) - && target_get_execution_direction () != EXEC_REVERSE) + && execution_direction != EXEC_REVERSE) /* There is a breakpoint at the address we will resume at, step one instruction before inserting breakpoints so that we do not stop right away (and report a second hit at this @@ -2642,7 +2642,7 @@ targets should add new threads to the thread list themselves in non-stop mode.") = !(bpstat_explains_signal (stop_bpstat) || stepping_over_breakpoint || (step_range_end && step_resume_breakpoint == NULL) - || (target_get_execution_direction () == EXEC_REVERSE) + || (execution_direction == EXEC_REVERSE) || RECORD_IS_USED); else { @@ -2882,7 +2882,7 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (!gdbarch_get_longjmp_target)\n"); return; } if (stop_pc == ecs->stop_func_start - && target_get_execution_direction () == EXEC_REVERSE) + && execution_direction == EXEC_REVERSE) { /* We are stepping over a function call in reverse, and just hit the step-resume breakpoint at the start @@ -3063,7 +3063,7 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (!gdbarch_get_longjmp_target)\n"); keep going back to the call point). */ if (stop_pc == step_range_start && stop_pc != ecs->stop_func_start - && target_get_execution_direction () == EXEC_REVERSE) + && execution_direction == EXEC_REVERSE) { stop_step = 1; print_stop_reason (END_STEPPING_RANGE, 0); @@ -3172,7 +3172,7 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (!gdbarch_get_longjmp_target)\n"); get there, we'll need to single-step back to the caller. */ - if (target_get_execution_direction () == EXEC_REVERSE) + if (execution_direction == EXEC_REVERSE) { if (ecs->stop_func_start == 0) { @@ -3244,7 +3244,7 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (!gdbarch_get_longjmp_target)\n"); tmp_sal = find_pc_line (ecs->stop_func_start, 0); if (tmp_sal.line != 0) { - if (target_get_execution_direction () == EXEC_REVERSE) + if (execution_direction == EXEC_REVERSE) handle_step_into_function_backward (ecs); else handle_step_into_function (ecs); @@ -3263,7 +3263,7 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (!gdbarch_get_longjmp_target)\n"); return; } - if (target_get_execution_direction () == EXEC_REVERSE) + if (execution_direction == EXEC_REVERSE) { /* Set a breakpoint at callee's start address. From there we can step once and be back in the caller. */ @@ -3407,7 +3407,7 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (!gdbarch_get_longjmp_target)\n"); if (debug_infrun) fprintf_unfiltered (gdb_stdlog, "infrun: no line number info\n"); - if (target_get_execution_direction () == EXEC_REVERSE) + if (execution_direction == EXEC_REVERSE) { /* Set a breakpoint at callee's start address. From there we can step once and be back in the caller. */ @@ -3446,7 +3446,7 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (!gdbarch_get_longjmp_target)\n"); return; } - if (target_get_execution_direction () == EXEC_REVERSE + if (execution_direction == EXEC_REVERSE && frame_id_eq (get_frame_id (get_current_frame ()), step_prev_frame_id)) { @@ -3462,11 +3462,11 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (!gdbarch_get_longjmp_target)\n"); } if (!frame_id_eq (get_frame_id (get_current_frame ()), step_frame_id) - && (target_get_execution_direction () == EXEC_REVERSE + && (execution_direction == EXEC_REVERSE || RECORD_IS_USED)) { if (stop_pc != stop_pc_sal.pc - && target_get_execution_direction () == EXEC_REVERSE + && execution_direction == EXEC_REVERSE && step_over_calls == STEP_OVER_ALL) { if (debug_infrun) @@ -3489,9 +3489,9 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (!gdbarch_get_longjmp_target)\n"); } #if 0 if (((stop_pc == stop_pc_sal.pc - && target_get_execution_direction () != EXEC_REVERSE) + && execution_direction != EXEC_REVERSE) || (stop_pc >= stop_pc_sal.pc && stop_pc < stop_pc_sal.end - && target_get_execution_direction () == EXEC_REVERSE)) + && execution_direction == EXEC_REVERSE)) && (tss->current_line != stop_pc_sal.line || tss->current_symtab != stop_pc_sal.symtab)) { @@ -4917,6 +4917,55 @@ save_inferior_ptid (void) } +/* User interface for reverse debugging: + Set exec-direction / show exec-direction commands + (returns error unless target implements to_set_exec_direction method). */ + +enum exec_direction_kind execution_direction = EXEC_FORWARD; +static const char exec_forward[] = "forward"; +static const char exec_reverse[] = "reverse"; +static const char *exec_direction = exec_forward; +static const char *exec_direction_names[] = { + exec_forward, + exec_reverse, + NULL +}; + +static void +set_exec_direction_func (char *args, int from_tty, + struct cmd_list_element *cmd) +{ + if (target_can_execute_reverse) + { + if (!strcmp (exec_direction, exec_forward)) + execution_direction = EXEC_FORWARD; + else if (!strcmp (exec_direction, exec_reverse)) + execution_direction = EXEC_REVERSE; + } +} + +static void +show_exec_direction_func (struct ui_file *out, int from_tty, + struct cmd_list_element *cmd, const char *value) +{ + switch (execution_direction) { + case EXEC_FORWARD: + fprintf_filtered (out, _("Forward.\n")); + break; + case EXEC_REVERSE: + fprintf_filtered (out, _("Reverse.\n")); + break; + case EXEC_ERROR: + default: + fprintf_filtered (out, + _("Forward (target `%s' does not support exec-direction).\n"), + target_shortname); + break; + } +} + +/* User interface for non-stop mode. */ + int non_stop = 0; static int non_stop_1 = 0; @@ -5142,6 +5191,14 @@ breakpoints, even if such is supported by the target."), &maintenance_set_cmdlist, &maintenance_show_cmdlist); + add_setshow_enum_cmd ("exec-direction", class_run, exec_direction_names, + &exec_direction, _("Set direction of execution.\n\ +Options are 'forward' or 'reverse'."), + _("Show direction of execution (forward/reverse)."), + _("Tells gdb whether to execute forward or backward."), + set_exec_direction_func, show_exec_direction_func, + &setlist, &showlist); + /* ptid initializations */ null_ptid = ptid_build (0, 0, 0); minus_one_ptid = ptid_build (-1, 0, 0); diff --git a/gdb/record.c b/gdb/record.c index 86a82a280c9..aecc71d20c9 100644 --- a/gdb/record.c +++ b/gdb/record.c @@ -44,7 +44,6 @@ static int record_insn_num = 0; struct target_ops record_ops; int record_resume_step = 0; -enum exec_direction_kind record_exec_direction = EXEC_FORWARD; static int record_get_sig = 0; static sigset_t record_maskall; static int record_not_record = 0; @@ -416,7 +415,6 @@ record_open (char *name, int from_tty) /* Reset */ record_insn_num = 0; - record_exec_direction = EXEC_FORWARD; record_list = &record_first; record_list->next = NULL; @@ -459,7 +457,7 @@ record_sig_handler (int signo) static void record_wait_cleanups (void *ignore) { - if (record_exec_direction == EXEC_REVERSE) + if (execution_direction == EXEC_REVERSE) { if (record_list->next) { @@ -517,7 +515,7 @@ record_wait (ptid_t ptid, struct target_waitstatus *status) /* In EXEC_FORWARD mode, record_list point to the tail of prev instruction. */ - if (record_exec_direction == EXEC_FORWARD && record_list->next) + if (execution_direction == EXEC_FORWARD && record_list->next) { record_list = record_list->next; } @@ -528,14 +526,14 @@ record_wait (ptid_t ptid, struct target_waitstatus *status) do { /* Check for beginning and end of log. */ - if (record_exec_direction == EXEC_REVERSE + if (execution_direction == EXEC_REVERSE && record_list == &record_first) { /* Hit beginning of record log in reverse. */ status->kind = TARGET_WAITKIND_NO_HISTORY; break; } - if (record_exec_direction != EXEC_REVERSE && !record_list->next) + if (execution_direction != EXEC_REVERSE && !record_list->next) { /* Hit end of record log going forward. */ status->kind = TARGET_WAITKIND_NO_HISTORY; @@ -603,7 +601,7 @@ record_wait (ptid_t ptid, struct target_waitstatus *status) record_list->u.need_dasm); } - if (record_exec_direction == EXEC_FORWARD) + if (execution_direction == EXEC_FORWARD) { need_dasm = record_list->u.need_dasm; } @@ -612,7 +610,7 @@ record_wait (ptid_t ptid, struct target_waitstatus *status) gdbarch_record_dasm (current_gdbarch); } - if (first_record_end && record_exec_direction == EXEC_REVERSE) + if (first_record_end && execution_direction == EXEC_REVERSE) { /* When reverse excute, the first record_end is the part of current instruction. */ @@ -666,7 +664,7 @@ record_wait (ptid_t ptid, struct target_waitstatus *status) } } } - if (record_exec_direction == EXEC_REVERSE) + if (execution_direction == EXEC_REVERSE) { need_dasm = record_list->u.need_dasm; } @@ -675,7 +673,7 @@ record_wait (ptid_t ptid, struct target_waitstatus *status) next: if (continue_flag) { - if (record_exec_direction == EXEC_REVERSE) + if (execution_direction == EXEC_REVERSE) { if (record_list->prev) record_list = record_list->prev; @@ -951,29 +949,10 @@ record_remove_breakpoint (struct bp_target_info *bp_tgt) return 0; } -static enum exec_direction_kind -record_get_exec_direction (void) -{ - if (record_debug > 1) - printf_filtered ("Process record: exec_direction is %s\n", - record_exec_direction == EXEC_FORWARD ? "forward" : - record_exec_direction == EXEC_REVERSE ? "reverse" : "unknown"); - return record_exec_direction; -} - static int -record_set_exec_direction (enum exec_direction_kind dir) +record_can_execute_reverse (void) { - if (record_debug) - printf_filtered ("Process record: set exec_direction: %s\n", - dir == EXEC_FORWARD ? "forward" : - dir == EXEC_REVERSE ? "reverse" : "bad direction"); - - /* FIXME: check target for capability. */ - if (dir == EXEC_FORWARD || dir == EXEC_REVERSE) - return (record_exec_direction = dir); - else - return EXEC_ERROR; + return 1; } static void @@ -996,8 +975,7 @@ init_record_ops (void) record_ops.to_xfer_partial = record_xfer_partial; record_ops.to_insert_breakpoint = record_insert_breakpoint; record_ops.to_remove_breakpoint = record_remove_breakpoint; - record_ops.to_get_exec_direction = record_get_exec_direction; - record_ops.to_set_exec_direction = record_set_exec_direction; + record_ops.to_can_execute_reverse = record_can_execute_reverse; record_ops.to_stratum = record_stratum; record_ops.to_magic = OPS_MAGIC; } @@ -1131,7 +1109,6 @@ _initialize_record (void) add_com_alias ("sr", "stoprecord", class_obscure, 1); /* Record instructions number limit command. */ - /* Teawater -- tell me if I got this one wrong. MVS */ add_setshow_zinteger_cmd ("record-auto-delete", no_class, &record_insn_max_mode, _("Set record/replay auto delete mode."), diff --git a/gdb/record.h b/gdb/record.h index be79f7b69bb..a10a9ec1412 100644 --- a/gdb/record.h +++ b/gdb/record.h @@ -23,7 +23,7 @@ #define RECORD_IS_USED \ (current_target.beneath == &record_ops) #define RECORD_IS_REPLAY \ - (record_list->next || record_exec_direction == EXEC_REVERSE) + (record_list->next || execution_direction == EXEC_REVERSE) #define RECORD_TARGET_SUPPORT_RECORD_WAIT \ (record_ops.beneath->to_support_record_wait) @@ -78,7 +78,6 @@ extern struct regcache *record_regcache; extern struct target_ops record_ops; extern int record_resume_step; -extern enum exec_direction_kind record_exec_direction; extern int record_arch_list_add_reg (int num); extern int record_arch_list_add_mem (CORE_ADDR addr, int len); diff --git a/gdb/remote.c b/gdb/remote.c index 4f50856b9c9..493b63122b5 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -3210,7 +3210,7 @@ remote_resume (ptid_t ptid, int step, enum target_signal siggnal) set_continue_thread (ptid); buf = rs->buf; - if (target_get_execution_direction () == EXEC_REVERSE) + if (execution_direction == EXEC_REVERSE) { /* We don't pass signals to the target in reverse exec mode. */ if (info_verbose && siggnal != TARGET_SIGNAL_0) @@ -7131,34 +7131,12 @@ remote_command (char *args, int from_tty) help_list (remote_cmdlist, "remote ", -1, gdb_stdout); } -/* Reverse execution. - FIXME: set up as a capability. */ -static enum exec_direction_kind remote_exec_direction = EXEC_FORWARD; +static int remote_target_can_reverse = 1; -static enum exec_direction_kind -remote_get_exec_direction (void) -{ - if (remote_debug && info_verbose) - printf_filtered ("remote exec_direction is %s\n", - remote_exec_direction == EXEC_FORWARD ? _("forward") : - remote_exec_direction == EXEC_REVERSE ? _("reverse") : - _("unknown")); - return remote_exec_direction; -} - -static int remote_set_exec_direction (enum exec_direction_kind dir) +static int +remote_can_execute_reverse (void) { - if (remote_debug && info_verbose) - printf_filtered ("Set remote exec_direction: %s\n", - dir == EXEC_FORWARD ? _("forward") : - dir == EXEC_REVERSE ? _("reverse") : - _("bad direction")); - - /* FIXME: check target for capability. */ - if (dir == EXEC_FORWARD || dir == EXEC_REVERSE) - return (remote_exec_direction = dir); - else - return EXEC_ERROR; + return remote_target_can_reverse; } static void @@ -7209,8 +7187,7 @@ Specify the serial device it is connected to\n\ remote_ops.to_has_registers = 1; remote_ops.to_has_execution = 1; remote_ops.to_has_thread_control = tc_schedlock; /* can lock scheduler */ - remote_ops.to_get_exec_direction = remote_get_exec_direction; - remote_ops.to_set_exec_direction = remote_set_exec_direction; + remote_ops.to_can_execute_reverse = remote_can_execute_reverse; remote_ops.to_magic = OPS_MAGIC; remote_ops.to_memory_map = remote_memory_map; remote_ops.to_flash_erase = remote_flash_erase; diff --git a/gdb/reverse.c b/gdb/reverse.c index ac89fbe635a..4952267cb34 100644 --- a/gdb/reverse.c +++ b/gdb/reverse.c @@ -25,68 +25,15 @@ #include "top.h" #include "cli/cli-cmds.h" #include "cli/cli-decode.h" - -/* User interface for reverse debugging: - Set exec-direction / show exec-direction commands - (returns error unless target implements to_set_exec_direction method). */ - -static const char exec_forward[] = "forward"; -static const char exec_reverse[] = "reverse"; -static const char *exec_direction = exec_forward; -static const char *exec_direction_names[] = { - exec_forward, - exec_reverse, - NULL -}; - -static void -set_exec_direction_func (char *args, int from_tty, - struct cmd_list_element *cmd) -{ - if (target_get_execution_direction () != EXEC_ERROR) - { - enum exec_direction_kind dir = EXEC_ERROR; - - if (!strcmp (exec_direction, exec_forward)) - dir = EXEC_FORWARD; - else if (!strcmp (exec_direction, exec_reverse)) - dir = EXEC_REVERSE; - - if (target_set_execution_direction (dir) != EXEC_ERROR) - return; - } -} - -static void -show_exec_direction_func (struct ui_file *out, int from_tty, - struct cmd_list_element *cmd, const char *value) -{ - enum exec_direction_kind dir = target_get_execution_direction (); - - switch (dir) { - case EXEC_FORWARD: - fprintf_filtered (out, _("Forward.\n")); - break; - case EXEC_REVERSE: - fprintf_filtered (out, _("Reverse.\n")); - break; - case EXEC_ERROR: - default: - fprintf_filtered (out, - _("Forward (target `%s' does not support exec-direction).\n"), - target_shortname); - break; - } -} +#include "inferior.h" /* User interface: - reverse-step, reverse-next etc. - (returns error unles target implements to_set_exec_direction method). */ + reverse-step, reverse-next etc. */ static void exec_direction_default (void *notused) { /* Return execution direction to default state. */ - target_set_execution_direction (EXEC_FORWARD); + execution_direction = EXEC_FORWARD; } /* exec_reverse_once -- accepts an arbitrary gdb command (string), @@ -99,7 +46,7 @@ exec_reverse_once (char *cmd, char *args, int from_tty) { /* String buffer for command consing. */ char reverse_command[512]; - enum exec_direction_kind dir = target_get_execution_direction (); + enum exec_direction_kind dir = execution_direction; struct cleanup *old_chain; if (dir == EXEC_ERROR) @@ -109,11 +56,13 @@ exec_reverse_once (char *cmd, char *args, int from_tty) error (_("Already in reverse mode. Use '%s' or 'set exec-dir forward'."), cmd); - if (target_set_execution_direction (EXEC_REVERSE) == EXEC_ERROR) + if (!target_can_execute_reverse) error (_("Target %s does not support this command."), target_shortname); old_chain = make_cleanup (exec_direction_default, NULL); sprintf (reverse_command, "%s %s", cmd, args ? args : ""); + + execution_direction = EXEC_REVERSE; execute_command (reverse_command, from_tty); do_cleanups (old_chain); } @@ -157,14 +106,6 @@ reverse_finish (char *args, int from_tty) void _initialize_reverse (void) { - add_setshow_enum_cmd ("exec-direction", class_run, exec_direction_names, - &exec_direction, _("Set direction of execution.\n\ -Options are 'forward' or 'reverse'."), - _("Show direction of execution (forward/reverse)."), - _("Tells gdb whether to execute forward or backward."), - set_exec_direction_func, show_exec_direction_func, - &setlist, &showlist); - add_com ("reverse-step", class_run, reverse_step, _("\ Step program backward until it reaches the beginning of another source line.\n\ Argument N means do this N times (or till program stops for another reason).") diff --git a/gdb/target.c b/gdb/target.c index 3cf44722b75..6871e94694a 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -486,8 +486,7 @@ update_current_target (void) INHERIT (to_find_memory_regions, t); INHERIT (to_make_corefile_notes, t); INHERIT (to_get_thread_local_address, t); - INHERIT (to_get_exec_direction, t); - INHERIT (to_set_exec_direction, t); + INHERIT (to_can_execute_reverse, t); /* Do not inherit to_read_description. */ /* Do not inherit to_search_memory. */ INHERIT (to_magic, t); diff --git a/gdb/target.h b/gdb/target.h index 69a30c455d8..74c2a84ca56 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -152,14 +152,6 @@ struct target_waitstatus value; }; -/* Reverse execution. */ -enum exec_direction_kind - { - EXEC_FORWARD, - EXEC_REVERSE, - EXEC_ERROR - }; - /* Possible types of events that the inferior handler will have to deal with. */ enum inferior_event_type @@ -535,10 +527,8 @@ struct target_ops const gdb_byte *pattern, ULONGEST pattern_len, CORE_ADDR *found_addrp); - /* Set execution direction (forward/reverse). */ - int (*to_set_exec_direction) (enum exec_direction_kind); - /* Get execution direction (forward/reverse). */ - enum exec_direction_kind (*to_get_exec_direction) (void); + /* Can target execute in reverse? */ + int (*to_can_execute_reverse) (); /* Default value is 0. Mean that this target doesn't support record wait. Need the help of infrun.c(handle_inferior_event). Set to 1 if this @@ -1143,17 +1133,10 @@ extern int target_stopped_data_address_p (struct target_ops *); #define target_watchpoint_addr_within_range(target, addr, start, length) \ (*target.to_watchpoint_addr_within_range) (target, addr, start, length) -/* Forward/reverse execution direction. - These will only be implemented by a target that supports reverse execution. -*/ -#define target_get_execution_direction() \ - (current_target.to_get_exec_direction ? \ - (*current_target.to_get_exec_direction) () : EXEC_ERROR) - -#define target_set_execution_direction(DIR) \ - (current_target.to_set_exec_direction ? \ - (*current_target.to_set_exec_direction) (DIR) : EXEC_ERROR) - +/* Target can execute in reverse? */ +#define target_can_execute_reverse \ + (current_target.to_can_execute_reverse ? \ + current_target.to_can_execute_reverse () : 0) extern const struct target_desc *target_read_description (struct target_ops *); -- cgit v1.2.1