From: Tom de Vries Date: Wed, 24 Jul 2024 12:44:33 +0000 (+0200) Subject: [gdb/testsuite] Fix gdb.cp/m-static.exp on arm X-Git-Tag: gdb-16-branchpoint~1330 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d4cea453901b3f1d1e7ea95e8ce0d7860fa9602b;p=thirdparty%2Fbinutils-gdb.git [gdb/testsuite] Fix gdb.cp/m-static.exp on arm 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. Approved-By: Andrew Burgess --- diff --git a/gdb/testsuite/gdb.cp/m-static.exp b/gdb/testsuite/gdb.cp/m-static.exp index 45bc090d01f..5b41898ec9d 100644 --- a/gdb/testsuite/gdb.cp/m-static.exp +++ b/gdb/testsuite/gdb.cp/m-static.exp @@ -71,11 +71,18 @@ if { [is_aarch32_target] } { gdb_test "print test5.single_constructor" \ { = {single_constructor \*\(single_constructor \* const\)} 0x[0-9a-f]+ } \ "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 re \ + [multi_line_string_to_regexp \ + "type = class single_constructor {" \ + "" \ + " public:" \ + " single_constructor(void);" \ + " ~single_constructor(void);" \ + "} *(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.