| 1 |
330 |
jeremybenn |
# Copyright 2009
|
| 2 |
|
|
# Free Software Foundation, Inc.
|
| 3 |
|
|
|
| 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 |
|
|
#
|
| 9 |
|
|
# This program is distributed in the hope that it will be useful,
|
| 10 |
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 11 |
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 12 |
|
|
# GNU General Public License for more details.
|
| 13 |
|
|
#
|
| 14 |
|
|
# You should have received a copy of the GNU General Public License
|
| 15 |
|
|
# along with this program. If not, see .
|
| 16 |
|
|
|
| 17 |
|
|
# Test Machine interface (MI) operations
|
| 18 |
|
|
# Verify that, using the MI, we can run a simple program in both forward
|
| 19 |
|
|
# and reverse directions with the following execution commands:
|
| 20 |
|
|
# - exec-continue
|
| 21 |
|
|
# - exec-finish
|
| 22 |
|
|
# - exec-next
|
| 23 |
|
|
# - exec-step
|
| 24 |
|
|
# - exec-next-instruction
|
| 25 |
|
|
# - exec-step-instruction
|
| 26 |
|
|
|
| 27 |
|
|
# The goal is not to test gdb functionality, which is done by other tests,
|
| 28 |
|
|
# but to verify the correct output response to MI operations.
|
| 29 |
|
|
#
|
| 30 |
|
|
|
| 31 |
|
|
if ![target_info exists gdb,can_reverse] {
|
| 32 |
|
|
return
|
| 33 |
|
|
}
|
| 34 |
|
|
|
| 35 |
|
|
load_lib mi-support.exp
|
| 36 |
|
|
set MIFLAGS "-i=mi"
|
| 37 |
|
|
|
| 38 |
|
|
gdb_exit
|
| 39 |
|
|
if [mi_gdb_start] {
|
| 40 |
|
|
continue
|
| 41 |
|
|
}
|
| 42 |
|
|
|
| 43 |
|
|
set testfile "basics"
|
| 44 |
|
|
set srcfile ${testfile}.c
|
| 45 |
|
|
set binfile ${objdir}/${subdir}/mi2-reverse
|
| 46 |
|
|
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
|
| 47 |
|
|
untested mi2-reverse.exp
|
| 48 |
|
|
return -1
|
| 49 |
|
|
}
|
| 50 |
|
|
|
| 51 |
|
|
mi_run_to_main
|
| 52 |
|
|
|
| 53 |
|
|
if [target_info exists gdb,use_precord] {
|
| 54 |
|
|
# Activate process record/replay
|
| 55 |
|
|
if [mi_gdb_test "-interpreter-exec console record" \
|
| 56 |
|
|
{\^done} "Turn on process record"] {
|
| 57 |
|
|
warning "Fail to activate process record/replay, tests in this group will not be performed.\n";
|
| 58 |
|
|
return -1
|
| 59 |
|
|
}
|
| 60 |
|
|
}
|
| 61 |
|
|
|
| 62 |
|
|
# Locate line numbers in basics.c.
|
| 63 |
|
|
set line_callee4_head [gdb_get_line_number "callee4 ("]
|
| 64 |
|
|
set line_callee4_body [expr $line_callee4_head + 2]
|
| 65 |
|
|
set line_callee3_head [gdb_get_line_number "callee3 ("]
|
| 66 |
|
|
set line_callee3_body [expr $line_callee3_head + 2]
|
| 67 |
|
|
set line_callee3_close [expr $line_callee3_head + 3]
|
| 68 |
|
|
set line_callee2_head [gdb_get_line_number "callee2 ("]
|
| 69 |
|
|
set line_callee2_body [expr $line_callee2_head + 2]
|
| 70 |
|
|
set line_callee2_close [expr $line_callee2_head + 3]
|
| 71 |
|
|
set line_callee1_head [gdb_get_line_number "callee1 ("]
|
| 72 |
|
|
set line_callee1_body [expr $line_callee1_head + 2]
|
| 73 |
|
|
set line_callee1_close [expr $line_callee1_head + 3]
|
| 74 |
|
|
set line_callme_head [gdb_get_line_number "callme"]
|
| 75 |
|
|
set line_callme_body [expr $line_callme_head + 2]
|
| 76 |
|
|
set line_main_head [gdb_get_line_number "main ("]
|
| 77 |
|
|
set line_main_body [expr $line_main_head + 2]
|
| 78 |
|
|
set line_main_hello [gdb_get_line_number "Hello, World!"]
|
| 79 |
|
|
set line_main_callme_1 [gdb_get_line_number "callme (1"]
|
| 80 |
|
|
|
| 81 |
|
|
# Forward execute to the callme() function, so that we can
|
| 82 |
|
|
# execute backward from there.
|
| 83 |
|
|
mi_continue_to callme
|
| 84 |
|
|
mi_delete_breakpoints
|
| 85 |
|
|
|
| 86 |
|
|
proc test_controlled_execution_reverse {} {
|
| 87 |
|
|
global mi_gdb_prompt
|
| 88 |
|
|
global srcfile
|
| 89 |
|
|
global hex
|
| 90 |
|
|
|
| 91 |
|
|
global line_callee4_head line_callee4_body
|
| 92 |
|
|
global line_callee3_head line_callee3_body line_callee3_close
|
| 93 |
|
|
global line_callee2_head line_callee2_body line_callee2_close
|
| 94 |
|
|
global line_callee1_head line_callee1_body line_callee1_close
|
| 95 |
|
|
global line_main_head line_main_body
|
| 96 |
|
|
global line_main_hello line_main_callme_1
|
| 97 |
|
|
|
| 98 |
|
|
# Test exec-reverse-finish
|
| 99 |
|
|
|
| 100 |
|
|
mi_execute_to "exec-finish --reverse" \
|
| 101 |
|
|
"end-stepping-range" "main" "" \
|
| 102 |
|
|
"basics.c" $line_main_callme_1 "" \
|
| 103 |
|
|
"reverse finish from callme"
|
| 104 |
|
|
|
| 105 |
|
|
# Test exec-reverse-next
|
| 106 |
|
|
# It takes two steps to get back to the previous line,
|
| 107 |
|
|
# as the first step moves us to the start of the current line,
|
| 108 |
|
|
# and the one after that moves back to the previous line.
|
| 109 |
|
|
|
| 110 |
|
|
mi_execute_to "exec-next --reverse 2" \
|
| 111 |
|
|
"end-stepping-range" "main" "" \
|
| 112 |
|
|
"basics.c" $line_main_hello "" \
|
| 113 |
|
|
"reverse next to get over the call to do_nothing"
|
| 114 |
|
|
|
| 115 |
|
|
# Test exec-reverse-step
|
| 116 |
|
|
|
| 117 |
|
|
mi_execute_to "exec-step --reverse" \
|
| 118 |
|
|
"end-stepping-range" "callee1" \
|
| 119 |
|
|
"\{name=\"intarg\",value=\"2\"\},\{name=\"strarg\",value=\"$hex \\\\\"A string argument\.\\\\\"\"\},\{name=\"fltarg\",value=\"3.5\"\}" \
|
| 120 |
|
|
"basics.c" $line_callee1_close "" \
|
| 121 |
|
|
"reverse step to callee1"
|
| 122 |
|
|
|
| 123 |
|
|
mi_execute_to "exec-step --reverse" \
|
| 124 |
|
|
"end-stepping-range" "callee2" \
|
| 125 |
|
|
"\{name=\"intarg\",value=\"2\"\},\{name=\"strarg\",value=\"$hex \\\\\"A string argument\.\\\\\"\"\}" \
|
| 126 |
|
|
"basics.c" $line_callee2_close "" \
|
| 127 |
|
|
"reverse step to callee2"
|
| 128 |
|
|
|
| 129 |
|
|
mi_execute_to "exec-step --reverse" \
|
| 130 |
|
|
"end-stepping-range" "callee3" \
|
| 131 |
|
|
"\{name=\"strarg\",value=\"$hex \\\\\"A string argument\.\\\\\"\"\}" \
|
| 132 |
|
|
"basics.c" $line_callee3_close "" \
|
| 133 |
|
|
"reverse step to callee3"
|
| 134 |
|
|
|
| 135 |
|
|
mi_execute_to "exec-step --reverse" \
|
| 136 |
|
|
"end-stepping-range" "callee4" "" \
|
| 137 |
|
|
"basics.c" "\[0-9\]+" "" \
|
| 138 |
|
|
"reverse step to callee4"
|
| 139 |
|
|
|
| 140 |
|
|
# Test exec-reverse-[step|next]-instruction
|
| 141 |
|
|
|
| 142 |
|
|
mi_execute_to "exec-step-instruction --reverse" \
|
| 143 |
|
|
"end-stepping-range" "callee4" "" \
|
| 144 |
|
|
"basics.c" "\[0-9\]+" "" \
|
| 145 |
|
|
"reverse-step-instruction at callee4"
|
| 146 |
|
|
|
| 147 |
|
|
mi_execute_to "exec-next-instruction --reverse" \
|
| 148 |
|
|
"end-stepping-range" "callee4" "" \
|
| 149 |
|
|
"basics.c" "\[0-9\]+" "" \
|
| 150 |
|
|
"reverse-next-instruction at callee4"
|
| 151 |
|
|
|
| 152 |
|
|
# Test exec-reverse-continue
|
| 153 |
|
|
|
| 154 |
|
|
mi_create_breakpoint "-t basics.c:$line_callee3_head" \
|
| 155 |
|
|
3 del callee3 ".*basics.c" $line_callee3_head $hex \
|
| 156 |
|
|
"insert temp breakpoint at basics.c:$line_callee3_head"
|
| 157 |
|
|
|
| 158 |
|
|
mi_execute_to "exec-continue --reverse" \
|
| 159 |
|
|
"breakpoint-hit" "callee3" \
|
| 160 |
|
|
"\{name=\"strarg\",value=\"$hex \\\\\"A string argument\.\\\\\"\"\}" \
|
| 161 |
|
|
"basics.c" "\[0-9\]+" \
|
| 162 |
|
|
{ "" "disp=\"del\""} \
|
| 163 |
|
|
"reverse-continue at callee3"
|
| 164 |
|
|
|
| 165 |
|
|
mi_execute_to "exec-continue --reverse" \
|
| 166 |
|
|
"" "main" "" \
|
| 167 |
|
|
"basics.c" $line_main_body "" \
|
| 168 |
|
|
"reverse-continue at main"
|
| 169 |
|
|
}
|
| 170 |
|
|
|
| 171 |
|
|
test_controlled_execution_reverse
|
| 172 |
|
|
|
| 173 |
|
|
mi_gdb_exit
|
| 174 |
|
|
return 0
|