aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.arch/i386-mpx-map.exp
blob: 96631743ab6298540bfeedd73d5fee99bb5e7d11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Copyright 2015-2021 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/>.

if { ![istarget i?86-*-*] && ![istarget x86_64-*-* ] } {
    verbose "Skipping x86 MPX tests."
    return
}

standard_testfile

if { ![supports_mpx_check_pointer_bounds] } {
    return -1
}

if { ![have_mpx] } {
    unsupported "processor does not support MPX"
    return -1
}

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 "