binutils-gdb/gdb/testsuite/gdb.arch/amd64-disp-step-avx.S
Andrew Burgess 376be529a7 gdb: Fix testsuite issue in gdb.arch/amd64-disp-step-avx.exp
This test starts up and confirms that $xmm0 has the value 0, it then
modifies $xmm0 (in the inferior) and confirms that the new value can
be read (in GDB).

On some machines I was noticing that this test would occasionally
fail, and on investigation I believe that the reason for this is that
the test is linked as a dynamically linked executable and makes use of
the system libraries during startup.  The reason that this causes
problems is that both the runtime linker and the startup code run
before main can, and do (on at least some platforms) make use of the
XMM registers.

In this commit I modify the test program slightly to allow it to be
linked statically, without using the startup libraries.  Now by the
time GDB reaches the symbol main we have only executed one 'nop'
instruction, and the XMM registers should all have the value 0.  I've
extended the test script to confirm that $xmm0 to $xmm15 are all
initially 0, and I also check that at the point after $xmm0 has been
modified, all the other XMM registers ($xmm1 to $xmm15) are still 0.

The test program is still linked against libc in order that we can
call the exit function, however, we now call _exit rather than exit in
order to avoid all of the usual cleanup that exit does.  This clean up
tries to tear down things that are usually setup during the startup
code, but now this isn't called calling exit will just result in a
crash.

gdb/testsuite/ChangeLog:

	* gdb.arch/amd64-disp-step-avx.S: Add '_start' label.
	(done): Call '_exit' not 'exit' to avoid atexit handlers.
	* gdb.arch/amd64-disp-step-avx.exp: Pass -static, and
	-nostartfiles when compiling the test.  Confirm that all registers
	xmm0 to xmm15 are initially 0, and that xmm1 to xmm15 are 0 after.
2018-03-23 11:55:02 +00:00

73 lines
1.6 KiB
ArmAsm

/* Copyright 2009-2018 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/>.
This file is part of the gdb testsuite.
Test displaced stepping over VEX-encoded RIP-relative AVX
instructions. */
.text
.global _start,main
_start:
nop
main:
nop
/***********************************************/
/* Test a VEX2-encoded RIP-relative instruction. */
.global test_rip_vex2
test_rip_vex2:
vmovsd ro_var(%rip),%xmm0
.global test_rip_vex2
test_rip_vex2_end:
nop
/* Test a VEX3-encoded RIP-relative instruction. */
.global test_rip_vex3
test_rip_vex3:
vextractf128 $0x0,%ymm0,var128(%rip)
.global test_rip_vex3
test_rip_vex3_end:
nop
/* skip over test data */
jmp done
/* RIP-relative ro-data for VEX2 test above. */
ro_var:
.8byte 0x1122334455667788
.8byte 0x8877665544332211
/***********************************************/
/* All done. */
done:
mov $0,%rdi
call _exit
hlt
/* RIP-relative data for VEX3 test above. */
.data
var128:
.8byte 0xaa55aa55aa55aa55
.8byte 0x55aa55aa55aa55aa