binutils-gdb/gdb/testsuite/gdb.opt
Tom de Vries 9e9f0d02b4 [gdb/testsuite] Fix gdb.opt/clobbered-registers-O2.exp with clang
When running test-case gdb.opt/clobbered-registers-O2.exp with clang 12.0.1, I
get:
...
(gdb) run ^M
Starting program: clobbered-registers-O2 ^M
^M
Program received signal SIGSEGV, Segmentation fault.^M
gen_movsd (operand0=<optimized out>, operand1=<optimized out>) at \
  clobbered-registers-O2.c:31^M
31              return *start_sequence(operand0, operand1);^M
(gdb) FAIL: gdb.opt/clobbered-registers-O2.exp: runto: run to start_sequence
...

The problem is that the breakpoint in start_sequence doesn't trigger, because:
- the call to start_sequence in gen_movsd is optimized away, despite the
  __attribute__((noinline)), so the actual function start_sequence doesn't get
  called, and
- the debug info doesn't contain inlined function info, so there's only one
  breakpoint location.

Adding noclone and noipa alongside the noinline attribute doesn't fix this.

Adding the clang-specific attribute optnone in start_sequence does, but since
it inhibits all optimization, that's not a preferred solution in a gdb.opt
test-case, and it would work only for clang and not other compilers that
possibly have the same issue.

Fix this by moving functions start_sequence and gen_movsd into their own
files, as a way of trying harder to enforce noinline/noipa/noclone.

Tested on x86_64-linux.
2022-05-24 22:41:45 +02:00
..
break-on-_exit.c
break-on-_exit.exp
clobbered-registers-O2-2.c [gdb/testsuite] Fix gdb.opt/clobbered-registers-O2.exp with clang 2022-05-24 22:41:45 +02:00
clobbered-registers-O2-3.c [gdb/testsuite] Fix gdb.opt/clobbered-registers-O2.exp with clang 2022-05-24 22:41:45 +02:00
clobbered-registers-O2.c [gdb/testsuite] Fix gdb.opt/clobbered-registers-O2.exp with clang 2022-05-24 22:41:45 +02:00
clobbered-registers-O2.exp [gdb/testsuite] Fix gdb.opt/clobbered-registers-O2.exp with clang 2022-05-24 22:41:45 +02:00
fortran-string.exp
fortran-string.f90
inline-break.c
inline-break.exp
inline-bt.c
inline-bt.exp
inline-cmds.c
inline-cmds.exp
inline-locals.c
inline-locals.exp
inline-markers.c
inline-small-func.c
inline-small-func.exp
inline-small-func.h
solib-intra-step-lib.c
solib-intra-step-main.c
solib-intra-step.exp