1 # Copyright 2008 Free Software Foundation, Inc.
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.
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.
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/>.
16 set testfile randomize
17 set srcfile ${testfile}.c
18 set binfile ${objdir}/${subdir}/${testfile}
19 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
20 untested "Couldn't compile test program"
28 gdb_reinitialize_dir $srcdir/$subdir
31 proc address_get { testname } {
38 # Do not rely on printf; some test configurations don't work with stdio.
40 gdb_breakpoint [gdb_get_line_number "print p"]
41 gdb_continue_to_breakpoint "$testname - address set"
43 gdb_test_multiple "print/x p" $testname {
44 -re "\\$\[0-9\]+ = (0x\[0-9a-f\]*)\r?\n$gdb_prompt $" {
46 return $expect_out(1,string)
51 set test "set disable-randomization off"
52 gdb_test_multiple "${test}" "${test}" {
53 -re "Disabling randomization .* unsupported .*$gdb_prompt $" {
54 untested "No randomization supported by this GDB"
61 gdb_test "show disable-randomization" \
62 "Disabling randomization .* is off." \
63 "show disable-randomization off"
65 set addr1 [address_get "randomized first address"]
66 set addr2 [address_get "randomized second address"]
67 set test "randomized addresses should not match"
68 if {$addr1 eq $addr2} {
69 untested "No randomization detected on this system"
75 gdb_test "set disable-randomization on"
76 gdb_test "show disable-randomization" \
77 "Disabling randomization .* is on." \
78 "show disable-randomization on"
80 set addr1 [address_get "fixed first address"]
81 set addr2 [address_get "fixed second address"]
82 set test "fixed addresses should match"
83 if {$addr1 eq $addr2} {