From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1983) id 665193858401; Fri, 17 Mar 2023 20:03:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 665193858401 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1679083430; bh=jO9cx+A7tMv0qJ+BfZaC4W4IiWxC0lwcDiTbOeCdaWM=; h=From:To:Subject:Date:From; b=VJupZCPzzmoGV2H3BclvK1aJm/fniI7bYbXyhewEX+U0ewBsOleGy29kTCPmiyPA6 x6PEkt91lMW7lfLMxp6YId5bdGne/oJHU1DOtN68JsUyDPDYE6C4PMOG63Db0W2ieD xpXfrQOwdo0y2rZcFEYhZntirjSIO5cwI3j0eN3E= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Carl Love To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Move step_until procedure X-Act-Checkin: binutils-gdb X-Git-Author: Carl Love X-Git-Refname: refs/heads/master X-Git-Oldrev: 1b046c8eb920bd264d57d472e31a01a32bb5ae89 X-Git-Newrev: 334d405c2ac395fca67b952affb20893002d969f Message-Id: <20230317200350.665193858401@sourceware.org> Date: Fri, 17 Mar 2023 20:03:50 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D334d405c2ac3= 95fca67b952affb20893002d969f commit 334d405c2ac395fca67b952affb20893002d969f Author: Carl Love Date: Wed Mar 1 11:45:43 2023 -0500 Move step_until procedure =20 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 pro= cedure 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 ca= ll 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. Diff: --- .../gdb.reverse/step-indirect-call-thunk.exp | 49 ++++--------------= ---- gdb/testsuite/lib/gdb.exp | 47 ++++++++++++++----= --- 2 files changed, 41 insertions(+), 55 deletions(-) diff --git a/gdb/testsuite/gdb.reverse/step-indirect-call-thunk.exp b/gdb/t= estsuite/gdb.reverse/step-indirect-call-thunk.exp index f433efb11c2..e6c81b80a7b 100644 --- a/gdb/testsuite/gdb.reverse/step-indirect-call-thunk.exp +++ b/gdb/testsuite/gdb.reverse/step-indirect-call-thunk.exp @@ -38,39 +38,6 @@ if { ![runto_main] } { return -1 } =20 -# 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. -# -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" - } - } -} - gdb_test_no_output "record" gdb_test "next" ".*" "record trace" =20 @@ -90,20 +57,20 @@ gdb_test "reverse-next" "apply\.2.*" \ "reverse-step through thunks and over inc" =20 # We can use instruction stepping to step into thunks. -step_until "stepi" "apply\.2" "indirect_thunk" "stepi into call thunk" -step_until "stepi" "indirect_thunk" "inc" \ +repeat_cmd_until "stepi" "apply\.2" "indirect_thunk" "stepi into call thun= k" +repeat_cmd_until "stepi" "indirect_thunk" "inc" \ "stepi out of call thunk into inc" set alphanum_re "\[a-zA-Z0-9\]" set pic_thunk_re "__$alphanum_re*\\.get_pc_thunk\\.$alphanum_re* \\(\\)" -step_until "stepi" "(inc|$pic_thunk_re)" "return_thunk" "stepi into return= thunk" -step_until "stepi" "return_thunk" "apply" \ +repeat_cmd_until "stepi" "(inc|$pic_thunk_re)" "return_thunk" "stepi into = return thunk" +repeat_cmd_until "stepi" "return_thunk" "apply" \ "stepi out of return thunk back into apply" =20 -step_until "reverse-stepi" "apply" "return_thunk" \ +repeat_cmd_until "reverse-stepi" "apply" "return_thunk" \ "reverse-stepi into return thunk" -step_until "reverse-stepi" "return_thunk" "inc" \ +repeat_cmd_until "reverse-stepi" "return_thunk" "inc" \ "reverse-stepi out of return thunk into inc" -step_until "reverse-stepi" "(inc|$pic_thunk_re)" "indirect_thunk" \ +repeat_cmd_until "reverse-stepi" "(inc|$pic_thunk_re)" "indirect_thunk" \ "reverse-stepi into call thunk" -step_until "reverse-stepi" "indirect_thunk" "apply" \ +repeat_cmd_until "reverse-stepi" "indirect_thunk" "apply" \ "reverse-stepi out of call thunk into apply" diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index e48b94b4696..86a05156e0a 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -9347,31 +9347,50 @@ gdb_caching_proc arm_cc_for_target {} { =20 # 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. =20 -proc gdb_step_until { regexp {test_name ""} {max_steps 10} } { - if { $test_name =3D=3D "" } { - 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 =20 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" + } } }