GNU Binutils with patches for OS216
リビジョン | efb0ddc166fc1b07a0c4564bf75b8c1c8584b1ab (tree) |
---|---|
日時 | 2008-10-08 09:26:50 |
作者 | Michael Snyder <msnyder@vmwa...> |
コミッター | Michael Snyder |
2008-10-07 Michael Snyder <msnyder@vmware.com>
* 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.
@@ -1,5 +1,42 @@ | ||
1 | 1 | 2008-10-07 Michael Snyder <msnyder@vmware.com> |
2 | 2 | |
3 | + * target.h (to_set_exec_direction, to_get_exec_direction): Remove. | |
4 | + (to_can_execute_reverse): New method. | |
5 | + (enum exec_direction_kind): Move to inferior.h. | |
6 | + * target.c (update_current_target): Inherit to_can_execute_reverse. | |
7 | + Remove to_set_exec_direction, to_get_exec_direction. | |
8 | + * inferior.h (enum exec_direction_kind): Move from target.h. | |
9 | + | |
10 | + * infrun.c (set_exec_direction_func): Move here from reverse.c. | |
11 | + (show_exec_direction_func): Ditto. | |
12 | + (proceed): Consult global execution_direction instead of | |
13 | + target method. | |
14 | + (handle_inferior_event): Ditto. | |
15 | + | |
16 | + * reverse.c (set_exec_direction_func): Move to infrun.c | |
17 | + (show_exec_direction_func): Ditto. | |
18 | + (exec_direction_default): Set infrun global variable. | |
19 | + (exec_reverse_once): Consult infrun global direction variable. | |
20 | + | |
21 | + * infcmd.c (step_1): Consult infrun global direction variable. | |
22 | + (step_once): Ditto. | |
23 | + (until_next_command): Ditto. | |
24 | + (finish_command): Ditto. | |
25 | + | |
26 | + * record.h (record_exec_direction): Delete. | |
27 | + (RECORD_IS_REPLAY): Consult infrun global direction variable. | |
28 | + | |
29 | + * record.c: (record_wait_cleanups): Use infrun state variable. | |
30 | + (record_wait): Ditto. | |
31 | + (record_get_exec_direction, record_set_exec_direction): Remove. | |
32 | + (record_can_execute_reverse): New target method. | |
33 | + | |
34 | + * remote.c (remote_resume): Use infrun state variable. | |
35 | + (remote_get_exec_direction, remote_set_exec_direction): Remove. | |
36 | + (remote_can_execute_reverse): New target method. | |
37 | + | |
38 | +2008-10-07 Michael Snyder <msnyder@vmware.com> | |
39 | + | |
3 | 40 | * infrun.c (stepped_into_function): Rename handle_step_into_function. |
4 | 41 | (stepped_into_function_backward): |
5 | 42 | Rename handle_step_into_function_backward. |
@@ -824,7 +824,7 @@ step_1 (int skip_subroutines, int single_inst, char *count_string) | ||
824 | 824 | error (_("No current frame")); |
825 | 825 | step_frame_id = get_frame_id (frame); |
826 | 826 | |
827 | - if (target_get_execution_direction () == EXEC_REVERSE) | |
827 | + if (execution_direction == EXEC_REVERSE) | |
828 | 828 | { |
829 | 829 | frame = get_prev_frame (frame); |
830 | 830 | if (frame) |
@@ -942,7 +942,7 @@ step_once (int skip_subroutines, int single_inst, int count, int thread) | ||
942 | 942 | error (_("No current frame")); |
943 | 943 | step_frame_id = get_frame_id (frame); |
944 | 944 | |
945 | - if (target_get_execution_direction () == EXEC_REVERSE) | |
945 | + if (execution_direction == EXEC_REVERSE) | |
946 | 946 | { |
947 | 947 | frame = get_prev_frame (frame); |
948 | 948 | if (frame) |
@@ -1221,7 +1221,7 @@ until_next_command (int from_tty) | ||
1221 | 1221 | step_over_calls = STEP_OVER_ALL; |
1222 | 1222 | step_frame_id = get_frame_id (frame); |
1223 | 1223 | |
1224 | - if (target_get_execution_direction () == EXEC_REVERSE) | |
1224 | + if (execution_direction == EXEC_REVERSE) | |
1225 | 1225 | { |
1226 | 1226 | frame = get_prev_frame (frame); |
1227 | 1227 | if (frame) |
@@ -1501,7 +1501,7 @@ finish_command (char *arg, int from_tty) | ||
1501 | 1501 | error (_("Asynchronous execution not supported on this target.")); |
1502 | 1502 | |
1503 | 1503 | /* Don't try to async in reverse. */ |
1504 | - if (async_exec && target_get_execution_direction () == EXEC_REVERSE) | |
1504 | + if (async_exec && execution_direction == EXEC_REVERSE) | |
1505 | 1505 | error (_("Asynchronous 'finish' not supported in reverse.")); |
1506 | 1506 | |
1507 | 1507 | /* 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) | ||
1531 | 1531 | source. */ |
1532 | 1532 | if (from_tty) |
1533 | 1533 | { |
1534 | - if (target_get_execution_direction () == EXEC_REVERSE) | |
1534 | + if (execution_direction == EXEC_REVERSE) | |
1535 | 1535 | printf_filtered (_("Run back to call of ")); |
1536 | 1536 | else |
1537 | 1537 | printf_filtered (_("Run till exit from ")); |
@@ -1539,7 +1539,7 @@ finish_command (char *arg, int from_tty) | ||
1539 | 1539 | print_stack_frame (get_selected_frame (NULL), 1, LOCATION); |
1540 | 1540 | } |
1541 | 1541 | |
1542 | - if (target_get_execution_direction () == EXEC_REVERSE) | |
1542 | + if (execution_direction == EXEC_REVERSE) | |
1543 | 1543 | { |
1544 | 1544 | /* Split off at this point. */ |
1545 | 1545 | finish_backward (function); |
@@ -386,6 +386,16 @@ enum stop_kind | ||
386 | 386 | |
387 | 387 | extern enum stop_kind stop_soon; |
388 | 388 | |
389 | +/* Reverse execution. */ | |
390 | +enum exec_direction_kind | |
391 | + { | |
392 | + EXEC_FORWARD, | |
393 | + EXEC_REVERSE, | |
394 | + EXEC_ERROR | |
395 | + }; | |
396 | + | |
397 | +extern enum exec_direction_kind execution_direction; | |
398 | + | |
389 | 399 | /* Nonzero if proceed is being used for a "finish" command or a similar |
390 | 400 | situation when stop_registers should be saved. */ |
391 | 401 |
@@ -1223,7 +1223,7 @@ proceed (CORE_ADDR addr, enum target_signal siggnal, int step) | ||
1223 | 1223 | if (addr == (CORE_ADDR) -1) |
1224 | 1224 | { |
1225 | 1225 | if (pc == stop_pc && breakpoint_here_p (pc) |
1226 | - && target_get_execution_direction () != EXEC_REVERSE) | |
1226 | + && execution_direction != EXEC_REVERSE) | |
1227 | 1227 | /* There is a breakpoint at the address we will resume at, |
1228 | 1228 | step one instruction before inserting breakpoints so that |
1229 | 1229 | 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.") | ||
2642 | 2642 | = !(bpstat_explains_signal (stop_bpstat) |
2643 | 2643 | || stepping_over_breakpoint |
2644 | 2644 | || (step_range_end && step_resume_breakpoint == NULL) |
2645 | - || (target_get_execution_direction () == EXEC_REVERSE) | |
2645 | + || (execution_direction == EXEC_REVERSE) | |
2646 | 2646 | || RECORD_IS_USED); |
2647 | 2647 | else |
2648 | 2648 | { |
@@ -2882,7 +2882,7 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (!gdbarch_get_longjmp_target)\n"); | ||
2882 | 2882 | return; |
2883 | 2883 | } |
2884 | 2884 | if (stop_pc == ecs->stop_func_start |
2885 | - && target_get_execution_direction () == EXEC_REVERSE) | |
2885 | + && execution_direction == EXEC_REVERSE) | |
2886 | 2886 | { |
2887 | 2887 | /* We are stepping over a function call in reverse, and |
2888 | 2888 | just hit the step-resume breakpoint at the start |
@@ -3063,7 +3063,7 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (!gdbarch_get_longjmp_target)\n"); | ||
3063 | 3063 | keep going back to the call point). */ |
3064 | 3064 | if (stop_pc == step_range_start |
3065 | 3065 | && stop_pc != ecs->stop_func_start |
3066 | - && target_get_execution_direction () == EXEC_REVERSE) | |
3066 | + && execution_direction == EXEC_REVERSE) | |
3067 | 3067 | { |
3068 | 3068 | stop_step = 1; |
3069 | 3069 | print_stop_reason (END_STEPPING_RANGE, 0); |
@@ -3172,7 +3172,7 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (!gdbarch_get_longjmp_target)\n"); | ||
3172 | 3172 | get there, we'll need to single-step back to the |
3173 | 3173 | caller. */ |
3174 | 3174 | |
3175 | - if (target_get_execution_direction () == EXEC_REVERSE) | |
3175 | + if (execution_direction == EXEC_REVERSE) | |
3176 | 3176 | { |
3177 | 3177 | if (ecs->stop_func_start == 0) |
3178 | 3178 | { |
@@ -3244,7 +3244,7 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (!gdbarch_get_longjmp_target)\n"); | ||
3244 | 3244 | tmp_sal = find_pc_line (ecs->stop_func_start, 0); |
3245 | 3245 | if (tmp_sal.line != 0) |
3246 | 3246 | { |
3247 | - if (target_get_execution_direction () == EXEC_REVERSE) | |
3247 | + if (execution_direction == EXEC_REVERSE) | |
3248 | 3248 | handle_step_into_function_backward (ecs); |
3249 | 3249 | else |
3250 | 3250 | handle_step_into_function (ecs); |
@@ -3263,7 +3263,7 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (!gdbarch_get_longjmp_target)\n"); | ||
3263 | 3263 | return; |
3264 | 3264 | } |
3265 | 3265 | |
3266 | - if (target_get_execution_direction () == EXEC_REVERSE) | |
3266 | + if (execution_direction == EXEC_REVERSE) | |
3267 | 3267 | { |
3268 | 3268 | /* Set a breakpoint at callee's start address. |
3269 | 3269 | 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"); | ||
3407 | 3407 | if (debug_infrun) |
3408 | 3408 | fprintf_unfiltered (gdb_stdlog, "infrun: no line number info\n"); |
3409 | 3409 | |
3410 | - if (target_get_execution_direction () == EXEC_REVERSE) | |
3410 | + if (execution_direction == EXEC_REVERSE) | |
3411 | 3411 | { |
3412 | 3412 | /* Set a breakpoint at callee's start address. |
3413 | 3413 | 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"); | ||
3446 | 3446 | return; |
3447 | 3447 | } |
3448 | 3448 | |
3449 | - if (target_get_execution_direction () == EXEC_REVERSE | |
3449 | + if (execution_direction == EXEC_REVERSE | |
3450 | 3450 | && frame_id_eq (get_frame_id (get_current_frame ()), |
3451 | 3451 | step_prev_frame_id)) |
3452 | 3452 | { |
@@ -3462,11 +3462,11 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (!gdbarch_get_longjmp_target)\n"); | ||
3462 | 3462 | } |
3463 | 3463 | |
3464 | 3464 | if (!frame_id_eq (get_frame_id (get_current_frame ()), step_frame_id) |
3465 | - && (target_get_execution_direction () == EXEC_REVERSE | |
3465 | + && (execution_direction == EXEC_REVERSE | |
3466 | 3466 | || RECORD_IS_USED)) |
3467 | 3467 | { |
3468 | 3468 | if (stop_pc != stop_pc_sal.pc |
3469 | - && target_get_execution_direction () == EXEC_REVERSE | |
3469 | + && execution_direction == EXEC_REVERSE | |
3470 | 3470 | && step_over_calls == STEP_OVER_ALL) |
3471 | 3471 | { |
3472 | 3472 | if (debug_infrun) |
@@ -3489,9 +3489,9 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (!gdbarch_get_longjmp_target)\n"); | ||
3489 | 3489 | } |
3490 | 3490 | #if 0 |
3491 | 3491 | if (((stop_pc == stop_pc_sal.pc |
3492 | - && target_get_execution_direction () != EXEC_REVERSE) | |
3492 | + && execution_direction != EXEC_REVERSE) | |
3493 | 3493 | || (stop_pc >= stop_pc_sal.pc && stop_pc < stop_pc_sal.end |
3494 | - && target_get_execution_direction () == EXEC_REVERSE)) | |
3494 | + && execution_direction == EXEC_REVERSE)) | |
3495 | 3495 | && (tss->current_line != stop_pc_sal.line |
3496 | 3496 | || tss->current_symtab != stop_pc_sal.symtab)) |
3497 | 3497 | { |
@@ -4917,6 +4917,55 @@ save_inferior_ptid (void) | ||
4917 | 4917 | } |
4918 | 4918 | |
4919 | 4919 | |
4920 | +/* User interface for reverse debugging: | |
4921 | + Set exec-direction / show exec-direction commands | |
4922 | + (returns error unless target implements to_set_exec_direction method). */ | |
4923 | + | |
4924 | +enum exec_direction_kind execution_direction = EXEC_FORWARD; | |
4925 | +static const char exec_forward[] = "forward"; | |
4926 | +static const char exec_reverse[] = "reverse"; | |
4927 | +static const char *exec_direction = exec_forward; | |
4928 | +static const char *exec_direction_names[] = { | |
4929 | + exec_forward, | |
4930 | + exec_reverse, | |
4931 | + NULL | |
4932 | +}; | |
4933 | + | |
4934 | +static void | |
4935 | +set_exec_direction_func (char *args, int from_tty, | |
4936 | + struct cmd_list_element *cmd) | |
4937 | +{ | |
4938 | + if (target_can_execute_reverse) | |
4939 | + { | |
4940 | + if (!strcmp (exec_direction, exec_forward)) | |
4941 | + execution_direction = EXEC_FORWARD; | |
4942 | + else if (!strcmp (exec_direction, exec_reverse)) | |
4943 | + execution_direction = EXEC_REVERSE; | |
4944 | + } | |
4945 | +} | |
4946 | + | |
4947 | +static void | |
4948 | +show_exec_direction_func (struct ui_file *out, int from_tty, | |
4949 | + struct cmd_list_element *cmd, const char *value) | |
4950 | +{ | |
4951 | + switch (execution_direction) { | |
4952 | + case EXEC_FORWARD: | |
4953 | + fprintf_filtered (out, _("Forward.\n")); | |
4954 | + break; | |
4955 | + case EXEC_REVERSE: | |
4956 | + fprintf_filtered (out, _("Reverse.\n")); | |
4957 | + break; | |
4958 | + case EXEC_ERROR: | |
4959 | + default: | |
4960 | + fprintf_filtered (out, | |
4961 | + _("Forward (target `%s' does not support exec-direction).\n"), | |
4962 | + target_shortname); | |
4963 | + break; | |
4964 | + } | |
4965 | +} | |
4966 | + | |
4967 | +/* User interface for non-stop mode. */ | |
4968 | + | |
4920 | 4969 | int non_stop = 0; |
4921 | 4970 | static int non_stop_1 = 0; |
4922 | 4971 |
@@ -5142,6 +5191,14 @@ breakpoints, even if such is supported by the target."), | ||
5142 | 5191 | &maintenance_set_cmdlist, |
5143 | 5192 | &maintenance_show_cmdlist); |
5144 | 5193 | |
5194 | + add_setshow_enum_cmd ("exec-direction", class_run, exec_direction_names, | |
5195 | + &exec_direction, _("Set direction of execution.\n\ | |
5196 | +Options are 'forward' or 'reverse'."), | |
5197 | + _("Show direction of execution (forward/reverse)."), | |
5198 | + _("Tells gdb whether to execute forward or backward."), | |
5199 | + set_exec_direction_func, show_exec_direction_func, | |
5200 | + &setlist, &showlist); | |
5201 | + | |
5145 | 5202 | /* ptid initializations */ |
5146 | 5203 | null_ptid = ptid_build (0, 0, 0); |
5147 | 5204 | minus_one_ptid = ptid_build (-1, 0, 0); |
@@ -44,7 +44,6 @@ static int record_insn_num = 0; | ||
44 | 44 | |
45 | 45 | struct target_ops record_ops; |
46 | 46 | int record_resume_step = 0; |
47 | -enum exec_direction_kind record_exec_direction = EXEC_FORWARD; | |
48 | 47 | static int record_get_sig = 0; |
49 | 48 | static sigset_t record_maskall; |
50 | 49 | static int record_not_record = 0; |
@@ -416,7 +415,6 @@ record_open (char *name, int from_tty) | ||
416 | 415 | |
417 | 416 | /* Reset */ |
418 | 417 | record_insn_num = 0; |
419 | - record_exec_direction = EXEC_FORWARD; | |
420 | 418 | record_list = &record_first; |
421 | 419 | record_list->next = NULL; |
422 | 420 |
@@ -459,7 +457,7 @@ record_sig_handler (int signo) | ||
459 | 457 | static void |
460 | 458 | record_wait_cleanups (void *ignore) |
461 | 459 | { |
462 | - if (record_exec_direction == EXEC_REVERSE) | |
460 | + if (execution_direction == EXEC_REVERSE) | |
463 | 461 | { |
464 | 462 | if (record_list->next) |
465 | 463 | { |
@@ -517,7 +515,7 @@ record_wait (ptid_t ptid, struct target_waitstatus *status) | ||
517 | 515 | |
518 | 516 | /* In EXEC_FORWARD mode, record_list point to the tail of prev |
519 | 517 | instruction. */ |
520 | - if (record_exec_direction == EXEC_FORWARD && record_list->next) | |
518 | + if (execution_direction == EXEC_FORWARD && record_list->next) | |
521 | 519 | { |
522 | 520 | record_list = record_list->next; |
523 | 521 | } |
@@ -528,14 +526,14 @@ record_wait (ptid_t ptid, struct target_waitstatus *status) | ||
528 | 526 | do |
529 | 527 | { |
530 | 528 | /* Check for beginning and end of log. */ |
531 | - if (record_exec_direction == EXEC_REVERSE | |
529 | + if (execution_direction == EXEC_REVERSE | |
532 | 530 | && record_list == &record_first) |
533 | 531 | { |
534 | 532 | /* Hit beginning of record log in reverse. */ |
535 | 533 | status->kind = TARGET_WAITKIND_NO_HISTORY; |
536 | 534 | break; |
537 | 535 | } |
538 | - if (record_exec_direction != EXEC_REVERSE && !record_list->next) | |
536 | + if (execution_direction != EXEC_REVERSE && !record_list->next) | |
539 | 537 | { |
540 | 538 | /* Hit end of record log going forward. */ |
541 | 539 | status->kind = TARGET_WAITKIND_NO_HISTORY; |
@@ -603,7 +601,7 @@ record_wait (ptid_t ptid, struct target_waitstatus *status) | ||
603 | 601 | record_list->u.need_dasm); |
604 | 602 | } |
605 | 603 | |
606 | - if (record_exec_direction == EXEC_FORWARD) | |
604 | + if (execution_direction == EXEC_FORWARD) | |
607 | 605 | { |
608 | 606 | need_dasm = record_list->u.need_dasm; |
609 | 607 | } |
@@ -612,7 +610,7 @@ record_wait (ptid_t ptid, struct target_waitstatus *status) | ||
612 | 610 | gdbarch_record_dasm (current_gdbarch); |
613 | 611 | } |
614 | 612 | |
615 | - if (first_record_end && record_exec_direction == EXEC_REVERSE) | |
613 | + if (first_record_end && execution_direction == EXEC_REVERSE) | |
616 | 614 | { |
617 | 615 | /* When reverse excute, the first record_end is the part of |
618 | 616 | current instruction. */ |
@@ -666,7 +664,7 @@ record_wait (ptid_t ptid, struct target_waitstatus *status) | ||
666 | 664 | } |
667 | 665 | } |
668 | 666 | } |
669 | - if (record_exec_direction == EXEC_REVERSE) | |
667 | + if (execution_direction == EXEC_REVERSE) | |
670 | 668 | { |
671 | 669 | need_dasm = record_list->u.need_dasm; |
672 | 670 | } |
@@ -675,7 +673,7 @@ record_wait (ptid_t ptid, struct target_waitstatus *status) | ||
675 | 673 | next: |
676 | 674 | if (continue_flag) |
677 | 675 | { |
678 | - if (record_exec_direction == EXEC_REVERSE) | |
676 | + if (execution_direction == EXEC_REVERSE) | |
679 | 677 | { |
680 | 678 | if (record_list->prev) |
681 | 679 | record_list = record_list->prev; |
@@ -951,29 +949,10 @@ record_remove_breakpoint (struct bp_target_info *bp_tgt) | ||
951 | 949 | return 0; |
952 | 950 | } |
953 | 951 | |
954 | -static enum exec_direction_kind | |
955 | -record_get_exec_direction (void) | |
956 | -{ | |
957 | - if (record_debug > 1) | |
958 | - printf_filtered ("Process record: exec_direction is %s\n", | |
959 | - record_exec_direction == EXEC_FORWARD ? "forward" : | |
960 | - record_exec_direction == EXEC_REVERSE ? "reverse" : "unknown"); | |
961 | - return record_exec_direction; | |
962 | -} | |
963 | - | |
964 | 952 | static int |
965 | -record_set_exec_direction (enum exec_direction_kind dir) | |
953 | +record_can_execute_reverse (void) | |
966 | 954 | { |
967 | - if (record_debug) | |
968 | - printf_filtered ("Process record: set exec_direction: %s\n", | |
969 | - dir == EXEC_FORWARD ? "forward" : | |
970 | - dir == EXEC_REVERSE ? "reverse" : "bad direction"); | |
971 | - | |
972 | - /* FIXME: check target for capability. */ | |
973 | - if (dir == EXEC_FORWARD || dir == EXEC_REVERSE) | |
974 | - return (record_exec_direction = dir); | |
975 | - else | |
976 | - return EXEC_ERROR; | |
955 | + return 1; | |
977 | 956 | } |
978 | 957 | |
979 | 958 | static void |
@@ -996,8 +975,7 @@ init_record_ops (void) | ||
996 | 975 | record_ops.to_xfer_partial = record_xfer_partial; |
997 | 976 | record_ops.to_insert_breakpoint = record_insert_breakpoint; |
998 | 977 | record_ops.to_remove_breakpoint = record_remove_breakpoint; |
999 | - record_ops.to_get_exec_direction = record_get_exec_direction; | |
1000 | - record_ops.to_set_exec_direction = record_set_exec_direction; | |
978 | + record_ops.to_can_execute_reverse = record_can_execute_reverse; | |
1001 | 979 | record_ops.to_stratum = record_stratum; |
1002 | 980 | record_ops.to_magic = OPS_MAGIC; |
1003 | 981 | } |
@@ -1131,7 +1109,6 @@ _initialize_record (void) | ||
1131 | 1109 | add_com_alias ("sr", "stoprecord", class_obscure, 1); |
1132 | 1110 | |
1133 | 1111 | /* Record instructions number limit command. */ |
1134 | - /* Teawater -- tell me if I got this one wrong. MVS */ | |
1135 | 1112 | add_setshow_zinteger_cmd ("record-auto-delete", no_class, |
1136 | 1113 | &record_insn_max_mode, |
1137 | 1114 | _("Set record/replay auto delete mode."), |
@@ -23,7 +23,7 @@ | ||
23 | 23 | #define RECORD_IS_USED \ |
24 | 24 | (current_target.beneath == &record_ops) |
25 | 25 | #define RECORD_IS_REPLAY \ |
26 | - (record_list->next || record_exec_direction == EXEC_REVERSE) | |
26 | + (record_list->next || execution_direction == EXEC_REVERSE) | |
27 | 27 | #define RECORD_TARGET_SUPPORT_RECORD_WAIT \ |
28 | 28 | (record_ops.beneath->to_support_record_wait) |
29 | 29 |
@@ -78,7 +78,6 @@ extern struct regcache *record_regcache; | ||
78 | 78 | |
79 | 79 | extern struct target_ops record_ops; |
80 | 80 | extern int record_resume_step; |
81 | -extern enum exec_direction_kind record_exec_direction; | |
82 | 81 | |
83 | 82 | extern int record_arch_list_add_reg (int num); |
84 | 83 | extern int record_arch_list_add_mem (CORE_ADDR addr, int len); |
@@ -3210,7 +3210,7 @@ remote_resume (ptid_t ptid, int step, enum target_signal siggnal) | ||
3210 | 3210 | set_continue_thread (ptid); |
3211 | 3211 | |
3212 | 3212 | buf = rs->buf; |
3213 | - if (target_get_execution_direction () == EXEC_REVERSE) | |
3213 | + if (execution_direction == EXEC_REVERSE) | |
3214 | 3214 | { |
3215 | 3215 | /* We don't pass signals to the target in reverse exec mode. */ |
3216 | 3216 | if (info_verbose && siggnal != TARGET_SIGNAL_0) |
@@ -7131,34 +7131,12 @@ remote_command (char *args, int from_tty) | ||
7131 | 7131 | help_list (remote_cmdlist, "remote ", -1, gdb_stdout); |
7132 | 7132 | } |
7133 | 7133 | |
7134 | -/* Reverse execution. | |
7135 | - FIXME: set up as a capability. */ | |
7136 | -static enum exec_direction_kind remote_exec_direction = EXEC_FORWARD; | |
7134 | +static int remote_target_can_reverse = 1; | |
7137 | 7135 | |
7138 | -static enum exec_direction_kind | |
7139 | -remote_get_exec_direction (void) | |
7140 | -{ | |
7141 | - if (remote_debug && info_verbose) | |
7142 | - printf_filtered ("remote exec_direction is %s\n", | |
7143 | - remote_exec_direction == EXEC_FORWARD ? _("forward") : | |
7144 | - remote_exec_direction == EXEC_REVERSE ? _("reverse") : | |
7145 | - _("unknown")); | |
7146 | - return remote_exec_direction; | |
7147 | -} | |
7148 | - | |
7149 | -static int remote_set_exec_direction (enum exec_direction_kind dir) | |
7136 | +static int | |
7137 | +remote_can_execute_reverse (void) | |
7150 | 7138 | { |
7151 | - if (remote_debug && info_verbose) | |
7152 | - printf_filtered ("Set remote exec_direction: %s\n", | |
7153 | - dir == EXEC_FORWARD ? _("forward") : | |
7154 | - dir == EXEC_REVERSE ? _("reverse") : | |
7155 | - _("bad direction")); | |
7156 | - | |
7157 | - /* FIXME: check target for capability. */ | |
7158 | - if (dir == EXEC_FORWARD || dir == EXEC_REVERSE) | |
7159 | - return (remote_exec_direction = dir); | |
7160 | - else | |
7161 | - return EXEC_ERROR; | |
7139 | + return remote_target_can_reverse; | |
7162 | 7140 | } |
7163 | 7141 | |
7164 | 7142 | static void |
@@ -7209,8 +7187,7 @@ Specify the serial device it is connected to\n\ | ||
7209 | 7187 | remote_ops.to_has_registers = 1; |
7210 | 7188 | remote_ops.to_has_execution = 1; |
7211 | 7189 | remote_ops.to_has_thread_control = tc_schedlock; /* can lock scheduler */ |
7212 | - remote_ops.to_get_exec_direction = remote_get_exec_direction; | |
7213 | - remote_ops.to_set_exec_direction = remote_set_exec_direction; | |
7190 | + remote_ops.to_can_execute_reverse = remote_can_execute_reverse; | |
7214 | 7191 | remote_ops.to_magic = OPS_MAGIC; |
7215 | 7192 | remote_ops.to_memory_map = remote_memory_map; |
7216 | 7193 | remote_ops.to_flash_erase = remote_flash_erase; |
@@ -25,68 +25,15 @@ | ||
25 | 25 | #include "top.h" |
26 | 26 | #include "cli/cli-cmds.h" |
27 | 27 | #include "cli/cli-decode.h" |
28 | - | |
29 | -/* User interface for reverse debugging: | |
30 | - Set exec-direction / show exec-direction commands | |
31 | - (returns error unless target implements to_set_exec_direction method). */ | |
32 | - | |
33 | -static const char exec_forward[] = "forward"; | |
34 | -static const char exec_reverse[] = "reverse"; | |
35 | -static const char *exec_direction = exec_forward; | |
36 | -static const char *exec_direction_names[] = { | |
37 | - exec_forward, | |
38 | - exec_reverse, | |
39 | - NULL | |
40 | -}; | |
41 | - | |
42 | -static void | |
43 | -set_exec_direction_func (char *args, int from_tty, | |
44 | - struct cmd_list_element *cmd) | |
45 | -{ | |
46 | - if (target_get_execution_direction () != EXEC_ERROR) | |
47 | - { | |
48 | - enum exec_direction_kind dir = EXEC_ERROR; | |
49 | - | |
50 | - if (!strcmp (exec_direction, exec_forward)) | |
51 | - dir = EXEC_FORWARD; | |
52 | - else if (!strcmp (exec_direction, exec_reverse)) | |
53 | - dir = EXEC_REVERSE; | |
54 | - | |
55 | - if (target_set_execution_direction (dir) != EXEC_ERROR) | |
56 | - return; | |
57 | - } | |
58 | -} | |
59 | - | |
60 | -static void | |
61 | -show_exec_direction_func (struct ui_file *out, int from_tty, | |
62 | - struct cmd_list_element *cmd, const char *value) | |
63 | -{ | |
64 | - enum exec_direction_kind dir = target_get_execution_direction (); | |
65 | - | |
66 | - switch (dir) { | |
67 | - case EXEC_FORWARD: | |
68 | - fprintf_filtered (out, _("Forward.\n")); | |
69 | - break; | |
70 | - case EXEC_REVERSE: | |
71 | - fprintf_filtered (out, _("Reverse.\n")); | |
72 | - break; | |
73 | - case EXEC_ERROR: | |
74 | - default: | |
75 | - fprintf_filtered (out, | |
76 | - _("Forward (target `%s' does not support exec-direction).\n"), | |
77 | - target_shortname); | |
78 | - break; | |
79 | - } | |
80 | -} | |
28 | +#include "inferior.h" | |
81 | 29 | |
82 | 30 | /* User interface: |
83 | - reverse-step, reverse-next etc. | |
84 | - (returns error unles target implements to_set_exec_direction method). */ | |
31 | + reverse-step, reverse-next etc. */ | |
85 | 32 | |
86 | 33 | static void exec_direction_default (void *notused) |
87 | 34 | { |
88 | 35 | /* Return execution direction to default state. */ |
89 | - target_set_execution_direction (EXEC_FORWARD); | |
36 | + execution_direction = EXEC_FORWARD; | |
90 | 37 | } |
91 | 38 | |
92 | 39 | /* exec_reverse_once -- accepts an arbitrary gdb command (string), |
@@ -99,7 +46,7 @@ exec_reverse_once (char *cmd, char *args, int from_tty) | ||
99 | 46 | { |
100 | 47 | /* String buffer for command consing. */ |
101 | 48 | char reverse_command[512]; |
102 | - enum exec_direction_kind dir = target_get_execution_direction (); | |
49 | + enum exec_direction_kind dir = execution_direction; | |
103 | 50 | struct cleanup *old_chain; |
104 | 51 | |
105 | 52 | if (dir == EXEC_ERROR) |
@@ -109,11 +56,13 @@ exec_reverse_once (char *cmd, char *args, int from_tty) | ||
109 | 56 | error (_("Already in reverse mode. Use '%s' or 'set exec-dir forward'."), |
110 | 57 | cmd); |
111 | 58 | |
112 | - if (target_set_execution_direction (EXEC_REVERSE) == EXEC_ERROR) | |
59 | + if (!target_can_execute_reverse) | |
113 | 60 | error (_("Target %s does not support this command."), target_shortname); |
114 | 61 | |
115 | 62 | old_chain = make_cleanup (exec_direction_default, NULL); |
116 | 63 | sprintf (reverse_command, "%s %s", cmd, args ? args : ""); |
64 | + | |
65 | + execution_direction = EXEC_REVERSE; | |
117 | 66 | execute_command (reverse_command, from_tty); |
118 | 67 | do_cleanups (old_chain); |
119 | 68 | } |
@@ -157,14 +106,6 @@ reverse_finish (char *args, int from_tty) | ||
157 | 106 | void |
158 | 107 | _initialize_reverse (void) |
159 | 108 | { |
160 | - add_setshow_enum_cmd ("exec-direction", class_run, exec_direction_names, | |
161 | - &exec_direction, _("Set direction of execution.\n\ | |
162 | -Options are 'forward' or 'reverse'."), | |
163 | - _("Show direction of execution (forward/reverse)."), | |
164 | - _("Tells gdb whether to execute forward or backward."), | |
165 | - set_exec_direction_func, show_exec_direction_func, | |
166 | - &setlist, &showlist); | |
167 | - | |
168 | 109 | add_com ("reverse-step", class_run, reverse_step, _("\ |
169 | 110 | Step program backward until it reaches the beginning of another source line.\n\ |
170 | 111 | Argument N means do this N times (or till program stops for another reason).") |
@@ -486,8 +486,7 @@ update_current_target (void) | ||
486 | 486 | INHERIT (to_find_memory_regions, t); |
487 | 487 | INHERIT (to_make_corefile_notes, t); |
488 | 488 | INHERIT (to_get_thread_local_address, t); |
489 | - INHERIT (to_get_exec_direction, t); | |
490 | - INHERIT (to_set_exec_direction, t); | |
489 | + INHERIT (to_can_execute_reverse, t); | |
491 | 490 | /* Do not inherit to_read_description. */ |
492 | 491 | /* Do not inherit to_search_memory. */ |
493 | 492 | INHERIT (to_magic, t); |
@@ -152,14 +152,6 @@ struct target_waitstatus | ||
152 | 152 | value; |
153 | 153 | }; |
154 | 154 | |
155 | -/* Reverse execution. */ | |
156 | -enum exec_direction_kind | |
157 | - { | |
158 | - EXEC_FORWARD, | |
159 | - EXEC_REVERSE, | |
160 | - EXEC_ERROR | |
161 | - }; | |
162 | - | |
163 | 155 | /* Possible types of events that the inferior handler will have to |
164 | 156 | deal with. */ |
165 | 157 | enum inferior_event_type |
@@ -535,10 +527,8 @@ struct target_ops | ||
535 | 527 | const gdb_byte *pattern, ULONGEST pattern_len, |
536 | 528 | CORE_ADDR *found_addrp); |
537 | 529 | |
538 | - /* Set execution direction (forward/reverse). */ | |
539 | - int (*to_set_exec_direction) (enum exec_direction_kind); | |
540 | - /* Get execution direction (forward/reverse). */ | |
541 | - enum exec_direction_kind (*to_get_exec_direction) (void); | |
530 | + /* Can target execute in reverse? */ | |
531 | + int (*to_can_execute_reverse) (); | |
542 | 532 | |
543 | 533 | /* Default value is 0. Mean that this target doesn't support record wait. |
544 | 534 | 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 *); | ||
1143 | 1133 | #define target_watchpoint_addr_within_range(target, addr, start, length) \ |
1144 | 1134 | (*target.to_watchpoint_addr_within_range) (target, addr, start, length) |
1145 | 1135 | |
1146 | -/* Forward/reverse execution direction. | |
1147 | - These will only be implemented by a target that supports reverse execution. | |
1148 | -*/ | |
1149 | -#define target_get_execution_direction() \ | |
1150 | - (current_target.to_get_exec_direction ? \ | |
1151 | - (*current_target.to_get_exec_direction) () : EXEC_ERROR) | |
1152 | - | |
1153 | -#define target_set_execution_direction(DIR) \ | |
1154 | - (current_target.to_set_exec_direction ? \ | |
1155 | - (*current_target.to_set_exec_direction) (DIR) : EXEC_ERROR) | |
1156 | - | |
1136 | +/* Target can execute in reverse? */ | |
1137 | +#define target_can_execute_reverse \ | |
1138 | + (current_target.to_can_execute_reverse ? \ | |
1139 | + current_target.to_can_execute_reverse () : 0) | |
1157 | 1140 | |
1158 | 1141 | extern const struct target_desc *target_read_description (struct target_ops *); |
1159 | 1142 |