]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/randomize.exp
Update Copyright year range in all files maintained by GDB.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / randomize.exp
CommitLineData
ecd75fc8 1# Copyright 2008-2014 Free Software Foundation, Inc.
10568435
JK
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program. If not, see <http://www.gnu.org/licenses/>.
15
822bd149
TT
16standard_testfile
17
18if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
19 untested $testfile.exp
10568435
JK
20 return -1
21}
22
10568435
JK
23proc address_get { testname } {
24 global gdb_prompt
25
26 if {![runto_main]} {
27 return -1
28 }
29
30 # Do not rely on printf; some test configurations don't work with stdio.
31
32 gdb_breakpoint [gdb_get_line_number "print p"]
33 gdb_continue_to_breakpoint "$testname - address set"
34
35 gdb_test_multiple "print/x p" $testname {
36 -re "\\$\[0-9\]+ = (0x\[0-9a-f\]*)\r?\n$gdb_prompt $" {
37 pass $testname
38 return $expect_out(1,string)
39 }
40 }
41}
42
43set test "set disable-randomization off"
44gdb_test_multiple "${test}" "${test}" {
45 -re "Disabling randomization .* unsupported .*$gdb_prompt $" {
b432ffe3
JK
46 untested "Disabling randomization is not supported on this Linux GDB"
47 return -1
48 }
49 -re "No symbol .* in current context.*$gdb_prompt $" {
50 untested "Disabling randomization is not supported on this GDB platform"
10568435
JK
51 return -1
52 }
53 -re "$gdb_prompt $" {
54 pass $test
55 }
56}
57gdb_test "show disable-randomization" \
58 "Disabling randomization .* is off." \
59 "show disable-randomization off"
60
61set addr1 [address_get "randomized first address"]
62set addr2 [address_get "randomized second address"]
63set test "randomized addresses should not match"
981505ef 64if [string equal $addr1 $addr2] {
10568435
JK
65 untested "No randomization detected on this system"
66 return -1
67} else {
68 pass $test
69}
70
27d3a1a2 71gdb_test_no_output "set disable-randomization on"
10568435
JK
72gdb_test "show disable-randomization" \
73 "Disabling randomization .* is on." \
74 "show disable-randomization on"
75
76set addr1 [address_get "fixed first address"]
77set addr2 [address_get "fixed second address"]
78set test "fixed addresses should match"
981505ef 79if [string equal $addr1 $addr2] {
10568435
JK
80 pass $test
81} else {
82 fail $test
83}