From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7872) id 6426A385840A; Sun, 24 Jul 2022 04:11:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6426A385840A Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Enze Li To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/testsuite: rename get_maint_bp_addr and move it to gdb-utils.exp X-Act-Checkin: binutils-gdb X-Git-Author: Enze Li X-Git-Refname: refs/heads/master X-Git-Oldrev: 561e83f7c5cdfb2737ba36a04ea008caa6bcaa36 X-Git-Newrev: c444385fad25c720ca6f7407f748f1d601463938 Message-Id: <20220724041125.6426A385840A@sourceware.org> Date: Sun, 24 Jul 2022 04:11:25 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Jul 2022 04:11:25 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dc444385fad25= c720ca6f7407f748f1d601463938 commit c444385fad25c720ca6f7407f748f1d601463938 Author: Enze Li Date: Fri Jun 24 21:00:40 2022 +0800 gdb/testsuite: rename get_maint_bp_addr and move it to gdb-utils.exp =20 The get_maint_bp_addr procedure will be shared by other test suite, so move it to gdb-utils.exp. =20 Following Andrew's suggestion, I renamed get_maint_bp_addr to gdb_get_bp_addr, since it would have handled normal breakpoints in addition to the internal ones. Note that there is still room for improvement in this procedure, which I indicated in comments nearby. Diff: --- gdb/testsuite/gdb.base/clear_non_user_bp.exp | 25 +------------------------ gdb/testsuite/lib/gdb-utils.exp | 28 ++++++++++++++++++++++++= ++++ 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/gdb/testsuite/gdb.base/clear_non_user_bp.exp b/gdb/testsuite/g= db.base/clear_non_user_bp.exp index 26d7a31fa47..da694351c87 100644 --- a/gdb/testsuite/gdb.base/clear_non_user_bp.exp +++ b/gdb/testsuite/gdb.base/clear_non_user_bp.exp @@ -16,29 +16,6 @@ # Regression test for PR gdb/7161. Test that GDB cannot delete non-user # breakpoints with clear command. =20 -# get_maint_bp_addr num -# -# Purpose: -# Get address of the specified internal breakpoint when using command -# "maint info breakpoints $num". -# -# Parameter: -# The parameter "num" indicates the number of the internal breakpoint -# to get. Note that this parameter must be a negative number. -# E.g., -1 means that we're gonna get the first internal breakpoint. -# -# Return: -# Internal breakpoint address. -# -proc get_maint_bp_addr { num } { - gdb_test_multiple "maint info break $num" "find address of internal bp= $num" { - -re -wrap ".*(0x\[0-9a-f\]+).*" { - return $expect_out(1,string) - } - } - return "" -} - # get_first_maint_bp_num # # Purpose: @@ -77,7 +54,7 @@ if ![runto_main] then { } =20 set bp_num [get_first_maint_bp_num] -set bp_addr [get_maint_bp_addr $bp_num] +set bp_addr [gdb_get_bp_addr $bp_num] =20 gdb_test "maint info break $bp_num" \ "$bp_num.*$bp_addr.*" \ diff --git a/gdb/testsuite/lib/gdb-utils.exp b/gdb/testsuite/lib/gdb-utils.= exp index ffdfb75557c..21953611ec2 100644 --- a/gdb/testsuite/lib/gdb-utils.exp +++ b/gdb/testsuite/lib/gdb-utils.exp @@ -72,3 +72,31 @@ proc style {str style} { } return "\033\\\[${style}m${str}\033\\\[m" } + +# gdb_get_bp_addr num +# +# Purpose: +# Get address of a particular breakpoint. +# +# Parameter: +# The parameter "num" indicates the number of the breakpoint to get. +# Note that *currently* this parameter must be an integer value. +# E.g., -1 means that we're gonna get the first internal breakpoint; +# 2 means to get the second user-defined breakpoint. +# +# Return: +# First address for a particular breakpoint. +# +# TODO: +# It would be nice if this procedure could accept floating point value. +# E.g., 'gdb_get_bp_addr 1.2' means to get the address of the second +# location of breakpoint #1. +# +proc gdb_get_bp_addr { num } { + gdb_test_multiple "maint info break $num" "find address of specified b= p $num" { + -re -wrap ".*(0x\[0-9a-f\]+).*" { + return $expect_out(1,string) + } + } + return "" +}