[gdb/testsuite] Fix gdb.cp/m-static.exp on arm
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gdb_build--master-arm |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-arm |
success
|
Test passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 |
success
|
Test passed
|
Commit Message
With test-case gdb.cp/m-static.exp on arm-linux, I get:
...
(gdb) ptype test5.single_constructor^M
type = class single_constructor {^M
^M
public:^M
single_constructor(void);^M
~single_constructor(void);^M
} *(single_constructor * const)^M
(gdb) FAIL: gdb.cp/m-static.exp: simple object instance, ptype constructor
...
The test-case expects:
- no empty line before "public:", and
- no "~single_constructor(void)", but "~single_constructor()"
The latter is due to commit 137c886e9a6 ("[gdb/c++] Print destructor the same
for gcc and clang").
The failing test is in a part only enabled for is_aarch32_target == 1, so it
looks like it was left behind.
I'm assuming the same happened for the other difference.
Fix this by updating the regexps to match the observed output.
Tested on arm-linux.
---
gdb/testsuite/gdb.cp/m-static.exp | 17 +++++++++++++----
gdb/testsuite/lib/gdb-utils.exp | 8 ++++++++
2 files changed, 21 insertions(+), 4 deletions(-)
base-commit: ad88661d55f3e62d90c44c8c286223db9aa76a77
Comments
Tom de Vries <tdevries@suse.de> writes:
> With test-case gdb.cp/m-static.exp on arm-linux, I get:
> ...
> (gdb) ptype test5.single_constructor^M
> type = class single_constructor {^M
> ^M
> public:^M
> single_constructor(void);^M
> ~single_constructor(void);^M
> } *(single_constructor * const)^M
> (gdb) FAIL: gdb.cp/m-static.exp: simple object instance, ptype constructor
> ...
>
> The test-case expects:
> - no empty line before "public:", and
> - no "~single_constructor(void)", but "~single_constructor()"
>
> The latter is due to commit 137c886e9a6 ("[gdb/c++] Print destructor the same
> for gcc and clang").
>
> The failing test is in a part only enabled for is_aarch32_target == 1, so it
> looks like it was left behind.
>
> I'm assuming the same happened for the other difference.
>
> Fix this by updating the regexps to match the observed output.
>
> Tested on arm-linux.
> ---
> gdb/testsuite/gdb.cp/m-static.exp | 17 +++++++++++++----
> gdb/testsuite/lib/gdb-utils.exp | 8 ++++++++
> 2 files changed, 21 insertions(+), 4 deletions(-)
>
> diff --git a/gdb/testsuite/gdb.cp/m-static.exp b/gdb/testsuite/gdb.cp/m-static.exp
> index 45bc090d01f..68b215a1d01 100644
> --- a/gdb/testsuite/gdb.cp/m-static.exp
> +++ b/gdb/testsuite/gdb.cp/m-static.exp
> @@ -71,11 +71,20 @@ if { [is_aarch32_target] } {
> gdb_test "print test5.single_constructor" \
> { = {single_constructor \*\(single_constructor \* const\)} 0x[0-9a-f]+ <single_constructor::single_constructor\(\)>} \
> "simple object instance, print constructor"
> - gdb_test "ptype test5.single_constructor" \
> - {type = class single_constructor {\r\n public:\r\n single_constructor\(void\);\r\n ~single_constructor\(\);\r\n} \*\(single_constructor \* const\)} \
> +
> + set open_scope "\{"
> + set close_scope "\}"
I'm confused by this. I didn't know that '{' needed escaping withing
TCL strings? I'm assuming this actually just becomes "{" and "}", in
which case, couldn't we just inline the braces into the lines below? I
think this would be clearer.
With that change:
Approved-By: Andrew Burgess <aburgess@redhat.com>
Thanks,
Andrew
> + set re \
> + [multi_line_string_to_regexp \
> + "type = class single_constructor $open_scope" \
> + "" \
> + " public:" \
> + " single_constructor(void);" \
> + " ~single_constructor(void);" \
> + "$close_scope *(single_constructor * const)"]
> + gdb_test "ptype test5.single_constructor" $re \
> "simple object instance, ptype constructor"
> - gdb_test "ptype single_constructor::single_constructor" \
> - {type = class single_constructor {\r\n public:\r\n single_constructor\(void\);\r\n ~single_constructor\(\);\r\n} \*\(single_constructor \* const\)} \
> + gdb_test "ptype single_constructor::single_constructor" $re \
> "simple object class, ptype constructor"
>
> gdb_test "print test1.~gnu_obj_1" \
> diff --git a/gdb/testsuite/lib/gdb-utils.exp b/gdb/testsuite/lib/gdb-utils.exp
> index 95c53d030d8..41989da3ed2 100644
> --- a/gdb/testsuite/lib/gdb-utils.exp
> +++ b/gdb/testsuite/lib/gdb-utils.exp
> @@ -38,6 +38,14 @@ proc string_to_regexp {str} {
> return $result
> }
>
> +# Convenience function that calls string_to_regexp for each arg, and
> +# joins the results using "\r\n".
> +
> +proc multi_line_string_to_regexp { args } {
> + set res [lmap arg $args {string_to_regexp $arg}]
> + return [multi_line {*}$res]
> +}
> +
> # Given a list of strings, adds backslashes as needed to each string to
> # create a regexp that will match the string, and join the result.
>
>
> base-commit: ad88661d55f3e62d90c44c8c286223db9aa76a77
> --
> 2.35.3
On 7/23/24 12:44, Andrew Burgess wrote:
> Tom de Vries <tdevries@suse.de> writes:
>
>> With test-case gdb.cp/m-static.exp on arm-linux, I get:
>> ...
>> (gdb) ptype test5.single_constructor^M
>> type = class single_constructor {^M
>> ^M
>> public:^M
>> single_constructor(void);^M
>> ~single_constructor(void);^M
>> } *(single_constructor * const)^M
>> (gdb) FAIL: gdb.cp/m-static.exp: simple object instance, ptype constructor
>> ...
>>
>> The test-case expects:
>> - no empty line before "public:", and
>> - no "~single_constructor(void)", but "~single_constructor()"
>>
>> The latter is due to commit 137c886e9a6 ("[gdb/c++] Print destructor the same
>> for gcc and clang").
>>
>> The failing test is in a part only enabled for is_aarch32_target == 1, so it
>> looks like it was left behind.
>>
>> I'm assuming the same happened for the other difference.
>>
>> Fix this by updating the regexps to match the observed output.
>>
>> Tested on arm-linux.
>> ---
>> gdb/testsuite/gdb.cp/m-static.exp | 17 +++++++++++++----
>> gdb/testsuite/lib/gdb-utils.exp | 8 ++++++++
>> 2 files changed, 21 insertions(+), 4 deletions(-)
>>
>> diff --git a/gdb/testsuite/gdb.cp/m-static.exp b/gdb/testsuite/gdb.cp/m-static.exp
>> index 45bc090d01f..68b215a1d01 100644
>> --- a/gdb/testsuite/gdb.cp/m-static.exp
>> +++ b/gdb/testsuite/gdb.cp/m-static.exp
>> @@ -71,11 +71,20 @@ if { [is_aarch32_target] } {
>> gdb_test "print test5.single_constructor" \
>> { = {single_constructor \*\(single_constructor \* const\)} 0x[0-9a-f]+ <single_constructor::single_constructor\(\)>} \
>> "simple object instance, print constructor"
>> - gdb_test "ptype test5.single_constructor" \
>> - {type = class single_constructor {\r\n public:\r\n single_constructor\(void\);\r\n ~single_constructor\(\);\r\n} \*\(single_constructor \* const\)} \
>> +
>> + set open_scope "\{"
>> + set close_scope "\}"
>
Hi Andrew,
thanks for the review.
> I'm confused by this. I didn't know that '{' needed escaping withing
> TCL strings? I'm assuming this actually just becomes "{" and "}", in
> which case, couldn't we just inline the braces into the lines below? I
> think this would be clearer.
>
It's not tcl as such that needs it, but my editor (emacs) on the system
I wrote the patch on.
I ran into this before, see for instance:
...
commit 6d5d644e3cece1b2bbfe50c9b7e5866d656f81fb
Author: Tom de Vries <tdevries@suse.de>
Date: Mon Apr 24 22:08:53 2023 +0200
[gdb/testsuite] Fix auto-indent in gdb.gdb/python-helper.exp
When editing gdb.gdb/python-helper.exp, auto-indent is broken in my
editor (emacs).
The problem is that this:
...
if { 1 } {
foo "{" "}"<ENTER>bar
}
...
produces this:
...
if { 1 } {
foo "{" "}"
bar
}
...
Note that this doesn't happen for "{}".
Fix this by using "\{" and "\}".
...
> With that change:
>
> Approved-By: Andrew Burgess <aburgess@redhat.com>
>
Pushed with that change.
Thanks,
- Tom
> Thanks,
> Andrew
>
>> + set re \
>> + [multi_line_string_to_regexp \
>> + "type = class single_constructor $open_scope" \
>> + "" \
>> + " public:" \
>> + " single_constructor(void);" \
>> + " ~single_constructor(void);" \
>> + "$close_scope *(single_constructor * const)"]
>> + gdb_test "ptype test5.single_constructor" $re \
>> "simple object instance, ptype constructor"
>> - gdb_test "ptype single_constructor::single_constructor" \
>> - {type = class single_constructor {\r\n public:\r\n single_constructor\(void\);\r\n ~single_constructor\(\);\r\n} \*\(single_constructor \* const\)} \
>> + gdb_test "ptype single_constructor::single_constructor" $re \
>> "simple object class, ptype constructor"
>>
>> gdb_test "print test1.~gnu_obj_1" \
>> diff --git a/gdb/testsuite/lib/gdb-utils.exp b/gdb/testsuite/lib/gdb-utils.exp
>> index 95c53d030d8..41989da3ed2 100644
>> --- a/gdb/testsuite/lib/gdb-utils.exp
>> +++ b/gdb/testsuite/lib/gdb-utils.exp
>> @@ -38,6 +38,14 @@ proc string_to_regexp {str} {
>> return $result
>> }
>>
>> +# Convenience function that calls string_to_regexp for each arg, and
>> +# joins the results using "\r\n".
>> +
>> +proc multi_line_string_to_regexp { args } {
>> + set res [lmap arg $args {string_to_regexp $arg}]
>> + return [multi_line {*}$res]
>> +}
>> +
>> # Given a list of strings, adds backslashes as needed to each string to
>> # create a regexp that will match the string, and join the result.
>>
>>
>> base-commit: ad88661d55f3e62d90c44c8c286223db9aa76a77
>> --
>> 2.35.3
>
@@ -71,11 +71,20 @@ if { [is_aarch32_target] } {
gdb_test "print test5.single_constructor" \
{ = {single_constructor \*\(single_constructor \* const\)} 0x[0-9a-f]+ <single_constructor::single_constructor\(\)>} \
"simple object instance, print constructor"
- gdb_test "ptype test5.single_constructor" \
- {type = class single_constructor {\r\n public:\r\n single_constructor\(void\);\r\n ~single_constructor\(\);\r\n} \*\(single_constructor \* const\)} \
+
+ set open_scope "\{"
+ set close_scope "\}"
+ set re \
+ [multi_line_string_to_regexp \
+ "type = class single_constructor $open_scope" \
+ "" \
+ " public:" \
+ " single_constructor(void);" \
+ " ~single_constructor(void);" \
+ "$close_scope *(single_constructor * const)"]
+ gdb_test "ptype test5.single_constructor" $re \
"simple object instance, ptype constructor"
- gdb_test "ptype single_constructor::single_constructor" \
- {type = class single_constructor {\r\n public:\r\n single_constructor\(void\);\r\n ~single_constructor\(\);\r\n} \*\(single_constructor \* const\)} \
+ gdb_test "ptype single_constructor::single_constructor" $re \
"simple object class, ptype constructor"
gdb_test "print test1.~gnu_obj_1" \
@@ -38,6 +38,14 @@ proc string_to_regexp {str} {
return $result
}
+# Convenience function that calls string_to_regexp for each arg, and
+# joins the results using "\r\n".
+
+proc multi_line_string_to_regexp { args } {
+ set res [lmap arg $args {string_to_regexp $arg}]
+ return [multi_line {*}$res]
+}
+
# Given a list of strings, adds backslashes as needed to each string to
# create a regexp that will match the string, and join the result.