diff options
Diffstat (limited to 'gdb/testsuite/gdb.arch')
-rw-r--r-- | gdb/testsuite/gdb.arch/i386-avx512.c | 128 | ||||
-rw-r--r-- | gdb/testsuite/gdb.arch/s390-vregs.exp | 18 | ||||
-rw-r--r-- | gdb/testsuite/gdb.arch/sparc64-adi.c | 145 | ||||
-rw-r--r-- | gdb/testsuite/gdb.arch/sparc64-adi.exp | 53 | ||||
-rw-r--r-- | gdb/testsuite/gdb.arch/thumb2-it.exp | 4 |
5 files changed, 274 insertions, 74 deletions
diff --git a/gdb/testsuite/gdb.arch/i386-avx512.c b/gdb/testsuite/gdb.arch/i386-avx512.c index 52c0ead..3e955a4 100644 --- a/gdb/testsuite/gdb.arch/i386-avx512.c +++ b/gdb/testsuite/gdb.arch/i386-avx512.c @@ -127,44 +127,44 @@ move_k_data_to_memory (void) void move_zmm_data_to_reg (void) { - asm ("vmovaps 0(%0), %%zmm0\n\t" - "vmovaps 64(%0), %%zmm1\n\t" - "vmovaps 128(%0), %%zmm2\n\t" - "vmovaps 192(%0), %%zmm3\n\t" - "vmovaps 256(%0), %%zmm4\n\t" - "vmovaps 320(%0), %%zmm5\n\t" - "vmovaps 384(%0), %%zmm6\n\t" - "vmovaps 448(%0), %%zmm7\n\t" + asm ("vmovups 0(%0), %%zmm0 \n\t" + "vmovups 64(%0), %%zmm1 \n\t" + "vmovups 128(%0), %%zmm2 \n\t" + "vmovups 192(%0), %%zmm3 \n\t" + "vmovups 256(%0), %%zmm4 \n\t" + "vmovups 320(%0), %%zmm5 \n\t" + "vmovups 384(%0), %%zmm6 \n\t" + "vmovups 448(%0), %%zmm7 \n\t" : /* no output operands */ : "r" (zmm_data)); #ifdef __x86_64__ - asm ("vmovaps 512(%0), %%zmm8\n\t" - "vmovaps 576(%0), %%zmm9\n\t" - "vmovaps 640(%0), %%zmm10\n\t" - "vmovaps 704(%0), %%zmm11\n\t" - "vmovaps 768(%0), %%zmm12\n\t" - "vmovaps 832(%0), %%zmm13\n\t" - "vmovaps 896(%0), %%zmm14\n\t" - "vmovaps 960(%0), %%zmm15\n\t" + asm ("vmovups 512(%0), %%zmm8 \n\t" + "vmovups 576(%0), %%zmm9 \n\t" + "vmovups 640(%0), %%zmm10 \n\t" + "vmovups 704(%0), %%zmm11 \n\t" + "vmovups 768(%0), %%zmm12 \n\t" + "vmovups 832(%0), %%zmm13 \n\t" + "vmovups 896(%0), %%zmm14 \n\t" + "vmovups 960(%0), %%zmm15 \n\t" : /* no output operands */ : "r" (zmm_data)); - asm ("vmovaps 1024(%0), %%zmm16\n\t" - "vmovaps 1088(%0), %%zmm17\n\t" - "vmovaps 1152(%0), %%zmm18\n\t" - "vmovaps 1216(%0), %%zmm19\n\t" - "vmovaps 1280(%0), %%zmm20\n\t" - "vmovaps 1344(%0), %%zmm21\n\t" - "vmovaps 1408(%0), %%zmm22\n\t" - "vmovaps 1472(%0), %%zmm23\n\t" - "vmovaps 1536(%0), %%zmm24\n\t" - "vmovaps 1600(%0), %%zmm25\n\t" - "vmovaps 1664(%0), %%zmm26\n\t" - "vmovaps 1728(%0), %%zmm27\n\t" - "vmovaps 1792(%0), %%zmm28\n\t" - "vmovaps 1856(%0), %%zmm29\n\t" - "vmovaps 1920(%0), %%zmm30\n\t" - "vmovaps 1984(%0), %%zmm31\n\t" + asm ("vmovups 1024(%0), %%zmm16 \n\t" + "vmovups 1088(%0), %%zmm17 \n\t" + "vmovups 1152(%0), %%zmm18 \n\t" + "vmovups 1216(%0), %%zmm19 \n\t" + "vmovups 1280(%0), %%zmm20 \n\t" + "vmovups 1344(%0), %%zmm21 \n\t" + "vmovups 1408(%0), %%zmm22 \n\t" + "vmovups 1472(%0), %%zmm23 \n\t" + "vmovups 1536(%0), %%zmm24 \n\t" + "vmovups 1600(%0), %%zmm25 \n\t" + "vmovups 1664(%0), %%zmm26 \n\t" + "vmovups 1728(%0), %%zmm27 \n\t" + "vmovups 1792(%0), %%zmm28 \n\t" + "vmovups 1856(%0), %%zmm29 \n\t" + "vmovups 1920(%0), %%zmm30 \n\t" + "vmovups 1984(%0), %%zmm31 \n\t" : /* no output operands */ : "r" (zmm_data)); #endif @@ -173,44 +173,44 @@ move_zmm_data_to_reg (void) void move_zmm_data_to_memory (void) { - asm ("vmovaps %%zmm0, 0(%0)\n\t" - "vmovaps %%zmm1, 64(%0)\n\t" - "vmovaps %%zmm2, 128(%0)\n\t" - "vmovaps %%zmm3, 192(%0)\n\t" - "vmovaps %%zmm4, 256(%0)\n\t" - "vmovaps %%zmm5, 320(%0)\n\t" - "vmovaps %%zmm6, 384(%0)\n\t" - "vmovaps %%zmm7, 448(%0)\n\t" + asm ("vmovups %%zmm0, 0(%0)\n\t" + "vmovups %%zmm1, 64(%0)\n\t" + "vmovups %%zmm2, 128(%0)\n\t" + "vmovups %%zmm3, 192(%0)\n\t" + "vmovups %%zmm4, 256(%0)\n\t" + "vmovups %%zmm5, 320(%0)\n\t" + "vmovups %%zmm6, 384(%0)\n\t" + "vmovups %%zmm7, 448(%0)\n\t" : /* no output operands */ : "r" (zmm_data)); #ifdef __x86_64__ - asm ("vmovaps %%zmm8, 512(%0)\n\t" - "vmovaps %%zmm9, 576(%0)\n\t" - "vmovaps %%zmm10, 640(%0)\n\t" - "vmovaps %%zmm11, 704(%0)\n\t" - "vmovaps %%zmm12, 768(%0)\n\t" - "vmovaps %%zmm13, 832(%0)\n\t" - "vmovaps %%zmm14, 896(%0)\n\t" - "vmovaps %%zmm15, 960(%0)\n\t" + asm ("vmovups %%zmm8, 512(%0)\n\t" + "vmovups %%zmm9, 576(%0)\n\t" + "vmovups %%zmm10, 640(%0)\n\t" + "vmovups %%zmm11, 704(%0)\n\t" + "vmovups %%zmm12, 768(%0)\n\t" + "vmovups %%zmm13, 832(%0)\n\t" + "vmovups %%zmm14, 896(%0)\n\t" + "vmovups %%zmm15, 960(%0)\n\t" : /* no output operands */ : "r" (zmm_data)); - asm ("vmovaps %%zmm16, 1024(%0)\n\t" - "vmovaps %%zmm17, 1088(%0)\n\t" - "vmovaps %%zmm18, 1152(%0)\n\t" - "vmovaps %%zmm19, 1216(%0)\n\t" - "vmovaps %%zmm20, 1280(%0)\n\t" - "vmovaps %%zmm21, 1344(%0)\n\t" - "vmovaps %%zmm22, 1408(%0)\n\t" - "vmovaps %%zmm23, 1472(%0)\n\t" - "vmovaps %%zmm24, 1536(%0)\n\t" - "vmovaps %%zmm25, 1600(%0)\n\t" - "vmovaps %%zmm26, 1664(%0)\n\t" - "vmovaps %%zmm27, 1728(%0)\n\t" - "vmovaps %%zmm28, 1792(%0)\n\t" - "vmovaps %%zmm29, 1856(%0)\n\t" - "vmovaps %%zmm30, 1920(%0)\n\t" - "vmovaps %%zmm31, 1984(%0)\n\t" + asm ("vmovups %%zmm16, 1024(%0)\n\t" + "vmovups %%zmm17, 1088(%0)\n\t" + "vmovups %%zmm18, 1152(%0)\n\t" + "vmovups %%zmm19, 1216(%0)\n\t" + "vmovups %%zmm20, 1280(%0)\n\t" + "vmovups %%zmm21, 1344(%0)\n\t" + "vmovups %%zmm22, 1408(%0)\n\t" + "vmovups %%zmm23, 1472(%0)\n\t" + "vmovups %%zmm24, 1536(%0)\n\t" + "vmovups %%zmm25, 1600(%0)\n\t" + "vmovups %%zmm26, 1664(%0)\n\t" + "vmovups %%zmm27, 1728(%0)\n\t" + "vmovups %%zmm28, 1792(%0)\n\t" + "vmovups %%zmm29, 1856(%0)\n\t" + "vmovups %%zmm30, 1920(%0)\n\t" + "vmovups %%zmm31, 1984(%0)\n\t" : /* no output operands */ : "r" (zmm_data)); #endif diff --git a/gdb/testsuite/gdb.arch/s390-vregs.exp b/gdb/testsuite/gdb.arch/s390-vregs.exp index 078c153..d2c31e1 100644 --- a/gdb/testsuite/gdb.arch/s390-vregs.exp +++ b/gdb/testsuite/gdb.arch/s390-vregs.exp @@ -147,14 +147,12 @@ gdb_continue_to_breakpoint "change vrs" set vregs [capture_command_output "info registers vector" ""] # Format a 128-bit value, given individual 4-byte values, as hex. -# Leading zeros are suppressed. +# Suppress leading zeros. proc hex128 {a_high a_low b_high b_low} { - set result [format %08x%08x%08x%08x \ - [expr $a_high * ($i + 1) * $a_high ] \ - [expr $a_low * ($i + 1) * $a_low ] \ - [expr $b_high * (32 - $i) * $b_high * 32] \ - [expr $b_low * (32 - $i) * $b_low * 32] ] - return [regsub -- "^0*" $result ""] + set result [format "%x%08x%08x%08x" $a_high $a_low $b_high $b_low] + regsub -- "^0*" $result "" result + if { $result eq "" } { set result 0 } + return $result } set j 1 @@ -162,7 +160,11 @@ foreach {- r i val} [regexp -all -inline -line \ {^(\D*)(\d+)\s+.*?uint128 = 0x([0-9a-f]+?)} $vregs] { if { $r ne "v" } { fail "info registers vector: bad line $j" - } elseif { $val ne [hex128 $a_high $a_low $b_high $b_low] } { + } elseif { $val ne [hex128 \ + [expr $a_high * ($i + 1) * $a_high ] \ + [expr $a_low * ($i + 1) * $a_low ] \ + [expr $b_high * (32 - $i) * $b_high * 32] \ + [expr $b_low * (32 - $i) * $b_low * 32] ] } { fail "compare \$v$i" } incr j 1 diff --git a/gdb/testsuite/gdb.arch/sparc64-adi.c b/gdb/testsuite/gdb.arch/sparc64-adi.c new file mode 100644 index 0000000..704fe26 --- /dev/null +++ b/gdb/testsuite/gdb.arch/sparc64-adi.c @@ -0,0 +1,145 @@ +/* Application Data Integrity (ADI) test in sparc64. + + Copyright 2017 Free Software Foundation, Inc. + + This file is part of GDB. + + 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 <stdio.h> +#include <stdlib.h> +#include <errno.h> +#include <pthread.h> +#include <sys/types.h> +#include <sys/wait.h> +#include <unistd.h> +#include <sys/errno.h> +#include <sys/utsname.h> +#include <sys/param.h> +#include <malloc.h> +#include <string.h> +#include <signal.h> +#include <sys/shm.h> +#include <errno.h> +#include <sys/mman.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <poll.h> +#include <setjmp.h> +#include "adi.h" + +#define ONEKB 1024 +#define PAT 0xdeadbeaf + +#define MAPSIZE 8192 +#define SHMSIZE 102400 +#ifndef PROT_ADI +#define PROT_ADI 0x10 +#endif + +static int +memory_fill (char *addr, size_t size, int pattern) +{ + long *aligned_addr = (long *) addr; + long i; + for (i = 0; i < size / sizeof (long); i += ONEKB) + { + *aligned_addr = pattern; + aligned_addr = aligned_addr + ONEKB; + } + return (0); +} + +int main () +{ + char *haddr; + caddr_t vaddr; + int version; + + /* Test ISM. */ + int shmid = shmget (IPC_PRIVATE, SHMSIZE, IPC_CREAT | 0666); + if (shmid == -1) + exit(1); + char *shmaddr = (char *)shmat (shmid, NULL, 0x666 | SHM_RND); + if (shmaddr == (char *)-1) + { + shmctl (shmid, IPC_RMID, NULL); + exit(1); + } + /* Enable ADI on ISM segment. */ + if (mprotect (shmaddr, SHMSIZE, PROT_READ|PROT_WRITE|PROT_ADI)) + { + perror ("mprotect failed"); + goto err_out; + } + if (memory_fill (shmaddr, SHMSIZE, PAT) != 0) /* line breakpoint here */ + { + exit(1); + } + adi_clr_version (shmaddr, SHMSIZE); + caddr_t vshmaddr = adi_set_version (shmaddr, SHMSIZE, 0x8); + if (vshmaddr == 0) + exit(1); + /* Test mmap. */ + int fd = open ("/dev/zero", O_RDWR); + if (fd < 0) + exit(1); + char *maddr = (char *)mmap (NULL, MAPSIZE, PROT_READ|PROT_WRITE, + MAP_PRIVATE, fd, 0); + if (maddr == (char *)-1) + exit(1); + /* Enable ADI. */ + if (mprotect (shmaddr, MAPSIZE, PROT_READ|PROT_WRITE|PROT_ADI)) + { + perror ("mprotect failed"); + goto err_out; + + } + if (memory_fill (maddr, MAPSIZE, PAT) != 0) + exit(1); + caddr_t vmaddr = adi_set_version (maddr, MAPSIZE, 0x8); + + /* Test heap. */ + haddr = (char*) memalign (MAPSIZE, MAPSIZE); + /* Enable ADI. */ + if (mprotect (shmaddr, MAPSIZE, PROT_READ|PROT_WRITE|PROT_ADI)) + { + perror ("mprotect failed"); + goto err_out; + } + + if (memory_fill (haddr, MAPSIZE, PAT) != 0) + exit(1); + adi_clr_version (haddr, MAPSIZE); + /* Set some ADP version number. */ + caddr_t vaddr1, vaddr2, vaddr3, vaddr4; + vaddr = adi_set_version (haddr, 64*2, 0x8); + vaddr1 = adi_set_version (haddr+64*2, 64*2, 0x9); + vaddr2 = adi_clr_version (haddr+64*4, 64*2); + vaddr3 = adi_set_version (haddr+64*6, 64*2, 0xa); + vaddr4 = adi_set_version (haddr+64*8, 64*10, 0x3); + if (vaddr == 0) + exit(1); + char *versioned_p = vaddr; + *versioned_p = 'a'; + char *uvp = haddr; // unversioned pointer + *uvp = 'b'; // version mismatch trap + + return (0); +err_out: + if (shmdt ((const void *)shmaddr) != 0) + perror ("Detach failure"); + shmctl (shmid, IPC_RMID, NULL); + exit (1); +} diff --git a/gdb/testsuite/gdb.arch/sparc64-adi.exp b/gdb/testsuite/gdb.arch/sparc64-adi.exp new file mode 100644 index 0000000..410bcf9 --- /dev/null +++ b/gdb/testsuite/gdb.arch/sparc64-adi.exp @@ -0,0 +1,53 @@ +# Copyright 2017 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. + +# Basic tests of examining/assigning ADI version tags, and reporting +# precise mismatch. + +if ![istarget "sparc64*-*-linux*"] then { + verbose "Skipping sparc64 ADI test." + return 0 +} + +standard_testfile + +if { [prepare_for_testing "failed to prepare" $testfile $srcfile \ + [list debug libs=-ladi]] } { + return -1 +} + +if ![runto_main] then { + untested "could not run to main" + return -1 +} + +gdb_test "break [gdb_get_line_number "line breakpoint here"]" \ + "Breakpoint .* at .*${srcfile}.*" \ + "set line breakpoint in main" +gdb_continue_to_breakpoint "continue to line breakpoint in main" + +########################################## +set newadi "7" +gdb_test "adi x shmaddr" "${hex}00:\t0" "examine ADI" +gdb_test_no_output "adi a/100 shmaddr=${newadi}" "assign ADI" +gdb_test "adi x/100 shmaddr" "${hex}00:\t${newadi} ${newadi}" \ + "examine new ADI" +gdb_test_no_output "adi a/100 shmaddr=0x0" "reset ADI" +gdb_test "continue" \ + [multi_line "Program received signal SIGSEGV, Segmentation fault.*" \ + "ADI precise mismatch while accessing address $hex.*" ] \ + "continue to sigsegv" diff --git a/gdb/testsuite/gdb.arch/thumb2-it.exp b/gdb/testsuite/gdb.arch/thumb2-it.exp index ab0dae3..e100d06 100644 --- a/gdb/testsuite/gdb.arch/thumb2-it.exp +++ b/gdb/testsuite/gdb.arch/thumb2-it.exp @@ -58,7 +58,7 @@ proc test_it_block { func } { return } - gdb_test "call ${func}()" "Breakpoint.*@ Setup.*" "$func, call" + gdb_test "call (int) ${func}()" "Breakpoint.*@ Setup.*" "$func, call" set expected 0 set reached 0 @@ -155,7 +155,7 @@ for { set i 1 } { $i <= 8 } { incr i } { } gdb_breakpoint "*it_breakpoints" -gdb_test "call it_breakpoints()" "Breakpoint.*" +gdb_test "call (int) it_breakpoints()" "Breakpoint.*" for { set i 1 } { $i <= 7 } { incr i } { test_it_break ${i} } |