diff options
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/gdb.arch/i386-mpx-call.c | 105 | ||||
-rw-r--r-- | gdb/testsuite/gdb.arch/i386-mpx-call.exp | 398 | ||||
-rw-r--r-- | gdb/testsuite/gdb.arch/i386-mpx-map.c | 61 | ||||
-rw-r--r-- | gdb/testsuite/gdb.arch/i386-mpx-map.exp | 56 | ||||
-rw-r--r-- | gdb/testsuite/gdb.arch/i386-mpx-sigsegv.c | 92 | ||||
-rw-r--r-- | gdb/testsuite/gdb.arch/i386-mpx-sigsegv.exp | 64 | ||||
-rw-r--r-- | gdb/testsuite/gdb.arch/i386-mpx-simple_segv.c | 36 | ||||
-rw-r--r-- | gdb/testsuite/gdb.arch/i386-mpx-simple_segv.exp | 124 | ||||
-rw-r--r-- | gdb/testsuite/gdb.arch/i386-mpx.c | 59 | ||||
-rw-r--r-- | gdb/testsuite/gdb.arch/i386-mpx.exp | 123 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-pp-maint.exp | 8 | ||||
-rw-r--r-- | gdb/testsuite/lib/gdb.exp | 89 |
12 files changed, 4 insertions, 1211 deletions
diff --git a/gdb/testsuite/gdb.arch/i386-mpx-call.c b/gdb/testsuite/gdb.arch/i386-mpx-call.c deleted file mode 100644 index 5949202..0000000 --- a/gdb/testsuite/gdb.arch/i386-mpx-call.c +++ /dev/null @@ -1,105 +0,0 @@ -/* Test for inferior function calls MPX context. - - Copyright (C) 2017-2024 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> - -/* Defined size for arrays. */ -#define ARRAY_LENGTH 5 - - -int -upper (int *a, int *b, int *c, int *d, int len) -{ - int value; - - value = *(a + len); - value = *(b + len); - value = *(c + len); - value = *(d + len); - - value = value - *a + 1; - return value; -} - - -int -lower (int *a, int *b, int *c, int *d, int len) -{ - int value; - - value = *(a - len); - value = *(b - len); - value = *(c - len); - value = *(d - len); - - value = value - *a + 1; - return value; -} - - -char -char_upper (char *str, int length) -{ - char ch; - ch = *(str + length); - - return ch; -} - - -char -char_lower (char *str, int length) -{ - char ch; - ch = *(str - length); - - return ch; -} - - -int -main (void) -{ - int sa[ARRAY_LENGTH]; - int sb[ARRAY_LENGTH]; - int sc[ARRAY_LENGTH]; - int sd[ARRAY_LENGTH]; - int *x, *a, *b, *c, *d; - char mchar; - char hello[] = "Hello"; - - x = malloc (sizeof (int) * ARRAY_LENGTH); - a = malloc (sizeof (int) * ARRAY_LENGTH); - b = malloc (sizeof (int) * ARRAY_LENGTH); - c = malloc (sizeof (int) * ARRAY_LENGTH); - d = malloc (sizeof (int) * ARRAY_LENGTH); - - *x = upper (sa, sb, sc, sd, 0); /* bkpt 1. */ - *x = lower (a, b, c, d, 0); - - mchar = char_upper (hello, 10); - mchar = char_lower (hello, 10); - - free (x); - free (a); - free (b); - free (c); - free (d); - - return 0; -} diff --git a/gdb/testsuite/gdb.arch/i386-mpx-call.exp b/gdb/testsuite/gdb.arch/i386-mpx-call.exp deleted file mode 100644 index e225484..0000000 --- a/gdb/testsuite/gdb.arch/i386-mpx-call.exp +++ /dev/null @@ -1,398 +0,0 @@ -# Copyright (C) 2017-2024 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/>. - - -require {is_any_target "i?86-*-*" "x86_64-*-*"} - -standard_testfile - -require supports_mpx_check_pointer_bounds have_mpx - -set comp_flags "-mmpx -fcheck-pointer-bounds -I${srcdir}/../nat" - -if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \ - [list debug additional_flags=${comp_flags}]] } { - return -1 -} - -if ![runto_main] { - return -1 -} - -set bounds_table 0 -gdb_test_multiple "disassemble upper" "" { - -re -wrap "bndldx.*" { - set bounds_table 1 - } - -re -wrap "" { - } -} - -# Convenience for returning from an inferior call that causes a BND violation. -# -gdb_test_no_output "set confirm off" - -# Convenience variable. -# -set bound_reg " = \\\{lbound = $hex, ubound = $hex\\\}.*" -set int_braw_reg " = \\\{lbound = 0x0, ubound_raw = 0x0\\\}.*" -set bndcfg_reg " = \\\{raw = $hex, config = \\\{base = $hex, reserved = $hex,\ - preserved = $hex, enabled = $hex\\\}\\\}" -set bndstatus_reg " = \\\{raw = $hex, status = \\\{bde = $hex,\ - error = $hex\\\}\\\}" -set u_fault [multi_line "Program received signal SIGSEGV, Segmentation fault" \ - "Upper bound violation while accessing address $hex" \ - "Bounds: \\\[lower = $hex, upper = $hex\\\]"] - - -# Simplify the tests below. -# -proc sanity_check_bndregs {arglist} { - - global int_braw_reg - - foreach a $arglist { - gdb_test "p /x $a" "$int_braw_reg"\ - "$a" - } -} - -# Set bnd register to have no access to memory. -# -proc remove_memory_access {reg} { - global hex - - sanity_check_bndregs {"\$bnd0raw" "\$bnd1raw" "\$bnd2raw" "\$bnd3raw"} - - gdb_test "p /x $reg.lbound = $reg.ubound" "= $hex"\ - "$reg lower bound set" - gdb_test "p /x $reg.ubound = 0" " = 0x0"\ - "$reg upper bound set" -} - - -# Prepare convenience variables for bndconfig and status -# for posterior comparison. -# -proc prepare_bndcfg_bndstatus {} { - - global bndcfg_reg - global bndstatus_reg - - gdb_test "p /x \$temp_bndcfgu = \$bndcfgu" "$bndcfg_reg"\ - "bndcfgu should not change" - - gdb_test "p /x \$temp_bndstatus = \$bndstatus" "$bndstatus_reg"\ - "bndstatus should not change" -} - -# Compare values set for convenience variables and actual values of bndconfig -# and bndstatus registers. -# -proc compare_bndstatus_with_convenience {} { - - gdb_test "p \$temp_bndcfgu == \$bndcfgu" "= 1"\ - "bndcfgu compare before and after" - gdb_test "p \$temp_bndstatus == \$bndstatus" "= 1"\ - "bndstatus compare before and after" -} - -# Perform an inferior call defined in func. -# -proc perform_a_call {func} { - - global inf_call_stopped - global gdb_prompt - - gdb_test "p /x $func" [multi_line "The program being debugged\ - stopped while in a function called from GDB." \ - "Evaluation of the expression containing the\ - function.*" \ - ] "inferior call stopped" -} - -# Perform an inferior call defined in func. -# -proc check_bound_violation {parm parm_type is_positive} { - - global u_fault bounds_table - - set have_bnd_violation 0 - gdb_test_multiple "continue" "continue to a bnd violation" { - -re -wrap "Continuing\." { - if { $bounds_table } { - pass $gdb_test_name - } else { - fail $gdb_test_name - } - } - -re -wrap "$u_fault.*" { - pass $gdb_test_name - set have_bnd_violation 1 - } - } - if { ! $have_bnd_violation } { - return - } - - set message "access only one position" - if {$is_positive == 1} { - gdb_test "p (((void *)\$_siginfo._sifields._sigfault.si_addr\ - - (void*)$parm))/sizeof($parm_type) == 1"\ - " = 1" $message - } else { - gdb_test "p ((void*)$parm\ - - (void *)\$_siginfo._sifields._sigfault.si_addr)\ - /sizeof($parm_type) == 1"\ - " = 1" $message - } - gdb_test "return" "\\\#.*main.*i386-mpx-call\\\.c:.*" "return from the fault" -} - - -# Start testing! -# - -# Set up for stopping in the middle of main for calling a function in the -# inferior. -# -set break "bkpt 1." -gdb_breakpoint [gdb_get_line_number "${break}"] -gdb_continue_to_breakpoint "${break}" ".*${break}.*" - - -# Consistency: -# default run execution of call should succeed without violations. -# -with_test_prefix "default_run" { - - gdb_test "p \$keep_bnd0_value=\$bnd0" $bound_reg\ - "store bnd0 register in a convenience variable" - - gdb_test "p /x upper (a, b, c, d, 0)" " = $hex"\ - "default inferior call" - - gdb_test "p ((\$bnd0.lbound==\$keep_bnd0_value.lbound) &&\ - (\$bnd0.ubound==\$keep_bnd0_value.ubound))" "= 1" \ - "bnd register value after and before call" -} - -# Consistency: Examine bnd registers values before and after the call. -# -# -with_test_prefix "verify_default_values" { - - prepare_bndcfg_bndstatus - - gdb_breakpoint "*upper" - perform_a_call "upper (a, b, c, d, 1)" - - sanity_check_bndregs {"\$bnd0raw" "\$bnd1raw" "\$bnd2raw" "\$bnd3raw"} - - compare_bndstatus_with_convenience - - gdb_test_multiple "continue" "inferior call test" { - -re ".*Continuing.\r\n$gdb_prompt " { - pass "inferior call performed" - } - } -} - -# Examine: Cause an upper bound violation changing BND0. -# -# -with_test_prefix "upper_bnd0" { - - prepare_bndcfg_bndstatus - - gdb_breakpoint "*upper" - perform_a_call "upper (a, b, c, d, 1)" - - remove_memory_access "\$bnd0" - - compare_bndstatus_with_convenience - - check_bound_violation "a" "int" 1 -} - -# Examine: Cause an upper bound violation changing BND1. -# -# -with_test_prefix "upper_bnd1" { - - prepare_bndcfg_bndstatus - - gdb_breakpoint "*upper" - perform_a_call "upper (a, b, c, d, 1)" - - remove_memory_access "\$bnd1" - - compare_bndstatus_with_convenience - - check_bound_violation "b" "int" 1 -} - -# Examine: Cause an upper bound violation changing BND2. -# -# -with_test_prefix "upper_bnd2" { - - prepare_bndcfg_bndstatus - - gdb_breakpoint "*upper" - perform_a_call "upper (a, b, c, d, 1)" - - remove_memory_access "\$bnd2" - - compare_bndstatus_with_convenience - - check_bound_violation "c" "int" 1 -} - -# Examine: Cause an upper bound violation changing BND3. -# -# -with_test_prefix "upper_bnd3" { - prepare_bndcfg_bndstatus - - gdb_breakpoint "*upper" - perform_a_call "upper (a, b, c, d, 1)" - - remove_memory_access "\$bnd3" - - compare_bndstatus_with_convenience - - check_bound_violation "d" "int" 1 -} - -# Examine: Cause a lower bound violation changing BND0. -# -# -with_test_prefix "lower_bnd0" { - - prepare_bndcfg_bndstatus - - gdb_breakpoint "*lower" - perform_a_call "lower (a, b, c, d, 1)" - - remove_memory_access "\$bnd0" - - compare_bndstatus_with_convenience - - check_bound_violation "a" "int" 0 -} - -# Examine: Cause a lower bound violation changing BND1. -# -# -with_test_prefix "lower_bnd1" { - - prepare_bndcfg_bndstatus - - gdb_breakpoint "*lower" - perform_a_call "lower (a, b, c, d, 1)" - - remove_memory_access "\$bnd1" - - compare_bndstatus_with_convenience - - check_bound_violation "b" "int" 0 -} - -# Examine: Cause a lower bound violation changing BND2. -# -# -with_test_prefix "lower_bnd2" { - - prepare_bndcfg_bndstatus - - gdb_breakpoint "*lower" - perform_a_call "lower (a, b, c, d, 1)" - - remove_memory_access "\$bnd2" - - compare_bndstatus_with_convenience - - check_bound_violation "c" "int" 0 -} - -# Examine: Cause a lower bound violation changing BND3. -# -# -with_test_prefix "lower_bnd3" { - - prepare_bndcfg_bndstatus - - gdb_breakpoint "*lower" - perform_a_call "lower (a, b, c, d, 1)" - - remove_memory_access "\$bnd3" - - compare_bndstatus_with_convenience - - check_bound_violation "d" "int" 0 -} - -# Examine: String causing a upper bound violation changing BND0. -# -# -with_test_prefix "chars_up" { - - prepare_bndcfg_bndstatus - - gdb_breakpoint "*char_upper" - perform_a_call "char_upper (hello, 1)" - - remove_memory_access "\$bnd0" - - compare_bndstatus_with_convenience - - check_bound_violation "str" "char" 1 -} - - -# Examine: String causing an lower bound violation changing BND0. -# -# -with_test_prefix "chars_low" { - - prepare_bndcfg_bndstatus - - gdb_breakpoint "*char_lower" - perform_a_call "char_lower (hello, 1)" - - remove_memory_access "\$bnd0" - - compare_bndstatus_with_convenience - - check_bound_violation "str" "char" 0 -} - -# Examine: String causing an lower bound violation changing BND0. -# -# -with_test_prefix "chars_low_adhoc_parm" { - - prepare_bndcfg_bndstatus - - gdb_breakpoint "*char_lower" - perform_a_call "char_lower (\"tryme\", 1)" - - remove_memory_access "\$bnd0" - - compare_bndstatus_with_convenience - - check_bound_violation "str" "char" 0 -} diff --git a/gdb/testsuite/gdb.arch/i386-mpx-map.c b/gdb/testsuite/gdb.arch/i386-mpx-map.c deleted file mode 100644 index c072e74..0000000 --- a/gdb/testsuite/gdb.arch/i386-mpx-map.c +++ /dev/null @@ -1,61 +0,0 @@ -/* Test program for MPX map allocated bounds. - - Copyright 2015-2024 Free Software Foundation, Inc. - - Contributed by Intel Corp. <walfred.tedeschi@intel.com> - <mircea.gherzan@intel.com> - - 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 <stdlib.h> -#define SIZE 5 - -typedef int T; - -void -foo (T *p) -{ - T *x; - -#if defined __GNUC__ && !defined __INTEL_COMPILER - __bnd_store_ptr_bounds (p, &p); -#endif - - x = p + SIZE - 1; - -#if defined __GNUC__ && !defined __INTEL_COMPILER - __bnd_store_ptr_bounds (x, &x); -#endif - /* Dummy assign. */ - x = x + 1; /* after-assign */ - return; -} - -int -main (void) -{ - T *a = NULL; - - a = calloc (SIZE, sizeof (T)); /* after-decl */ -#if defined __GNUC__ && !defined __INTEL_COMPILER - __bnd_store_ptr_bounds (a, &a); -#endif - - foo (a); /* after-alloc */ - free (a); - - return 0; -} diff --git a/gdb/testsuite/gdb.arch/i386-mpx-map.exp b/gdb/testsuite/gdb.arch/i386-mpx-map.exp deleted file mode 100644 index d955187..0000000 --- a/gdb/testsuite/gdb.arch/i386-mpx-map.exp +++ /dev/null @@ -1,56 +0,0 @@ -# Copyright 2015-2024 Free Software Foundation, Inc. -# -# Contributed by Intel Corp. <walfred.tedeschi@intel.com>, -# <mircea.gherzan@intel.com> -# -# 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/>. - -require {is_any_target i?86-*-* x86_64-*-*} - -standard_testfile - -require supports_mpx_check_pointer_bounds have_mpx - -set comp_flags "-mmpx -fcheck-pointer-bounds -I${srcdir}/../nat/" - -if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \ - [list debug nowarnings additional_flags=${comp_flags}]] } { - return -1 -} - -if ![runto_main] { - return -1 -} - -gdb_breakpoint [ gdb_get_line_number "after-decl" ] -gdb_breakpoint [ gdb_get_line_number "after-alloc" ] -gdb_breakpoint [ gdb_get_line_number "after-assign" ] - -gdb_test "show mpx bound 0x0" "Invalid bounds directory entry at $hex." "NULL address of the pointer" - -gdb_continue_to_breakpoint "after-decl" ".*after-decl.*" -gdb_test "show mpx bound a" "Invalid bounds directory entry at $hex." "pointer instead of pointer address" - -gdb_continue_to_breakpoint "after-alloc" ".*after-alloc.*" -gdb_test "show mpx bound a" "\\\{lbound = $hex, ubound = $hex\\\}: pointer value = $hex, size = \[8, 4\], metadata = 0x0+" "pointer after allocation" - -gdb_continue_to_breakpoint "after-assign" ".*after-assign.*" -gdb_test "show mpx bound x" "\\\{lbound = $hex, ubound = $hex\\\}: pointer value = $hex, size = \[8, 4\], metadata = 0x0+" "pointer after assignment" -gdb_test "set mpx bound 0x0, 0x1, 0x2" "Invalid bounds directory entry at $hex." "set mpx bound: NULL address of the pointer" -gdb_test_no_output "set mpx bound x, 0xcafebabe, 0xdeadbeef" "set mpx bound: set bounds for a valid pointer address" -gdb_test "show mpx bound x" "\\\{lbound = .*cafebabe, ubound = .*deadbeef\\\}: pointer value = $hex, size = $decimal, metadata = 0x0+" "set mpx bound: bounds map entry after set mpx bound" - - -gdb_test "set mpx bound 0x0, 0x1 0x2" "A syntax error in expression.*" "set mpx bound: Controlling syntax error, missing comma " -gdb_test "set mpx bound 0x0, 0x1" "Wrong number of arguments.*" "set mpx bound: Controlling syntax error, missing argument " diff --git a/gdb/testsuite/gdb.arch/i386-mpx-sigsegv.c b/gdb/testsuite/gdb.arch/i386-mpx-sigsegv.c deleted file mode 100644 index 54722e3..0000000 --- a/gdb/testsuite/gdb.arch/i386-mpx-sigsegv.c +++ /dev/null @@ -1,92 +0,0 @@ -/* Copyright (C) 2015-2024 Free Software Foundation, Inc. - - Contributed by Intel Corp. <walfred.tedeschi@intel.com> - - 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/>. */ - -#define OUR_SIZE 5 - -int gx[OUR_SIZE]; -int ga[OUR_SIZE]; -int gb[OUR_SIZE]; -int gc[OUR_SIZE]; -int gd[OUR_SIZE]; - -int -bp1 (int value) -{ - return 1; -} - -int -bp2 (int value) -{ - return 1; -} - -void -upper (int * p, int * a, int * b, int * c, int * d, int len) -{ - int value; - value = *(p + len); - value = *(a + len); - value = *(b + len); - value = *(c + len); - value = *(d + len); -} - -void -lower (int * p, int * a, int * b, int * c, int * d, int len) -{ - int value; - value = *(p - len); - value = *(a - len); - value = *(b - len); - value = *(c - len); - bp2 (value); - value = *(d - len); -} - -int -main (void) -{ - int sx[OUR_SIZE]; - int sa[OUR_SIZE]; - int sb[OUR_SIZE]; - int sc[OUR_SIZE]; - int sd[OUR_SIZE]; - int *x, *a, *b, *c, *d; - - x = calloc (OUR_SIZE, sizeof (int)); - a = calloc (OUR_SIZE, sizeof (int)); - b = calloc (OUR_SIZE, sizeof (int)); - c = calloc (OUR_SIZE, sizeof (int)); - d = calloc (OUR_SIZE, sizeof (int)); - - upper (x, a, b, c, d, OUR_SIZE + 2); - upper (sx, sa, sb, sc, sd, OUR_SIZE + 2); - upper (gx, ga, gb, gc, gd, OUR_SIZE + 2); - lower (x, a, b, c, d, 1); - lower (sx, sa, sb, sc, sd, 1); - bp1 (*x); - lower (gx, ga, gb, gc, gd, 1); - - free (x); - free (a); - free (b); - free (c); - free (d); - - return 0; -} diff --git a/gdb/testsuite/gdb.arch/i386-mpx-sigsegv.exp b/gdb/testsuite/gdb.arch/i386-mpx-sigsegv.exp deleted file mode 100644 index 75f7e65..0000000 --- a/gdb/testsuite/gdb.arch/i386-mpx-sigsegv.exp +++ /dev/null @@ -1,64 +0,0 @@ -# Copyright (C) 2015-2024 Free Software Foundation, Inc. -# -# Contributed by Intel Corp. <walfred.tedeschi@intel.com> -# -# 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/>. - - -require {is_any_target "i?86-*-*" "x86_64-*-*"} - -standard_testfile - -require supports_mpx_check_pointer_bounds have_mpx - -set comp_flags "-mmpx -fcheck-pointer-bounds -I${srcdir}/../nat/" - -if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \ - [list debug nowarnings additional_flags=${comp_flags}]] } { - return -1 -} - -if ![runto_main] { - return -1 -} - -set u_fault [multi_line "Program received signal SIGSEGV, Segmentation fault" \ - "Upper bound violation while accessing address $hex" \ - "Bounds: \\\[lower = $hex, upper = $hex\\\]"] - -set l_fault [multi_line "Program received signal SIGSEGV, Segmentation fault" \ - "Lower bound violation while accessing address $hex" \ - "Bounds: \\\[lower = $hex, upper = $hex\\\]"] - -for {set i 0} {$i < 15} {incr i} { - set message "MPX signal segv Upper: ${i}" - - if {[gdb_test "continue" "$u_fault.*" $message] != 0} { - break - } - - gdb_test "where" ".*#0 $hex in upper.*"\ - "$message: should be in upper" -} - -for {set i 0} {$i < 15} {incr i} { - set message "MPX signal segv Lower: ${i}" - - if {[gdb_test "continue" "$l_fault.*" $message] != 0} { - break - } - - gdb_test "where" ".*#0 $hex in lower.*"\ - "$message: should be in lower" -} diff --git a/gdb/testsuite/gdb.arch/i386-mpx-simple_segv.c b/gdb/testsuite/gdb.arch/i386-mpx-simple_segv.c deleted file mode 100644 index 6843317..0000000 --- a/gdb/testsuite/gdb.arch/i386-mpx-simple_segv.c +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright (C) 2015-2024 Free Software Foundation, Inc. - - Contributed by Intel Corp. <walfred.tedeschi@intel.com> - - 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/>. */ - -#define OUR_SIZE 5 - -void -upper (int * p, int len) -{ - int value; - len++; /* b0-size-test. */ - value = *(p + len); -} - -int -main (void) -{ - int a = 0; /* Dummy variable for debugging purposes. */ - int sx[OUR_SIZE]; - a++; /* register-eval. */ - upper (sx, OUR_SIZE + 2); - return sx[1]; -} diff --git a/gdb/testsuite/gdb.arch/i386-mpx-simple_segv.exp b/gdb/testsuite/gdb.arch/i386-mpx-simple_segv.exp deleted file mode 100644 index 8a6c9dd..0000000 --- a/gdb/testsuite/gdb.arch/i386-mpx-simple_segv.exp +++ /dev/null @@ -1,124 +0,0 @@ -# Copyright (C) 2015-2024 Free Software Foundation, Inc. -# -# Contributed by Intel Corp. <walfred.tedeschi@intel.com> -# -# 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/>. - -# Testing handle setup together with boundary violation signals. -# -# Some states are not allowed as reported on the manual, as noprint -# implies nostop, but nostop might print. -# -# Caveat: Setting the handle to nopass, ends up in a endless loop. - -require {is_any_target i?86-*-* x86_64-*-*} - -standard_testfile - -require supports_mpx_check_pointer_bounds have_mpx - -set comp_flags "-mmpx -fcheck-pointer-bounds -I${srcdir}/../nat/" - -if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \ - [list debug nowarnings additional_flags=${comp_flags}]] } { - return -1 -} - -if ![runto_main] { - return -1 -} - -set violation [multi_line "Program received signal SIGSEGV, Segmentation fault" \ - "Upper bound violation while accessing address $hex" \ - "Bounds: \\\[lower = $hex, upper = $hex\\\]"] - -set segv_with_exit "Program received signal SIGSEGV,\ - Segmentation fault.*$inferior_exited_re.*" - - -# Test handler for segmentation fault for: -# print pass stop -# -set parameters "print pass stop" -with_test_prefix "$parameters" { - if ![runto_main] { - return -1 - } - - gdb_test "handle SIGSEGV $parameters"\ - ".*SIGSEGV.*Yes.*Yes.*Yes.*Segmentation fault.*"\ - "set parameters" - - gdb_test "continue" ".*$violation.*" "display" - - gdb_test "where" ".*#0 $hex in upper.*"\ - "should be in upper" -} - -# Test handler for segmentation fault for: -# print pass nostop -# -set parameters "print pass nostop" -with_test_prefix "$parameters" { - if ![runto_main] { - return -1 - } - - gdb_test "handle SIGSEGV $parameters"\ - ".*SIGSEGV.*No.*Yes.*Yes.*Segmentation fault.*"\ - "set parameters" - - gdb_test "continue" ".*$segv_with_exit.*" "display" - - gdb_test "where" "No stack." "no inferior" -} - -# Test handler for segmentation fault for: -# print nopass stop -# -set parameters "print nopass stop" -with_test_prefix "$parameters" { - if ![runto_main] { - return -1 - } - - gdb_test "handle SIGSEGV $parameters"\ - ".*SIGSEGV.*Yes.*Yes.*No.*Segmentation fault.*"\ - "set parameters" - - gdb_test "continue" ".*$violation.*" "display" - - gdb_test "where" ".*#0 $hex in upper.*"\ - "should be in upper" -} - -# Test handler for segmentation fault for: -# print nopass stop -# -set parameters "noprint pass nostop" -with_test_prefix "$parameters" { - if ![runto_main] { - return -1 - } - - gdb_test "handle SIGSEGV $parameters"\ - ".*SIGSEGV.*No.*No.*Yes.*Segmentation fault.*"\ - "set parameters" - - gdb_test "continue" "Continuing\..*$inferior_exited_re.*"\ - "Display" - - gdb_test "where" "No stack." "no inferior" -} - diff --git a/gdb/testsuite/gdb.arch/i386-mpx.c b/gdb/testsuite/gdb.arch/i386-mpx.c deleted file mode 100644 index 99f6744..0000000 --- a/gdb/testsuite/gdb.arch/i386-mpx.c +++ /dev/null @@ -1,59 +0,0 @@ -/* Test program for MPX registers. - - Copyright 2013-2024 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/>. */ - -int -main (void) -{ -#ifdef __x86_64__ - asm ("mov $10, %rax\n\t" - "mov $9, %rdx\n\t" - "bndmk (%rax,%rdx), %bnd0\n\t" - "mov $20, %rax\n\t" - "mov $9, %rdx\n\t" - "bndmk (%rax,%rdx), %bnd1\n\t" - "mov $30, %rax\n\t" - "mov $9, %rdx\n\t" - "bndmk (%rax,%rdx), %bnd2\n\t" - "mov $40, %rax\n\t" - "mov $9, %rdx\n\t" - "bndmk (%rax,%rdx), %bnd3\n\t" - "bndstx %bnd3, (%rax) \n\t" - "nop\n\t" - ); -#else - asm ("mov $10, %eax\n\t" - "mov $9, %edx\n\t" - "bndmk (%eax,%edx), %bnd0\n\t" - "mov $20, %eax\n\t" - "mov $9, %edx\n\t" - "bndmk (%eax,%edx), %bnd1\n\t" - "mov $30, %eax\n\t" - "mov $9, %edx\n\t" - "bndmk (%eax,%edx), %bnd2\n\t" - "mov $40, %eax\n\t" - "mov $9, %edx\n\t" - "bndmk (%eax,%edx), %bnd3\n\t" - "bndstx %bnd3, (%eax)\n\t" - "nop\n\t" - ); -#endif - asm ("nop\n\t"); /* break here. */ - - return 0; -} diff --git a/gdb/testsuite/gdb.arch/i386-mpx.exp b/gdb/testsuite/gdb.arch/i386-mpx.exp deleted file mode 100644 index 9d71feb..0000000 --- a/gdb/testsuite/gdb.arch/i386-mpx.exp +++ /dev/null @@ -1,123 +0,0 @@ -# Copyright 2013-2024 Free Software Foundation, Inc. -# -# Contributed by Intel Corp. <walfred.tedeschi@intel.com> -# -# 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/>. - -require {is_any_target i?86-*-* x86_64-*-*} - -standard_testfile - -require {is_any_target i?86-*-* x86_64-*-*} - -require supports_mpx_check_pointer_bounds have_mpx - -set comp_flags "-mmpx -fcheck-pointer-bounds -I${srcdir}/../nat/" - -if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \ - [list debug nowarnings additional_flags=${comp_flags}]] } { - return -1 -} - -if ![runto_main] { - return -1 -} - -# Test bndcfg register and bndstatus at startup -set test_string "\\\{raw = 0x\[0-9a-f\]+, config = \\\{base = \[0-9\]+,\ -reserved = \[0-9\]+, preserved = \[0-9\]+, enabled = \[0-9\]+\\\}\\\}" - -gdb_test "print \$bndcfgu" $test_string "bndcfgu formating" -gdb_test "print \$bndcfgu.config.enabled" "= 1" "test if bndstatus is enabled" -gdb_test "print \$bndstatus" "\\\{raw = 0x0, status = \\\{bde = 0, error = 0\\\}\\\}" \ - "bndstatus formating" -gdb_test "print \$bndstatus.raw" "= \\\(void \\\*\\\) 0x0" "bndstatus is zero by startup" - -# Read values from pseudo registers. -gdb_breakpoint [ gdb_get_line_number "break here" ] -gdb_continue_to_breakpoint "break here" ".*break here.*" - -set test_string ".*\\\{lbound = 0xa, ubound = 0x13\\\}.*" -gdb_test "info register bnd0" ".*bnd0$test_string" "pure bnd0 register" - -set test_string ".*\\\{lbound = 0x14, ubound = 0x1d\\\}.*" -gdb_test "info register bnd1" ".*bnd1$test_string" "pure bnd1 register" - -set test_string ".*\\\{lbound = 0x1e, ubound = 0x27\\\}.*" -gdb_test "info register bnd2" ".*bnd2$test_string" "pure bnd2 register" - -set test_string ".*\\\{lbound = 0x28, ubound = 0x31\\\}.*" -gdb_test "info register bnd3" ".*bnd3$test_string" "pure bnd3 register" - -# Read value from registers bndrs. - -set test_string ".*\\\{lbound = 0xa, ubound_raw = 0x\[f\]+ec\\\}.*" -gdb_test "info register bnd0raw" ".*bnd0$test_string" "pure bnd0r register" - -set test_string ".*\\\{lbound = 0x14, ubound_raw = 0x\[f\]+e2\\\}.*" -gdb_test "info register bnd1raw" ".*bnd1$test_string" "pure bnd1r register" - -set test_string ".*\\\{lbound = 0x1e, ubound_raw = 0x\[f\]+d8\\\}.*" -gdb_test "info register bnd2raw" ".*bnd2$test_string" "pure bnd2r register" - -set test_string ".*\\\{lbound = 0x28, ubound_raw = 0x\[f\]+ce\\\}.*" -gdb_test "info register bnd3raw" ".*bnd3$test_string" "pure bnd3r register" - -# Setting fields on bnds -set test_string ".*\\\{lbound = 0xa, ubound = 0x400\\\}.*" -gdb_test "print \$bnd0.ubound = 0x400" "= \\\(void \\\*\\\) 0x400" "set value for bnd0.ubound" -gdb_test "print \$bnd0" "$test_string" "after setting bnd0.ubound" -set test_string ".*\\\{lbound = 0xa, ubound_raw = 0x\[f\]+bff\\\}.*" -gdb_test "print /x \$bnd0raw" "$test_string" "bnd0raw after set bnd0.ubound" - -set test_string ".*\\\{lbound = 0x1, ubound = 0x400\\\}.*" -gdb_test "print \$bnd0.lbound = 0x1" "= \\\(void \\\*\\\) 0x1" "set value for bnd0.lbound" -gdb_test "print \$bnd0" "$test_string" "after setting bnd0.lbound" -set test_string ".*\\\{lbound = 0x1, ubound_raw = 0x\[f\]+bff\\\}.*" -gdb_test "print /x \$bnd0raw" "$test_string" "bnd0raw after set bnd0.lbound" - -# Setting fields on bnd0raw. -set test_string ".*\\\{lbound = 0x1, ubound_raw = 0x600\\\}.*" -gdb_test "print /x \$bnd0raw.ubound_raw = 0x600" "= 0x600" "set value for bnd0raw.ubound" -gdb_test "print /x \$bnd0raw" "$test_string" "bnd0raw after setting bnd0raw.ubound" -set test_string ".*\\\{lbound = 0x1, ubound = 0x\[f\]+9ff\\\}.*" -gdb_test "print /x \$bnd0" "$test_string" "bnd0 after set bnd0raw.ubound" - -set test_string ".*\\\{lbound = 0x100, ubound_raw = 0x600\\\}.*" -gdb_test "print /x \$bnd0raw.lbound = 0x100" "= 0x100" "set value for bnd0raw.lbound" -gdb_test "print /x \$bnd0raw" "$test_string" "bnd0raw after setting bnd0raw.lbound" -set test_string ".*\\\{lbound = 0x100, ubound = 0x\[f\]+9ff\\\}.*" -gdb_test "print /x \$bnd0" "$test_string" "bnd0 after set bnd0raw.lbound" - -# Set full value bnd raw -set test_string ".*\\\{lbound = 0x10, ubound_raw = 0x\[f\]+cff\\\}.*" -gdb_test "print /x \$bnd0raw = {0x10, ~0x300}" "$test_string" "set full value for bnd0raw" -set test_string ".*\\\{lbound = 0x10, ubound = 0x300\\\}.*" -gdb_test "print /x \$bnd0" "$test_string" "bnd0raw after setting full bnd0raw" - -# Set full value bnd -set test_string ".*\\\{lbound = 0x10, ubound = 0x300\\\}.*" -gdb_test "print /x \$bnd0 = {0x10, 0x300}" "$test_string" "set full value for bnd0" -set test_string ".*\\\{lbound = 0x10, ubound_raw = 0x\[f\]+cff\\\}.*" -gdb_test "print /x \$bnd0raw" "$test_string" "bnd0raw after setting full bnd0" - -# Test bndcfg register and bndstatus after a failure on bndstr -gdb_test "print \$bndstatus.status.error" "= 2" "bndstatus error is 2\ -after a failure on allocating an entry" - -# Going to test the python extension for lenght. -if { ![allow_python_tests] } { continue } -# Verify if size is right -set test_string ".*\\\: size 0x11.*" -gdb_test "print /x \$bnd0 = {0x10, 0x20}" "$test_string" "verify size for bnd0" diff --git a/gdb/testsuite/gdb.python/py-pp-maint.exp b/gdb/testsuite/gdb.python/py-pp-maint.exp index f224ae7..1ee206c 100644 --- a/gdb/testsuite/gdb.python/py-pp-maint.exp +++ b/gdb/testsuite/gdb.python/py-pp-maint.exp @@ -55,7 +55,7 @@ gdb_test "print flt" " = x=<42> y=<43>" \ gdb_test "print ss" " = a=<a=<1> b=<$hex>> b=<a=<2> b=<$hex>>" \ "print ss enabled #1" -set num_pp 7 +set num_pp 6 gdb_test "disable pretty-printer" \ "$num_pp printers disabled.*0 of $num_pp printers enabled" @@ -75,7 +75,7 @@ gdb_test "disable pretty-printer global lookup_function_lookup_test" \ "1 printer disabled.*[expr $num_pp - 1] of $num_pp printers enabled" gdb_test "disable pretty-printer global pp-test;.*" \ - "[expr $num_pp - 2] printers disabled.*1 of $num_pp printers enabled" + "[expr 5] printers disabled.*0 of $num_pp printers enabled" gdb_test "info pretty-printer global .*function" \ {.*function_lookup_test \[disabled\].*} \ @@ -92,13 +92,13 @@ gdb_test "print ss" " = {a = {a = 1, b = $hex}, b = {a = 2, b = $hex}}" \ "print ss disabled" gdb_test "enable pretty-printer global lookup_function_lookup_test" \ - "1 printer enabled.*2 of $num_pp printers enabled" + "1 printer enabled.*1 of $num_pp printers enabled" # This doesn't enable any printers because each subprinter in the collection # is still individually disabled. But this is still needed, to enable the # collection itself. gdb_test "enable pretty-printer global pp-test" \ - "0 printers enabled.*2 of $num_pp printers enabled" + "0 printers enabled.*1 of $num_pp printers enabled" gdb_test "enable pretty-printer global pp-test;.*ss.*" \ "2 printers enabled.*[expr $num_pp - 3] of $num_pp printers enabled" diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 9ea9c3b..0475fb9 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -9815,18 +9815,6 @@ gdb_caching_proc supports_statement_frontiers {} { } executable "additional_flags=-gstatement-frontiers"] } -# Return 1 if compiler supports -mmpx -fcheck-pointer-bounds. Otherwise, -# return 0. - -gdb_caching_proc supports_mpx_check_pointer_bounds {} { - set flags "additional_flags=-mmpx additional_flags=-fcheck-pointer-bounds" - return [gdb_can_simple_compile supports_mpx_check_pointer_bounds { - int main () { - return 0; - } - } executable $flags] -} - # Return 1 if compiler supports -fcf-protection=. Otherwise, # return 0. @@ -10255,83 +10243,6 @@ gdb_caching_proc supports_gnuc {} { return [gdb_simple_compile $me $src object ""] } -# Return 1 if target supports mpx, otherwise return 0. -gdb_caching_proc have_mpx {} { - global srcdir - - set me "have_mpx" - if { ![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] } { - verbose "$me: target does not support mpx, returning 0" 2 - return 0 - } - - # Compile a test program. - set src { - #include "nat/x86-cpuid.h" - - int main() { - unsigned int eax, ebx, ecx, edx; - - if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) - return 0; - - if ((ecx & bit_OSXSAVE) == bit_OSXSAVE) - { - if (__get_cpuid_max (0, (void *)0) < 7) - return 0; - - __cpuid_count (7, 0, eax, ebx, ecx, edx); - - if ((ebx & bit_MPX) == bit_MPX) - return 1; - - } - return 0; - } - } - set compile_flags "incdir=${srcdir}/.." - if {![gdb_simple_compile $me $src executable $compile_flags]} { - return 0 - } - - set target_obj [gdb_remote_download target $obj] - set result [remote_exec target $target_obj] - set status [lindex $result 0] - set output [lindex $result 1] - if { $output != "" } { - set status 0 - } - - remote_file build delete $obj - - if { $status == 0 } { - verbose "$me: returning $status" 2 - return $status - } - - # Compile program with -mmpx -fcheck-pointer-bounds, try to trigger - # 'No MPX support', in other words, see if kernel supports mpx. - set src { int main (void) { return 0; } } - set comp_flags {} - append comp_flags " additional_flags=-mmpx" - append comp_flags " additional_flags=-fcheck-pointer-bounds" - if {![gdb_simple_compile $me-2 $src executable $comp_flags]} { - return 0 - } - - set target_obj [gdb_remote_download target $obj] - set result [remote_exec target $target_obj] - set status [lindex $result 0] - set output [lindex $result 1] - set status [expr ($status == 0) \ - && ![regexp "^No MPX support\r?\n" $output]] - - remote_file build delete $obj - - verbose "$me: returning $status" 2 - return $status -} - # Return 1 if target supports avx, otherwise return 0. gdb_caching_proc have_avx {} { global srcdir |