public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH, testsuite] Allow function arguments in bp print match in selftest_setup
@ 2018-06-12 15:15 Tom de Vries
  2018-06-13 12:56 ` Pedro Alves
  0 siblings, 1 reply; 6+ messages in thread
From: Tom de Vries @ 2018-06-12 15:15 UTC (permalink / raw)
  To: gdb-patches

Hi,

atm selftest.exp fails for me.

One of the reasons is that setting the breakpoint on captured_main and running
to it gives us:
...
Breakpoint 1, captured_main (data=data@entry=0x7fffffffdb80) at main.c:1144
...
while the matching in selftest_setup only allows '()', like this:
...
Breakpoint 1, captured_main () at main.c:1144
...

The patch fixes this by allowing for random strings inbetween the parentheses.

Tested selftest.exp (with two other selftest.exp related fixes applied).

OK for trunk?

Thanks,
- Tom

[gdb] Allow function arguments in bp print match in selftest_setup

2018-06-12  Tom de Vries  <tdevries@suse.de>

	* lib/selftest-support.exp (selftest_setup): Allow function arguments in
	matching of breakpoint printing.

---
 gdb/testsuite/lib/selftest-support.exp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/lib/selftest-support.exp b/gdb/testsuite/lib/selftest-support.exp
index f7169e0955..0542861e78 100644
--- a/gdb/testsuite/lib/selftest-support.exp
+++ b/gdb/testsuite/lib/selftest-support.exp
@@ -88,10 +88,10 @@ proc selftest_setup { executable function } {
 
     set description "run until breakpoint at $function"
     gdb_test_multiple "run $INTERNAL_GDBFLAGS" "$description" {
-        -re "Starting program.*Breakpoint \[0-9\]+,.*$function \\(\\).* at .*main.c:.*$gdb_prompt $" {
+        -re "Starting program.*Breakpoint \[0-9\]+,.*$function \\(.*\\).* at .*main.c:.*$gdb_prompt $" {
             pass "$description"
         }
-        -re "Starting program.*Breakpoint \[0-9\]+,.*$function \\(\\).*$gdb_prompt $" {
+        -re "Starting program.*Breakpoint \[0-9\]+,.*$function \\(.*\\).*$gdb_prompt $" {
             xfail "$description (line numbers scrambled?)"
         }
 	-re "Starting program.*Breakpoint \[0-9\]+,.* at .*main.c:.*$function.*$gdb_prompt $" {

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH, testsuite] Allow function arguments in bp print match in selftest_setup
  2018-06-12 15:15 [PATCH, testsuite] Allow function arguments in bp print match in selftest_setup Tom de Vries
@ 2018-06-13 12:56 ` Pedro Alves
  2018-06-14 10:21   ` Tom de Vries
  0 siblings, 1 reply; 6+ messages in thread
From: Pedro Alves @ 2018-06-13 12:56 UTC (permalink / raw)
  To: Tom de Vries, gdb-patches

On 06/12/2018 04:15 PM, Tom de Vries wrote:
> Hi,
> 
> atm selftest.exp fails for me.
> 

[1]

> One of the reasons is that setting the breakpoint on captured_main and running
> to it gives us:
> ...
> Breakpoint 1, captured_main (data=data@entry=0x7fffffffdb80) at main.c:1144
> ...
> while the matching in selftest_setup only allows '()', like this:
> ...
> Breakpoint 1, captured_main () at main.c:1144
> ...
> 
> The patch fixes this by allowing for random strings inbetween the parentheses.
> 
> Tested selftest.exp (with two other selftest.exp related fixes applied).
> 
> OK for trunk?

Yes, please push.

[1] Funny, it passes for me (with the fix for stopping at captured_main),
because the pattern below the one you're touching matches:

	-re "Starting program.*Breakpoint \[0-9\]+,.* at .*main.c:.*$function.*$gdb_prompt $" {
	    # $function may be inlined, so the program stops at the line
	    # calling $function.
	    pass "$description"
	}

and it only happens to match because captured_main calls
captured_main_1 first thing, which coincidentally
matches "$function.*":

 Breakpoint 1, captured_main (data=<optimized out>) at gdb/binutils-gdb/src/gdb/main.c:1147
 1147      captured_main_1 (context);

That would probably be better "$function .*", with a space, but I 
think that even better, we should try removing the "may be inlined" case
too now, because since ddfe970e6bec ("Don't elide all inlined frames") GDB
presents the stop at the inline function instead of at the caller.
Like below.  Comments?

From: Pedro Alves <palves@redhat.com>
Date: 2018-06-13 13:44:16 +0100

remove inline
---

 gdb/testsuite/lib/selftest-support.exp |    5 -----
 1 file changed, 5 deletions(-)

diff --git a/gdb/testsuite/lib/selftest-support.exp b/gdb/testsuite/lib/selftest-support.exp
index f7169e0955e..c05f3b119be 100644
--- a/gdb/testsuite/lib/selftest-support.exp
+++ b/gdb/testsuite/lib/selftest-support.exp
@@ -94,11 +94,6 @@ proc selftest_setup { executable function } {
         -re "Starting program.*Breakpoint \[0-9\]+,.*$function \\(\\).*$gdb_prompt $" {
             xfail "$description (line numbers scrambled?)"
         }
-	-re "Starting program.*Breakpoint \[0-9\]+,.* at .*main.c:.*$function.*$gdb_prompt $" {
-	    # $function may be inlined, so the program stops at the line
-	    # calling $function.
-	    pass "$description"
-	}
         -re "vfork: No more processes.*$gdb_prompt $" {
             fail "$description (out of virtual memory)"
             set timeout $oldtimeout

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH, testsuite] Allow function arguments in bp print match in selftest_setup
  2018-06-13 12:56 ` Pedro Alves
@ 2018-06-14 10:21   ` Tom de Vries
  2018-06-14 10:46     ` Pedro Alves
  0 siblings, 1 reply; 6+ messages in thread
From: Tom de Vries @ 2018-06-14 10:21 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

On Wed, Jun 13, 2018 at 01:56:38PM +0100, Pedro Alves wrote:
> On 06/12/2018 04:15 PM, Tom de Vries wrote:
> > Hi,
> > 
> > atm selftest.exp fails for me.
> > 
> 
> [1]
> 
> > One of the reasons is that setting the breakpoint on captured_main and running
> > to it gives us:
> > ...
> > Breakpoint 1, captured_main (data=data@entry=0x7fffffffdb80) at main.c:1144
> > ...
> > while the matching in selftest_setup only allows '()', like this:
> > ...
> > Breakpoint 1, captured_main () at main.c:1144
> > ...
> > 
> > The patch fixes this by allowing for random strings inbetween the parentheses.
> > 
> > Tested selftest.exp (with two other selftest.exp related fixes applied).
> > 
> > OK for trunk?
> 
> Yes, please push.
>

Done.

> [1] Funny, it passes for me (with the fix for stopping at captured_main),
> because the pattern below the one you're touching matches:
> 
> 	-re "Starting program.*Breakpoint \[0-9\]+,.* at .*main.c:.*$function.*$gdb_prompt $" {
> 	    # $function may be inlined, so the program stops at the line
> 	    # calling $function.
> 	    pass "$description"
> 	}
> 
> and it only happens to match because captured_main calls
> captured_main_1 first thing, which coincidentally
> matches "$function.*":
> 
>  Breakpoint 1, captured_main (data=<optimized out>) at gdb/binutils-gdb/src/gdb/main.c:1147
>  1147      captured_main_1 (context);
>
> That would probably be better "$function .*", with a space,

Right, I observed that as well, and was thinking of this type of fix.

> but I 
> think that even better, we should try removing the "may be inlined" case
> too now, because since ddfe970e6bec ("Don't elide all inlined frames") GDB
> presents the stop at the inline function instead of at the caller.
> Like below.  Comments?
>

Agreed, that's a better solution.

Thanks,
- Tom

> From: Pedro Alves <palves@redhat.com>
> Date: 2018-06-13 13:44:16 +0100
> 
> remove inline
> ---
> 
>  gdb/testsuite/lib/selftest-support.exp |    5 -----
>  1 file changed, 5 deletions(-)
> 
> diff --git a/gdb/testsuite/lib/selftest-support.exp b/gdb/testsuite/lib/selftest-support.exp
> index f7169e0955e..c05f3b119be 100644
> --- a/gdb/testsuite/lib/selftest-support.exp
> +++ b/gdb/testsuite/lib/selftest-support.exp
> @@ -94,11 +94,6 @@ proc selftest_setup { executable function } {
>          -re "Starting program.*Breakpoint \[0-9\]+,.*$function \\(\\).*$gdb_prompt $" {
>              xfail "$description (line numbers scrambled?)"
>          }
> -	-re "Starting program.*Breakpoint \[0-9\]+,.* at .*main.c:.*$function.*$gdb_prompt $" {
> -	    # $function may be inlined, so the program stops at the line
> -	    # calling $function.
> -	    pass "$description"
> -	}
>          -re "vfork: No more processes.*$gdb_prompt $" {
>              fail "$description (out of virtual memory)"
>              set timeout $oldtimeout
> 
> Thanks,
> Pedro Alves

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH, testsuite] Allow function arguments in bp print match in selftest_setup
  2018-06-14 10:21   ` Tom de Vries
@ 2018-06-14 10:46     ` Pedro Alves
  2018-06-14 13:49       ` Tom de Vries
  0 siblings, 1 reply; 6+ messages in thread
From: Pedro Alves @ 2018-06-14 10:46 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches

On 06/14/2018 11:21 AM, Tom de Vries wrote:

>> [1] Funny, it passes for me (with the fix for stopping at captured_main),
>> because the pattern below the one you're touching matches:
>>
>> 	-re "Starting program.*Breakpoint \[0-9\]+,.* at .*main.c:.*$function.*$gdb_prompt $" {
>> 	    # $function may be inlined, so the program stops at the line
>> 	    # calling $function.
>> 	    pass "$description"
>> 	}
>>
>> and it only happens to match because captured_main calls
>> captured_main_1 first thing, which coincidentally
>> matches "$function.*":
>>
>>  Breakpoint 1, captured_main (data=<optimized out>) at gdb/binutils-gdb/src/gdb/main.c:1147
>>  1147      captured_main_1 (context);
>>
>> That would probably be better "$function .*", with a space,
> 
> Right, I observed that as well, and was thinking of this type of fix.

Please don't be shy about stating those things upfront, makes
review easier.  :-)

> 
>> but I 
>> think that even better, we should try removing the "may be inlined" case
>> too now, because since ddfe970e6bec ("Don't elide all inlined frames") GDB
>> presents the stop at the inline function instead of at the caller.
>> Like below.  Comments?
>>
> 
> Agreed, that's a better solution.

Alright, I've pushed this, as below.

From 1d39de443a38448226ffc408290c17c54c598c39 Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Thu, 14 Jun 2018 11:40:23 +0100
Subject: [PATCH] Remove stale inline function handling from selftest_setup

Before commit 70ee000084aa ("[gdb] Allow function arguments in bp
print match in selftest_setup"), this pattern in selftest_setup:

	-re "Starting program.*Breakpoint \[0-9\]+,.* at .*main.c:.*$function.*$gdb_prompt $" {
	    # $function may be inlined, so the program stops at the line
	    # calling $function.
	    pass "$description"
	}

happened to match if captured_main_1 was inlined and captured_main was
not, because captured_main calls captured_main_1 first thing, which
coincidentally matches "$function.*":

 Breakpoint 1, captured_main (data=<optimized out>) at src/gdb/main.c:1147
 1147      captured_main_1 (context);

That would probably be better "$function .*", with a space, but I
think that even better is to remove the "may be inlined" case too now,
because since ddfe970e6bec ("Don't elide all inlined frames") GDB
presents the stop at the inline function instead of at the caller.

gdb/testsuite/ChangeLog:
2018-06-14  Pedro Alves  <palves@redhat.com>

	* lib/selftest-support.exp (selftest_setup): Remove inlined
	function handling.
---
 gdb/testsuite/ChangeLog                | 5 +++++
 gdb/testsuite/lib/selftest-support.exp | 5 -----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 723fa299a38..fd6b8fcbf2f 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2018-06-14  Pedro Alves  <palves@redhat.com>
+
+	* lib/selftest-support.exp (selftest_setup): Remove inlined
+	function handling.
+
 2018-06-14  Tom de Vries  <tdevries@suse.de>
 
 	* lib/selftest-support.exp (selftest_setup): Allow function arguments in
diff --git a/gdb/testsuite/lib/selftest-support.exp b/gdb/testsuite/lib/selftest-support.exp
index 0542861e78b..887ea20d73a 100644
--- a/gdb/testsuite/lib/selftest-support.exp
+++ b/gdb/testsuite/lib/selftest-support.exp
@@ -94,11 +94,6 @@ proc selftest_setup { executable function } {
         -re "Starting program.*Breakpoint \[0-9\]+,.*$function \\(.*\\).*$gdb_prompt $" {
             xfail "$description (line numbers scrambled?)"
         }
-	-re "Starting program.*Breakpoint \[0-9\]+,.* at .*main.c:.*$function.*$gdb_prompt $" {
-	    # $function may be inlined, so the program stops at the line
-	    # calling $function.
-	    pass "$description"
-	}
         -re "vfork: No more processes.*$gdb_prompt $" {
             fail "$description (out of virtual memory)"
             set timeout $oldtimeout
-- 
2.14.3

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH, testsuite] Allow function arguments in bp print match in selftest_setup
  2018-06-14 10:46     ` Pedro Alves
@ 2018-06-14 13:49       ` Tom de Vries
  2018-06-14 13:52         ` Pedro Alves
  0 siblings, 1 reply; 6+ messages in thread
From: Tom de Vries @ 2018-06-14 13:49 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

On 06/14/2018 12:45 PM, Pedro Alves wrote:
> On 06/14/2018 11:21 AM, Tom de Vries wrote:
> 
>>> [1] Funny, it passes for me (with the fix for stopping at captured_main),
>>> because the pattern below the one you're touching matches:
>>>
>>> 	-re "Starting program.*Breakpoint \[0-9\]+,.* at .*main.c:.*$function.*$gdb_prompt $" {
>>> 	    # $function may be inlined, so the program stops at the line
>>> 	    # calling $function.
>>> 	    pass "$description"
>>> 	}
>>>
>>> and it only happens to match because captured_main calls
>>> captured_main_1 first thing, which coincidentally
>>> matches "$function.*":
>>>
>>>  Breakpoint 1, captured_main (data=<optimized out>) at gdb/binutils-gdb/src/gdb/main.c:1147
>>>  1147      captured_main_1 (context);
>>>
>>> That would probably be better "$function .*", with a space,
>> Right, I observed that as well, and was thinking of this type of fix.

> Please don't be shy about stating those things upfront, makes
> review easier.  :-)
> 

Ack, yeah, sorry about that. I'm currently visiting the Nuremberg
office, so I'm a bit more distracted than usual.

Thanks,
- Tom

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH, testsuite] Allow function arguments in bp print match in selftest_setup
  2018-06-14 13:49       ` Tom de Vries
@ 2018-06-14 13:52         ` Pedro Alves
  0 siblings, 0 replies; 6+ messages in thread
From: Pedro Alves @ 2018-06-14 13:52 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches

On 06/14/2018 02:49 PM, Tom de Vries wrote:
> On 06/14/2018 12:45 PM, Pedro Alves wrote:
>> On 06/14/2018 11:21 AM, Tom de Vries wrote:
>>
>>>> [1] Funny, it passes for me (with the fix for stopping at captured_main),
>>>> because the pattern below the one you're touching matches:
>>>>
>>>> 	-re "Starting program.*Breakpoint \[0-9\]+,.* at .*main.c:.*$function.*$gdb_prompt $" {
>>>> 	    # $function may be inlined, so the program stops at the line
>>>> 	    # calling $function.
>>>> 	    pass "$description"
>>>> 	}
>>>>
>>>> and it only happens to match because captured_main calls
>>>> captured_main_1 first thing, which coincidentally
>>>> matches "$function.*":
>>>>
>>>>  Breakpoint 1, captured_main (data=<optimized out>) at gdb/binutils-gdb/src/gdb/main.c:1147
>>>>  1147      captured_main_1 (context);
>>>>
>>>> That would probably be better "$function .*", with a space,
>>> Right, I observed that as well, and was thinking of this type of fix.
> 
>> Please don't be shy about stating those things upfront, makes
>> review easier.  :-)
>>
> 
> Ack, yeah, sorry about that. I'm currently visiting the Nuremberg
> office, so I'm a bit more distracted than usual.

Really no biggie.  Thanks for all the fixes.  Hope you're having fun.  :-)

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-06-14 13:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-12 15:15 [PATCH, testsuite] Allow function arguments in bp print match in selftest_setup Tom de Vries
2018-06-13 12:56 ` Pedro Alves
2018-06-14 10:21   ` Tom de Vries
2018-06-14 10:46     ` Pedro Alves
2018-06-14 13:49       ` Tom de Vries
2018-06-14 13:52         ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).