From d211b4d17c4c2253d85a73a78db5581b369746bd Mon Sep 17 00:00:00 2001 From: Carl Love Date: Wed, 1 Mar 2023 14:50:15 +0100 Subject: [PATCH] [gdb/testsuite] Introduce repeat_cmd_until Test-case gdb.reverse/step-indirect-call-thunk.exp contains a proc step_until. OTOH, we've got a somewhat similar proc in lib/gdb.exp: gdb_step_until. Fix this by: - moving step_until into lib/gdb.exp and renaming to repeat_cmd_until, - reimplementing gdb_step_until using repeat_cmd_until, and - reimplementing step_until as an local alias of repeat_cmd_until (in order to avoid polluting history with updating all the calls). Tested on x86_64-linux. --- .../gdb.reverse/step-indirect-call-thunk.exp | 32 +----------- gdb/testsuite/lib/gdb.exp | 49 ++++++++++++++----- 2 files changed, 40 insertions(+), 41 deletions(-) diff --git a/gdb/testsuite/gdb.reverse/step-indirect-call-thunk.exp b/gdb/testsuite/gdb.reverse/step-indirect-call-thunk.exp index f433efb11c2..d431d174f88 100644 --- a/gdb/testsuite/gdb.reverse/step-indirect-call-thunk.exp +++ b/gdb/testsuite/gdb.reverse/step-indirect-call-thunk.exp @@ -38,37 +38,9 @@ if { ![runto_main] } { return -1 } -# 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 is the test name -# -# The function issues repeated COMMANDs as long as the location matches -# CURRENT up to a maximum of 100 steps. -# -# TEST passes if the resulting location matches TARGET and fails -# otherwise. -# +# Local alias for repeat_cmd_until. proc step_until { command current target test } { - global gdb_prompt - - set count 0 - gdb_test_multiple "$command" "$test" { - -re "$current.*$gdb_prompt $" { - incr count - if { $count < 100 } { - send_gdb "$command\n" - exp_continue - } else { - fail "$test" - } - } - -re "$target.*$gdb_prompt $" { - pass "$test" - } - } + repeat_cmd_until $command $current $target $test } gdb_test_no_output "record" diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 19c782bea46..650a44aab1e 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -9270,31 +9270,58 @@ 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} } { +proc gdb_step_until { regexp {test_name ""} {current ""} \ + { max_steps 10 } } { + if { $current == "" } { + set current "\}" + } + if { $test_name == "" } { + set test_name "stepping until regexp" + } + + 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 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 100 steps. +# +# TEST passes if the resulting location matches TARGET and fails +# otherwise. +# +proc repeat_cmd_until { command current target test_name {max_steps 100} } { + global gdb_prompt if { $test_name == "" } { set test_name "stepping until regexp" } 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" + } } } base-commit: 2c29b1ed19711fa2a16558015e5a6b46a09aefeb -- 2.35.3