[pushed] Fix gdb.base/advance-until-multiple-locations.exp with some compilers (Re: [PATCH 2/2] Fix advance/until and multiple locations (PR gdb/26524))

Message ID cf6d6488-f3c2-6704-98a9-788d87227635@palves.net
State New
Headers show
Series
  • [pushed] Fix gdb.base/advance-until-multiple-locations.exp with some compilers (Re: [PATCH 2/2] Fix advance/until and multiple locations (PR gdb/26524))
Related show

Commit Message

Pedro Alves Aug. 28, 2020, 6:52 p.m.
On 8/28/20 9:49 AM, Tom de Vries wrote:
> On 8/28/20 10:31 AM, Tom de Vries wrote:

>> On 8/22/20 10:38 PM, Pedro Alves wrote:

>>> 	* gdb.base/advance-until-multiple-locations.cc: New.

>>> 	* gdb.base/advance-until-multiple-locations.exp: New.

>>

>> Hi,

>>

>> just to note that this fails for me with gcc 7, gcc 4.8 and clang 10:

>> ...

>> Breakpoint 10, test () at advance-until-multiple-locations.cc:45^M

>> 45        int i = 0;^M

>> (gdb) until ovld_func^M

>> main () at advance-until-multiple-locations.cc:61^M

>> 61      }^M

>> (gdb) FAIL: gdb.base/advance-until-multiple-locations.exp:

>> until_overload: until ovld_func

>> ...

>>

>> It passes with gcc-8, gcc-9, gcc-10 and gcc-11.

> 

> OK, this is due to the difference in line number info between gcc-7 and

> gcc-8, a known issue: with gcc-8, we have additional "recommended

> breakpoint locations".

> 

> This fixes it for me:

> ...

> diff --git a/gdb/testsuite/gdb.base/advance-until-multiple-locations.cc

> b/gdb/t

> estsuite/gdb.base/advance-until-multiple-locations.cc

> index a90493805f..15e651abae 100644

> --- a/gdb/testsuite/gdb.base/advance-until-multiple-locations.cc

> +++ b/gdb/testsuite/gdb.base/advance-until-multiple-locations.cc

> @@ -58,4 +58,4 @@ int

>  main ()

>  {

>    return test ();

> -}

> +} // main

> diff --git a/gdb/testsuite/gdb.base/advance-until-multiple-locations.exp

> b/gdb/

> testsuite/gdb.base/advance-until-multiple-locations.exp

> index a6a1de6653..037b81947e 100644

> --- a/gdb/testsuite/gdb.base/advance-until-multiple-locations.exp

> +++ b/gdb/testsuite/gdb.base/advance-until-multiple-locations.exp

> @@ -129,7 +129,7 @@ proc_with_prefix until_overload {} {

>      # ovld_func is a different frame, so it shouldn't cause a stop.

>      # Instead, the program should stop at the caller frame.

>      gdb_test "until ovld_func" \

> -       "main .* at .*return test \\(\\);.*"

> +       "main .* at .*(return test \\(\\);|\} // main)"

>  }


Thanks.  Curiously, that particular test passes for me, and
a different one fails.  I've applied this to fix it.

From 8f57f343104b8d3632e65ac1fbb12ee69891ef5f Mon Sep 17 00:00:00 2001
From: Pedro Alves <pedro@palves.net>

Date: Fri, 28 Aug 2020 18:44:39 +0100
Subject: [PATCH] Fix gdb.base/advance-until-multiple-locations.exp with some
 compilers

The tests in gdb.base/advance-until-multiple-locations.exp that expect
the program to stop at a caller fail on some systems, depending on
compiler.  E.g., with Clang 10, I see:

 advance ovld_func
 0x00000000004011a3 in test () at /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.base/advance-until-multiple-locations.cc:51
 51        ovld_func ();
 (gdb) FAIL: gdb.base/advance-until-multiple-locations.exp: advance_overload: second advance stops at caller

And Tom de Vries saw:

 ...
 (gdb) until ovld_func^M
 main () at advance-until-multiple-locations.cc:61^M
 61      }^M
 (gdb) FAIL: gdb.base/advance-until-multiple-locations.exp:until_overload: until ovld_func
 ...

Which exact line the program stops is not important.  All we care
about here is that the program stopped at the caller function.

So fix it by adjusting the patterns to match the frame header/function
reported by the breakpoint hits instead of the source lines text.

Tested against:

 - gcc {4.8, 4.9, 7.3.1, 9.3.0, trunk-20200828}
 - clang {5.0.2, 10}

gdb/testsuite/ChangeLog:

	* gdb.base/advance-until-multiple-locations.exp
	(advance_overload, until_overload): Adjust to match the
	frame/function header instead of the source line text.
---
 gdb/testsuite/ChangeLog                                     | 6 ++++++
 gdb/testsuite/gdb.base/advance-until-multiple-locations.exp | 4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)


base-commit: e0814aae5f16c06d82fde23f8bea15eea205aa54
-- 
2.14.5

Patch

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 6335ece30d7..af4444040b8 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@ 
+2020-08-28  Pedro Alves  <pedro@palves.net>
+
+	* gdb.base/advance-until-multiple-locations.exp
+	(advance_overload, until_overload): Adjust to match the
+	frame/function header instead of the source line text.
+
 2020-08-28  Tom de Vries  <tdevries@suse.de>
 
 	* gdb.base/label-without-address.c: New test.
diff --git a/gdb/testsuite/gdb.base/advance-until-multiple-locations.exp b/gdb/testsuite/gdb.base/advance-until-multiple-locations.exp
index a6a1de6653d..0f919b46d4b 100644
--- a/gdb/testsuite/gdb.base/advance-until-multiple-locations.exp
+++ b/gdb/testsuite/gdb.base/advance-until-multiple-locations.exp
@@ -104,7 +104,7 @@  proc_with_prefix advance_overload {} {
     # Need to issue the advance twice, because advance also stops upon
     # exit from the current stack frame.
     gdb_test "advance ovld_func" \
-	"ovld_func \\(0\\);.*" \
+	"test \\(\\) at .*" \
 	"second advance stops at caller"
 
     gdb_test "advance ovld_func" \
@@ -129,7 +129,7 @@  proc_with_prefix until_overload {} {
     # ovld_func is a different frame, so it shouldn't cause a stop.
     # Instead, the program should stop at the caller frame.
     gdb_test "until ovld_func" \
-	"main .* at .*return test \\(\\);.*"
+	"main \\(\\) at .*"
 }
 
 foreach_with_prefix cmd {"until" "advance"} {