Fixed top frame assumption in watchpoint-hw-attach

Message ID d8b751d8-b6dd-2bda-50cd-102e0d9fe32a@arm.com
State New, archived
Headers

Commit Message

Richard Bunt June 27, 2018, 10:17 a.m. UTC
  Fixed top frame assumption in watchpoint-hw-attach

watchpoint-hw-attach.exp was noticed to fail on some machines.
Thanks to the input from sergiodj and palves on the IRC channel,
it was concluded that the test case incorrectly assumed that on
attach it was landed in the top-most frame of the inferior. This
was fixed by running to a break point in main by explicitly
defining the source file name before continuing with the test.

Tested on the following architectures x86_64, aarch64 and ppc64le.

gdb/testsuite/ChangeLog:

2018-06-25  Richard Bunt  <richard.bunt@arm.com>

	* gdb.base/watchpoint-hw-attach.c (main): Remove unneeded
	code.
	* gdb.base/watchpoint-hw-attach.exp: Break in outermost frame.
---
 gdb/testsuite/gdb.base/watchpoint-hw-attach.c   | 1 -
 gdb/testsuite/gdb.base/watchpoint-hw-attach.exp | 8 ++++----
 2 files changed, 4 insertions(+), 5 deletions(-)
  

Comments

Simon Marchi June 27, 2018, 1:29 p.m. UTC | #1
On 2018-06-27 06:17 AM, Richard Bunt wrote:
> Fixed top frame assumption in watchpoint-hw-attach
> 
> watchpoint-hw-attach.exp was noticed to fail on some machines.
> Thanks to the input from sergiodj and palves on the IRC channel,
> it was concluded that the test case incorrectly assumed that on
> attach it was landed in the top-most frame of the inferior. This
> was fixed by running to a break point in main by explicitly
> defining the source file name before continuing with the test.
> 
> Tested on the following architectures x86_64, aarch64 and ppc64le.

LGTM, thanks!

Simon
  
Pedro Alves June 29, 2018, 2:51 p.m. UTC | #2
Hi,

On 06/27/2018 11:17 AM, Richard Bunt wrote:

> --- a/gdb/testsuite/gdb.base/watchpoint-hw-attach.exp
> +++ b/gdb/testsuite/gdb.base/watchpoint-hw-attach.exp
> @@ -57,12 +57,12 @@ clean_restart $binfile
> 
>  gdb_test "attach $testpid" "Attaching to program: .*, process $testpid.*"

Diffing test results, I noticed:

 PASS: gdb.base/watchpoint-hw-attach.exp: continue to breakpoint: pidacquired
 PASS: gdb.base/watchpoint-hw-attach.exp: get integer valueof "mypid"
 PASS: gdb.base/watchpoint-hw-attach.exp: detach
 PASS: gdb.base/watchpoint-hw-attach.exp: attach 25501
                                                 ^^^^^

It's better to avoid using unstable numbers in test names.  Can you
fix this in the obvious way (make it print "attach" only)?  Thanks.

Thanks,
Pedro Alves
  
Richard Bunt June 29, 2018, 3:23 p.m. UTC | #3
On 06/29/2018 03:51 PM, Pedro Alves wrote:
> Hi,
> 
> On 06/27/2018 11:17 AM, Richard Bunt wrote:
> 
>> --- a/gdb/testsuite/gdb.base/watchpoint-hw-attach.exp
>> +++ b/gdb/testsuite/gdb.base/watchpoint-hw-attach.exp
>> @@ -57,12 +57,12 @@ clean_restart $binfile
>>
>>  gdb_test "attach $testpid" "Attaching to program: .*, process $testpid.*"
> 
> Diffing test results, I noticed:
> 
>  PASS: gdb.base/watchpoint-hw-attach.exp: continue to breakpoint: pidacquired
>  PASS: gdb.base/watchpoint-hw-attach.exp: get integer valueof "mypid"
>  PASS: gdb.base/watchpoint-hw-attach.exp: detach
>  PASS: gdb.base/watchpoint-hw-attach.exp: attach 25501
>                                                  ^^^^^
> 
> It's better to avoid using unstable numbers in test names.  Can you
> fix this in the obvious way (make it print "attach" only)?  Thanks.
> 

Understood, I'll prepare a fix.

> Thanks,
> Pedro Alves
> 

Many thanks,
Rich
  
Richard Bunt June 29, 2018, 4:39 p.m. UTC | #4
On 06/29/2018 03:51 PM, Pedro Alves wrote:
> Hi,
> 
> On 06/27/2018 11:17 AM, Richard Bunt wrote:
> 
>> --- a/gdb/testsuite/gdb.base/watchpoint-hw-attach.exp
>> +++ b/gdb/testsuite/gdb.base/watchpoint-hw-attach.exp
>> @@ -57,12 +57,12 @@ clean_restart $binfile
>>
>>  gdb_test "attach $testpid" "Attaching to program: .*, process $testpid.*"
> 
> Diffing test results, I noticed:
> 
>  PASS: gdb.base/watchpoint-hw-attach.exp: continue to breakpoint: pidacquired
>  PASS: gdb.base/watchpoint-hw-attach.exp: get integer valueof "mypid"
>  PASS: gdb.base/watchpoint-hw-attach.exp: detach
>  PASS: gdb.base/watchpoint-hw-attach.exp: attach 25501
>                                                  ^^^^^
> 
> It's better to avoid using unstable numbers in test names.  Can you
> fix this in the obvious way (make it print "attach" only)?  Thanks.
> 
> Thanks,
> Pedro Alves
> 

Fix pushed. Sorry about this.

Many thanks,
Rich
  
Pedro Alves June 29, 2018, 4:40 p.m. UTC | #5
On 06/29/2018 05:39 PM, Richard Bunt wrote:

> Fix pushed. Sorry about this.

Thanks!  And no worries.  :-)

Thanks,
Pedro Alves
  

Patch

diff --git a/gdb/testsuite/gdb.base/watchpoint-hw-attach.c
b/gdb/testsuite/gdb.base/watchpoint-hw-attach.c
index 9d55b28..5bfea50 100644
--- a/gdb/testsuite/gdb.base/watchpoint-hw-attach.c
+++ b/gdb/testsuite/gdb.base/watchpoint-hw-attach.c
@@ -36,7 +36,6 @@  main (void)
   for (counter = 0; !should_continue && counter < 100; counter++)
     sleep (1);			/* pidacquired */

-  watched_variable = 0;		/* prewatchtrigger */
   /* Trigger a watchpoint.  */
   watched_variable = 4;
   printf ("My variable is %d\n", watched_variable);
diff --git a/gdb/testsuite/gdb.base/watchpoint-hw-attach.exp
b/gdb/testsuite/gdb.base/watchpoint-hw-attach.exp
index 0c5037c..ba7205d 100644
--- a/gdb/testsuite/gdb.base/watchpoint-hw-attach.exp
+++ b/gdb/testsuite/gdb.base/watchpoint-hw-attach.exp
@@ -57,12 +57,12 @@  clean_restart $binfile

 gdb_test "attach $testpid" "Attaching to program: .*, process $testpid.*"

-gdb_test_no_output "set should_continue = 1"
-
 # Ensure the test program is in the top frame so the required
 # variables are in scope.
-gdb_breakpoint [gdb_get_line_number "prewatchtrigger"]
-gdb_continue_to_breakpoint "prewatchtrigger"
+gdb_breakpoint $srcfile:[gdb_get_line_number "pidacquired"]
+gdb_continue_to_breakpoint "$srcfile:pidacquired"
+
+gdb_test_no_output "set should_continue = 1"

 gdb_test "watch watched_variable" \
 	 "Hardware watchpoint $decimal: watched_variable"