From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7872) id 39DD2385735E; Wed, 27 Apr 2022 14:14:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 39DD2385735E 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: fix FAIL in gdb.base/clear_non_user_bp.exp X-Act-Checkin: binutils-gdb X-Git-Author: Enze Li X-Git-Refname: refs/heads/master X-Git-Oldrev: 36b124126b33765da21a065d3aaf572dbdbf477b X-Git-Newrev: 41b96eef5f1de451e5e95cca053df0550f66bbf5 Message-Id: <20220427141407.39DD2385735E@sourceware.org> Date: Wed, 27 Apr 2022 14:14:07 +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: Wed, 27 Apr 2022 14:14:07 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D41b96eef5f1d= e451e5e95cca053df0550f66bbf5 commit 41b96eef5f1de451e5e95cca053df0550f66bbf5 Author: Enze Li Date: Wed Apr 27 21:12:27 2022 +0800 gdb/testsuite: fix FAIL in gdb.base/clear_non_user_bp.exp =20 Tom and Simon feedback that there is a test failing in this commit: =20 commit a5c69b1e49bae4d0dcb20f324cebb310c63495c6 Date: Sun Apr 17 15:09:46 2022 +0800 =20 gdb: fix using clear command to delete non-user breakpoints(PR cli/= 7161) =20 Then, I reproduced the same fail with Ubuntu 20.04 as Simon said, and I fixed the nit in this patch. The root of the problem is not correctly matching the presentation of internal breakpoints. =20 In addition, as Pedro pointed out, the original testcase is not portable in some methods, so this patch fixes this issue and some other improvements. =20 Tested on x86_64 ubuntu 20.04.4 and openSUSE Tumbleweed(VERSION_ID=3D"2= 0220425"). Diff: --- gdb/testsuite/gdb.base/clear_non_user_bp.exp | 66 ++++++++++++++++++++----= ---- 1 file changed, 48 insertions(+), 18 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 d7bb8ab7e9a..26d7a31fa47 100644 --- a/gdb/testsuite/gdb.base/clear_non_user_bp.exp +++ b/gdb/testsuite/gdb.base/clear_non_user_bp.exp @@ -16,17 +16,45 @@ # Regression test for PR gdb/7161. Test that GDB cannot delete non-user # breakpoints with clear command. =20 -proc get_maint_info_bp { var } { - global expect_out - global gdb_prompt - - gdb_test_multiple "maint info break $var" "find address of internal bp= $var" { - -re ".*(0x\[0-9a-f\]+).*$gdb_prompt $" { +# 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) } - timeout { - perror "couldn't find address of $var" - return "" + } + return "" +} + +# get_first_maint_bp_num +# +# Purpose: +# Get the first number of all internal breakpoints when using command +# "maint info breakpoints". +# +# Parameter: +# None. +# +# Return: +# Internal breakpoint number, which is negative. +# +proc get_first_maint_bp_num { } { + gdb_test_multiple "maint info break" "find first internal bp num" { + -re -wrap "(-\[0-9\]).*" { + return $expect_out(1,string) } } return "" @@ -48,17 +76,19 @@ if ![runto_main] then { return 0 } =20 -gdb_test "break main.c:21" \ - ".*Breakpoint.* at .*" \ - "set breakpoint" +set bp_num [get_first_maint_bp_num] +set bp_addr [get_maint_bp_addr $bp_num] =20 -set bp_addr [get_maint_info_bp "-1"] - -gdb_test "maint info break -1" \ - "-1.*shlib events.*keep y.*$bp_addr.*" \ - "maint info breakpoint -1 error" +gdb_test "maint info break $bp_num" \ + "$bp_num.*$bp_addr.*" \ + "maint info breakpoint \$bp_num" =20 gdb_test "clear *$bp_addr" \ "No breakpoint at \\*$bp_addr." \ - "clear internal breakpoint error" + "clear internal breakpoint" + +# Check again, make sure that GDB really didn't delete the internal breakp= oint. +gdb_test "maint info break $bp_num" \ + "$bp_num.*$bp_addr.*" \ + "maint info breakpoint \$bp_num after clear"