Files
binutils-gdb/gdb/testsuite/gdb.cp/step-and-next-inline.cc
Tom de Vries 5f3356899d [gdb/testsuite] Fix gdb.cp/step-and-next-inline.exp with gcc-11
When running test-case gdb.cp/step-and-next-inline.exp with gcc-11, I run
into:
...
KPASS: gdb.cp/step-and-next-inline.exp: no_header: next step 1 \
  (PRMS symtab/25507)
FAIL: gdb.cp/step-and-next-inline.exp: no_header: next step 2
KPASS: gdb.cp/step-and-next-inline.exp: no_header: next step 3 \
  (PRMS symtab/25507)
...

[ Note that I get the same result with gcc-11 and target board
unix/gdb:debug_flags=-gdwarf-4, so this is not a dwarf 4 vs 5 issue. ]

With gcc-10, I have this trace:
...
64        get_alias_set (&xx);
get_alias_set (t=0x601038 <xx>) at step-and-next-inline.cc:51
51        if (t != NULL
40        if (t->x != i)
52            && TREE_TYPE (t).z != 1
43        return x;
53            && TREE_TYPE (t).z != 2
43        return x;
54            && TREE_TYPE (t).z != 3)
43        return x;
main () at step-and-next-inline.cc:65
65        return 0;
...
and with gcc-11, I have instead:
...
64        get_alias_set (&xx);
get_alias_set (t=0x601038 <xx>) at step-and-next-inline.cc:51
51        if (t != NULL
52            && TREE_TYPE (t).z != 1
43        return x;
53            && TREE_TYPE (t).z != 2
43        return x;
54            && TREE_TYPE (t).z != 3)
43        return x;
main () at step-and-next-inline.cc:65
65        return 0;
...
and with clang-10, I have instead:
...
64        get_alias_set (&xx);
get_alias_set (t=0x601034 <xx>) at step-and-next-inline.cc:51
51        if (t != NULL
52            && TREE_TYPE (t).z != 1
53            && TREE_TYPE (t).z != 2
54            && TREE_TYPE (t).z != 3)
51        if (t != NULL
57      }
main () at step-and-next-inline.cc:65
65        return 0;
...

The test-case tries to verify that we don't step into inlined function
tree_check (lines 40-43) (so, with the clang trace we get that right).

The test-case then tries to kfail the problems when using gcc, but this is
done in such a way that the testing still gets out of sync after a failure.
That is: the "next step 2" check that is supposed to match
"TREE_TYPE (t).z != 2" is actually matching "TREE_TYPE (t).z != 1":
...
(gdb) next^M
52            && TREE_TYPE (t).z != 1^M
(gdb) PASS: gdb.cp/step-and-next-inline.exp: no_header: next step 2
...

Fix this by issuing extra nexts to arrive at the required lines.

Tested on x86_64-linux, with gcc-8, gcc-9, gcc-10, gcc-11, clang-8, clang-10
and clang-12.

gdb/testsuite/ChangeLog:

2021-07-20  Tom de Vries  <tdevries@suse.de>

	* gdb.cp/step-and-next-inline.cc (tree_check, get_alias_set, main):
	Tag closing brace with comment.
	* gdb.cp/step-and-next-inline.h: Update to keep identical with
	step-and-next-inline.cc.
	* gdb.cp/step-and-next-inline.exp: Issue extra next when required.
2021-07-21 21:08:07 +02:00

67 lines
1.5 KiB
C++

/* This testcase is part of GDB, the GNU debugger.
Copyright 2019-2021 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifdef USE_NEXT_INLINE_H
#include "step-and-next-inline.h"
#else /* USE_NEXT_INLINE_H */
/* The code below must remain identical to the code in
step-and-next-inline.h. */
#include <stdlib.h>
struct tree
{
volatile int x;
volatile int z;
};
#define TREE_TYPE(NODE) (*tree_check (NODE, 0))
inline tree *
tree_check (tree *t, int i)
{
if (t->x != i)
abort();
tree *x = t;
return x;
} // tree-check
#endif /* USE_NEXT_INLINE_H */
int __attribute__((noinline, noclone))
get_alias_set (tree *t)
{
if (t != NULL
&& TREE_TYPE (t).z != 1
&& TREE_TYPE (t).z != 2
&& TREE_TYPE (t).z != 3)
return 0;
return 1;
} // get_alias_set
tree xx;
int
main()
{
get_alias_set (&xx);
return 0;
} // main