Fix crash when exiting TUI with gdb -tui
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.arch / i386-mpx-map.exp
CommitLineData
b811d2c2 1# Copyright 2015-2020 Free Software Foundation, Inc.
29c1c244
WT
2#
3# Contributed by Intel Corp. <walfred.tedeschi@intel.com>,
4# <mircea.gherzan@intel.com>
5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19if { ![istarget i?86-*-*] && ![istarget x86_64-*-* ] } {
20 verbose "Skipping x86 MPX tests."
21 return
22}
23
24standard_testfile
25
5beb4d17
TV
26if { ![supports_mpx_check_pointer_bounds] } {
27 return -1
28}
29
1a2ccd2e 30set comp_flags "-mmpx -fcheck-pointer-bounds -I${srcdir}/../nat/"
29c1c244 31
5b362f04 32if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
29c1c244
WT
33 [list debug nowarnings additional_flags=${comp_flags}]] } {
34 return -1
35}
36
37if ![runto_main] {
38 untested "could not run to main"
39 return -1
40}
41
42set supports_mpx 0
43set test "probe MPX support"
44
45gdb_test_multiple "print have_mpx()" $test {
46 -re ".. = 1\r\n$gdb_prompt $" {
47 pass $test
48 set supports_mpx 1
49 }
50 -re ".. = 0\r\n$gdb_prompt $" {
51 pass $test
52 }
53}
54
55if { !$supports_mpx } {
56 unsupported "processor does not support MPX"
57 return
58}
59
60gdb_breakpoint [ gdb_get_line_number "after-decl" ]
61gdb_breakpoint [ gdb_get_line_number "after-alloc" ]
62gdb_breakpoint [ gdb_get_line_number "after-assign" ]
63
64gdb_test "show mpx bound 0x0" "Invalid bounds directory entry at $hex." "NULL address of the pointer"
65
66gdb_continue_to_breakpoint "after-decl" ".*after-decl.*"
67gdb_test "show mpx bound a" "Invalid bounds directory entry at $hex." "pointer instead of pointer address"
68
69gdb_continue_to_breakpoint "after-alloc" ".*after-alloc.*"
70gdb_test "show mpx bound a" "\\\{lbound = $hex, ubound = $hex\\\}: pointer value = $hex, size = \[8, 4\], metadata = 0x0+" "pointer after allocation"
71
72gdb_continue_to_breakpoint "after-assign" ".*after-assign.*"
73gdb_test "show mpx bound x" "\\\{lbound = $hex, ubound = $hex\\\}: pointer value = $hex, size = \[8, 4\], metadata = 0x0+" "pointer after assignment"
74gdb_test "set mpx bound 0x0, 0x1, 0x2" "Invalid bounds directory entry at $hex." "set mpx bound: NULL address of the pointer"
75gdb_test_no_output "set mpx bound x, 0xcafebabe, 0xdeadbeef" "set mpx bound: set bounds for a valid pointer address"
76gdb_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"
77
78
79gdb_test "set mpx bound 0x0, 0x1 0x2" "A syntax error in expression.*" "set mpx bound: Controlling syntax error, missing comma "
80gdb_test "set mpx bound 0x0, 0x1" "Wrong number of arguments.*" "set mpx bound: Controlling syntax error, missing argument "
This page took 0.720223 seconds and 4 git commands to generate.