diff options
author | Carl Love <cel@us.ibm.com> | 2023-03-01 11:45:43 -0500 |
---|---|---|
committer | Carl Love <cel@us.ibm.com> | 2023-03-17 16:02:48 -0400 |
commit | 334d405c2ac395fca67b952affb20893002d969f (patch) | |
tree | cde2e808763575007af434e17b5f32c61e683b49 /gdb/testsuite/lib | |
parent | 1b046c8eb920bd264d57d472e31a01a32bb5ae89 (diff) | |
download | binutils-334d405c2ac395fca67b952affb20893002d969f.zip binutils-334d405c2ac395fca67b952affb20893002d969f.tar.gz binutils-334d405c2ac395fca67b952affb20893002d969f.tar.bz2 |
Move step_until procedure
Procedure step_until from test gdb.reverse/step-indirect-call-thunk.exp
is moved to lib/gdb.exp and renamed repeat_cmd_until. The existing procedure
gdb_step_until in lib/gdb.exp is simpler variant of the new repeat_cmd_until
procedure. The existing procedure gdb_step_until is changed to just call
the new repeat_cmd_until procedure with the command set to "step" and an
optional CURRENT string. The default CURRENT string is set to "\}" to work
with the existing uses of procedure gdb_step_until.
Diffstat (limited to 'gdb/testsuite/lib')
-rw-r--r-- | gdb/testsuite/lib/gdb.exp | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index e48b94b..86a0515 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -9347,31 +9347,50 @@ gdb_caching_proc arm_cc_for_target {} { # Step until the pattern REGEXP is found. Step at most # MAX_STEPS times, but stop stepping once REGEXP is found. -# +# CURRENT matches current location # If REGEXP is found then a single pass is emitted, otherwise, after # MAX_STEPS steps, a single fail is emitted. # # TEST_NAME is the name used in the pass/fail calls. -proc gdb_step_until { regexp {test_name ""} {max_steps 10} } { - if { $test_name == "" } { - set test_name "stepping until regexp" - } +proc gdb_step_until { regexp {test_name "stepping until regexp"} \ + {current "\}"} { max_steps 10 } } { + repeat_cmd_until "step" $current $regexp $test_name "10" +} + +# Do repeated stepping COMMANDs in order to reach TARGET from CURRENT +# +# COMMAND is a stepping command +# CURRENT is a string matching the current location +# TARGET is a string matching the target location +# TEST_NAME is the test name +# MAX_STEPS is number of steps attempted before fail is emitted +# +# The function issues repeated COMMANDs as long as the location matches +# CURRENT up to a maximum of MAX_STEPS. +# +# TEST_NAME passes if the resulting location matches TARGET and fails +# otherwise. + +proc repeat_cmd_until { command current target \ + {test_name "stepping until regexp"} \ + {max_steps 100} } { + global gdb_prompt set count 0 - gdb_test_multiple "step" "$test_name" { - -re "$regexp\r\n$::gdb_prompt $" { - pass $test_name - } - -re ".*$::gdb_prompt $" { - if {$count < $max_steps} { - incr count - send_gdb "step\n" + gdb_test_multiple "$command" "$test_name" { + -re "$current.*$gdb_prompt $" { + incr count + if { $count < $max_steps } { + send_gdb "$command\n" exp_continue } else { - fail $test_name + fail "$test_name" } } + -re "$target.*$gdb_prompt $" { + pass "$test_name" + } } } |