[05/11] gdb/testsuite: allow for clang style destructors on gdb.cp/m-static.exp

Message ID 20221004170747.154307-7-blarsen@redhat.com
State Committed
Headers
Series Cleanup gdb.cp tests when running with clang |

Commit Message

Guinevere Larsen Oct. 4, 2022, 5:07 p.m. UTC
  when running gdb.cp/m-static.exp using clang, we get the following
failures:

    print test1.~gnu_obj_1^M
    $6 = {void (gnu_obj_1 * const)} 0x555555555470 <gnu_obj_1::~gnu_obj_1()>^M
    (gdb) FAIL: gdb.cp/m-static.exp: simple object instance, print destructor
    ptype test1.~gnu_obj_1^M
    type = void (gnu_obj_1 * const)^M
    (gdb) FAIL: gdb.cp/m-static.exp: simple object instance, ptype destructor
    print test1.'~gnu_obj_1'^M
    $7 = {void (gnu_obj_1 * const)} 0x555555555470 <gnu_obj_1::~gnu_obj_1()>^M
    (gdb) FAIL: gdb.cp/m-static.exp: simple object instance, print quoted destructor

This is because the test is expecting an extra integer parameter on the
destructor. Looking at the debuginfo, it seems that there is nothing
actually wrong with this output, so these tests were changed to test
multiple possible regexps.
---
 gdb/testsuite/gdb.cp/m-static.exp | 36 ++++++++++++++++++++++---------
 1 file changed, 26 insertions(+), 10 deletions(-)
  

Comments

Andrew Burgess Oct. 26, 2022, 1:04 p.m. UTC | #1
Bruno Larsen via Gdb-patches <gdb-patches@sourceware.org> writes:

> when running gdb.cp/m-static.exp using clang, we get the following
> failures:
>
>     print test1.~gnu_obj_1^M
>     $6 = {void (gnu_obj_1 * const)} 0x555555555470 <gnu_obj_1::~gnu_obj_1()>^M
>     (gdb) FAIL: gdb.cp/m-static.exp: simple object instance, print destructor
>     ptype test1.~gnu_obj_1^M
>     type = void (gnu_obj_1 * const)^M
>     (gdb) FAIL: gdb.cp/m-static.exp: simple object instance, ptype destructor
>     print test1.'~gnu_obj_1'^M
>     $7 = {void (gnu_obj_1 * const)} 0x555555555470 <gnu_obj_1::~gnu_obj_1()>^M
>     (gdb) FAIL: gdb.cp/m-static.exp: simple object instance, print quoted destructor
>
> This is because the test is expecting an extra integer parameter on the
> destructor. Looking at the debuginfo, it seems that there is nothing
> actually wrong with this output, so these tests were changed to test
> multiple possible regexps.
> ---
>  gdb/testsuite/gdb.cp/m-static.exp | 36 ++++++++++++++++++++++---------
>  1 file changed, 26 insertions(+), 10 deletions(-)
>
> diff --git a/gdb/testsuite/gdb.cp/m-static.exp b/gdb/testsuite/gdb.cp/m-static.exp
> index 979de23a44f..332e1cbe1f9 100644
> --- a/gdb/testsuite/gdb.cp/m-static.exp
> +++ b/gdb/testsuite/gdb.cp/m-static.exp
> @@ -102,16 +102,32 @@ if { [is_aarch32_target] } {
>  	{type = void \(single_constructor \* const\)} \
>  	"simple object class, ptype constructor"
>  
> -    gdb_test "print test1.~gnu_obj_1" \
> -	{ = {void \(gnu_obj_1 \* const, int\)} 0x[0-9a-f]+ <gnu_obj_1::~gnu_obj_1\(\)>} \
> -	"simple object instance, print destructor"

Rather than switching to gdb_test_multiple, it might be better to just
update the regexp, like:

  { = {void \(gnu_obj_1 \* const(?:, int)?\)} 0x[0-9a-f]+ <gnu_obj_1::~gnu_obj_1\(\)>}

We already use something like this (though without the '?:' modifier) in
one of the tests below, so I think there's precedent.

Thanks,
Andrew


> -    gdb_test "ptype test1.~gnu_obj_1" \
> -	{type = void \(gnu_obj_1 \* const, int\)} \
> -	"simple object instance, ptype destructor"
> -
> -    gdb_test "print test1.'~gnu_obj_1'" \
> -	{ = {void \(gnu_obj_1 \*( const)?, int\)} 0x[0-9a-f]+ <gnu_obj_1::~gnu_obj_1\(\)>} \
> -	"simple object instance, print quoted destructor"
> +    gdb_test_multiple "print test1.~gnu_obj_1" "simple object instance, print destructor" {
> +	-re -wrap { = {void \(gnu_obj_1 \* const, int\)} 0x[0-9a-f]+ <gnu_obj_1::~gnu_obj_1\(\)>} {
> +	    pass $gdb_test_name
> +	}
> +	-re -wrap { = {void \(gnu_obj_1 \* const\)} 0x[0-9a-f]+ <gnu_obj_1::~gnu_obj_1\(\)>} {
> +	    pass $gdb_test_name
> +	}
> +    }
> +	
> +    gdb_test_multiple "ptype test1.~gnu_obj_1" "simple object instance, ptype destructor" {
> +	-re -wrap {type = void \(gnu_obj_1 \* const, int\)} {
> +	    pass $gdb_test_name
> +	}
> +	-re -wrap {type = void \(gnu_obj_1 \* const\)} {
> +	    pass $gdb_test_name
> +	}
> +    }
> +
> +    gdb_test_multiple "print test1.'~gnu_obj_1'" "simple object instance, print quoted destructor" {
> +	-re -wrap { = {void \(gnu_obj_1 \*( const)?, int\)} 0x[0-9a-f]+ <gnu_obj_1::~gnu_obj_1\(\)>} {
> +	    pass $gdb_test_name
> +	}
> +	-re -wrap { = {void \(gnu_obj_1 \*( const)?\)} 0x[0-9a-f]+ <gnu_obj_1::~gnu_obj_1\(\)>} {
> +	    pass $gdb_test_name
> +	}
> +    }
>  
>      gdb_test "ptype gnu_obj_1::'~gnu_obj_1'" \
>  	{type = void \(gnu_obj_1 \* const\)} \
> -- 
> 2.37.3
  
Andrew Burgess Oct. 26, 2022, 2:51 p.m. UTC | #2
Bruno Larsen via Gdb-patches <gdb-patches@sourceware.org> writes:

> when running gdb.cp/m-static.exp using clang, we get the following

s/clang/Clang/.

Thanks,
Andrew

> failures:
>
>     print test1.~gnu_obj_1^M
>     $6 = {void (gnu_obj_1 * const)} 0x555555555470 <gnu_obj_1::~gnu_obj_1()>^M
>     (gdb) FAIL: gdb.cp/m-static.exp: simple object instance, print destructor
>     ptype test1.~gnu_obj_1^M
>     type = void (gnu_obj_1 * const)^M
>     (gdb) FAIL: gdb.cp/m-static.exp: simple object instance, ptype destructor
>     print test1.'~gnu_obj_1'^M
>     $7 = {void (gnu_obj_1 * const)} 0x555555555470 <gnu_obj_1::~gnu_obj_1()>^M
>     (gdb) FAIL: gdb.cp/m-static.exp: simple object instance, print quoted destructor
>
> This is because the test is expecting an extra integer parameter on the
> destructor. Looking at the debuginfo, it seems that there is nothing
> actually wrong with this output, so these tests were changed to test
> multiple possible regexps.
> ---
>  gdb/testsuite/gdb.cp/m-static.exp | 36 ++++++++++++++++++++++---------
>  1 file changed, 26 insertions(+), 10 deletions(-)
>
> diff --git a/gdb/testsuite/gdb.cp/m-static.exp b/gdb/testsuite/gdb.cp/m-static.exp
> index 979de23a44f..332e1cbe1f9 100644
> --- a/gdb/testsuite/gdb.cp/m-static.exp
> +++ b/gdb/testsuite/gdb.cp/m-static.exp
> @@ -102,16 +102,32 @@ if { [is_aarch32_target] } {
>  	{type = void \(single_constructor \* const\)} \
>  	"simple object class, ptype constructor"
>  
> -    gdb_test "print test1.~gnu_obj_1" \
> -	{ = {void \(gnu_obj_1 \* const, int\)} 0x[0-9a-f]+ <gnu_obj_1::~gnu_obj_1\(\)>} \
> -	"simple object instance, print destructor"
> -    gdb_test "ptype test1.~gnu_obj_1" \
> -	{type = void \(gnu_obj_1 \* const, int\)} \
> -	"simple object instance, ptype destructor"
> -
> -    gdb_test "print test1.'~gnu_obj_1'" \
> -	{ = {void \(gnu_obj_1 \*( const)?, int\)} 0x[0-9a-f]+ <gnu_obj_1::~gnu_obj_1\(\)>} \
> -	"simple object instance, print quoted destructor"
> +    gdb_test_multiple "print test1.~gnu_obj_1" "simple object instance, print destructor" {
> +	-re -wrap { = {void \(gnu_obj_1 \* const, int\)} 0x[0-9a-f]+ <gnu_obj_1::~gnu_obj_1\(\)>} {
> +	    pass $gdb_test_name
> +	}
> +	-re -wrap { = {void \(gnu_obj_1 \* const\)} 0x[0-9a-f]+ <gnu_obj_1::~gnu_obj_1\(\)>} {
> +	    pass $gdb_test_name
> +	}
> +    }
> +	
> +    gdb_test_multiple "ptype test1.~gnu_obj_1" "simple object instance, ptype destructor" {
> +	-re -wrap {type = void \(gnu_obj_1 \* const, int\)} {
> +	    pass $gdb_test_name
> +	}
> +	-re -wrap {type = void \(gnu_obj_1 \* const\)} {
> +	    pass $gdb_test_name
> +	}
> +    }
> +
> +    gdb_test_multiple "print test1.'~gnu_obj_1'" "simple object instance, print quoted destructor" {
> +	-re -wrap { = {void \(gnu_obj_1 \*( const)?, int\)} 0x[0-9a-f]+ <gnu_obj_1::~gnu_obj_1\(\)>} {
> +	    pass $gdb_test_name
> +	}
> +	-re -wrap { = {void \(gnu_obj_1 \*( const)?\)} 0x[0-9a-f]+ <gnu_obj_1::~gnu_obj_1\(\)>} {
> +	    pass $gdb_test_name
> +	}
> +    }
>  
>      gdb_test "ptype gnu_obj_1::'~gnu_obj_1'" \
>  	{type = void \(gnu_obj_1 \* const\)} \
> -- 
> 2.37.3
  

Patch

diff --git a/gdb/testsuite/gdb.cp/m-static.exp b/gdb/testsuite/gdb.cp/m-static.exp
index 979de23a44f..332e1cbe1f9 100644
--- a/gdb/testsuite/gdb.cp/m-static.exp
+++ b/gdb/testsuite/gdb.cp/m-static.exp
@@ -102,16 +102,32 @@  if { [is_aarch32_target] } {
 	{type = void \(single_constructor \* const\)} \
 	"simple object class, ptype constructor"
 
-    gdb_test "print test1.~gnu_obj_1" \
-	{ = {void \(gnu_obj_1 \* const, int\)} 0x[0-9a-f]+ <gnu_obj_1::~gnu_obj_1\(\)>} \
-	"simple object instance, print destructor"
-    gdb_test "ptype test1.~gnu_obj_1" \
-	{type = void \(gnu_obj_1 \* const, int\)} \
-	"simple object instance, ptype destructor"
-
-    gdb_test "print test1.'~gnu_obj_1'" \
-	{ = {void \(gnu_obj_1 \*( const)?, int\)} 0x[0-9a-f]+ <gnu_obj_1::~gnu_obj_1\(\)>} \
-	"simple object instance, print quoted destructor"
+    gdb_test_multiple "print test1.~gnu_obj_1" "simple object instance, print destructor" {
+	-re -wrap { = {void \(gnu_obj_1 \* const, int\)} 0x[0-9a-f]+ <gnu_obj_1::~gnu_obj_1\(\)>} {
+	    pass $gdb_test_name
+	}
+	-re -wrap { = {void \(gnu_obj_1 \* const\)} 0x[0-9a-f]+ <gnu_obj_1::~gnu_obj_1\(\)>} {
+	    pass $gdb_test_name
+	}
+    }
+	
+    gdb_test_multiple "ptype test1.~gnu_obj_1" "simple object instance, ptype destructor" {
+	-re -wrap {type = void \(gnu_obj_1 \* const, int\)} {
+	    pass $gdb_test_name
+	}
+	-re -wrap {type = void \(gnu_obj_1 \* const\)} {
+	    pass $gdb_test_name
+	}
+    }
+
+    gdb_test_multiple "print test1.'~gnu_obj_1'" "simple object instance, print quoted destructor" {
+	-re -wrap { = {void \(gnu_obj_1 \*( const)?, int\)} 0x[0-9a-f]+ <gnu_obj_1::~gnu_obj_1\(\)>} {
+	    pass $gdb_test_name
+	}
+	-re -wrap { = {void \(gnu_obj_1 \*( const)?\)} 0x[0-9a-f]+ <gnu_obj_1::~gnu_obj_1\(\)>} {
+	    pass $gdb_test_name
+	}
+    }
 
     gdb_test "ptype gnu_obj_1::'~gnu_obj_1'" \
 	{type = void \(gnu_obj_1 \* const\)} \