Files
Tom de Vries 803d0592ab [gdb/testsuite] Fix step-reverse.c with gcc-10
The file gdb.reverse/step-reverse.c is used in test-cases:
- gdb.reverse/step-reverse.exp
- gdb.reverse/next-reverse-bkpt-over-sr.exp
- gdb.reverse/step-precsave.exp

With gcc-7, there are only PASSes (apart from one KFAIL), but with gcc-10, we
have the following FAILs:
...
FAIL: gdb.reverse/step-reverse.exp: reverse stepi from a function call \
  (start statement)
FAIL: gdb.reverse/step-reverse.exp: simple reverse stepi
FAIL: gdb.reverse/step-reverse.exp: reverse step out of called fn
FAIL: gdb.reverse/step-reverse.exp: reverse next over call
FAIL: gdb.reverse/step-reverse.exp: reverse step test 1
FAIL: gdb.reverse/step-reverse.exp: reverse next test 1
FAIL: gdb.reverse/step-reverse.exp: reverse step test 2
FAIL: gdb.reverse/step-reverse.exp: reverse next test 2
FAIL: gdb.reverse/step-precsave.exp: reverse stepi from a function call \
  (start statement)
FAIL: gdb.reverse/step-precsave.exp: simple reverse stepi
FAIL: gdb.reverse/step-precsave.exp: reverse step out of called fn
FAIL: gdb.reverse/step-precsave.exp: reverse next over call
FAIL: gdb.reverse/step-precsave.exp: reverse step test 1
FAIL: gdb.reverse/step-precsave.exp: reverse next test 1
FAIL: gdb.reverse/step-precsave.exp: reverse step test 2
FAIL: gdb.reverse/step-precsave.exp: reverse next test 2
...

Looking at the first step-precsave.exp FAIL, we have:
...
(gdb) stepi^M
26        myglob++; return 0;   /* ARRIVED IN CALLEE */^M
(gdb) PASS: gdb.reverse/step-precsave.exp: reverse stepi thru function return
stepi^M
0x000000000040055f      26        myglob++; return 0;   /* ARRIVED IN CALLEE */^M
(gdb) FAIL: gdb.reverse/step-precsave.exp: reverse stepi from a function call \
  (start statement)
...

There's a difference in line info for callee:
...
    25  int callee() {          /* ENTER CALLEE */
    26    myglob++; return 0;   /* ARRIVED IN CALLEE */
    27  }                       /* RETURN FROM CALLEE */
...
between gcc-7:
...
Line number    Starting address    View    Stmt
         25            0x400557               x
         26            0x40055b               x
         27            0x40056f               x
...
and gcc-10:
...
         25            0x400552               x
         26            0x400556               x
         26            0x400565               x
         27            0x40056a               x
...

The two "recommend breakpoint location" entries at line 26 are for the two
statements ("myglob++" and "return 0"), but the test-case expects to hit line
26 only once.

Fix this by rewriting the two statements into a single statement:
...
-  myglob++; return 0;  /* ARRIVED IN CALLEE */
+  return myglob++;     /* ARRIVED IN CALLEE */
...

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-07-21  Tom de Vries  <tdevries@suse.de>

	* gdb.reverse/step-reverse.c (callee): Merge statements.
2020-07-21 15:27:18 +02:00

79 lines
2.0 KiB
C

/* This testcase is part of GDB, the GNU debugger.
Copyright 2008-2020 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/>. */
#include <stdlib.h>
#include <string.h>
/* Test various kinds of stepping.
*/
int myglob = 0;
int callee() { /* ENTER CALLEE */
return myglob++; /* ARRIVED IN CALLEE */
} /* RETURN FROM CALLEE */
/* A structure which, we hope, will need to be passed using memcpy. */
struct rhomboidal {
int rather_large[100];
};
void
large_struct_by_value (struct rhomboidal r)
{
myglob += r.rather_large[42]; /* step-test.exp: arrive here 1 */
}
int main () {
int w,x,y,z;
int a[10], b[10];
/* Test "next" and "step" */
w = 0; /* BREAK AT MAIN */
x = 1; /* NEXT TEST 1 */
y = 2; /* STEP TEST 1 */
z = 3; /* REVERSE NEXT TEST 1 */
w = w + 2; /* NEXT TEST 2 */
x = x + 3; /* REVERSE STEP TEST 1 */
y = y + 4;
z = z + 5; /* STEP TEST 2 */
/* Test that "next" goes over a call */
callee(); /* NEXT OVER THIS CALL */
/* Test that "step" doesn't */
callee(); /* STEP INTO THIS CALL */
/* Test "stepi" */
a[5] = a[3] - a[4]; /* FINISH TEST */
callee(); /* STEPI TEST */
/* Test "nexti" */
callee(); /* NEXTI TEST */
y = w + z;
{
struct rhomboidal r;
memset (r.rather_large, 0, sizeof (r.rather_large));
r.rather_large[42] = 10;
large_struct_by_value (r); /* step-test.exp: large struct by value */
}
exit (0); /* end of main */
}