1 # Copyright 2008-2016 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/>.
18 if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
19 untested $testfile.exp
23 proc address_get { testname } {
30 # Do not rely on printf; some test configurations don't work with stdio.
32 gdb_breakpoint [gdb_get_line_number "print p"]
33 gdb_continue_to_breakpoint "$testname - address set"
35 gdb_test_multiple "print/x p" $testname {
36 -re "\\$\[0-9\]+ = (0x\[0-9a-f\]*)\r?\n$gdb_prompt $" {
38 return $expect_out(1,string)
43 set test "set disable-randomization off"
44 gdb_test_multiple "${test}" "${test}" {
45 -re "Disabling randomization .* unsupported .*$gdb_prompt $" {
46 untested "Disabling randomization is not supported on this Linux GDB"
49 -re "No symbol .* in current context.*$gdb_prompt $" {
50 untested "Disabling randomization is not supported on this GDB platform"
57 gdb_test "show disable-randomization" \
58 "Disabling randomization .* is off." \
59 "show disable-randomization off"
61 set addr1 [address_get "randomized first address"]
62 set addr2 [address_get "randomized second address"]
63 set test "randomized addresses should not match"
64 if [string equal $addr1 $addr2] {
65 untested "No randomization detected on this system"
71 gdb_test_no_output "set disable-randomization on"
72 gdb_test "show disable-randomization" \
73 "Disabling randomization .* is on." \
74 "show disable-randomization on"
76 set addr1 [address_get "fixed first address"]
77 set addr2 [address_get "fixed second address"]
78 set test "fixed addresses should match"
79 if [string equal $addr1 $addr2] {