From patchwork Mon Mar 24 11:16:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gerlicher, Klaus" X-Patchwork-Id: 108954 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8CED5385608D for ; Mon, 24 Mar 2025 11:18:01 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) by sourceware.org (Postfix) with ESMTPS id E5137385B83A for ; Mon, 24 Mar 2025 11:17:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E5137385B83A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E5137385B83A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1742815042; cv=none; b=OIDMDZF3Bve2/ttWRWWEF3r3PZXup0z3oKzodeaw6CLv+0j5ZAvqccLb/+V51337SBMUIwSAY+gDdMO2rfjeEnTWjGPGgLB3SjcF18dSdqC8X8rOO8oCSKMF47n30IRsmXYvgDUKlq6cX5nxC19+VN4MN1olDcq7EHFCsvpmLs8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1742815042; c=relaxed/simple; bh=82vBE2Be0iKALdGULo0XQ7mUhnTH4dGnHS86We9xtl4=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=aSmwG2AWaB38hgKtaoc0tTLk5PWiPj2r7eG99WkmVk/6nCWxlwHidmHMuUHL/5TzcskkTvfbdQM3QgCvl83aR6jA9+19zinORneHx54eU/nzndP2NXPvTGEuhr+amIbdA/OWhxuFIUz/6C3OaU5d71Xml/uebVLBy3U4geBUQcg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E5137385B83A Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=mTkdP8K2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1742815042; x=1774351042; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=82vBE2Be0iKALdGULo0XQ7mUhnTH4dGnHS86We9xtl4=; b=mTkdP8K2wsyhp5eQp7Xlj4TTS3JqPtrS+SWDPH3Yhn4DwmBUEUGIUiXx V7jdo128MJUfkUJWSeMvrcOqJeLpu+bfbz6vIA7Bmh3lt9Yshp6AgmXjj 6UYeGPt7pr/Af0FCVxvFi6gBMUq5QUudVKUGyfaJDlQYvAmYW+LqmYzfn EjbOXFZknCU16difhQA7lSSC/cYr2ob4J99a9AENUQ7s3HQiIueytLz5t mFfdo2b94qi5Wzmq4730B7Bb2z3WvXmk+PcCIjGXKj2CfZp7CrckOFdyg 4Q+EhkOs2HOX+jKXxNmHqhjL8n0otmLRePUsjUrsyOOxLh/dl+vZwe3Y3 Q==; X-CSE-ConnectionGUID: 5BU9fl7iSaCfebROL/+5vg== X-CSE-MsgGUID: hzyWyc1BQK2jBzpHLU19Lg== X-IronPort-AV: E=McAfee;i="6700,10204,11382"; a="44203365" X-IronPort-AV: E=Sophos;i="6.14,271,1736841600"; d="scan'208";a="44203365" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2025 04:17:20 -0700 X-CSE-ConnectionGUID: 6L5ZPywWRSqd6LooFDIfUA== X-CSE-MsgGUID: BDsopZvjT6qbfiNqewsEQA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,271,1736841600"; d="scan'208";a="155031318" Received: from dut1505dg2frd.igk.intel.com (HELO localhost) ([10.102.46.29]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2025 04:17:18 -0700 From: Klaus Gerlicher To: gdb-patches@sourceware.org, blarsen@redhat.com, aburgess@redhat.com, eliz@gnu.org Subject: [PATCH v9 1/2] gdb: extend gdb_breakpoint for multiple locations Date: Mon, 24 Mar 2025 11:16:45 +0000 Message-Id: <20250324111646.3201607-2-klaus.gerlicher@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250324111646.3201607-1-klaus.gerlicher@intel.com> References: <20250324111646.3201607-1-klaus.gerlicher@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org From: "Gerlicher, Klaus" Many tests have gdb_test "break..." style testing which could be more generically handled by gdb_breakpoint. This, for example gdb_test "break func2" \ "Breakpoint.*at.*func2.*\\(2 locations\\)" becomes gdb_breakpoint "func2" -locs 2 where -locs specifies that gdb_breakpoint should try to match to 2 locations in the "break" output. Extend gdb_breakpoint with options for matching multiple breakpoint locations. Also remove one historical stale comment and trailing space and indent issues. --- gdb/testsuite/gdb.ada/bp_inlined_func.exp | 4 +- gdb/testsuite/gdb.ada/homonym.exp | 8 +- gdb/testsuite/gdb.ada/operator_bp.exp | 18 +--- .../gdb.base/condbreak-multi-context.exp | 30 +++--- gdb/testsuite/gdb.base/dtrace-probe.exp | 4 +- gdb/testsuite/gdb.base/foll-fork.exp | 7 +- gdb/testsuite/gdb.base/msym-bp-shl.exp | 4 +- gdb/testsuite/gdb.base/msym-bp.exp | 2 +- gdb/testsuite/gdb.base/solib-symbol.exp | 4 +- gdb/testsuite/gdb.base/stap-probe.exp | 8 +- gdb/testsuite/gdb.base/step-over-exit.exp | 2 +- gdb/testsuite/gdb.cp/breakpoint-locs.exp | 2 +- gdb/testsuite/gdb.cp/ena-dis-br-range.exp | 4 +- gdb/testsuite/gdb.cp/mb-ctor.exp | 8 +- gdb/testsuite/gdb.cp/mb-inline.exp | 8 +- gdb/testsuite/gdb.cp/mb-templates.exp | 13 +-- gdb/testsuite/gdb.cp/meth-typedefs.exp | 2 +- gdb/testsuite/gdb.cp/ovldbreak.exp | 4 +- gdb/testsuite/gdb.cp/paramless.exp | 4 +- gdb/testsuite/gdb.cp/templates.exp | 22 ++--- gdb/testsuite/gdb.dwarf2/dw2-inline-break.exp | 20 ++-- .../gdb.dwarf2/dw2-skip-prologue.exp | 2 +- gdb/testsuite/gdb.linespec/break-asm-file.exp | 4 +- gdb/testsuite/gdb.linespec/linespec.exp | 20 +--- .../gdb.multi/bp-thread-specific.exp | 6 +- .../gdb.multi/inferior-specific-bp.exp | 3 +- gdb/testsuite/gdb.opt/inline-break.exp | 23 ++--- gdb/testsuite/gdb.python/py-bp-locations.exp | 2 +- gdb/testsuite/lib/gdb.exp | 99 +++++++++++++++---- 29 files changed, 165 insertions(+), 172 deletions(-) diff --git a/gdb/testsuite/gdb.ada/bp_inlined_func.exp b/gdb/testsuite/gdb.ada/bp_inlined_func.exp index db56a11d12a..028863af3fc 100644 --- a/gdb/testsuite/gdb.ada/bp_inlined_func.exp +++ b/gdb/testsuite/gdb.ada/bp_inlined_func.exp @@ -32,9 +32,7 @@ if {![runto_main]} { # Check that inserting breakpoint on read_small inlined function inserts # 4 breakpoints (or possibly 5, including the read_small function itself). -gdb_test "break read_small" \ - "Breakpoint $decimal at $hex: read_small\\. \\(\[45\] locations\\)" \ - "set breakpoint at read_small" +gdb_breakpoint "read_small" -locs "\[45\]" # We do not verify each breakpoint info, but use continue commands instead # to verify that we properly stop on each expected breakpoint. diff --git a/gdb/testsuite/gdb.ada/homonym.exp b/gdb/testsuite/gdb.ada/homonym.exp index 2fef3c6fbce..15920866daa 100644 --- a/gdb/testsuite/gdb.ada/homonym.exp +++ b/gdb/testsuite/gdb.ada/homonym.exp @@ -29,13 +29,9 @@ clean_restart ${testfile} # Do these tests before running, so we are operating in a known # environment. -gdb_test "break Get_Value" \ - "Breakpoint \[0-9\]+ at $hex: Get_Value. .2 locations." \ - "set breakpoint at Get_Value" +gdb_breakpoint "Get_Value" -locs 2 -gdb_test "break homonym.adb:Get_Value" \ - "Breakpoint \[0-9\]+ at $hex: homonym.adb:Get_Value. .2 locations." \ - "set breakpoint at homonym.adb:Get_Value" +gdb_breakpoint "homonym.adb:Get_Value" -locs 2 gdb_test "break " \ ".*Breakpoint \[0-9\]+ at $hex: (file .*homonym\\.adb, line $decimal\\.|\\. .2 locations.)" \ diff --git a/gdb/testsuite/gdb.ada/operator_bp.exp b/gdb/testsuite/gdb.ada/operator_bp.exp index 2335d492798..d3f78ee6fe6 100644 --- a/gdb/testsuite/gdb.ada/operator_bp.exp +++ b/gdb/testsuite/gdb.ada/operator_bp.exp @@ -33,22 +33,12 @@ runto "ops_test.adb:$bp_location" # Set breakpoints for all operators, using just the operator name in quotes. -set bp_re "Breakpoint $decimal at $hex" foreach op { "+" "-" } { - set op_re [string_to_regexp $op] - gdb_test "break \"$op\"" "$bp_re: \"$op_re\"\\. \\($decimal locations\\).*" + gdb_breakpoint "\"$op\"" -locs $::decimal } foreach op { "*" "/" "mod" "rem" "**" "<" "<=" ">" ">=" "=" "and" "or" "xor" "&" "abs" "not"} { - set op_re [string_to_regexp $op] - gdb_test_multiple "break \"$op\"" "" { - -re -wrap "$bp_re: file .*ops.adb, line $decimal." { - pass $gdb_test_name - } - -re -wrap "$bp_re: \"$op_re\"\\. \\($decimal locations\\).*" { - pass $gdb_test_name - } - } + gdb_breakpoint "\"$op\"" } # Make sure we stop correctly in each operator function. @@ -70,9 +60,7 @@ runto "ops_test.adb:$bp_location" # Set breakpoints for all operators, using just the operator name in quotes. foreach op { "+" "-" } { - set op_re [string_to_regexp $op] - gdb_test "break ops.\"$op\"" \ - "Breakpoint $decimal at $hex: ops\\.\"$op_re\"\\. \\(2 locations\\)" + gdb_breakpoint "ops.\"$op\"" -locs 2 } foreach op { "*" "/" "mod" "rem" "**" "<" "<=" ">" ">=" "=" "and" "or" "xor" "&" "abs" "not"} { diff --git a/gdb/testsuite/gdb.base/condbreak-multi-context.exp b/gdb/testsuite/gdb.base/condbreak-multi-context.exp index 024f7689355..7db8acbaa53 100644 --- a/gdb/testsuite/gdb.base/condbreak-multi-context.exp +++ b/gdb/testsuite/gdb.base/condbreak-multi-context.exp @@ -142,24 +142,22 @@ proc_with_prefix scenario_1 { start_before } { # and C::func) should be disabled. We do not test location # indices strictly at this moment, because we don't know them, # yet. We have strict location index tests below. - gdb_test "break func if aaa == 10" \ - [multi_line \ - "${warning} at location $decimal, disabling:" \ - " No symbol \"aaa\" in current context." \ - "${warning} at location $decimal, disabling:" \ - " No symbol \"aaa\" in current context." \ - "Breakpoint $decimal at $fill .3 locations."] \ - "define bp with condition aaa == 10" + set extra [multi_line \ + "${warning} at location $decimal, disabling:" \ + " No symbol \"aaa\" in current context." \ + "${warning} at location $decimal, disabling:" \ + " No symbol \"aaa\" in current context."] + gdb_breakpoint "func if aaa == 10" -locs 3 -extra $extra -locspec "func" + set bpnum1 [get_integer_valueof "\$bpnum" 0 "get bpnum1"] - gdb_test "break func if ccc == 30" \ - [multi_line \ - ".*${warning} at location $decimal, disabling:" \ - " No symbol \"ccc\" in current context." \ - ".*${warning} at location $decimal, disabling:" \ - " No symbol \"ccc\" in current context." \ - ".*Breakpoint $decimal at $fill .3 locations."] \ - "define bp with condition ccc == 30" + set extra [multi_line \ + "${warning} at location $decimal, disabling:" \ + " No symbol \"ccc\" in current context." \ + "${warning} at location $decimal, disabling:" \ + " No symbol \"ccc\" in current context."] + gdb_breakpoint "func if ccc == 30" -locs 3 -extra $extra -locspec "func" + set bpnum2 [get_integer_valueof "\$bpnum" 0 "get bpnum2"] with_test_prefix "after creating b/p" { diff --git a/gdb/testsuite/gdb.base/dtrace-probe.exp b/gdb/testsuite/gdb.base/dtrace-probe.exp index a8c38f91fb6..a8338fb4f02 100644 --- a/gdb/testsuite/gdb.base/dtrace-probe.exp +++ b/gdb/testsuite/gdb.base/dtrace-probe.exp @@ -92,9 +92,7 @@ proc dtrace_test {} { "print \$_probe_arg1 for probe progress-counter" # Set a breakpoint with multiple probe locations. - gdb_test "break -pdtrace test:two-locations" \ - "Breakpoint \[0-9\]+ at $hex.*2 locations.*" \ - "set multi-location probe breakpoint (probe two-locations)" + gdb_breakpoint "-pdtrace test:two-locations" -locs 2 -locspec "" return 0 } diff --git a/gdb/testsuite/gdb.base/foll-fork.exp b/gdb/testsuite/gdb.base/foll-fork.exp index 0d801f004e4..177bc71f9bc 100644 --- a/gdb/testsuite/gdb.base/foll-fork.exp +++ b/gdb/testsuite/gdb.base/foll-fork.exp @@ -183,11 +183,8 @@ proc_with_prefix test_follow_fork { follow-fork-mode detach-on-fork cmd } { # locations it means there are two program spaces. if {${detach-on-fork} == "off" || ${follow-fork-mode} == "child"} { set bpnum "" - gdb_test_multiple "break callee" "break callee" { - -re -wrap "Breakpoint ($::decimal) at $::hex: callee\\. \\(2 locations\\)" { - set bpnum $expect_out(1,string) - pass $gdb_test_name - } + if { [gdb_breakpoint "callee" -locs 2] } { + set bpnum [get_integer_valueof "\$bpnum" 0 "get bpnum"] } set any {[^\r\n]+} diff --git a/gdb/testsuite/gdb.base/msym-bp-shl.exp b/gdb/testsuite/gdb.base/msym-bp-shl.exp index 31af1f90f31..ab178a18f9e 100644 --- a/gdb/testsuite/gdb.base/msym-bp-shl.exp +++ b/gdb/testsuite/gdb.base/msym-bp-shl.exp @@ -61,7 +61,7 @@ proc test {debug} { # Should find two locations: the static foo in the # msym-bp-shl-main-2 file, and , both in the main binary. with_test_prefix "before run" { - gdb_test "break foo" "\\(2 locations\\)" + gdb_breakpoint "foo" -locs 2 -locspec "" if {$debug} { test_info_break_2 \ @@ -85,7 +85,7 @@ proc test {debug} { # foo in the msym-bp-shl-main-2 file, and the extern foo in the # shared library. with_test_prefix "at main" { - gdb_test "break foo" "\\(2 locations\\)" + gdb_breakpoint "foo" -locs 2 -locspec "" if {$debug} { test_info_break_2 \ diff --git a/gdb/testsuite/gdb.base/msym-bp.exp b/gdb/testsuite/gdb.base/msym-bp.exp index 84d29020900..e154ea6da16 100644 --- a/gdb/testsuite/gdb.base/msym-bp.exp +++ b/gdb/testsuite/gdb.base/msym-bp.exp @@ -52,7 +52,7 @@ proc test {debug} { upvar debug debug with_test_prefix $prefix { - gdb_test "break foo" "\\(2 locations\\)" + gdb_breakpoint "foo" -locs 2 -locspec "" if {$debug} { test_info_break_2 \ diff --git a/gdb/testsuite/gdb.base/solib-symbol.exp b/gdb/testsuite/gdb.base/solib-symbol.exp index 1ec386703cf..6759156ef83 100644 --- a/gdb/testsuite/gdb.base/solib-symbol.exp +++ b/gdb/testsuite/gdb.base/solib-symbol.exp @@ -57,8 +57,6 @@ gdb_test "continue" \ "Continuing.*" # This symbol is now looked up in the ELF library and the binary. -gdb_test "br foo2" \ - "Breakpoint.*: foo2. .2 locations..*" \ - "foo2 in mdlib" +gdb_breakpoint "foo2" -locs 2 gdb_exit diff --git a/gdb/testsuite/gdb.base/stap-probe.exp b/gdb/testsuite/gdb.base/stap-probe.exp index 40e8c5e06f3..6bbbe837f84 100644 --- a/gdb/testsuite/gdb.base/stap-probe.exp +++ b/gdb/testsuite/gdb.base/stap-probe.exp @@ -181,9 +181,7 @@ proc stap_test {exec_name {args ""}} { "check \$_probe_arg1 for probe user" # Set a breakpoint with multiple probe locations. - gdb_test "break -pstap test:two" \ - "Breakpoint \[0-9\]+ at $hex.*2 locations.*" \ - "set multi-location probe breakpoint (probe two)" + gdb_breakpoint "-pstap test:two" -locs 2 -locspec "" # Reinit GDB, set a breakpoint on probe m4. delete_breakpoints @@ -273,9 +271,7 @@ proc stap_test_no_debuginfo {exec_name {args ""}} { # Set a breakpoint with multiple probe locations. # In this scenario, we may expect more than 2 locations because of # the optimizations (inlining, loop unrolling, etc). - gdb_test "break -pstap test:two" \ - "Breakpoint .* at $hex.*\[0-9\]+ locations.*" \ - "set multi-location probe breakpoint (probe two)" + gdb_breakpoint "-pstap test:two" -locs "\[0-9\]+" # Reinit GDB, set a breakpoint on probe m4. delete_breakpoints diff --git a/gdb/testsuite/gdb.base/step-over-exit.exp b/gdb/testsuite/gdb.base/step-over-exit.exp index d373b1a28ad..7c657c7f0f8 100644 --- a/gdb/testsuite/gdb.base/step-over-exit.exp +++ b/gdb/testsuite/gdb.base/step-over-exit.exp @@ -44,7 +44,7 @@ gdb_test "set detach-on-fork off" # Step 1, find the syscall instruction address. -gdb_test "break _exit" "Breakpoint $decimal at .*" +gdb_breakpoint "_exit" # Hit the breakpoint on _exit. The address of syscall insn is recorded. diff --git a/gdb/testsuite/gdb.cp/breakpoint-locs.exp b/gdb/testsuite/gdb.cp/breakpoint-locs.exp index 088a7660276..e873a97356e 100644 --- a/gdb/testsuite/gdb.cp/breakpoint-locs.exp +++ b/gdb/testsuite/gdb.cp/breakpoint-locs.exp @@ -26,4 +26,4 @@ if { [prepare_for_testing "failed to prepare" $testfile "$srcfile $srcfile2"\ return -1 } -gdb_test "break N1::C1::baz" "\\(2 locations\\)" +gdb_breakpoint "N1::C1::baz" -locs 2 diff --git a/gdb/testsuite/gdb.cp/ena-dis-br-range.exp b/gdb/testsuite/gdb.cp/ena-dis-br-range.exp index 103d38baa2f..0bd1d2e1c0d 100644 --- a/gdb/testsuite/gdb.cp/ena-dis-br-range.exp +++ b/gdb/testsuite/gdb.cp/ena-dis-br-range.exp @@ -51,9 +51,7 @@ proc make_info_breakpoint_reply_re {b1 b2 b21 b22 b23 b24} { ] } -gdb_test "break foo::overload" \ - "Breakpoint \[0-9\]+ at $hex: foo::overload. .4 locations." \ - "set breakpoint at overload" +gdb_breakpoint "foo::overload" -locs 4 gdb_test "info break" [make_info_breakpoint_reply_re y y y y y y] \ "breakpoint info" diff --git a/gdb/testsuite/gdb.cp/mb-ctor.exp b/gdb/testsuite/gdb.cp/mb-ctor.exp index 1a84b7990f4..f628ea5e997 100644 --- a/gdb/testsuite/gdb.cp/mb-ctor.exp +++ b/gdb/testsuite/gdb.cp/mb-ctor.exp @@ -38,15 +38,11 @@ if {![runto_main]} { # Set a breakpoint with multiple locations # and a condition. -gdb_test "break 'Derived::Derived(int)'" \ - "Breakpoint.*at.*: Derived::Derived.int.. \\(2 locations\\).*" \ - "set-breakpoint at ctor" +gdb_breakpoint "Derived::Derived(int)" -locs 2 gdb_breakpoint [gdb_get_line_number "set breakpoint here"] -gdb_test "break 'Derived::~Derived()'" \ - "Breakpoint.*at.*: Derived::~Derived... \\(2 locations\\).*" \ - "set-breakpoint at dtor" +gdb_breakpoint "Derived::~Derived()" -locs 2 gdb_test "continue" \ ".*Breakpoint.*Derived.*i=7.*" \ diff --git a/gdb/testsuite/gdb.cp/mb-inline.exp b/gdb/testsuite/gdb.cp/mb-inline.exp index db80bb48e40..f34a12e4953 100644 --- a/gdb/testsuite/gdb.cp/mb-inline.exp +++ b/gdb/testsuite/gdb.cp/mb-inline.exp @@ -33,9 +33,7 @@ set bp_location [gdb_get_line_number "set breakpoint here" $hdrfile] # Set a breakpoint with multiple locations. -gdb_test "break $hdrfile:$bp_location" \ - "Breakpoint.*at.*: $hdrfile:$bp_location. \\(2 locations\\).*" \ - "set breakpoint" +gdb_breakpoint "$hdrfile:$bp_location" -locs 2 # Do "info break" now so we can easily compare it with the later "info break" # if problems arise. @@ -83,9 +81,7 @@ if { ![runto_main] } { return 0 } -gdb_test "break $hdrfile:$bp_location" \ - "Breakpoint.*at.*: $hdrfile:$bp_location. \\(2 locations\\).*" \ - "set multi_line_foo breakpoint" +gdb_breakpoint "$hdrfile:$bp_location" -locs 2 gdb_test "continue" \ ".*Breakpoint.*multi_line_foo \\(i=0\\).*" \ "run to multi_line_foo breakpoint 4 afn" diff --git a/gdb/testsuite/gdb.cp/mb-templates.exp b/gdb/testsuite/gdb.cp/mb-templates.exp index 2df88a322bb..f707220caac 100644 --- a/gdb/testsuite/gdb.cp/mb-templates.exp +++ b/gdb/testsuite/gdb.cp/mb-templates.exp @@ -30,9 +30,8 @@ set bp_location [gdb_get_line_number "set breakpoint here"] # Set a breakpoint with multiple locations # and a condition. -gdb_test "break $srcfile:$bp_location if i==1" \ - "Breakpoint.*at.*: $srcfile:$bp_location. \\(2 locations\\).*" \ - "initial condition: set breakpoint" +gdb_breakpoint "$srcfile:$bp_location if i==1" -locs 2 \ + -locspec "$srcfile:$bp_location" gdb_run_cmd @@ -55,9 +54,7 @@ delete_breakpoints gdb_test "kill" "" "kill" \ {Kill the program being debugged\? \(y or n\) } "y" -gdb_test "break $srcfile:$bp_location" \ - "Breakpoint.*at.*: $srcfile:$bp_location. \\(2 locations\\).*" \ - "separate condition: set breakpoint" +gdb_breakpoint "$srcfile:$bp_location" -locs 2 gdb_test_no_output {condition $bpnum i==1} \ "separate condition: set condition" @@ -111,9 +108,7 @@ if { ![runto_main] } { return 0 } -gdb_test "break $srcfile:$bp_location" \ - "Breakpoint.*at.*: $srcfile:$bp_location. \\(2 locations\\).*" \ - "set multi_line_foo breakpoint" +gdb_breakpoint "$srcfile:$bp_location" -locs 2 gdb_test "continue" \ ".*Breakpoint.*multi_line_foo \\(i=0\\).*" \ "run to multi_line_foo breakpoint 2 " diff --git a/gdb/testsuite/gdb.cp/meth-typedefs.exp b/gdb/testsuite/gdb.cp/meth-typedefs.exp index 149f44c6c17..03163121df2 100644 --- a/gdb/testsuite/gdb.cp/meth-typedefs.exp +++ b/gdb/testsuite/gdb.cp/meth-typedefs.exp @@ -181,7 +181,7 @@ foreach f [list "$func" "'$func'"] { "$line3${any}// test${any}"] delete_breakpoints - gdb_test "break $f" "\\(3 locations\\)" + gdb_breakpoint "$f" -locs 3 -locspec "" } gdb_exit diff --git a/gdb/testsuite/gdb.cp/ovldbreak.exp b/gdb/testsuite/gdb.cp/ovldbreak.exp index 99d0a388adb..84efb37b8db 100644 --- a/gdb/testsuite/gdb.cp/ovldbreak.exp +++ b/gdb/testsuite/gdb.cp/ovldbreak.exp @@ -443,9 +443,7 @@ gdb_test "break foo::foofunc" \ # Test breaking on an overloaded function when multiple-symbols # is set to "all" gdb_test_no_output "set multiple-symbols all" -gdb_test "break foo::foofunc" \ - "Breakpoint \[0-9\]+ at ${hex}: foo::foofunc. .2 locations..*" \ - "break on ambiguous symbol when multiple-symbols is set to all" +gdb_breakpoint "foo::foofunc" -locs 2 # That's all, folks. diff --git a/gdb/testsuite/gdb.cp/paramless.exp b/gdb/testsuite/gdb.cp/paramless.exp index 68f66441f80..3658ef7107e 100644 --- a/gdb/testsuite/gdb.cp/paramless.exp +++ b/gdb/testsuite/gdb.cp/paramless.exp @@ -35,7 +35,7 @@ foreach ordinary {"outer::fn" "outer::fn" "toplev"} { clean_restart $testfile } -gdb_test "break outer::fn" "Breakpoint $decimal at .*2 locations." +gdb_breakpoint "outer::fn" -locs 2 clean_restart $testfile -gdb_test "break toplev" "Breakpoint $decimal at .*2 locations." +gdb_breakpoint "toplev" -locs 2 diff --git a/gdb/testsuite/gdb.cp/templates.exp b/gdb/testsuite/gdb.cp/templates.exp index 8dd0cdc70ef..3ca8b20d844 100644 --- a/gdb/testsuite/gdb.cp/templates.exp +++ b/gdb/testsuite/gdb.cp/templates.exp @@ -620,25 +620,25 @@ gdb_test_no_output "set multiple-symbols all" # Test setting breakpoints in a method of all class template instantiations, # including overloads. -gdb_test "break Foo::foo" "Breakpoint.*at.* \\(3 locations\\)" +gdb_breakpoint "Foo::foo" -locs 3 foreach t [list "int" "char" "volatile char *"] { gdb_breakpoint "Foo<$t>::foo (int, $t)" gdb_breakpoint "Foo::foo (int, $t)" } -gdb_test "break Bar::bar" "Breakpoint.*at.* \\(2 locations\\)" -gdb_test "break Bar::bar (int, int)" "Breakpoint.*at.* \\(2 locations\\)" +gdb_breakpoint "Bar::bar" -locs 2 +gdb_breakpoint "Bar::bar (int, int)" -locs 2 foreach val [list 1 33] { gdb_breakpoint "Bar::bar (int, int)" } # Test setting breakpoints in a member function template of a class template, # including overloads. -gdb_test "break Foozle::fogey" "Breakpoint.*at.* \\(9 locations\\)" \ - "break at template method fogey" +gdb_breakpoint "Foozle::fogey" -locs 9 + foreach t [list "int" "char" "Empty"] { - gdb_test "break Foozle::fogey ($t)" "Breakpoint.*at.* \\(3 locations\\)" - gdb_test "break Foozle::fogey<$t>" "Breakpoint.*at.* \\(3 locations\\)" + gdb_breakpoint "Foozle::fogey ($t)" -locs 3 + gdb_breakpoint "Foozle::fogey<$t>" -locs 3 foreach u [list "int" "char" "Empty"] { gdb_breakpoint "Foozle<$t>::fogey<$u>" message gdb_assert { [gdb_breakpoint "Foozle<$t>::fogey<$u> ($u)" no-message] } \ @@ -657,10 +657,10 @@ foreach t [list "int" "char" "Empty"] { # operator<<: # 1. operator<< > # 2. operator<< > -gdb_test "break -source $srcfile -func operator<" \ - "Breakpoint.*at.* \\(4 locations\\)" -gdb_test "break -source $srcfile -func operator<<" \ - "Breakpoint.*at.* \\(2 locations\\)" +gdb_breakpoint "-source $srcfile -func operator<" -locs 4 -locspec \ + "-source $srcfile -function operator<" +gdb_breakpoint "-source $srcfile -func operator<<" -locs 2 -locspec \ + "-source $srcfile -function operator<<" foreach t [list "Empty" "Foozle"] { set tt "$t" gdb_breakpoint "operator< <$tt>" message diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-break.exp b/gdb/testsuite/gdb.dwarf2/dw2-inline-break.exp index 2e6f7114c33..6371b629d9b 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-inline-break.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-break.exp @@ -44,8 +44,8 @@ gdb_test "break func1" \ # The result should be a breakpoint with two locations: the # out-of-line function and the single inlined instance. # -gdb_test "break func2" \ - "Breakpoint.*at.*func2.*\\(2 locations\\)" +gdb_breakpoint "func2" -locs 2 + # # func3b is a static inlined function that is called once from @@ -62,8 +62,7 @@ gdb_test "break func3b" \ # the inlined call to func4a in main, and the inlined instance # within the out-of-line func4a. # -gdb_test "break func4b" \ - "Breakpoint.*at.*func4b.*\\(2 locations\\)" +gdb_breakpoint "func4b" -locs 2 # # func5b is a non-static inlined function that is called once @@ -71,8 +70,8 @@ gdb_test "break func4b" \ # breakpoint with two locations: the out-of-line function and the # inlined instance within the inlined call to func5a in main. # -gdb_test "break func5b" \ - "Breakpoint.*at.*func5b.*\\(2 locations\\)" +gdb_breakpoint "func5b" -locs 2 + # # func6b is a non-static inlined function that is called once from # within another non-static inlined function. The result should be @@ -80,8 +79,7 @@ gdb_test "break func5b" \ # inlined instance within the out-of-line func6a, and the inlined # instance within the inlined call to func6a in main, # -gdb_test "break func6b" \ - "Breakpoint.*at.*func6b.*\\(3 locations\\)" +gdb_breakpoint "func6b" -locs 3 # # func7b is a static inlined function that is called twice: once from @@ -89,8 +87,7 @@ gdb_test "break func6b" \ # two locations: the inlined instance within the inlined instance of # func7a, and the inlined instance within main. # -gdb_test "break func7b" \ - "Breakpoint.*at.*func7b.*\\(2 locations\\)" +gdb_breakpoint "func7b" -locs 2 # # func8b is a non-static inlined function that is called twice: once @@ -99,8 +96,7 @@ gdb_test "break func7b" \ # within the inlined instance of func7a, and the inlined instance # within main. # -gdb_test "break func8b" \ - "Breakpoint.*at.*func8b.*\\(3 locations\\)" +gdb_breakpoint "func8b" -locs 3 # # func1 is a static inlined function. The result should be that no diff --git a/gdb/testsuite/gdb.dwarf2/dw2-skip-prologue.exp b/gdb/testsuite/gdb.dwarf2/dw2-skip-prologue.exp index 78ac57439f3..49fc2293dc4 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-skip-prologue.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-skip-prologue.exp @@ -71,7 +71,7 @@ if ![runto_main] { return -1 } -gdb_breakpoint "func" +gdb_breakpoint "func" -locs 2 -locspec "" gdb_continue_to_breakpoint "func" # Sanity check GDB has really found 2 locations diff --git a/gdb/testsuite/gdb.linespec/break-asm-file.exp b/gdb/testsuite/gdb.linespec/break-asm-file.exp index 1044fc79a26..3977e6aac85 100644 --- a/gdb/testsuite/gdb.linespec/break-asm-file.exp +++ b/gdb/testsuite/gdb.linespec/break-asm-file.exp @@ -60,7 +60,5 @@ gdb_test "break b/$asm_file0:func" \ gdb_test "delete 2" -gdb_test "break $asm_file0:func" \ - "Breakpoint 3 at 0x\[0-9a-fA-F\]+: .*$asm_file0.*(2 locations).*" \ - "set a break-point at function in all instances for a selected ASM file." +gdb_breakpoint "$asm_file0:func" -locs 2 diff --git a/gdb/testsuite/gdb.linespec/linespec.exp b/gdb/testsuite/gdb.linespec/linespec.exp index 576d788cae0..6398309f7e4 100644 --- a/gdb/testsuite/gdb.linespec/linespec.exp +++ b/gdb/testsuite/gdb.linespec/linespec.exp @@ -144,17 +144,11 @@ if { [is_remote host] } { } } -gdb_test "break thefile.cc:$l1" \ - "Breakpoint $decimal at $hex: thefile.cc:$l1. \[(\]2 locations\[)\]" \ - "multi-location break using file:line" +gdb_breakpoint "thefile.cc:$l1" -locs 2 -gdb_test "break dupname" \ - "Breakpoint $decimal at $hex: dupname. \[(\]2 locations\[)\]" \ - "multi-location break using duplicate function name" +gdb_breakpoint "dupname" -locs 2 -gdb_test "break dupname:label" \ - "Breakpoint $decimal at $hex: dupname:label. \[(\]2 locations\[)\]" \ - "multi-location break using duplicate function name and label" +gdb_breakpoint "dupname:label" -locs 2 # Testing if the "condition" command completes only the breakpoints, # not the locations. @@ -165,9 +159,7 @@ gdb_test "break lspec.cc:nosuchfunction" \ "Function \"nosuchfunction\" not defined in \"lspec.cc\"." \ "set breakpoint on non-existent function" -gdb_test "break NameSpace::overload" \ - "Breakpoint \[0-9\]+ at $hex: NameSpace::overload. \[(\]3 locations\[)\]" \ - "set breakpoint at all instances of NameSpace::overload" +gdb_breakpoint "NameSpace::overload" -locs 3 gdb_test "break lspec.cc:NameSpace::overload" \ "Breakpoint \[0-9\]+ at $hex: file .*lspec.cc, line 7." \ @@ -210,6 +202,4 @@ gdb_test "file $binfile" \ "Reading symbols from .*" \ "set the new inferior file for linespec tests" -gdb_test "break -q main" \ - "Breakpoint \[0-9\]+ at $hex: -qualified main. .2 locations." \ - "set breakpoint at main in both inferiors" +gdb_breakpoint "-qualified main" -locs 2 diff --git a/gdb/testsuite/gdb.multi/bp-thread-specific.exp b/gdb/testsuite/gdb.multi/bp-thread-specific.exp index 11dc2483624..0e289790d7d 100644 --- a/gdb/testsuite/gdb.multi/bp-thread-specific.exp +++ b/gdb/testsuite/gdb.multi/bp-thread-specific.exp @@ -73,16 +73,14 @@ gdb_test "info threads" \ # Set the first breakpoint. Currently this is going to insert at two # locations ('foo' in both inferiors) even though only one of those # locations will ever trigger ('foo' in inferior 2). -gdb_test "break foo thread 2.1" \ - "Breakpoint $decimal at $hex: file \[^\r\n\]+$srcfile, line $decimal\\." +gdb_breakpoint "foo thread 2.1" set bpnum [get_integer_valueof "\$bpnum" "INVALID"] # Now set another breakpoint that will be at the same location as the # earlier breakpoint. Check that the thread-id used when describing # the earlier breakpoints is correct. -gdb_test "break foo thread 1.1" \ - "Breakpoint $decimal at $hex: file \[^\r\n\]+$srcfile, line $decimal\\." +gdb_breakpoint "foo thread 1.1" # Save the breakpoints into a file. if {[is_remote host]} { diff --git a/gdb/testsuite/gdb.multi/inferior-specific-bp.exp b/gdb/testsuite/gdb.multi/inferior-specific-bp.exp index 82cc9240e50..67069e1da4d 100644 --- a/gdb/testsuite/gdb.multi/inferior-specific-bp.exp +++ b/gdb/testsuite/gdb.multi/inferior-specific-bp.exp @@ -172,8 +172,7 @@ proc check_info_breakpoints { testname bp_number expected_loc_count } { # Create an inferior-specific breakpoint. Use gdb_test instead of # gdb_breakpoint here as we want to check the breakpoint was placed in # multiple locations. -gdb_test "break foo inferior 1" \ - "Breakpoint $decimal at $hex: foo\\. \\(2 locations\\)" +gdb_breakpoint "foo inferior 1" -locs 2 -locspec "foo" set bp_number [get_integer_valueof "\$bpnum" "INVALID" \ "get b/p number for inferior specific breakpoint"] diff --git a/gdb/testsuite/gdb.opt/inline-break.exp b/gdb/testsuite/gdb.opt/inline-break.exp index 9c57d22404b..70549301964 100644 --- a/gdb/testsuite/gdb.opt/inline-break.exp +++ b/gdb/testsuite/gdb.opt/inline-break.exp @@ -96,8 +96,7 @@ gdb_test "break func1" \ # The result should be a breakpoint with two locations: the # out-of-line function and the single inlined instance. # -gdb_test "break func2" \ - "Breakpoint.*at.*func2.*\\(2 locations\\)" +gdb_breakpoint "func2" -locs 2 # # func3b is a static inlined function that is called once from @@ -114,8 +113,8 @@ gdb_test "break func3b" \ # the inlined call to func4a in main, and the inlined instance # within the out-of-line func4a. # -gdb_test "break func4b" \ - "Breakpoint.*at.*func4b.*\\(2 locations\\)" +gdb_breakpoint "func4b" -locs 2 + # # func5b is a non-static inlined function that is called once @@ -123,8 +122,8 @@ gdb_test "break func4b" \ # breakpoint with two locations: the out-of-line function and the # inlined instance within the inlined call to func5a in main. # -gdb_test "break func5b" \ - "Breakpoint.*at.*func5b.*\\(2 locations\\)" +gdb_breakpoint "func5b" -locs 2 + # # func6b is a non-static inlined function that is called once from # within another non-static inlined function. The result should be @@ -132,8 +131,7 @@ gdb_test "break func5b" \ # inlined instance within the out-of-line func6a, and the inlined # instance within the inlined call to func6a in main, # -gdb_test "break func6b" \ - "Breakpoint.*at.*func6b.*\\(3 locations\\)" +gdb_breakpoint "func6b" -locs 3 # # func7b is a static inlined function that is called twice: once from @@ -141,8 +139,7 @@ gdb_test "break func6b" \ # two locations: the inlined instance within the inlined instance of # func7a, and the inlined instance within main. # -gdb_test "break func7b" \ - "Breakpoint.*at.*func7b.*\\(2 locations\\)" +gdb_breakpoint "func7b" -locs 2 # # func8b is a non-static inlined function that is called twice: once @@ -151,8 +148,7 @@ gdb_test "break func7b" \ # within the inlined instance of func7a, and the inlined instance # within main. # -gdb_test "break func8b" \ - "Breakpoint.*at.*func8b.*\\(3 locations\\)" +gdb_breakpoint "func8b" -locs 3 # # func1 is a static inlined function. The result should be that no @@ -314,8 +310,7 @@ with_test_prefix "check alignment" { continue } - gdb_test "break func4b" \ - "Breakpoint.*at.*func4b.*\\(2 locations\\)" + gdb_breakpoint "func4b" -locs 2 set expected_line_length -1 gdb_test_multiple "info break \$bpnum" "xxxx" { diff --git a/gdb/testsuite/gdb.python/py-bp-locations.exp b/gdb/testsuite/gdb.python/py-bp-locations.exp index 4892947ca55..a2bff8a655e 100644 --- a/gdb/testsuite/gdb.python/py-bp-locations.exp +++ b/gdb/testsuite/gdb.python/py-bp-locations.exp @@ -56,7 +56,7 @@ proc build_bpl_regexp { args } { } # Set breakpoint with 2 locations. -gdb_breakpoint "add" +gdb_breakpoint "add" -locs 2 set expected_line_a [gdb_get_line_number "a + b"] set expected_line_b [gdb_get_line_number "c + d"] diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 3349da7a263..4a5f1e0df89 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -672,6 +672,19 @@ proc gdb_starti_cmd { {inferior_args {}} } { # # If there is an additional argument it is a list of options; the supported # options are allow-pending, temporary, message, no-message and qualified. +# For multiple breakpoint locations additional options are used. These +# are -locspec, -locs and -extra: +# -locspec specifies a regex for the location spec output of the break command. +# This is only used when multiple locations matching is enabled by +# the -locs option. It is useful when a very specific breakpoint +# output is expected. For example, "func if a == 0" and the caller +# wants to match "func" in the breakpoint command output. When +# not set the content of LINESPEC is matched, regardless of -locs. +# -locs specifies a regex for the number of locations that are printed by the +# break command. This also enforces that a single location match is +# treated as an error. +# -extra allows specifying a regex for extra matches that need to appear before +# the breakpoint command output. # # The result is 1 for success, 0 for failure. # @@ -685,17 +698,32 @@ proc gdb_breakpoint { linespec args } { global gdb_prompt global decimal + parse_some_args { + {locspec "\[^\r\n\]*"} + {locs "\[0-9\]+"} + {extra ""} + } + + if { $locspec eq "\[^\r\n\]*" && $locs ne "\[0-9\]+"} { + set locspec [string_to_regexp $linespec] + } + set pending_response n if {[lsearch -exact $args allow-pending] != -1} { set pending_response y } set break_command "break" - set break_message "Breakpoint" + # Expecting some output before breakmessage, append it before it. + if { $extra ne "" } { + append extra "\r\n" + } + set break_message "Breakpoint $decimal" if {[lsearch -exact $args temporary] != -1} { set break_command "tbreak" - set break_message "Temporary breakpoint" + set break_message "Temporary breakpoint $decimal" } + set break_message "$extra$break_message" if {[lsearch -exact $args qualified] != -1} { append break_command " -qualified" @@ -712,36 +740,73 @@ proc gdb_breakpoint { linespec args } { set print_pass 1 } + # Counters for single and multiple locations + set multiple_locs 0 + set single_loc 0 + set test_name "gdb_breakpoint: set breakpoint at $linespec" - # The first two regexps are what we get with -g, the third is without -g. + set fill "\[^\r\n]" + + # The extra regex is setup to not match unless the caller specifies + # an extra match. gdb_test_multiple "$break_command $linespec" $test_name { - -re "$break_message \[0-9\]* at .*: file .*, line $decimal.\r\n$gdb_prompt $" {} - -re "$break_message \[0-9\]*: file .*, line $decimal.\r\n$gdb_prompt $" {} - -re "$break_message \[0-9\]* at .*$gdb_prompt $" {} - -re "$break_message \[0-9\]* \\(.*\\) pending.*$gdb_prompt $" { - if {$pending_response == "n"} { - if { $print_fail } { - fail $gdb_test_name - } - return 0 + -re -wrap "$break_message at $fill+: file $fill+, line $decimal\\." { + incr single_loc + } + -re -wrap "$break_message: file .*, line $decimal\\." { + incr single_loc + } + -re -wrap "$break_message at $::hex$fill*$locspec$fill*\($locs locations\)$fill+" { + incr multiple_locs + } + -re -wrap "$break_message at $fill+\." { + incr single_loc + } + -re -wrap "$break_message \\(.*\\) pending$fill+" { + if {$pending_response == "n"} { + if { $print_fail } { + fail $gdb_test_name } + return 0 + } } - -re "Make breakpoint pending.*y or \\\[n\\\]. $" { - send_gdb "$pending_response\n" - exp_continue + -re "Make breakpoint pending.*y or \\\[n\\\]. $" { + send_gdb "$pending_response\n" + exp_continue } - -re "$gdb_prompt $" { + -re -wrap "" { if { $print_fail } { fail $test_name } return 0 } } + + # If multiple locations where requested, assert we didn't + # see a single location match. + if { $locs ne "\[0-9\]+" + && $locs ne 1 + && $single_loc != 0 } { + if { $print_fail } { + fail $test_name + } + return 0 + } + + # Special case to enforce single location matches only. If -LOCS is set to + # 1 fail if we get multi location matches. + if { $locs eq 1 && $multiple_locs != 0 } { + if { $print_fail } { + fail $test_name + } + return 0 + } + if { $print_pass } { pass $test_name } return 1 -} +} # Set breakpoint at function and run gdb until it breaks there. # Since this is the only breakpoint that will be set, if it stops From patchwork Mon Mar 24 11:16:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gerlicher, Klaus" X-Patchwork-Id: 108955 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2725B385B538 for ; Mon, 24 Mar 2025 11:18:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2725B385B538 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=T0lJQcca X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) by sourceware.org (Postfix) with ESMTPS id 2507B385B517 for ; Mon, 24 Mar 2025 11:17:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2507B385B517 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2507B385B517 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1742815051; cv=none; b=oguvZPxUlIA7fgBW4ckZpZTeAySpytROf99WCtSsye1urTeyb5A+NWGljW2mfD0oOC4+7JNzid+uxK3V+T++hDSiqk07PqP/8D80a5Qm20gsBabYv1jYjznRa2u+6AVv+0sT3oIYFB108+vcNEEdZthfvr+raEKBDbkRsx6oukw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1742815051; c=relaxed/simple; bh=8G7oSqVjPvsXjmpiA+a4bb7OOgEXMvDg3B4nJAUCKwE=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=LXbiKj0csamGTDd8kKNMr/4qdO4+WwTM1YepQ4eGrNqs8LHqL8BWhbhoxk26OxKp0YeFfRCIH6tqyvzn1ikxeFZyNSi2ytmWrmES+iuTJD0kKPL0ypb66hg+ZYsfYCnhfanzILJMa7Iu6RXLf+XSC7zhBdRr0dAdngBIaujyu7w= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2507B385B517 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1742815051; x=1774351051; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=8G7oSqVjPvsXjmpiA+a4bb7OOgEXMvDg3B4nJAUCKwE=; b=T0lJQccaXvUBNvJKwKyaPJqaipmLpeYdcEbpNgZjZzy2TM0a5OgcTvJV kpEPTn2wo3wByaoCbjNKDs6a8dYeT92/YtwTTf5YJvQtnHCWdNA+49IDT 79NTc35VWai0b2nK9micfMJj9H7sqnSQNN8415myYswoGsi2OeNEbdVNE XbznxmtvrugPmh2RYPLFPAqAFwMQEPewWku9MAetdgDfpoI48SFc0vfOt A8KbuibN9nTuaAfyOCdfhSqITceTcv5BQJyFcBlFt5FoIhmvvxAXoCzFG TzBF4pDjRoNVI+fgUDNQv4ReUDAMejH+VIUaupifUe9MnnlsrX3VlGGvT g==; X-CSE-ConnectionGUID: y0e1n+trQ7uTd07pSvBL+Q== X-CSE-MsgGUID: bJaCpKgrS3aq94jHJ80iaQ== X-IronPort-AV: E=McAfee;i="6700,10204,11382"; a="44203376" X-IronPort-AV: E=Sophos;i="6.14,271,1736841600"; d="scan'208";a="44203376" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2025 04:17:30 -0700 X-CSE-ConnectionGUID: //OdxeMbQ+ecI5uIyEAaeg== X-CSE-MsgGUID: ZIwU336HT12O8ldhhpdCQA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,271,1736841600"; d="scan'208";a="155031330" Received: from dut1505dg2frd.igk.intel.com (HELO localhost) ([10.102.46.29]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2025 04:17:29 -0700 From: Klaus Gerlicher To: gdb-patches@sourceware.org, blarsen@redhat.com, aburgess@redhat.com, eliz@gnu.org Subject: [PATCH v9 2/2] gdb, breakpoint: output multiple bp locations Date: Mon, 24 Mar 2025 11:16:46 +0000 Message-Id: <20250324111646.3201607-3-klaus.gerlicher@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250324111646.3201607-1-klaus.gerlicher@intel.com> References: <20250324111646.3201607-1-klaus.gerlicher@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org From: "Gerlicher, Klaus" When setting a breakpoint that resolves to multiple locations only the address of the first location is printed but multiple locations are indicated. See this example: 01 template 02 T 03 f (T t) 04 { 05 return t; 06 } 07 08 int 09 main (void) 10 { 11 return f (1) + f (1.0f) + f (1) 12 + f (1) + f (1); 13 } Setting a breakpoint on line 5 will yield 5 locations: (gdb) b 5 Breakpoint 1 at 0x11cf: main.cpp:5. (5 locations) Even though this indicates multiple locations, it only shows the first one. A better way would be: Set how many locations to be printed, then... (gdb) set breakpoint max-locations-printed 4 ... set breakpoint. (gdb) b 5 Breakpoint 1 for main.cpp:5 at 5 locations: Location 1 at 0x11cf in function f(int) in file main.cpp, line 5. Location 2 at 0x11e1 in function f(float) in file main.cpp, line 5. Location 3 at 0x11f5 in function f(char) in file main.cpp, line 5. Location 4 at 0x1209 in function f(short) in file main.cpp, line 5. 1 additional location not printed. Setting a breakpoint on a single location will also show the function name if available: (gdb) b func Breakpoint 1 at 0x1188 in function func(int): file main.cpp, line 5. Make the number of breakpoint locations printed configurable. Introduce the "set breakpoint max-locations-printed" command. Setting this to unlimited will not cap the output of breakpoint locations. max-locations-printed defaults to 10 locations. Setting it to zero will display no individual locations: (gdb) b func Breakpoint 1 for func at 5 locations Convert tests that use gdb_test "break" to using gdb_breakpoint because previously the "break" output was parseable with a single regex. Now that it has become multi-line, tests that were previously creating multiple locations unknowingly need to be fixed to use the right regex which is simpler (and more properly) done by using the gdb_breakpoint. gdb_breakpoint knows which regex to use for any case. This also adds one more options to gdb_breakpoint, -add_locs: -add_locs is used for testing the additional print when there are more locations then allowed to be printed with the "set max-locations-printed" command. Reviewed-By: Eli Zaretskii --- gdb/NEWS | 4 + gdb/breakpoint.c | 123 ++++++++++++++---- gdb/doc/gdb.texinfo | 57 +++++++- gdb/testsuite/gdb.ada/bp_c_mixed_case.exp | 3 +- gdb/testsuite/gdb.ada/bp_enum_homonym.exp | 3 +- gdb/testsuite/gdb.ada/bp_range_type.exp | 3 +- gdb/testsuite/gdb.ada/bp_reset.exp | 6 +- gdb/testsuite/gdb.ada/fullname_bp.exp | 12 +- gdb/testsuite/gdb.ada/fun_in_declare.exp | 4 +- gdb/testsuite/gdb.ada/homonym.exp | 8 +- gdb/testsuite/gdb.ada/inline-section-gc.exp | 4 +- gdb/testsuite/gdb.ada/nested.exp | 20 +-- gdb/testsuite/gdb.ada/operator_bp.exp | 3 +- gdb/testsuite/gdb.ada/task_bp.exp | 4 +- gdb/testsuite/gdb.ada/tasks.exp | 2 +- .../gdb.arch/aarch64-brk-patterns.exp | 4 +- gdb/testsuite/gdb.arch/aarch64-fp.exp | 4 +- gdb/testsuite/gdb.base/annota1.exp | 13 +- gdb/testsuite/gdb.base/annota3.exp | 11 +- gdb/testsuite/gdb.base/break.exp | 4 +- gdb/testsuite/gdb.base/c-linkage-name.exp | 3 +- gdb/testsuite/gdb.base/call-ar-st.exp | 6 +- .../gdb.base/consecutive-step-over.exp | 4 +- gdb/testsuite/gdb.base/consecutive.exp | 3 +- gdb/testsuite/gdb.base/ctxobj.exp | 4 +- gdb/testsuite/gdb.base/dmsym.exp | 3 +- gdb/testsuite/gdb.base/enum_cond.exp | 3 +- gdb/testsuite/gdb.base/fullpath-expand.exp | 2 +- gdb/testsuite/gdb.base/func-ptrs.exp | 14 +- gdb/testsuite/gdb.base/gnu-ifunc.exp | 4 +- gdb/testsuite/gdb.base/hbreak.exp | 2 +- gdb/testsuite/gdb.base/nested-subp1.exp | 4 +- gdb/testsuite/gdb.base/nested-subp2.exp | 4 +- gdb/testsuite/gdb.base/nested-subp3.exp | 4 +- gdb/testsuite/gdb.base/print-file-var.exp | 4 +- gdb/testsuite/gdb.base/realname-expand.exp | 4 +- gdb/testsuite/gdb.base/recpar.exp | 4 +- .../run-control-while-bg-execution.exp | 2 +- gdb/testsuite/gdb.base/start-cpp.exp | 4 +- gdb/testsuite/gdb.base/watchpoint.exp | 6 +- gdb/testsuite/gdb.cp/annota2.exp | 2 +- gdb/testsuite/gdb.cp/annota3.exp | 2 +- gdb/testsuite/gdb.cp/break-template-cast.exp | 3 +- gdb/testsuite/gdb.cp/bs15503.exp | 3 +- gdb/testsuite/gdb.cp/cp-relocate.exp | 6 +- gdb/testsuite/gdb.cp/cplabel.exp | 3 +- gdb/testsuite/gdb.cp/namespace.exp | 14 +- gdb/testsuite/gdb.cp/ovldbreak.exp | 12 +- gdb/testsuite/gdb.cp/pr-1023.exp | 4 +- gdb/testsuite/gdb.cp/templates.exp | 2 +- gdb/testsuite/gdb.dwarf2/dw2-abs-hi-pc.exp | 4 +- gdb/testsuite/gdb.dwarf2/dw2-bad-elf.exp | 2 +- .../gdb.dwarf2/dw2-prologue-end-2.exp | 2 +- .../gdb.dwarf2/missing-line-table.exp | 2 +- gdb/testsuite/gdb.linespec/break-ask.exp | 4 +- gdb/testsuite/gdb.linespec/break-asm-file.exp | 4 +- gdb/testsuite/gdb.linespec/cpcompletion.exp | 8 ++ gdb/testsuite/gdb.linespec/linespec.exp | 16 +-- gdb/testsuite/gdb.linespec/ls-dollar.exp | 6 +- gdb/testsuite/gdb.linespec/multiple-locs.cc | 41 ++++++ gdb/testsuite/gdb.linespec/multiple-locs.exp | 57 ++++++++ .../mi-breakpoint-multiple-locations.exp | 4 +- .../gdb.mi/user-selected-context-sync.exp | 16 +-- .../gdb.multi/inferior-specific-bp.exp | 2 +- .../gdb.multi/multi-target-continue.exp | 3 +- .../gdb.multi/multi-target-ping-pong-next.exp | 6 +- gdb/testsuite/gdb.opt/inline-break.exp | 4 +- gdb/testsuite/gdb.python/py-breakpoint.exp | 5 +- gdb/testsuite/gdb.python/py-mi-events.exp | 2 +- gdb/testsuite/gdb.reverse/aarch64-mops.exp | 6 +- .../gdb.reverse/consecutive-precsave.exp | 2 +- .../gdb.reverse/consecutive-reverse.exp | 2 +- gdb/testsuite/gdb.reverse/fstatat-reverse.exp | 8 +- gdb/testsuite/gdb.reverse/getrandom.exp | 4 +- .../gdb.reverse/getresuid-reverse.exp | 4 +- gdb/testsuite/gdb.reverse/pipe-reverse.exp | 4 +- gdb/testsuite/gdb.reverse/readv-reverse.exp | 4 +- gdb/testsuite/gdb.reverse/recvmsg-reverse.exp | 4 +- gdb/testsuite/gdb.reverse/s390-mvcle.exp | 4 +- gdb/testsuite/gdb.reverse/time-reverse.exp | 2 +- gdb/testsuite/gdb.reverse/waitpid-reverse.exp | 4 +- gdb/testsuite/gdb.reverse/watch-precsave.exp | 4 +- gdb/testsuite/gdb.reverse/watch-reverse.exp | 4 +- .../gdb.server/bkpt-other-inferior.exp | 2 +- gdb/testsuite/gdb.server/target-exec-file.exp | 2 +- gdb/testsuite/gdb.threads/print-threads.exp | 6 +- gdb/testsuite/gdb.trace/save-trace.exp | 2 +- gdb/testsuite/gdb.trace/tracecmd.exp | 8 +- gdb/testsuite/lib/completion-support.exp | 7 +- gdb/testsuite/lib/gdb.exp | 44 ++++++- 90 files changed, 457 insertions(+), 285 deletions(-) create mode 100644 gdb/testsuite/gdb.linespec/multiple-locs.cc create mode 100644 gdb/testsuite/gdb.linespec/multiple-locs.exp diff --git a/gdb/NEWS b/gdb/NEWS index 2fdb849a81b..1ab5d7963c5 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -118,6 +118,10 @@ qXfer:threads:read one used by the Linear Address Masking (LAM) feature provided by Intel. +* Printing multiple breakpoint locations when setting a breakpoint that is + instantiated for multiple locations now prints all locations limited by + "set breakpoint max-breakpoint-location-printed ". + * Debugging support for Intel MPX has been removed. This includes the removal of ** MPX register support diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 3085ca111bf..809a2a44e13 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -170,6 +170,19 @@ static bool bl_address_is_meaningful (const bp_location *loc); static int find_loc_num_by_location (const bp_location *loc); +/* Maximum number of locations printed when setting a breakpoint. Controlled + by "set breakpoint max-locations-printed ". */ + +static unsigned int breakpoint_show_max_locations = 10; +static void +show_max_breakpoint_location_printed (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char *value) +{ + gdb_printf (file, + _("Number of breakpoint location printed is %s.\n"), + value); +} + /* update_global_location_list's modes of operation wrt to whether to insert locations now. */ enum ugll_insert_mode @@ -11830,6 +11843,35 @@ bpstat_remove_bp_location (bpstat *bps, struct breakpoint *bpt) } } +/* Helper for printing a breakpoint location. */ + +static void +print_location (const bp_location &bl, bool print_address) +{ + if (print_address || bl.symtab == nullptr) + gdb_printf (" at %ps", + styled_string (address_style.style (), + paddress (bl.gdbarch, bl.address))); + if (bl.symtab != nullptr) + { + const char *filename = symtab_to_filename_for_display (bl.symtab); + const struct symbol *sym = bl.symbol; + if (sym != nullptr) + gdb_printf (" in function %ps: file %ps, line %ps.", + styled_string (function_name_style.style (), + sym->print_name ()), + styled_string (file_name_style.style (), filename), + styled_string (line_number_style.style (), + pulongest (bl.line_number))); + else + gdb_printf (": file " + "%ps, line %ps.", + styled_string (file_name_style.style (), filename), + styled_string (line_number_style.style (), + pulongest (bl.line_number))); + } +} + /* See breakpoint.h. */ void @@ -11865,37 +11907,46 @@ code_breakpoint::say_where () const } else { - const bp_location &bl = this->first_loc (); - if (opts.addressprint || bl.symtab == nullptr) - gdb_printf (" at %ps", - styled_string (address_style.style (), - paddress (bl.gdbarch, - bl.address))); - if (bl.symtab != NULL) - { - /* If there is a single location, we can print the location - more nicely. */ - if (!this->has_multiple_locations ()) + if (this->has_multiple_locations ()) + { + int n = std::distance (m_locations.begin (), m_locations.end ()); + + gdb_printf (" for %s at %d locations%s", + locspec->to_string (), n, + breakpoint_show_max_locations != 0 ? ":\n" : ""); + + int loc_idx = 0; + for (const bp_location &bl : m_locations) { - const char *filename - = symtab_to_filename_for_display (bl.symtab); - gdb_printf (": file %ps, line %ps.", - styled_string (file_name_style.style (), - filename), - styled_string (line_number_style.style (), - pulongest (bl.line_number))); + /* The user (or default) has selected a maximum number of + locations to be printed. */ + if (++loc_idx > breakpoint_show_max_locations) + break; + + gdb_printf (" Location %d", loc_idx); + print_location (bl, opts.addressprint); + + if (loc_idx < n) + gdb_printf ("\n"); } - else - /* This is not ideal, but each location may have a - different file name, and this at least reflects the - real situation somewhat. */ - gdb_printf (": %s.", locspec->to_string ()); - } - if (this->has_multiple_locations ()) + /* We printed less locations than there are present, let the user + know how many more there are. */ + if (breakpoint_show_max_locations > 0 && loc_idx < n) + { + int omitted_locs = n - loc_idx + 1; + if (omitted_locs == 1) + gdb_printf (_("%u additional location not printed."), + omitted_locs); + else + gdb_printf (_("%u additional locations not printed."), + omitted_locs); + } + } + else { - int n = std::distance (m_locations.begin (), m_locations.end ()); - gdb_printf (" (%d locations)", n); + const bp_location &bl = this->first_loc (); + print_location (bl, opts.addressprint); } } } @@ -15322,6 +15373,24 @@ Usage: agent-printf \"format string\", ARG1, ARG2, ARG3, ..., ARGN\n\ This supports most C printf format specifications, like %s, %d, etc.\n\ This is useful for formatted output in user-defined commands.")); + static const literal_def max_bp_locations_literals[] = { + { "unlimited", UINT_MAX, {} }, + { nullptr } + }; + + add_setshow_uinteger_cmd ("max-locations-printed", + class_breakpoint, + &breakpoint_show_max_locations, + max_bp_locations_literals, _("\ +Set number of locations printed when setting a breakpoint."), _("\ +Show number of locations printed when setting a breakpoint."), _("\ +Use this to choose the number of locations printed when setting\n\ +a breakpoint.\n\ +A value of \"unlimited\", or zero, means there's no limit."), + nullptr, /* set_cmd. */ + show_max_breakpoint_location_printed, + &breakpoint_set_cmdlist, &breakpoint_show_cmdlist); + automatic_hardware_breakpoints = true; gdb::observers::about_to_proceed.attach (breakpoint_about_to_proceed, diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index e034ac53295..88ddf8edc53 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -4535,23 +4535,62 @@ Breakpoints are set with the @code{break} command (abbreviated number of the breakpoint you've set most recently: @smallexample (gdb) b main -Breakpoint 1 at 0x11c6: file zeoes.c, line 24. +Breakpoint 1 at 0x11c6 in function main(): file zoeos.cpp, line 24. (gdb) p $bpnum $1 = 1 @end smallexample A breakpoint may be mapped to multiple code locations for example with inlined functions, Ada generics, C@t{++} templates or overloaded function names. -@value{GDBN} then indicates the number of code locations in the breakpoint +@value{GDBN} then lists the number of code locations in the breakpoint command output: @smallexample (gdb) b some_func -Breakpoint 2 at 0x1179: some_func. (3 locations) +Breakpoint 2 for some_func at 3 locations: + Location 1 at 0x118e in function some_func: file somefunc.cc, line 23. + Location 2 at 0x11ee in function some_func: file somefunc.cc, line 38. + Location 3 at 0x12fe in function some_func: file someother.cc, line 58. (gdb) p $bpnum $2 = 2 (gdb) @end smallexample +@cindex @code{break}, how many locations are displayed +By default, @value{GDBN} prints up to 10 breakpoint locations, you can change +this using @code{set breakpoint max-locations-printed}: + +@smallexample +(gdb) set breakpoint max-locations-printed 2 +(gdb) b some_func +Breakpoint 2 for some_func at 3 locations: + Location 1 at 0x118e in function some_func: file somefunc.cc, line 23. + Location 2 at 0x11ee in function some_func: file somefunc.cc, line 38. +1 additional location not printed. +(gdb) +@end smallexample + +@table @code +@kindex set breakpoint max-locations-printed +@item set breakpoint max-locations-printed @var{count} +@itemx set breakpoint max-locations-printed unlimited +Make the @code{break} command display up to @var{count} locations. +Setting @var{count} to @code{unlimited} means there's no limit. Setting +@var{count} to @code{0} will display summary information only. + +@smallexample +(gdb) set breakpoint max-locations-printed 0 +(gdb) b func +Breakpoint 1 for func at 5 locations +(gdb) +@end smallexample + +@kindex show breakpoint max-locations-printed +@item show breakpoint max-locations-printed +Display the number of locations that @code{break} will print. If the number +of locations is greater than the limit, the breakpoint command will add a +line reporting the number of locations that were not listed due to the limit. +@end table + @vindex $_hit_bpnum@r{, convenience variable} @vindex $_hit_locno@r{, convenience variable} When your program stops on a breakpoint, the convenience variables @@ -4661,7 +4700,10 @@ warning: failed to validate condition at location 0x11ce, disabling: No symbol "a" in current context. warning: failed to validate condition at location 0x11b6, disabling: No symbol "a" in current context. -Breakpoint 1 at 0x11b6: func. (3 locations) +Breakpoint 1 for func at 3 locations: + Location 1 at 0x11ce in function func: file somefunc.cc, line 23. + Location 2 at 0x11b6 in function func: file somefunc.cc, line 38. + Location 3 at 0x12fe in function func: file someother.cc, line 58. @end smallexample Locations that are disabled because of the condition are denoted by an @@ -4705,7 +4747,10 @@ warning: failed to validate condition at location 2, disabling: No symbol "foo" in current context. warning: failed to validate condition at location 3, disabling: No symbol "foo" in current context. -Breakpoint 1 at 0x1158: test.c:18. (3 locations) +Breakpoint 1 for func at 3 locations: + Location 1 at 0x1158 in function func: file test.c, line 18. + Location 2 at 0x11b6 in function func: file test.c, line 28. + Location 3 at 0x12fe in function func: file test.c, line 58. @end smallexample This causes all the present locations where the breakpoint would @@ -51773,3 +51818,5 @@ Richard M. Stallman and Roland H. Pesch, July 1991. @end tex @bye +======= +@{name= diff --git a/gdb/testsuite/gdb.ada/bp_c_mixed_case.exp b/gdb/testsuite/gdb.ada/bp_c_mixed_case.exp index 2286e463514..674e19143af 100644 --- a/gdb/testsuite/gdb.ada/bp_c_mixed_case.exp +++ b/gdb/testsuite/gdb.ada/bp_c_mixed_case.exp @@ -68,8 +68,7 @@ gdb_test "p " \ # name has some uppercase letters, we need to use the "<...>" notation. # The purpose of this testcase is to verify that we can in fact do so # and that it inserts the breakpoint at the expected location. -gdb_test "break " \ - "Breakpoint $decimal at $hex: file .*bar.c, line $decimal\\." +gdb_breakpoint "" # Same, but this time on the function with no debug info. gdb_test "break " \ diff --git a/gdb/testsuite/gdb.ada/bp_enum_homonym.exp b/gdb/testsuite/gdb.ada/bp_enum_homonym.exp index dc9f96a48ee..450011cc7f3 100644 --- a/gdb/testsuite/gdb.ada/bp_enum_homonym.exp +++ b/gdb/testsuite/gdb.ada/bp_enum_homonym.exp @@ -34,8 +34,7 @@ gdb_test "list pck.adb:1" \ # the subprogram and the enumeral for the location of the breakpoint. # Instead, it should insert the breakpoint on the function alone. -gdb_test "break archive" \ - "Breakpoint $decimal at $hex: file .*pck.adb, line $decimal\\." +gdb_breakpoint "archive" # Run the program. Make sure the program runs until it hits # the breakpoint and that the debugger does not unexpectedly ask diff --git a/gdb/testsuite/gdb.ada/bp_range_type.exp b/gdb/testsuite/gdb.ada/bp_range_type.exp index 26829464810..99eb9848227 100644 --- a/gdb/testsuite/gdb.ada/bp_range_type.exp +++ b/gdb/testsuite/gdb.ada/bp_range_type.exp @@ -27,8 +27,7 @@ clean_restart ${testfile} set bp_location [gdb_get_line_number "STOP" ${testdir}/foo.adb] -gdb_test "break foo.adb:$bp_location if small_value > 20" \ - "Breakpoint $decimal at $hex: file .*foo.adb, line $decimal\\." +gdb_breakpoint "foo.adb:$bp_location if small_value > 20" -locexpr "foo.adb" gdb_run_cmd gdb_test "" \ diff --git a/gdb/testsuite/gdb.ada/bp_reset.exp b/gdb/testsuite/gdb.ada/bp_reset.exp index 440784f7b6f..8cbe4375395 100644 --- a/gdb/testsuite/gdb.ada/bp_reset.exp +++ b/gdb/testsuite/gdb.ada/bp_reset.exp @@ -25,11 +25,9 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug ]] != "" } clean_restart ${testfile} -gdb_test "break nested_sub" \ - "Breakpoint $decimal at $hex: file .*foo.adb, line $decimal\\." +gdb_breakpoint "nested_sub" -gdb_test "break do_nothing" \ - "Breakpoint $decimal at $hex: file .*pck.adb, line $decimal\\." +gdb_breakpoint "do_nothing" # Run the program. Make sure the program runs until it hits # the first breakpoint inside nested_sub. diff --git a/gdb/testsuite/gdb.ada/fullname_bp.exp b/gdb/testsuite/gdb.ada/fullname_bp.exp index 26240d713d4..aaed8dddabf 100644 --- a/gdb/testsuite/gdb.ada/fullname_bp.exp +++ b/gdb/testsuite/gdb.ada/fullname_bp.exp @@ -30,26 +30,22 @@ clean_restart ${testfile} # Break on "pck.hello" rather than just "hello" to make sure we trigger # the non-wild symbol lookup. -gdb_test "break pck.hello" \ - "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*pck.adb, line \[0-9\]+." +gdb_breakpoint "pck.hello" # Do the same, but this time using a linespec where the user also # provided a filename. clean_restart ${testfile} -gdb_test "break pck.adb:pck.hello" \ - "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*pck.adb, line \[0-9\]+." +gdb_breakpoint "pck.adb:pck.hello" # Same scenarios as above, but with a function name that is spelled # with upper-case letters. clean_restart ${testfile} -gdb_test "break Pck.Hello" \ - "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*pck.adb, line \[0-9\]+." +gdb_breakpoint "Pck.Hello" clean_restart ${testfile} -gdb_test "break pck.adb:Pck.Hello" \ - "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*pck.adb, line \[0-9\]+." +gdb_breakpoint "pck.adb:Pck.Hello" diff --git a/gdb/testsuite/gdb.ada/fun_in_declare.exp b/gdb/testsuite/gdb.ada/fun_in_declare.exp index a73a91ff8dc..7b7a955270f 100644 --- a/gdb/testsuite/gdb.ada/fun_in_declare.exp +++ b/gdb/testsuite/gdb.ada/fun_in_declare.exp @@ -35,9 +35,7 @@ set any_nb "\[0-9\]+" set any_addr "0x\[0-9a-zA-Z\]+" set bp_location [gdb_get_line_number "STOP" ${testdir}/foo.adb] -gdb_test "break foo.adb:$bp_location" \ - "Breakpoint $any_nb at $any_addr: file .*foo.adb, line $any_nb." \ - "insert breakpoint inside foo.call_me" +gdb_breakpoint "foo.adb:$bp_location" gdb_test "continue" \ ".*Breakpoint $any_nb, foo\\.call_me \\(\\) at .*foo.adb:$any_nb.*" \ diff --git a/gdb/testsuite/gdb.ada/homonym.exp b/gdb/testsuite/gdb.ada/homonym.exp index 15920866daa..25c8b2ec56c 100644 --- a/gdb/testsuite/gdb.ada/homonym.exp +++ b/gdb/testsuite/gdb.ada/homonym.exp @@ -33,9 +33,7 @@ gdb_breakpoint "Get_Value" -locs 2 gdb_breakpoint "homonym.adb:Get_Value" -locs 2 -gdb_test "break " \ - ".*Breakpoint \[0-9\]+ at $hex: (file .*homonym\\.adb, line $decimal\\.|\\. .2 locations.)" \ - "set breakpoint at " +gdb_breakpoint "" delete_breakpoints @@ -71,9 +69,7 @@ gdb_test "print lcl" \ # in the new scope are different. set bp_location [gdb_get_line_number "BREAK_2" ${testdir}/homonym.adb] -gdb_test "break homonym.adb:$bp_location" \ - "Breakpoint \[0-9\]+ at 0x\[0-9a-fA-F\]+: file .*homonym\\.adb, line \[0-9\]+\\." \ - "break at BREAK_2" +gdb_breakpoint "homonym.adb:$bp_location" gdb_test "continue" \ ".*Breakpoint \[0-9\]+, homonym\\.get_value \\(\\) at .*homonym\\.adb:.*" \ diff --git a/gdb/testsuite/gdb.ada/inline-section-gc.exp b/gdb/testsuite/gdb.ada/inline-section-gc.exp index 78539aa432a..f38ac4bbdf4 100644 --- a/gdb/testsuite/gdb.ada/inline-section-gc.exp +++ b/gdb/testsuite/gdb.ada/inline-section-gc.exp @@ -53,10 +53,10 @@ set message "Breakpoint set" # The bug here was that gdb would set a breakpoint with two locations, # one of them at 0x0. gdb_test_multiple $test $message { - -re "Breakpoint $decimal at $hex: file .*callee.adb, line $bp_location1." { + -re "Breakpoint $decimal at $hex$::fill: file .*callee.adb, line $bp_location1." { pass $test } - -re "Breakpoint $decimal at $hex: file .*caller.adb, line $bp_location2." { + -re "Breakpoint $decimal at $hex$::fill: file .*caller.adb, line $bp_location2." { pass $test } } diff --git a/gdb/testsuite/gdb.ada/nested.exp b/gdb/testsuite/gdb.ada/nested.exp index 9f5cfc4c076..4026837510e 100644 --- a/gdb/testsuite/gdb.ada/nested.exp +++ b/gdb/testsuite/gdb.ada/nested.exp @@ -30,22 +30,12 @@ set any_addr "0x\[0-9a-zA-Z\]+" # Try breaking on a nested function. -gdb_test "break first" \ - "Breakpoint $any_nb at $any_addr: file .*hello.adb, line $any_nb." \ - "break on nested function First" +gdb_breakpoint "first" -gdb_test "break fourth" \ - "Breakpoint $any_nb at $any_addr: file .*hello.adb, line $any_nb." \ - "break on nested function fourth" +gdb_breakpoint "fourth" -gdb_test "break hello.fourth" \ - "Breakpoint $any_nb at $any_addr: file .*hello.adb, line $any_nb." \ - "full-qualified break on nested function fourth" +gdb_breakpoint "hello.fourth" -gdb_test "break fifth" \ - "Breakpoint $any_nb at $any_addr: file .*hello.adb, line $any_nb." \ - "break on nested function fifth" +gdb_breakpoint "fifth" -gdb_test "break hello.fourth.fifth" \ - "Breakpoint $any_nb at $any_addr: file .*hello.adb, line $any_nb." \ - "full-qualified break on nested function fifth" +gdb_breakpoint "hello.fourth.fifth" diff --git a/gdb/testsuite/gdb.ada/operator_bp.exp b/gdb/testsuite/gdb.ada/operator_bp.exp index d3f78ee6fe6..3d26976fb88 100644 --- a/gdb/testsuite/gdb.ada/operator_bp.exp +++ b/gdb/testsuite/gdb.ada/operator_bp.exp @@ -65,8 +65,7 @@ foreach op { "+" "-" } { foreach op { "*" "/" "mod" "rem" "**" "<" "<=" ">" ">=" "=" "and" "or" "xor" "&" "abs" "not"} { set op_re [string_to_regexp $op] - gdb_test "break ops.\"$op\"" \ - "Breakpoint $decimal at $hex: file .*ops.adb, line $decimal." + gdb_breakpoint "ops.\"$op\"" } # Make sure we stop correctly in each operator function. diff --git a/gdb/testsuite/gdb.ada/task_bp.exp b/gdb/testsuite/gdb.ada/task_bp.exp index 4b32a3d6c2a..123ad78be84 100644 --- a/gdb/testsuite/gdb.ada/task_bp.exp +++ b/gdb/testsuite/gdb.ada/task_bp.exp @@ -36,9 +36,7 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" } # order to test one given linespec under multiple conditions. proc test_bp { loc msg } { - gdb_test "break $loc" \ - "Breakpoint \[0-9\]+ at 0x\[0-9a-fA-F\]+: file .*pck.adb, line \[0-9\]+\\." \ - "break $loc - $msg" + gdb_breakpoint "$loc" gdb_run_cmd gdb_test "" \ diff --git a/gdb/testsuite/gdb.ada/tasks.exp b/gdb/testsuite/gdb.ada/tasks.exp index ecbfbd5522f..fd3dacf00e3 100644 --- a/gdb/testsuite/gdb.ada/tasks.exp +++ b/gdb/testsuite/gdb.ada/tasks.exp @@ -84,7 +84,7 @@ gdb_test "info breakpoints" "foo.adb:${decimal}\r\n\\s+stop only in task 1" \ gdb_test "break break_me task 3" \ [multi_line \ "Note: breakpoint $bp_number \\(task 1\\) also set at pc $hex\\." \ - "Breakpoint $decimal at $hex: \[^\r\n\]+"] + "Breakpoint $decimal at $hex$::fill"] set bp_number [get_integer_valueof "\$bpnum" "INVALID" \ "get number of breakpoint for task 3"] gdb_test "info breakpoints" "foo.adb:${decimal}\r\n\\s+stop only in task 3" \ diff --git a/gdb/testsuite/gdb.arch/aarch64-brk-patterns.exp b/gdb/testsuite/gdb.arch/aarch64-brk-patterns.exp index d52df43d058..9573aa3064b 100644 --- a/gdb/testsuite/gdb.arch/aarch64-brk-patterns.exp +++ b/gdb/testsuite/gdb.arch/aarch64-brk-patterns.exp @@ -45,9 +45,7 @@ while {$keep_going} { # Insert a breakpoint at the program breakpoint instruction so # GDB can step over it. - gdb_test "break" \ - "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \ - "insert breakpoint at brk instruction $count" + gdb_breakpoint "" incr count } # We've reached the end of the test. diff --git a/gdb/testsuite/gdb.arch/aarch64-fp.exp b/gdb/testsuite/gdb.arch/aarch64-fp.exp index 6284e413273..f2cda987e90 100644 --- a/gdb/testsuite/gdb.arch/aarch64-fp.exp +++ b/gdb/testsuite/gdb.arch/aarch64-fp.exp @@ -31,9 +31,7 @@ if ![runto_main] { set endianness [get_endianness] -gdb_test "break ${srcfile}:[gdb_get_line_number "return"]" \ - "Breakpoint $decimal at 0x\[0-9a-fA-F\]+: file .*${srcfile}.*\\\." \ - "set the breakpoint after setting the fp registers" +gdb_breakpoint "${srcfile}:[gdb_get_line_number "return"]" gdb_test "continue" \ "Continuing.*Breakpoint $decimal.*" \ diff --git a/gdb/testsuite/gdb.base/annota1.exp b/gdb/testsuite/gdb.base/annota1.exp index 927e8a7e579..0d5b96c8e11 100644 --- a/gdb/testsuite/gdb.base/annota1.exp +++ b/gdb/testsuite/gdb.base/annota1.exp @@ -44,10 +44,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } { set main_line [gdb_get_line_number "break main"] -gdb_test "break ${srcfile}:${main_line}" \ - "Breakpoint.*at.* file .*$srcfile, line $main_line\\." \ - "breakpoint main" - +gdb_breakpoint " ${srcfile}:${main_line}" # # NOTE: this prompt is OK only when the annotation level is > 1 @@ -238,7 +235,7 @@ gdb_test_multiple "print non_existent_value" "print non_existent_value" { # we can test annotate-signal-handler-caller # gdb_test_multiple "break handle_USR1" "break handle_USR1" { - -re "\r\n\032\032post-prompt\r\nBreakpoint.*at $hex: file.*$srcfile, line.*\r\n\032\032breakpoints-invalid\r\n.*$gdb_prompt$" { + -re "\r\n\032\032post-prompt\r\nBreakpoint.*at $hex$::fill: file.*$srcfile, line.*\r\n\032\032breakpoints-invalid\r\n.*$gdb_prompt$" { pass $gdb_test_name } } @@ -394,10 +391,10 @@ gdb_test_multiple "delete 3" "delete bp 3" { # to test the annotate output for the display command. # gdb_test_multiple "break ${srcfile}:${main_line}" "break in main" { - -re "post-prompt.*Breakpoint 4 at $hex: file ${escapedsrcfile}, line $main_line.*\032\032breakpoints-invalid.*$gdb_prompt$" { + -re "post-prompt.*Breakpoint 4 at $hex$::fill: file ${escapedsrcfile}, line $main_line.*\032\032breakpoints-invalid.*$gdb_prompt$" { pass $gdb_test_name } - -re "post-prompt.*Breakpoint 4 at $hex: file .*${srcfile}, line $main_line.*\032\032breakpoints-invalid.*$gdb_prompt$" { + -re "post-prompt.*Breakpoint 4 at $hex$::fill: file .*${srcfile}, line $main_line.*\032\032breakpoints-invalid.*$gdb_prompt$" { setup_xfail "*-*-*" 8375 fail $gdb_test_name } @@ -454,7 +451,7 @@ gdb_expect { set value_inc_line [gdb_get_line_number "increment value"] gdb_test_multiple "break $value_inc_line" "break at value++" { - -re "Breakpoint 5 at $hex: file .*$srcfile, line $value_inc_line.*$gdb_prompt$" { + -re "Breakpoint 5 at $hex$::fill: file .*$srcfile, line $value_inc_line.*$gdb_prompt$" { pass "break at value++" } } diff --git a/gdb/testsuite/gdb.base/annota3.exp b/gdb/testsuite/gdb.base/annota3.exp index 134a3d37c80..59b5dd5984a 100644 --- a/gdb/testsuite/gdb.base/annota3.exp +++ b/gdb/testsuite/gdb.base/annota3.exp @@ -39,10 +39,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } { set main_line [gdb_get_line_number "break main"] -gdb_test "break ${srcfile}:${main_line}" \ - "Breakpoint.*at.* file .*$srcfile, line $main_line\\." \ - "breakpoint main" - +gdb_breakpoint "${srcfile}:${main_line}" # NOTE: this prompt is OK only when the annotation level is > 1 @@ -152,7 +149,7 @@ gdb_expect_list "print non_existent_value" "$gdb_prompt$" { # break at signal handler # gdb_test -prompt "$gdb_prompt$" "break handle_USR1" \ - "\r\n\032\032post-prompt\r\nBreakpoint \[^\r\n\]+ at $hex: file \[^\r\n\]+/$srcfile, line\[^\r\n\]+\\." + "\r\n\032\032post-prompt\r\nBreakpoint \[^\r\n\]+ at $hex$::fill: file \[^\r\n\]+/$srcfile, line\[^\r\n\]+\\." # # Break at printf. @@ -239,7 +236,7 @@ gdb_expect_list "delete bp 3" "$gdb_prompt$" { # to test the annotate output for the display command. # gdb_test -prompt "$gdb_prompt$" "break ${srcfile}:${main_line}" \ - "\r\n\032\032post-prompt\r\nBreakpoint 4 at $hex: file \[^\r\n\]+/$srcfile, line $main_line\\." \ + "\r\n\032\032post-prompt\r\nBreakpoint 4 at $hex$::fill: file \[^\r\n\]+/$srcfile, line $main_line\\." \ "break in main" # @@ -286,7 +283,7 @@ gdb_expect { set value_inc_line [gdb_get_line_number "increment value"] gdb_test -prompt "$gdb_prompt$" "break $value_inc_line" \ - "\r\n\032\032post-prompt\r\nBreakpoint 5 at $hex: file\[^\r\n\]*$srcfile, line $value_inc_line\\." \ + "\r\n\032\032post-prompt\r\nBreakpoint 5 at $hex$::fill: file\[^\r\n\]*$srcfile, line $value_inc_line\\." \ "break at value++" send_gdb "ignore 5 4\n" diff --git a/gdb/testsuite/gdb.base/break.exp b/gdb/testsuite/gdb.base/break.exp index 34ac21982ea..1116608b6f1 100644 --- a/gdb/testsuite/gdb.base/break.exp +++ b/gdb/testsuite/gdb.base/break.exp @@ -355,7 +355,7 @@ proc_with_prefix test_break {} { # Test the 'list' commands sets current file for the 'break LINENO' command. set bp_marker1 [gdb_get_line_number "set breakpoint 15 here" $::srcfile1] gdb_test "list marker1" ".*" - gdb_test "break $bp_marker1" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*$::srcfile1, line ${bp_marker1}\\." \ + gdb_test "break $bp_marker1" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+.*: file .*$::srcfile1, line ${bp_marker1}\\." \ "break lineno" gdb_test_no_output {delete $bpnum} @@ -907,7 +907,7 @@ proc_with_prefix test_break_file_line_convenience_var {} { set line_actual "-1" set test "break $::srcfile:\$l" gdb_test_multiple "$test" $test { - -re "Breakpoint $::decimal at $::hex: file .*break\\.c, line ($::decimal)\\.\r\n$::gdb_prompt $" { + -re "Breakpoint $::decimal at $::hex.*: file .*break\\.c, line ($::decimal)\\.\r\n$::gdb_prompt $" { # Save the actual line number on which the breakpoint was # actually set. On some systems (Eg: Ubuntu 16.04 with GCC # version 5.4.0), that line gets completely inlined, including diff --git a/gdb/testsuite/gdb.base/c-linkage-name.exp b/gdb/testsuite/gdb.base/c-linkage-name.exp index 3d219bdd3b7..00527e14eab 100644 --- a/gdb/testsuite/gdb.base/c-linkage-name.exp +++ b/gdb/testsuite/gdb.base/c-linkage-name.exp @@ -54,8 +54,7 @@ if { $readnow } { # our symada__cS symbol by, e.g. inserting a breakpoint on one # of the founction also provided by the same using. -gdb_test "break do_something_other_cu" \ - "Breakpoint $decimal at $hex: file .*$srcfile2, line $decimal\\." +gdb_breakpoint "do_something_other_cu" # Verify that partial symtab expansion has taken place for # c-linkage-name-2.c. diff --git a/gdb/testsuite/gdb.base/call-ar-st.exp b/gdb/testsuite/gdb.base/call-ar-st.exp index c0a47a7858a..e7ddccf5457 100644 --- a/gdb/testsuite/gdb.base/call-ar-st.exp +++ b/gdb/testsuite/gdb.base/call-ar-st.exp @@ -257,7 +257,7 @@ if ![gdb_skip_stdio_test "print print_array_rep(...)"] { set stop_line [gdb_get_line_number "-tbreak5-"] gdb_test "tbreak $stop_line" \ - "Temporary breakpoint..* file .*$srcfile, line $stop_line.*" \ + "Temporary breakpoint.* file .*$srcfile, line $stop_line.*" \ "tbreakpoint at tbreak5" gdb_test "continue" \ @@ -273,9 +273,7 @@ gdb_test "continue" \ # in the right place, and a step may end up in memcpy instead. This # may itself be a bug, but it's not the one we're trying to catch # here. I've added something to step-test.exp for this. -gdb_test "break sum_array_print" \ - ".*Breakpoint ${decimal}: file .*$srcfile, line.*" \ - "set breakpoint in sum_array_print" +gdb_breakpoint "sum_array_print" gdb_test_no_output "set print frame-arguments all" gdb_test "continue" \ ".*Breakpoint ${decimal}, sum_array_print \\(seed=10, linked_list1=.next_index = .1, 2, 3, 4, 5, 6, 7, 8, 9, 10., values = .4, 6, 8, 10, 12, 14, 16, 18, 20, 22., head = 0., linked_list2=.next_index = .1, 2, 3, 4, 5, 6, 7, 8, 9, 10., values = .8, 10, 12, 14, 16, 18, 20, 22, 24, 26., head = 0., linked_list3=.next_index = .1, 2, 3, 4, 5, 6, 7, 8, 9, 10., values = .10, 12, 14, 16, 18, 20, 22, 24, 26, 28., head = 0., linked_list4=.next_index = .1, 2, 3, 4, 5, 6, 7, 8, 9, 10., values = .20, 22, 24, 26, 28, 30, 32, 34, 36, 38., head = 0.\\) at .*$srcfile:${decimal}\[ \t\n\r\]+${decimal}.*printf\\(.Sum of 4 arrays, by element \\(add in seed as well\\).*\\);.*" \ diff --git a/gdb/testsuite/gdb.base/consecutive-step-over.exp b/gdb/testsuite/gdb.base/consecutive-step-over.exp index 9da35df5f72..481b929c933 100644 --- a/gdb/testsuite/gdb.base/consecutive-step-over.exp +++ b/gdb/testsuite/gdb.base/consecutive-step-over.exp @@ -53,9 +53,7 @@ if { [gdb_test_multiple "x /[expr $n_insns + 1]i \$pc" $test { for {set i 1} {$i <= $n_insns} {incr i} { with_test_prefix "insn $i" { - gdb_test "break \*$bp_addrs($i)" \ - "Breakpoint $decimal at $bp_addrs($i): file .*" \ - "set breakpoint" + gdb_breakpoint "\*$bp_addrs($i)" # Give the breakpoint a condition that always fails, so that # the thread is immediately re-resumed. diff --git a/gdb/testsuite/gdb.base/consecutive.exp b/gdb/testsuite/gdb.base/consecutive.exp index 5ea146c6ef3..f4d4636dec4 100644 --- a/gdb/testsuite/gdb.base/consecutive.exp +++ b/gdb/testsuite/gdb.base/consecutive.exp @@ -48,8 +48,7 @@ gdb_test_multiple "x /2i \$pc" "get breakpoint address for foo" { } } -gdb_test "break \*$bp_addr" "Breakpoint $decimal at $bp_addr: file .*" \ - "set bp, 2nd instr" +gdb_breakpoint "\*$bp_addr" gdb_test_multiple "step" "stopped at bp, 2nd instr" { -re -wrap "Breakpoint $decimal, ($hex) in foo.*" { diff --git a/gdb/testsuite/gdb.base/ctxobj.exp b/gdb/testsuite/gdb.base/ctxobj.exp index d1137189108..e73b29fcf3a 100644 --- a/gdb/testsuite/gdb.base/ctxobj.exp +++ b/gdb/testsuite/gdb.base/ctxobj.exp @@ -61,9 +61,7 @@ if ![runto_main] { } set bp_location [gdb_get_line_number "STOP" "ctxobj-f.c"] -gdb_test "break ctxobj-f.c:$bp_location" \ - "Breakpoint \[0-9\]+ at 0x\[0-9a-fA-F\]+: .*" \ - "break in get_version functions" +gdb_breakpoint "ctxobj-f.c:$bp_location" global expect_out set test "continue to get_version_1" diff --git a/gdb/testsuite/gdb.base/dmsym.exp b/gdb/testsuite/gdb.base/dmsym.exp index a80684500df..e56da7fce34 100644 --- a/gdb/testsuite/gdb.base/dmsym.exp +++ b/gdb/testsuite/gdb.base/dmsym.exp @@ -50,8 +50,7 @@ set addr "0x\[0-9a-zA-Z\]+" # there is no debugging info available, this is a data symbol and thus # should not be used for breakpoint purposes. -gdb_test "break test_minsym" \ - "Breakpoint $num at $addr.: file .*dmsym_main\\.c, line $num\\." +gdb_breakpoint "test_minsym" # However, verify that the `info line' command, on the other hand, # finds both locations. diff --git a/gdb/testsuite/gdb.base/enum_cond.exp b/gdb/testsuite/gdb.base/enum_cond.exp index d58da4796fe..44412b1f890 100644 --- a/gdb/testsuite/gdb.base/enum_cond.exp +++ b/gdb/testsuite/gdb.base/enum_cond.exp @@ -44,8 +44,7 @@ if {![runto_main]} { return } -gdb_test "break call_me if param.e == 1" \ - "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal\\." +gdb_breakpoint "call_me if param.e == 1" -locexpr "call_me" # Continue. We should hit our breakpoint... gdb_test "continue" \ diff --git a/gdb/testsuite/gdb.base/fullpath-expand.exp b/gdb/testsuite/gdb.base/fullpath-expand.exp index c2ae85a60dc..b9c78097969 100644 --- a/gdb/testsuite/gdb.base/fullpath-expand.exp +++ b/gdb/testsuite/gdb.base/fullpath-expand.exp @@ -43,7 +43,7 @@ clean_restart ${testfile} gdb_test "rbreak $realsrcfile2:func" \ [multi_line \ - "Breakpoint 1 at 0x\[0-9a-f\]+: file [string_to_regexp ${subdir}/${srcfile2}], line \[0-9\]+\\." \ + "Breakpoint 1 at 0x\[0-9a-f\]+$::fill: file [string_to_regexp ${subdir}/${srcfile2}], line \[0-9\]+\\." \ "void func\\(void\\);" \ "Successfully created breakpoint 1."] \ "rbreak XXX/fullpath-expand-func.c:func" diff --git a/gdb/testsuite/gdb.base/func-ptrs.exp b/gdb/testsuite/gdb.base/func-ptrs.exp index cf6da04b722..f616feccd72 100644 --- a/gdb/testsuite/gdb.base/func-ptrs.exp +++ b/gdb/testsuite/gdb.base/func-ptrs.exp @@ -26,17 +26,9 @@ if { ![runto_main] } { # First set our breakpoints. -set fp_breakpoint_re \ - "Breakpoint $decimal at $hex: file .*${srcfile}, line $decimal\\." -gdb_test "break sentinel if calc == decr" \ - "${fp_breakpoint_re}" \ - "breakpoint at sentinel" -gdb_test "break incr" \ - "${fp_breakpoint_re}" \ - "breakpoint at incr" -gdb_test "break decr" \ - "${fp_breakpoint_re}" \ - "breakpoint at decr" +gdb_breakpoint "sentinel if calc == decr" -locexp "sentinel" +gdb_breakpoint "incr" +gdb_breakpoint "decr" # Check if we run through to the breakpoint in incr. diff --git a/gdb/testsuite/gdb.base/gnu-ifunc.exp b/gdb/testsuite/gdb.base/gnu-ifunc.exp index ff1d5617430..400b46fba71 100644 --- a/gdb/testsuite/gdb.base/gnu-ifunc.exp +++ b/gdb/testsuite/gdb.base/gnu-ifunc.exp @@ -170,12 +170,12 @@ proc_with_prefix set-break {resolver_attr resolver_debug final_debug} { set lineno -1 set test "break final" gdb_test_multiple $test $test { - -re "Breakpoint .* at $hex: file .*$final_src, line ($decimal)\\.\r\n$gdb_prompt $" { + -re "Breakpoint .* at $hex$::fill: file .*$final_src, line ($decimal)\\.\r\n$gdb_prompt $" { set lineno $expect_out(1,string) pass $test } } - gdb_test "break gnu_ifunc" "Breakpoint .* at $hex: file .*$final_src, line $lineno\\." + gdb_test "break gnu_ifunc" "Breakpoint .* at $hex$::fill: file .*$final_src, line $lineno\\." set location "$decimal${ws}breakpoint${ws}keep${ws}y${ws}$hex in final at .*$final_src:$lineno" } diff --git a/gdb/testsuite/gdb.base/hbreak.exp b/gdb/testsuite/gdb.base/hbreak.exp index 73a3e2afb67..b4d7511224f 100644 --- a/gdb/testsuite/gdb.base/hbreak.exp +++ b/gdb/testsuite/gdb.base/hbreak.exp @@ -28,7 +28,7 @@ if ![runto_main] { set breakline [gdb_get_line_number "break-at-exit"] gdb_test "hbreak ${srcfile}:${breakline}" \ - "Hardware assisted breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*${srcfile}, line ${breakline}\\." \ + "Hardware assisted breakpoint \[0-9\]+ at 0x\[0-9a-f\]+$::fill: file .*${srcfile}, line ${breakline}\\." \ "hbreak" gdb_test "continue" \ diff --git a/gdb/testsuite/gdb.base/nested-subp1.exp b/gdb/testsuite/gdb.base/nested-subp1.exp index f9d614d7885..458f3268c25 100644 --- a/gdb/testsuite/gdb.base/nested-subp1.exp +++ b/gdb/testsuite/gdb.base/nested-subp1.exp @@ -45,9 +45,7 @@ if ![runto_main] { } set bp_location [gdb_get_line_number "STOP" "${testcase}.c"] -gdb_test "break ${testcase}.c:${bp_location}" \ - "Breakpoint \[0-9\]+ at 0x\[0-9a-fA-F\]+: .*" \ - "breakpoint to the STOP marker" +gdb_breakpoint "${testcase}.c:${bp_location}" gdb_test "continue" \ "Breakpoint \[0-9\]+, nested .*" \ "continue to the STOP marker" diff --git a/gdb/testsuite/gdb.base/nested-subp2.exp b/gdb/testsuite/gdb.base/nested-subp2.exp index 10449c92356..23d0f0542ee 100644 --- a/gdb/testsuite/gdb.base/nested-subp2.exp +++ b/gdb/testsuite/gdb.base/nested-subp2.exp @@ -54,9 +54,7 @@ if ![runto_main] { } set bp_location [gdb_get_line_number "STOP" "${testcase}.c"] -gdb_test "break ${testcase}.c:${bp_location}" \ - "Breakpoint \[0-9\]+ at 0x\[0-9a-fA-F\]+: .*" \ - "breakpoint to the STOP marker" +gdb_breakpoint "${testcase}.c:${bp_location}" with_test_prefix "stop at first iteration" { gdb_test "continue" \ diff --git a/gdb/testsuite/gdb.base/nested-subp3.exp b/gdb/testsuite/gdb.base/nested-subp3.exp index 0f75a844f83..95e52b2b045 100644 --- a/gdb/testsuite/gdb.base/nested-subp3.exp +++ b/gdb/testsuite/gdb.base/nested-subp3.exp @@ -54,9 +54,7 @@ if ![runto_main] { } set bp_location [gdb_get_line_number "STOP" "${testcase}.c"] -gdb_test "break ${testcase}.c:${bp_location}" \ - "Breakpoint \[0-9\]+ at 0x\[0-9a-fA-F\]+: .*" \ - "breakpoint to the STOP marker" +gdb_breakpoint "${testcase}.c:${bp_location}" gdb_test "continue" \ "Breakpoint \[0-9\]+, child .*" \ "continue to the STOP marker" diff --git a/gdb/testsuite/gdb.base/print-file-var.exp b/gdb/testsuite/gdb.base/print-file-var.exp index 70e454d8e21..5acaca4474f 100644 --- a/gdb/testsuite/gdb.base/print-file-var.exp +++ b/gdb/testsuite/gdb.base/print-file-var.exp @@ -105,9 +105,7 @@ proc test {hidden dlopen version_id_main lang} { set bp_location \ [gdb_get_line_number "STOP" "${main}.c"] - gdb_test "break $main.c:$bp_location" \ - "Breakpoint \[0-9\]+ at 0x\[0-9a-fA-F\]+: .*" \ - "breakpoint at STOP marker" + gdb_breakpoint "$main.c:$bp_location" gdb_test "continue" \ "Breakpoint \[0-9\]+, main \\(\\) at.*STOP.*" \ diff --git a/gdb/testsuite/gdb.base/realname-expand.exp b/gdb/testsuite/gdb.base/realname-expand.exp index e62a4db22bd..7f459654d20 100644 --- a/gdb/testsuite/gdb.base/realname-expand.exp +++ b/gdb/testsuite/gdb.base/realname-expand.exp @@ -41,11 +41,11 @@ gdb_test_no_output "set basenames-may-differ on" gdb_test "rbreak realname-expand-real.c:func" \ [multi_line "" \ - "Breakpoint 1 at $hex: file \[^\r\n\]*/realname-expand-link\\.c, line $decimal\\." \ + "Breakpoint 1 at $hex$::fill: file \[^\r\n\]*/realname-expand-link\\.c, line $decimal\\." \ "void func\\(void\\);" \ "Successfully created breakpoint 1."] delete_breakpoints gdb_test "break realname-expand-real.c:func" \ - "\r\nBreakpoint 2 at $hex: file \[^\r\n\]*/realname-expand-link\\.c, line $decimal\\." + "\r\nBreakpoint 2 at $hex$::fill: file \[^\r\n\]*/realname-expand-link\\.c, line $decimal\\." diff --git a/gdb/testsuite/gdb.base/recpar.exp b/gdb/testsuite/gdb.base/recpar.exp index b62b6aa6ba4..d42f8480c86 100644 --- a/gdb/testsuite/gdb.base/recpar.exp +++ b/gdb/testsuite/gdb.base/recpar.exp @@ -23,8 +23,8 @@ if ![runto_main] { return -1 } -gdb_test "break $srcfile:[gdb_get_line_number BREAK $srcfile] if n == 3" \ - "Breakpoint $decimal at $hex: file .*recpar\\.c, line $decimal\\." +set lineno [gdb_get_line_number BREAK $srcfile] +gdb_breakpoint "$srcfile:$lineno if n == 3" -locexpr "$srcfile:$lineno" gdb_test "continue" \ "Breakpoint .* foo \\(n=3\\) at .*$srcfile:$decimal.*" diff --git a/gdb/testsuite/gdb.base/run-control-while-bg-execution.exp b/gdb/testsuite/gdb.base/run-control-while-bg-execution.exp index 380047ae854..fd395f10387 100644 --- a/gdb/testsuite/gdb.base/run-control-while-bg-execution.exp +++ b/gdb/testsuite/gdb.base/run-control-while-bg-execution.exp @@ -90,7 +90,7 @@ proc do_test { action1 action2 } { if { $action2 == "start" } { gdb_test "start" "Temporary breakpoint $::decimal\(?:\.$::decimal\)?, main .*" } elseif { $action2 == "run" } { - gdb_test "break main" "Breakpoint $::decimal at $::hex.*" + gdb_breakpoint "main" gdb_test "run" "Breakpoint $::decimal\(?:\.$::decimal\)?, main .*" } elseif { $action2 == "attach" } { set test_spawn_id [spawn_wait_for_attach $::binfile] diff --git a/gdb/testsuite/gdb.base/start-cpp.exp b/gdb/testsuite/gdb.base/start-cpp.exp index 330c6ea9a67..0f40a36fce0 100644 --- a/gdb/testsuite/gdb.base/start-cpp.exp +++ b/gdb/testsuite/gdb.base/start-cpp.exp @@ -39,5 +39,5 @@ if { [gdb_start_cmd] < 0 } { } gdb_test "" \ - "Temporary breakpoint $decimal at $hex: file.*main \\(\\) at .*start-cpp.cc:.*" \ - "start" + "Temporary breakpoint $decimal at $hex$::fill: file.*main \\(\\) at .*start-cpp.cc:.*" \ + "start" diff --git a/gdb/testsuite/gdb.base/watchpoint.exp b/gdb/testsuite/gdb.base/watchpoint.exp index 2449663ef8b..f7cf1b08455 100644 --- a/gdb/testsuite/gdb.base/watchpoint.exp +++ b/gdb/testsuite/gdb.base/watchpoint.exp @@ -55,12 +55,12 @@ proc initialize {} { global decimal global srcfile - if [gdb_test "break marker1" "Breakpoint 1 at $hex: file .*$srcfile, line $decimal.*" "set breakpoint at marker1" ] { + if [gdb_test "break marker1" "Breakpoint 1 at $hex$::fill: file .*$srcfile, line $decimal.*" "set breakpoint at marker1" ] { return 0 } - if [gdb_test "break marker2" "Breakpoint 2 at $hex: file .*$srcfile, line $decimal.*" "set breakpoint at marker2" ] { + if [gdb_test "break marker2" "Breakpoint 2 at $hex$::fill: file .*$srcfile, line $decimal.*" "set breakpoint at marker2" ] { return 0 } @@ -71,7 +71,7 @@ proc initialize {} { gdb_test "watch ival3" ".*\[Ww\]atchpoint 3: ival3.*" "set watchpoint on ival3" - if [gdb_test "info watch" "3\[ \]*.*watchpoint.*ival3" "watchpoint found in watchpoint/breakpoint table" ] { + if [gdb_test "info watch" "3\[ \]*.*watchpoint.*ival3" "watchpoint found in watchpoint/breakpoint table" ] { return 0 } diff --git a/gdb/testsuite/gdb.cp/annota2.exp b/gdb/testsuite/gdb.cp/annota2.exp index 1b1c26b0d86..3ebe1bfc073 100644 --- a/gdb/testsuite/gdb.cp/annota2.exp +++ b/gdb/testsuite/gdb.cp/annota2.exp @@ -179,7 +179,7 @@ gdb_expect { # set pat [multi_line "" \ "\032\032post-prompt" \ - "Breakpoint.*at $hex: file.*$srcfile, line.*" \ + "Breakpoint.*at $hex$::fill: file.*$srcfile, line.*" \ "\032\032breakpoints-invalid.*" \ $gdb_prompt$] diff --git a/gdb/testsuite/gdb.cp/annota3.exp b/gdb/testsuite/gdb.cp/annota3.exp index e5da031a25c..adcbf006e7d 100644 --- a/gdb/testsuite/gdb.cp/annota3.exp +++ b/gdb/testsuite/gdb.cp/annota3.exp @@ -136,7 +136,7 @@ gdb_expect { send_gdb "break 22\n" gdb_expect_list "break at main" "$gdb_prompt$" { "\r\n\032\032post-prompt\r\n" - "Breakpoint.*at 0x\[a-z0-9\]+: file.*annota3.cc, line 22.\r\n" + "Breakpoint.*at 0x\[a-z0-9\]+\[^\r\n]+: file.*annota3.cc, line 22.\r\n" } # diff --git a/gdb/testsuite/gdb.cp/break-template-cast.exp b/gdb/testsuite/gdb.cp/break-template-cast.exp index 30e4229eee3..1d2e7568994 100644 --- a/gdb/testsuite/gdb.cp/break-template-cast.exp +++ b/gdb/testsuite/gdb.cp/break-template-cast.exp @@ -25,5 +25,4 @@ if { [prepare_for_testing "failed to prepare" $testfile "$srcfile"\ return -1 } -gdb_test "break foo" \ - "Breakpoint $decimal at $hex: foo\\. \\(2 locations\\)" +gdb_breakpoint "foo" -locs 2 diff --git a/gdb/testsuite/gdb.cp/bs15503.exp b/gdb/testsuite/gdb.cp/bs15503.exp index 1c509c41299..e6fcedd26c5 100644 --- a/gdb/testsuite/gdb.cp/bs15503.exp +++ b/gdb/testsuite/gdb.cp/bs15503.exp @@ -31,8 +31,7 @@ if {![runto_main]} { # Set breakpoint on template function -gdb_test "break StringTest::testFunction" \ - "Breakpoint $decimal at $hex: file .*${srcfile}, line $decimal." +gdb_breakpoint "StringTest::testFunction" gdb_test "continue" \ ".*Breakpoint $decimal, StringTest::testFunction \\(this=$hex\\).*" \ diff --git a/gdb/testsuite/gdb.cp/cp-relocate.exp b/gdb/testsuite/gdb.cp/cp-relocate.exp index 14ce9f5acfe..365d0ef88f4 100644 --- a/gdb/testsuite/gdb.cp/cp-relocate.exp +++ b/gdb/testsuite/gdb.cp/cp-relocate.exp @@ -127,7 +127,5 @@ gdb_test "add-symbol-file $host_binfile 0 -s ${func1_sec} 0x10000 -s ${func2_sec "y" # Make sure the function addresses were updated. -gdb_test "break *$func1_name" \ - "Breakpoint $decimal at 0x1....: file .*" -gdb_test "break *$func2_name" \ - "Breakpoint $decimal at 0x2....: file .*" +gdb_breakpoint "*$func1_name" +gdb_breakpoint "*$func2_name" diff --git a/gdb/testsuite/gdb.cp/cplabel.exp b/gdb/testsuite/gdb.cp/cplabel.exp index 5865352baea..71c53085242 100644 --- a/gdb/testsuite/gdb.cp/cplabel.exp +++ b/gdb/testsuite/gdb.cp/cplabel.exp @@ -33,7 +33,6 @@ set labels {"to_the_top" "get_out_of_here"} foreach m $methods { foreach l $labels { set line [gdb_get_line_number "$m:$l"] - gdb_test "break foo::$m:$l" \ - "Breakpoint $decimal at $hex: file .*$srcfile, line $line\." + gdb_breakpoint "foo::$m:$l" } } diff --git a/gdb/testsuite/gdb.cp/namespace.exp b/gdb/testsuite/gdb.cp/namespace.exp index 504359d4998..1c06d67ade0 100644 --- a/gdb/testsuite/gdb.cp/namespace.exp +++ b/gdb/testsuite/gdb.cp/namespace.exp @@ -105,13 +105,11 @@ gdb_test "print AAA::xyzq('x')" \ # Break on a function in a namespace -gdb_test "break AAA::xyzq" \ - "Breakpoint.*at $hex: file.*namespace.cc, line 47\\." +gdb_breakpoint "AAA::xyzq" # Break on a function in the global namespace. -gdb_test "break -qualified ::ensureOtherRefs" \ - "Breakpoint.*at $hex: file.*$srcfile2, line $decimal\\." +gdb_breakpoint "::ensureOtherRefs" {qualified} # Call a function in a nested namespace @@ -123,13 +121,11 @@ gdb_test "print BBB::CCC::xyzq('x')" \ # Break on a function in a nested namespace -gdb_test "break BBB::CCC::xyzq" \ - "Breakpoint.*at $hex: file.*namespace.cc, line 63\\." +gdb_breakpoint "BBB::CCC::xyzq" # Break on the same function, starting with the global namespace. -gdb_test "break ::BBB::CCC::xyzq" \ - ".*Breakpoint.*at $hex: file.*$srcfile, line 63\\." +gdb_breakpoint "::BBB::CCC::xyzq" # Print address of a function in a class in a namespace @@ -142,7 +138,7 @@ gdb_test "print BBB::Class::xyzq" \ # Break on a function in a class in a namespace gdb_test "break BBB::Class::xyzq" \ - "Breakpoint.*at $hex: file.*namespace.cc, line 68\\." + "Breakpoint.*at $hex$::fill: file.*namespace.cc, line 68\\." # Tests accessing static elements in namespace of other file. diff --git a/gdb/testsuite/gdb.cp/ovldbreak.exp b/gdb/testsuite/gdb.cp/ovldbreak.exp index 84efb37b8db..6e10d5b7ac1 100644 --- a/gdb/testsuite/gdb.cp/ovldbreak.exp +++ b/gdb/testsuite/gdb.cp/ovldbreak.exp @@ -97,7 +97,7 @@ proc set_bp_overloaded {name expectedmenu mychoice bpnumber linenumbers} { # Choose my choice. gdb_test_multiple "$mychoice" "set bp $bpnumber on $name $mychoice line $linenumbers" { - -re "Breakpoint ($decimal) at $hex: file$any$srcfile, line ($decimal).\r\n" { + -re "Breakpoint ($decimal) at $hex$::fill: file$any$srcfile, line ($decimal).\r\n" { set got_num $expect_out(1,string) set got_line $expect_out(2,string) @@ -253,7 +253,7 @@ gdb_test "info break" $bptable "breakpoint info, after setting one-by-one" # Test choice "cancel". # This is copy-and-paste from set_bp_overloaded. -send_gdb "break foo::overload1arg\n" +send_gdb "break foo::overload1arg\n" gdb_expect { -re "$menu_overload1arg" { pass "bp menu for foo::overload1arg choice cancel" @@ -332,15 +332,19 @@ gdb_test "info breakpoints" "No breakpoints, watchpoints, tracepoints, or catchp # Test choice "all". # This is copy-and-paste from set_bp_overloaded. +gdb_test_no_output "set breakpoint max-locations-printed unlimited" + +set breakmsg [gdb_multi_loc_regex "Breakpoint $decimal" 12] + incr bpnum -send_gdb "break foo::overload1arg\n" +send_gdb "break foo::overload1arg\n" gdb_expect { -re "$menu_overload1arg" { pass "bp menu for foo::overload1arg choice all" # Choose all. send_gdb "1\n" gdb_expect { - -re "Breakpoint $bpnum at $hex: foo::overload1arg. .12 locations.\r\n.*$gdb_prompt $" { + -re "$breakmsg$gdb_prompt $" { pass "set bp on overload1arg all" } -re ".*$gdb_prompt $" { diff --git a/gdb/testsuite/gdb.cp/pr-1023.exp b/gdb/testsuite/gdb.cp/pr-1023.exp index d39deec9d75..e047ed3ad7e 100644 --- a/gdb/testsuite/gdb.cp/pr-1023.exp +++ b/gdb/testsuite/gdb.cp/pr-1023.exp @@ -35,7 +35,7 @@ if {![runto_main]} { } gdb_test_multiple "break myClass::performBlocking" "break myClass::performBlocking" { - -re "Breakpoint $decimal at $hex: file .*$srcfile, line 12.*$gdb_prompt $" { + -re "Breakpoint $decimal at $hex$::fill: file .*$srcfile, line 12.*$gdb_prompt $" { pass "break myClass::performBlocking" } -re "the class myClass does not have any method named performBlocking.*$gdb_prompt $" { @@ -47,6 +47,6 @@ gdb_test_multiple "break myClass::performBlocking" "break myClass::performBlocki gdb_test \ "break myClass::performUnblocking" \ - "Breakpoint $decimal at $hex: file .*$srcfile, line 10.*" + "Breakpoint $decimal at $hex$::fill: file .*$srcfile, line 10.*" gdb_exit diff --git a/gdb/testsuite/gdb.cp/templates.exp b/gdb/testsuite/gdb.cp/templates.exp index 3ca8b20d844..6c49e5af401 100644 --- a/gdb/testsuite/gdb.cp/templates.exp +++ b/gdb/testsuite/gdb.cp/templates.exp @@ -609,7 +609,7 @@ gdb_test "print Garply >::garply" \ # djb - 06-03-2000 # Now should work fine gdb_test "break Garply >::garply" \ - "Breakpoint \[0-9\]* at $hex: file .*templates.cc, line.*" + "Breakpoint \[0-9\]* at $hex$::fill: file .*templates.cc, line.*" # # Template wild-matching tests diff --git a/gdb/testsuite/gdb.dwarf2/dw2-abs-hi-pc.exp b/gdb/testsuite/gdb.dwarf2/dw2-abs-hi-pc.exp index e93d2faffeb..0c1c8a51d7d 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-abs-hi-pc.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-abs-hi-pc.exp @@ -56,7 +56,7 @@ if {[build_executable ${testfile}.exp ${executable} $sources $flags] == -1} { clean_restart $executable gdb_test "break hello" \ - "Breakpoint $decimal at $hex: file .*dw2-abs-hi-pc-hello\\.c, line 24\\." + "Breakpoint $decimal at $hex$::fill: file .*dw2-abs-hi-pc-hello\\.c, line 24\\." gdb_test "break world" \ - "Breakpoint $decimal at $hex: file .*dw2-abs-hi-pc-world\\.c, line 24\\." + "Breakpoint $decimal at $hex$::fill: file .*dw2-abs-hi-pc-world\\.c, line 24\\." diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bad-elf.exp b/gdb/testsuite/gdb.dwarf2/dw2-bad-elf.exp index c678c209473..1149a2d90bd 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-bad-elf.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-bad-elf.exp @@ -180,7 +180,7 @@ proc run_test { goto_main } { # Place a breakpoint. gdb_test "break some_func" \ - "Breakpoint $decimal at $hex: file .*dw2-bad-elf-other\\.c, line 6\\." + "Breakpoint $decimal at $hex$::fill: file .*dw2-bad-elf-other\\.c, line 6\\." # Check GDB is still alive. gdb_test "echo hello\\n" "hello" diff --git a/gdb/testsuite/gdb.dwarf2/dw2-prologue-end-2.exp b/gdb/testsuite/gdb.dwarf2/dw2-prologue-end-2.exp index ef9dde8c713..17e29df78a1 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-prologue-end-2.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-prologue-end-2.exp @@ -83,7 +83,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} \ set break_addr "" gdb_test_multiple "break foo" "" { - -re -wrap "at ($hex):\[^\r\n\]*" { + -re -wrap "at ($hex)\[^\r\n\]*" { set break_addr $expect_out(1,string) pass $gdb_test_name } diff --git a/gdb/testsuite/gdb.dwarf2/missing-line-table.exp b/gdb/testsuite/gdb.dwarf2/missing-line-table.exp index 77618dea824..c80527c2bbc 100644 --- a/gdb/testsuite/gdb.dwarf2/missing-line-table.exp +++ b/gdb/testsuite/gdb.dwarf2/missing-line-table.exp @@ -90,7 +90,7 @@ proc check_breakpoint { func start end } { with_test_prefix "func=$func" { set addr "*unknown*" gdb_test_multiple "break $func" "place breakpoint" { - -re -wrap "Breakpoint $::decimal at ($::hex)(?:: \[^\r\n\]+)?" { + -re -wrap "Breakpoint $::decimal at ($::hex)(?:$::fill: $::fill)?" { set addr $expect_out(1,string) pass $gdb_test_name } diff --git a/gdb/testsuite/gdb.linespec/break-ask.exp b/gdb/testsuite/gdb.linespec/break-ask.exp index 2f786f20263..128a80a558a 100644 --- a/gdb/testsuite/gdb.linespec/break-ask.exp +++ b/gdb/testsuite/gdb.linespec/break-ask.exp @@ -68,7 +68,7 @@ gdb_test_multiple $cmd $test { pass $test } } -gdb_test "2" "^Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file thefile\\.cc, line \[0-9a-f\]+\\." +gdb_test "2" "^Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+$::fill: file thefile\\.cc, line \[0-9a-f\]+\\." gdb_breakpoint "body_elsewhere" @@ -88,7 +88,7 @@ gdb_test_multiple $cmd $test { pass $test } } -gdb_test "3" "^Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file thefile\\.cc, line \[0-9a-f\]+\\." +gdb_test "3" "^Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+$::fill: file thefile\\.cc, line \[0-9a-f\]+\\." gdb_breakpoint "body_elsewhere" diff --git a/gdb/testsuite/gdb.linespec/break-asm-file.exp b/gdb/testsuite/gdb.linespec/break-asm-file.exp index 3977e6aac85..eceb054097b 100644 --- a/gdb/testsuite/gdb.linespec/break-asm-file.exp +++ b/gdb/testsuite/gdb.linespec/break-asm-file.exp @@ -49,13 +49,13 @@ if {[gdb_compile [list ${binfile}1.o ${binfile}2.o ${binfile}3.o] \ clean_restart $execfile gdb_test "break a/$asm_file0:func" \ - "Breakpoint 1 at 0x\[0-9a-fA-F\]+: file .*a/$asm_file0, line 7\\\." \ + "Breakpoint 1 at 0x\[0-9a-fA-F\]+$::fill: file .*a/$asm_file0, line 7\\\." \ "set a break-point at a global function only for a selected ASM file." gdb_test "delete 1" gdb_test "break b/$asm_file0:func" \ - "Breakpoint 2 at 0x\[0-9a-fA-F\]+: file .*b/$asm_file0, line 7\\\." \ + "Breakpoint 2 at 0x\[0-9a-fA-F\]+$::fill: file .*b/$asm_file0, line 7\\\." \ "set a break-point at a function only for a selected ASM file." gdb_test "delete 2" diff --git a/gdb/testsuite/gdb.linespec/cpcompletion.exp b/gdb/testsuite/gdb.linespec/cpcompletion.exp index b5fc5eb897b..542c540c095 100644 --- a/gdb/testsuite/gdb.linespec/cpcompletion.exp +++ b/gdb/testsuite/gdb.linespec/cpcompletion.exp @@ -671,6 +671,10 @@ proc_with_prefix template-function-foo {} { check_setting_bp_fails "$cmd_prefix foo" should give any function with one parameter of any type # of A. While the parameter list in the template should be ignored, # the function's argument list should not be ignored. @@ -1402,4 +1406,8 @@ proc test_driver {} { if-expression } +with_test_prefix "global" { + gdb_test_no_output "set breakpoint max-locations-printed unlimited" +} + test_driver diff --git a/gdb/testsuite/gdb.linespec/linespec.exp b/gdb/testsuite/gdb.linespec/linespec.exp index 6398309f7e4..8743d559ea4 100644 --- a/gdb/testsuite/gdb.linespec/linespec.exp +++ b/gdb/testsuite/gdb.linespec/linespec.exp @@ -48,9 +48,7 @@ gdb_test_no_output "set breakpoint pending off" \ if { [is_remote host] } { untested "breakpoints using dir/file:line" } else { - gdb_test "break one/thefile.cc:$l1" \ - "Breakpoint $decimal at $hex: file .*thefile.cc, line $l1." \ - "single-location break using dir/file:line" + gdb_breakpoint "one/thefile.cc:$l1" gdb_test "clear one/thefile.cc:$l1" \ "Deleted breakpoint $decimal *" \ @@ -69,7 +67,7 @@ if { [is_remote host] } { send_gdb "\n" gdb_test "" \ - "Breakpoint $decimal at $hex: thefile.cc:twodup\\(\\). \[(\]2 locations\[)\]" \ + "[gdb_multi_loc_regex "Breakpoint $decimal" 2]\[^\r\n\]*" \ "set break at unique function name in two source files" } } @@ -110,7 +108,7 @@ if { [is_remote host] } { send_gdb "\n" gdb_test "" \ - "Breakpoint $decimal at $hex: file .*thefile.cc, line \[^\r\n\]*" \ + "Breakpoint $decimal at $hex$::fill: file .*thefile.cc, line \[^\r\n\]*" \ "set break at unique function name in disambiguated source file" } } @@ -162,7 +160,7 @@ gdb_test "break lspec.cc:nosuchfunction" \ gdb_breakpoint "NameSpace::overload" -locs 3 gdb_test "break lspec.cc:NameSpace::overload" \ - "Breakpoint \[0-9\]+ at $hex: file .*lspec.cc, line 7." \ + "Breakpoint \[0-9\]+ at $hex$::fill: file .*lspec.cc, line 7." \ "set breakpoint at lspec.cc instance of NameSpace::overload" gdb_test "break lspec.cc:NameSpace::overload(double)" \ @@ -170,7 +168,7 @@ gdb_test "break lspec.cc:NameSpace::overload(double)" \ "set breakpoint at non-existent lspec.cc instance of NameSpace::overload" gdb_test "break NameSpace::overload()" \ - "Breakpoint \[0-9\]+ at $hex: file .*lspec.cc, line 7." \ + "Breakpoint \[0-9\]+ at $hex$::fill: file .*lspec.cc, line 7." \ "set breakpoint at specific instance of NameSpace::overload" # This should manage to set a breakpoint even though body.h does not @@ -182,9 +180,7 @@ gdb_test "break body.h:$line" \ # This should only have a single location -- in f1. set line [gdb_get_line_number "f1 breakpoint" lspec.h] -gdb_test "break lspec.h:$line" \ - "Breakpoint \[0-9\]+ at $hex: file .*lspec.h, line $line." \ - "set breakpoint in f1" +gdb_breakpoint "lspec.h:$line" # # Multi-inferior tests. diff --git a/gdb/testsuite/gdb.linespec/ls-dollar.exp b/gdb/testsuite/gdb.linespec/ls-dollar.exp index 15952d7db2b..5fd2c245624 100644 --- a/gdb/testsuite/gdb.linespec/ls-dollar.exp +++ b/gdb/testsuite/gdb.linespec/ls-dollar.exp @@ -31,12 +31,10 @@ set line [gdb_get_line_number {dollar_func}] gdb_test "list \$dollar_var" \ ".*static int [string_to_regexp {$dollar_var}] = 0;" -gdb_test "break \$dollar_func" \ - "Breakpoint $decimal at $hex: file .*$srcfile, line $line\\\." +gdb_breakpoint "\$dollar_func" gdb_test_no_output "set var \$theline = $line" gdb_test "list $srcfile:\$theline" \ ".*[string_to_regexp {/* dollar_func */}]" -gdb_test "break $srcfile:\$theline" \ - "Breakpoint $decimal at $hex: file .*$srcfile, line $line\\\." +gdb_breakpoint "$srcfile:\$theline" diff --git a/gdb/testsuite/gdb.linespec/multiple-locs.cc b/gdb/testsuite/gdb.linespec/multiple-locs.cc new file mode 100644 index 00000000000..e7ca889e0fa --- /dev/null +++ b/gdb/testsuite/gdb.linespec/multiple-locs.cc @@ -0,0 +1,41 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2024 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +template +int +templ1 (T param) +{ + return (int) param; /* Break here. */ +} + +template <> +int +templ1 (char* param) +{ + return 2; +} + +int +main () +{ + templ1 (1L); + templ1 (1.0f); + templ1 (1U); + templ1 (1UL); + templ1 (1ULL); + return 0; +} diff --git a/gdb/testsuite/gdb.linespec/multiple-locs.exp b/gdb/testsuite/gdb.linespec/multiple-locs.exp new file mode 100644 index 00000000000..26c616a3f55 --- /dev/null +++ b/gdb/testsuite/gdb.linespec/multiple-locs.exp @@ -0,0 +1,57 @@ +# Copyright 2024 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Tests of printing of multiple breakpoint locations when setting a breakpoint. + +standard_testfile .cc + +require allow_cplus_tests + +if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} { + return -1 +} + +gdb_test_no_output "set confirm off" + +gdb_test_no_output "set multiple-symbols all" + +set bp_location [gdb_get_line_number "Break here." $srcfile] +gdb_breakpoint "$bp_location" -locs 5 + +delete_breakpoints + +gdb_test_no_output "set breakpoint max-locations-printed 2" + +set bp_location [gdb_get_line_number "Break here." $srcfile] + +gdb_breakpoint $bp_location -locs 5 -add_locs 3 + +delete_breakpoints + +set bp_location [gdb_get_line_number "Break here." $srcfile] + +gdb_breakpoint "$bp_location inferior 1" -locs 5 -locspec "$bp_location" \ + -add_locs 3 -inferior 1 + +delete_breakpoints + +# Now add the 2nd inferior. +gdb_test "add-inferior" "Added inferior 2.*" "add inferior 2" +gdb_test "inferior 2" "Switching to inferior 2.*" "switch to inferior 2" +gdb_file_cmd $binfile + +gdb_test_no_output "set breakpoint max-locations-printed 20" + +gdb_breakpoint "$bp_location" -locs 10 -inferior "\[12\]" diff --git a/gdb/testsuite/gdb.mi/mi-breakpoint-multiple-locations.exp b/gdb/testsuite/gdb.mi/mi-breakpoint-multiple-locations.exp index 93ddad84444..a02fe1f7cce 100644 --- a/gdb/testsuite/gdb.mi/mi-breakpoint-multiple-locations.exp +++ b/gdb/testsuite/gdb.mi/mi-breakpoint-multiple-locations.exp @@ -69,7 +69,9 @@ proc do_test { mi_version use_fix_flag expect_fixed_output } { set pattern [make_breakpoints_pattern $expect_fixed_output 2 y y] mi_gdb_test "break a_very_unique_name" \ [multi_line "&\"break a_very_unique_name\\\\n\"" \ - "~\"Breakpoint ${decimal} at.*\\(2 locations\\)\\\\n\"" \ + "~\"Breakpoint ${decimal} for.*at.*2 locations:\\\\n\"" \ + "~\" Location ${decimal}.*\\\\n\"" \ + "~\" Location ${decimal}.*\\\\n\"" \ "=breakpoint-created,${pattern}" \ "\\^done" ] \ "break a_very_unique_name" diff --git a/gdb/testsuite/gdb.mi/user-selected-context-sync.exp b/gdb/testsuite/gdb.mi/user-selected-context-sync.exp index 675965fec60..45a5360b24c 100644 --- a/gdb/testsuite/gdb.mi/user-selected-context-sync.exp +++ b/gdb/testsuite/gdb.mi/user-selected-context-sync.exp @@ -293,9 +293,7 @@ proc test_continue_to_start { mode inf } { with_spawn_id $gdb_main_spawn_id { # Continue to the point where we know for sure the threads are # started. - gdb_test "tbreak $srcfile:$main_break_line" \ - "Temporary breakpoint ${any}" \ - "set breakpoint in main" + gdb_breakpoint "$srcfile:$main_break_line" {temporary} gdb_continue_to_breakpoint "main breakpoint" @@ -321,9 +319,7 @@ proc test_continue_to_start { mode inf } { foreach thread { 2 3 } { gdb_test "thread $inf.$thread" ".*" "select child thread $inf.$thread" - gdb_test "tbreak $srcfile:$thread_loop_line" \ - "Temporary breakpoint ${any}" \ - "set breakpoint for thread $inf.$thread" + gdb_breakpoint "$srcfile:$thread_loop_line" {temporary} gdb_continue_to_breakpoint "continue thread $inf.$thread to infinite loop breakpoint" @@ -347,12 +343,8 @@ proc test_continue_to_start { mode inf } { # Put a thread-specific breakpoint for thread 2 of the current # inferior. We don't put a breakpoint for thread 3, since we # want to let it run. - set test "set thread-specific breakpoint, thread $inf.2" - gdb_test_multiple "tbreak $srcfile:$thread_loop_line thread $inf.2" $test { - -re "Temporary breakpoint ${any}\r\n$gdb_prompt " { - pass $test - } - } + gdb_breakpoint "$srcfile:$thread_loop_line thread $inf.2" \ + {temporary} # Confirm the stop of thread $inf.2. set test "thread $inf.2 stops CLI" diff --git a/gdb/testsuite/gdb.multi/inferior-specific-bp.exp b/gdb/testsuite/gdb.multi/inferior-specific-bp.exp index 67069e1da4d..3c37c068b71 100644 --- a/gdb/testsuite/gdb.multi/inferior-specific-bp.exp +++ b/gdb/testsuite/gdb.multi/inferior-specific-bp.exp @@ -172,7 +172,7 @@ proc check_info_breakpoints { testname bp_number expected_loc_count } { # Create an inferior-specific breakpoint. Use gdb_test instead of # gdb_breakpoint here as we want to check the breakpoint was placed in # multiple locations. -gdb_breakpoint "foo inferior 1" -locs 2 -locspec "foo" +gdb_breakpoint "foo inferior 1" -locs 2 -locspec "foo" -inferior 1 set bp_number [get_integer_valueof "\$bpnum" "INVALID" \ "get b/p number for inferior specific breakpoint"] diff --git a/gdb/testsuite/gdb.multi/multi-target-continue.exp b/gdb/testsuite/gdb.multi/multi-target-continue.exp index d4b2fc28133..2e8dcae13bf 100644 --- a/gdb/testsuite/gdb.multi/multi-target-continue.exp +++ b/gdb/testsuite/gdb.multi/multi-target-continue.exp @@ -29,8 +29,7 @@ proc test_continue {non-stop} { } proc set_break {inf} { - gdb_test "break function${inf} thread ${inf}.1" \ - "Breakpoint ${::decimal} at ${::hex}: file .*, line ${::decimal}\\." + gdb_breakpoint "function${inf} thread ${inf}.1" } # Select inferior INF, and then run to a breakpoint on inferior diff --git a/gdb/testsuite/gdb.multi/multi-target-ping-pong-next.exp b/gdb/testsuite/gdb.multi/multi-target-ping-pong-next.exp index 36f9d24a917..fe2683e9edb 100644 --- a/gdb/testsuite/gdb.multi/multi-target-ping-pong-next.exp +++ b/gdb/testsuite/gdb.multi/multi-target-ping-pong-next.exp @@ -51,13 +51,11 @@ proc test_ping_pong_next {} { gdb_test "thread 1.1" "Switching to thread 1.1 .*" - gdb_test "break $srcfile:$line1 thread 1.1" \ - "Breakpoint .*$srcfile, line $line1\\." + gdb_breakpoint "$srcfile:$line1 thread 1.1" gdb_test "continue" "hit Breakpoint .*" - gdb_test "break $srcfile:$line2 thread 2.1" \ - "Breakpoint .*$srcfile, line $line2\\." + gdb_breakpoint "$srcfile:$line2 thread 2.1" # Now block inferior 1 and issue "next". We should stop at the # breakpoint for inferior 2, given schedlock off. diff --git a/gdb/testsuite/gdb.opt/inline-break.exp b/gdb/testsuite/gdb.opt/inline-break.exp index 70549301964..738438489ef 100644 --- a/gdb/testsuite/gdb.opt/inline-break.exp +++ b/gdb/testsuite/gdb.opt/inline-break.exp @@ -292,9 +292,7 @@ with_test_prefix "address" { # Set the breakpoint by address, and check that GDB reports the # breakpoint location being the inline function. - gdb_test "break *$address" \ - ".*Breakpoint .* at $address: file .*$srcfile, line $line." \ - "set breakpoint on address" + gdb_breakpoint "*$address" gdb_test "info break \$bpnum" "in func1 at .*$srcfile:$line" diff --git a/gdb/testsuite/gdb.python/py-breakpoint.exp b/gdb/testsuite/gdb.python/py-breakpoint.exp index 6f9245c75c6..f0826710170 100644 --- a/gdb/testsuite/gdb.python/py-breakpoint.exp +++ b/gdb/testsuite/gdb.python/py-breakpoint.exp @@ -764,8 +764,9 @@ proc_with_prefix test_bkpt_qualified {} { # Start with a fresh gdb. clean_restart ${testfile} - set one_location_re "Breakpoint $decimal at $hex:.*line $decimal." - set two_location_re "Breakpoint $decimal at $hex:.*2 locations." + set one_location_re "Breakpoint $decimal at $hex$::fill:.*line $decimal." + set two_location_re \ + "[gdb_multi_loc_regex "Breakpoint $decimal" 2]\[^\r\n\]*" if {![runto_main]} { return 0 diff --git a/gdb/testsuite/gdb.python/py-mi-events.exp b/gdb/testsuite/gdb.python/py-mi-events.exp index d5de2473dd6..7752c607f63 100644 --- a/gdb/testsuite/gdb.python/py-mi-events.exp +++ b/gdb/testsuite/gdb.python/py-mi-events.exp @@ -61,7 +61,7 @@ set lineno [gdb_get_line_number "i++;"] # set a breakpoint into the for loop mi_gdb_test "break ${srcfile}:$lineno" \ - ".*Breakpoint $decimal at 0x\[0-9a-fA-F\]+: file .*${srcfile}.*\\\.*\\^done" \ + ".*Breakpoint $decimal at 0x\[0-9a-fA-F\]+$::fill: file .*${srcfile}.*\\\.*\\^done" \ "set the breakpoint" diff --git a/gdb/testsuite/gdb.reverse/aarch64-mops.exp b/gdb/testsuite/gdb.reverse/aarch64-mops.exp index 05a991d4bfb..eb1f52c652a 100644 --- a/gdb/testsuite/gdb.reverse/aarch64-mops.exp +++ b/gdb/testsuite/gdb.reverse/aarch64-mops.exp @@ -53,7 +53,7 @@ foreach_with_prefix insn_prefix {"set" "cpy" "cpyf"} { set after_seq [gdb_get_line_number "After ${insn_prefix}e"] gdb_test "break $before_seq" \ - "Breakpoint $decimal at $hex: file .*/aarch64-mops.c, line $decimal\\." \ + "Breakpoint $decimal at $hex$::fill: file .*/aarch64-mops.c, line $decimal\\." \ "break before instruction sequence" gdb_continue_to_breakpoint "about to execute instruction sequence" \ [multi_line ".*/aarch64-mops.c:$decimal" \ @@ -64,7 +64,7 @@ foreach_with_prefix insn_prefix {"set" "cpy" "cpyf"} { arrive_at_instruction "${insn_prefix}p" # Add a breakpoint that we're sure is at the prologue instruction. gdb_test "break *\$pc" \ - "Breakpoint $decimal at $hex: file .*/aarch64-mops.c, line $decimal\\." \ + "Breakpoint $decimal at $hex$::fill: file .*/aarch64-mops.c, line $decimal\\." \ "break at prologue instruction" # Record the initial memory and register values. @@ -84,7 +84,7 @@ foreach_with_prefix insn_prefix {"set" "cpy" "cpyf"} { } gdb_test "break $after_seq" \ - "Breakpoint $decimal at $hex: file .*/aarch64-mops.c, line $decimal\\." \ + "Breakpoint $decimal at $hex$::fill: file .*/aarch64-mops.c, line $decimal\\." \ "break after instruction sequence" gdb_continue_to_breakpoint "executed instruction sequence" \ [multi_line ".*/aarch64-mops.c:$decimal" "$decimal\[ \t\]+p = dest;"] diff --git a/gdb/testsuite/gdb.reverse/consecutive-precsave.exp b/gdb/testsuite/gdb.reverse/consecutive-precsave.exp index 134d85be512..92078e33671 100644 --- a/gdb/testsuite/gdb.reverse/consecutive-precsave.exp +++ b/gdb/testsuite/gdb.reverse/consecutive-precsave.exp @@ -72,7 +72,7 @@ gdb_test_multiple "x /2i \$pc" "get breakpoint address for foo" { } } -gdb_test "break \*$foo2_addr" "Breakpoint $decimal at $foo2_addr: file .*" \ +gdb_test "break \*$foo2_addr" "Breakpoint $decimal at $foo2_addr$::fill: file .*" \ "set bp, 2nd instr" set testmsg "stopped at bp, 2nd instr" diff --git a/gdb/testsuite/gdb.reverse/consecutive-reverse.exp b/gdb/testsuite/gdb.reverse/consecutive-reverse.exp index f5cbe060883..dfc905a49a7 100644 --- a/gdb/testsuite/gdb.reverse/consecutive-reverse.exp +++ b/gdb/testsuite/gdb.reverse/consecutive-reverse.exp @@ -54,7 +54,7 @@ gdb_test_multiple "x /2i \$pc" "get breakpoint address for foo" { } } -gdb_test "break \*$foo2_addr" "Breakpoint $decimal at $foo2_addr: file .*" \ +gdb_test "break \*$foo2_addr" "Breakpoint $decimal at $foo2_addr$::fill: file .*" \ "set bp, 2nd instr" set testmsg "stopped at bp, 2nd instr" diff --git a/gdb/testsuite/gdb.reverse/fstatat-reverse.exp b/gdb/testsuite/gdb.reverse/fstatat-reverse.exp index 396d40ed084..ff3b982a579 100644 --- a/gdb/testsuite/gdb.reverse/fstatat-reverse.exp +++ b/gdb/testsuite/gdb.reverse/fstatat-reverse.exp @@ -34,15 +34,11 @@ if [supports_process_record] { gdb_test_no_output "record" "turn on process record" } -gdb_test "break marker2" \ - "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \ - "set breakpoint at marker2" +gdb_breakpoint "marker2" gdb_continue_to_breakpoint "marker2" ".*$srcfile:.*" -gdb_test "break marker1" \ - "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \ - "set breakpoint at marker1" +gdb_breakpoint "marker1" gdb_test "reverse-continue" ".*$srcfile:$decimal.*" "reverse to marker1" diff --git a/gdb/testsuite/gdb.reverse/getrandom.exp b/gdb/testsuite/gdb.reverse/getrandom.exp index 572356bbf57..3f20413c265 100644 --- a/gdb/testsuite/gdb.reverse/getrandom.exp +++ b/gdb/testsuite/gdb.reverse/getrandom.exp @@ -36,13 +36,13 @@ if [supports_process_record] { } gdb_test "break marker2" \ - "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \ + "Breakpoint $decimal at $hex$::fill: file .*$srcfile, line $decimal.*" \ "set breakpoint at marker2" gdb_continue_to_breakpoint "marker2" ".*$srcfile:.*" gdb_test "break marker1" \ - "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \ + "Breakpoint $decimal at $hex$::fill: file .*$srcfile, line $decimal.*" \ "set breakpoint at marker1" gdb_test "reverse-continue" ".*$srcfile:$decimal.*" "reverse to marker1" diff --git a/gdb/testsuite/gdb.reverse/getresuid-reverse.exp b/gdb/testsuite/gdb.reverse/getresuid-reverse.exp index 50d327a4605..8dca120dc58 100644 --- a/gdb/testsuite/gdb.reverse/getresuid-reverse.exp +++ b/gdb/testsuite/gdb.reverse/getresuid-reverse.exp @@ -35,13 +35,13 @@ if [supports_process_record] { } gdb_test "break marker2" \ - "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \ + "Breakpoint $decimal at $hex$::fill: file .*$srcfile, line $decimal.*" \ "set breakpoint at marker2" gdb_continue_to_breakpoint "marker2" ".*$srcfile:.*" gdb_test "break marker1" \ - "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \ + "Breakpoint $decimal at $hex$::fill: file .*$srcfile, line $decimal.*" \ "set breakpoint at marker1" gdb_test "reverse-continue" ".*$srcfile:$decimal.*" "reverse to marker1" diff --git a/gdb/testsuite/gdb.reverse/pipe-reverse.exp b/gdb/testsuite/gdb.reverse/pipe-reverse.exp index ccf54816a01..f4dc3d0dfb4 100644 --- a/gdb/testsuite/gdb.reverse/pipe-reverse.exp +++ b/gdb/testsuite/gdb.reverse/pipe-reverse.exp @@ -35,13 +35,13 @@ if [supports_process_record] { } gdb_test "break marker2" \ - "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \ + "Breakpoint $decimal at $hex$::fill: file .*$srcfile, line $decimal.*" \ "set breakpoint at marker2" gdb_continue_to_breakpoint "marker2" ".*$srcfile:.*" gdb_test "break marker1" \ - "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \ + "Breakpoint $decimal at $hex$::fill: file .*$srcfile, line $decimal.*" \ "set breakpoint at marker1" gdb_test "reverse-continue" ".*$srcfile:$decimal.*" "reverse to marker1" diff --git a/gdb/testsuite/gdb.reverse/readv-reverse.exp b/gdb/testsuite/gdb.reverse/readv-reverse.exp index 35d0d2e73e2..945d118e714 100644 --- a/gdb/testsuite/gdb.reverse/readv-reverse.exp +++ b/gdb/testsuite/gdb.reverse/readv-reverse.exp @@ -35,13 +35,13 @@ if [supports_process_record] { } gdb_test "break marker2" \ - "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \ + "Breakpoint $decimal at $hex$::fill: file .*$srcfile, line $decimal.*" \ "set breakpoint at marker2" gdb_continue_to_breakpoint "marker2" ".*$srcfile:.*" gdb_test "break marker1" \ - "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \ + "Breakpoint $decimal at $hex$::fill: file .*$srcfile, line $decimal.*" \ "set breakpoint at marker1" gdb_test "reverse-continue" ".*$srcfile:$decimal.*" "reverse to marker1" diff --git a/gdb/testsuite/gdb.reverse/recvmsg-reverse.exp b/gdb/testsuite/gdb.reverse/recvmsg-reverse.exp index 95d1165914e..1725c582ed7 100644 --- a/gdb/testsuite/gdb.reverse/recvmsg-reverse.exp +++ b/gdb/testsuite/gdb.reverse/recvmsg-reverse.exp @@ -35,13 +35,13 @@ if [supports_process_record] { } gdb_test "break marker2" \ - "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \ + "Breakpoint $decimal at $hex$::fill: file .*$srcfile, line $decimal.*" \ "set breakpoint at marker2" gdb_continue_to_breakpoint "marker2" ".*$srcfile:.*" gdb_test "break marker1" \ - "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \ + "Breakpoint $decimal at $hex$::fill: file .*$srcfile, line $decimal.*" \ "set breakpoint at marker1" gdb_test "reverse-continue" ".*$srcfile:$decimal.*" "reverse to marker1" diff --git a/gdb/testsuite/gdb.reverse/s390-mvcle.exp b/gdb/testsuite/gdb.reverse/s390-mvcle.exp index 033d459028e..49b88b088da 100644 --- a/gdb/testsuite/gdb.reverse/s390-mvcle.exp +++ b/gdb/testsuite/gdb.reverse/s390-mvcle.exp @@ -33,11 +33,11 @@ if [supports_process_record] { } gdb_test "break marker1" \ - "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \ + "Breakpoint $decimal at $hex$::fill: file .*$srcfile, line $decimal.*" \ "set breakpoint at marker1" gdb_test "break marker2" \ - "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \ + "Breakpoint $decimal at $hex$::fill: file .*$srcfile, line $decimal.*" \ "set breakpoint at marker2" gdb_continue_to_breakpoint "marker1" ".*$srcfile:.*" diff --git a/gdb/testsuite/gdb.reverse/time-reverse.exp b/gdb/testsuite/gdb.reverse/time-reverse.exp index 35415a0fe1f..9c30ec56e02 100644 --- a/gdb/testsuite/gdb.reverse/time-reverse.exp +++ b/gdb/testsuite/gdb.reverse/time-reverse.exp @@ -46,7 +46,7 @@ proc test {mode} { } gdb_test "break marker2" \ - "Breakpoint $::decimal at $::hex: file .*$::srcfile, line $::decimal.*" \ + "Breakpoint $::decimal at $::hex$::fill: file .*$::srcfile, line $::decimal.*" \ "set breakpoint at marker2" gdb_continue_to_breakpoint "marker2" ".*$::srcfile:.*" diff --git a/gdb/testsuite/gdb.reverse/waitpid-reverse.exp b/gdb/testsuite/gdb.reverse/waitpid-reverse.exp index 7b667d93e1f..de54b027c77 100644 --- a/gdb/testsuite/gdb.reverse/waitpid-reverse.exp +++ b/gdb/testsuite/gdb.reverse/waitpid-reverse.exp @@ -37,13 +37,13 @@ if [supports_process_record] { } gdb_test "break marker2" \ - "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \ + "Breakpoint $decimal at $hex$::fill: file .*$srcfile, line $decimal.*" \ "set breakpoint at marker2" gdb_continue_to_breakpoint "marker2" ".*$srcfile:.*" gdb_test "break marker1" \ - "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \ + "Breakpoint $decimal at $hex$::fill: file .*$srcfile, line $decimal.*" \ "set breakpoint at marker1" gdb_test "reverse-continue" ".*$srcfile:$decimal.*" "reverse to marker1" diff --git a/gdb/testsuite/gdb.reverse/watch-precsave.exp b/gdb/testsuite/gdb.reverse/watch-precsave.exp index 98f406fadc7..4dc91c5542c 100644 --- a/gdb/testsuite/gdb.reverse/watch-precsave.exp +++ b/gdb/testsuite/gdb.reverse/watch-precsave.exp @@ -54,11 +54,11 @@ gdb_test "record restore $precsave" \ gdb_test_no_output "set can-use-hw-watchpoints 0" "" gdb_test "break marker1" \ - "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \ + "Breakpoint $decimal at $hex$::fill: file .*$srcfile, line $decimal.*" \ "set breakpoint at marker1" gdb_test "break marker2" \ - "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \ + "Breakpoint $decimal at $hex$::fill: file .*$srcfile, line $decimal.*" \ "set breakpoint at marker2" gdb_continue_to_breakpoint "marker1" ".*$srcfile:.*" diff --git a/gdb/testsuite/gdb.reverse/watch-reverse.exp b/gdb/testsuite/gdb.reverse/watch-reverse.exp index fb783e97c2e..8d2dd762cab 100644 --- a/gdb/testsuite/gdb.reverse/watch-reverse.exp +++ b/gdb/testsuite/gdb.reverse/watch-reverse.exp @@ -37,11 +37,11 @@ if [supports_process_record] { gdb_test_no_output "set can-use-hw-watchpoints 0" "disable hw watchpoints" gdb_test "break marker1" \ - "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \ + "Breakpoint $decimal at $hex$::fill: file .*$srcfile, line $decimal.*" \ "set breakpoint at marker1" gdb_test "break marker2" \ - "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \ + "Breakpoint $decimal at $hex$::fill: file .*$srcfile, line $decimal.*" \ "set breakpoint at marker2" gdb_continue_to_breakpoint "marker1" ".*$srcfile:.*" diff --git a/gdb/testsuite/gdb.server/bkpt-other-inferior.exp b/gdb/testsuite/gdb.server/bkpt-other-inferior.exp index 46c07d1926a..41432d5af3a 100644 --- a/gdb/testsuite/gdb.server/bkpt-other-inferior.exp +++ b/gdb/testsuite/gdb.server/bkpt-other-inferior.exp @@ -91,7 +91,7 @@ foreach inf_sel {1 2} { fail $test } else { set re \ - "Breakpoint $decimal at $hex: \[^\r\n\]+" + "Breakpoint $decimal at $hex$::fill: \[^\r\n\]+" set re "^$re\r\n$" gdb_assert { [regexp $re $lines] } $test } diff --git a/gdb/testsuite/gdb.server/target-exec-file.exp b/gdb/testsuite/gdb.server/target-exec-file.exp index 9a24b7a7720..498c062c9ca 100644 --- a/gdb/testsuite/gdb.server/target-exec-file.exp +++ b/gdb/testsuite/gdb.server/target-exec-file.exp @@ -174,7 +174,7 @@ proc start_inferior { testname expect_reread } { -re "^Expanding full symbols from \[^\r\n\]+\\.\\.\\.\r\n" { exp_continue } - -re "^Temporary breakpoint $::decimal at $::hex: \[^\r\n\]+\r\n" { + -re "^Temporary breakpoint $::decimal at $::hex$::fill: \[^\r\n\]+\r\n" { exp_continue } -re "^Starting program: \[^\r\n\]+\r\n" { diff --git a/gdb/testsuite/gdb.threads/print-threads.exp b/gdb/testsuite/gdb.threads/print-threads.exp index 6fae36a28a4..67c166fac26 100644 --- a/gdb/testsuite/gdb.threads/print-threads.exp +++ b/gdb/testsuite/gdb.threads/print-threads.exp @@ -88,12 +88,12 @@ proc test_all_threads { name kill } { set oldtimeout $timeout runto_main -gdb_test "break thread_function" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*print-threads.c, line \[0-9\]*\\." +gdb_test "break thread_function" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+$::fill: file .*print-threads.c, line \[0-9\]+\\." gdb_test_no_output "set var slow = 0" test_all_threads "fast" 0 runto_main -gdb_test "break thread_function" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*print-threads.c, line \[0-9\]*\\." "break thread_function, 2" +gdb_test "break thread_function" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+$::fill: file .*print-threads.c, line \[0-9\]+\\." "break thread_function, 2" gdb_test_no_output "set var slow = 1" # Extend the timeout for slower tests. set timeout [expr $oldtimeout + 120] @@ -101,7 +101,7 @@ test_all_threads "slow" 0 set timeout $oldtimeout runto_main -gdb_test "break thread_function" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*print-threads.c, line \[0-9\]*\\." "break thread_function, 3" +gdb_test "break thread_function" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+$::fill: file .*print-threads.c, line \[0-9\]+\\." "break thread_function, 3" gdb_test_no_output "set var slow = 1" "set var slow = 1, 2" gdb_breakpoint "kill" # Extend the timeout for slower tests. diff --git a/gdb/testsuite/gdb.trace/save-trace.exp b/gdb/testsuite/gdb.trace/save-trace.exp index f30b5b59b4d..2c1390c1a21 100644 --- a/gdb/testsuite/gdb.trace/save-trace.exp +++ b/gdb/testsuite/gdb.trace/save-trace.exp @@ -72,7 +72,7 @@ foreach x { 1 2 3 4 5 6 } { } gdb_test "ftrace fast_tracepoint_loc" \ - "Fast tracepoint $decimal at $hex: file .*$srcfile, line $decimal.*" \ + "Fast tracepoint $decimal at $hex$::fill: file .*$srcfile, line $decimal.*" \ "set a fast tracepoint" gdb_test_no_output "set default-collect gdb_char_test, gdb_long_test - 100" \ diff --git a/gdb/testsuite/gdb.trace/tracecmd.exp b/gdb/testsuite/gdb.trace/tracecmd.exp index 688980c78f7..8a483975d89 100644 --- a/gdb/testsuite/gdb.trace/tracecmd.exp +++ b/gdb/testsuite/gdb.trace/tracecmd.exp @@ -55,7 +55,7 @@ test_class_help "tracepoints" { # 1.1 trace source line gdb_delete_tracepoints gdb_test "trace $srcfile:$testline2" \ - "Tracepoint $decimal at $hex: file.*$srcfile, line $testline2." \ + "Tracepoint $decimal at $hex$::fill: file.*$srcfile, line $testline2." \ "1.1a: set tracepoint at sourceline" gdb_test "info trace" "in gdb_recursion_test.*$srcfile:$testline2. \[\t \]+not installed on target" \ @@ -80,7 +80,7 @@ gdb_test "info trace" "No tracepoints.*" \ # 1.4 trace function by name gdb_delete_tracepoints gdb_test "trace gdb_recursion_test" \ - "Tracepoint $decimal at $hex: file.*$srcfile, line $testline1." \ + "Tracepoint $decimal at $hex$::fill: file.*$srcfile, line $testline1." \ "1.4a: trace function by name" gdb_test "info trace" "in gdb_recursion_test.*$srcfile:$testline1. \[\t \]+not installed on target" \ @@ -136,7 +136,7 @@ gdb_test "trace" "No default breakpoint address now." \ # 1.11 tracepoint conditions gdb_delete_tracepoints gdb_test "trace gdb_recursion_test if q1 > 0" \ - "Tracepoint $decimal at $hex: file.*$srcfile, line $testline1." \ + "Tracepoint $decimal at $hex$::fill: file.*$srcfile, line $testline1." \ "1.11a: conditional tracepoint" gdb_test "info trace" "in gdb_recursion_test.*$srcfile:$testline1. \[\t \]+trace only if q1 > 0. @@ -158,7 +158,7 @@ gdb_delete_tracepoints # Acceptance vs rejection of a location are target-specific, so allow both. gdb_test_multiple "ftrace gdb_recursion_test" "set a fast tracepoint" { - -re "Fast tracepoint $decimal at $hex: file.*$srcfile, line $testline1.*$gdb_prompt $" { + -re "Fast tracepoint $decimal at $hex$::fill: file.*$srcfile, line $testline1.*$gdb_prompt $" { pass "set a fast tracepoint" } -re ".*May not have a fast tracepoint at $hex.*$gdb_prompt $" { diff --git a/gdb/testsuite/lib/completion-support.exp b/gdb/testsuite/lib/completion-support.exp index 5f0f6199894..453c9f925ac 100644 --- a/gdb/testsuite/lib/completion-support.exp +++ b/gdb/testsuite/lib/completion-support.exp @@ -412,12 +412,17 @@ proc completion::_create_bp {break_command} { set found_locations -1 + set breakpoint_msg "Breakpoint $decimal" + set test "set breakpoint" gdb_test_multiple "$break_command" $test { -re "\\\(\($decimal\) locations\\\)\r\n$gdb_prompt $" { set found_locations "$expect_out(1,string)" } - -re "Breakpoint $decimal at $hex: file .*, line .*$gdb_prompt $" { + -re "[gdb_multi_loc_regex $breakpoint_msg $decimal]$gdb_prompt $" { + set found_locations 1 + } + -re "Breakpoint $decimal at $hex$::fill: file .*, line .*$gdb_prompt $" { set found_locations 1 } -re "Make breakpoint pending on future shared library load.*y or .n.. $" { diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 4a5f1e0df89..3bce2c5d374 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -668,12 +668,28 @@ proc gdb_starti_cmd { {inferior_args {}} } { return -1 } +# Construct a breakpoint regex for multiple bp locations given a breakpoint +# command BREAK_MESSAGE and a regex of expected locations LOCS. +# This is useful for constructing multiple location regex where the +# gdb_breakpoint proc cannot be used (for instance in completion tests). +# It is also used in proc gdb_breakpoint. + +proc gdb_multi_loc_regex { break_message locs {locspec ""} } { + set fill "\[^\r\n\]" + return [multi_line \ + "$break_message for $fill*$locspec at $locs locations:" \ + "(?: Location $::decimal at $::hex$fill*\.\r\n)+" ] +} + +# Fill pattern that is often used, especially in breakpoint matching. +set fill "\[^\r\n\]+" + # Set a breakpoint using LINESPEC. # # If there is an additional argument it is a list of options; the supported # options are allow-pending, temporary, message, no-message and qualified. # For multiple breakpoint locations additional options are used. These -# are -locspec, -locs and -extra: +# are -locspec, -locs, -extra, -add_locs and -inferior: # -locspec specifies a regex for the location spec output of the break command. # This is only used when multiple locations matching is enabled by # the -locs option. It is useful when a very specific breakpoint @@ -685,6 +701,8 @@ proc gdb_starti_cmd { {inferior_args {}} } { # treated as an error. # -extra allows specifying a regex for extra matches that need to appear before # the breakpoint command output. +# -add_locs specifies a regex for additional locations printed. +# -inferior specifies a regex for "in inferior" in the break command output. # # The result is 1 for success, 0 for failure. # @@ -701,6 +719,7 @@ proc gdb_breakpoint { linespec args } { parse_some_args { {locspec "\[^\r\n\]*"} {locs "\[0-9\]+"} + {add_locs ""} {extra ""} } @@ -745,24 +764,35 @@ proc gdb_breakpoint { linespec args } { set single_loc 0 set test_name "gdb_breakpoint: set breakpoint at $linespec" - set fill "\[^\r\n]" + + set multiloc_msg \ + [gdb_multi_loc_regex $break_message $locs $locspec] + + set additional_locs "" + if { $add_locs != "" } { + set additional_locs \ + "$add_locs additional location\[s\]* not printed\.\r\n" + } # The extra regex is setup to not match unless the caller specifies # an extra match. gdb_test_multiple "$break_command $linespec" $test_name { - -re -wrap "$break_message at $fill+: file $fill+, line $decimal\\." { + -re -wrap "$break_message at $::fill: file $::fill, line $decimal\\." { + incr single_loc + } + -re -wrap "$break_message at $::fill in function $::fill: file $::fill, line $decimal\\." { incr single_loc } - -re -wrap "$break_message: file .*, line $decimal\\." { + -re -wrap "$break_message$::fill: file .*, line $decimal\\." { incr single_loc } - -re -wrap "$break_message at $::hex$fill*$locspec$fill*\($locs locations\)$fill+" { + -re "$multiloc_msg$additional_locs$gdb_prompt $" { incr multiple_locs } - -re -wrap "$break_message at $fill+\." { + -re ".*$break_message at $::fill\..*$gdb_prompt $" { incr single_loc } - -re -wrap "$break_message \\(.*\\) pending$fill+" { + -re -wrap "$break_message \\(.*\\) pending$::fill" { if {$pending_response == "n"} { if { $print_fail } { fail $gdb_test_name