]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/randomize.exp
GDB copyright headers update after running GDB's copyright.py script.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / randomize.exp
1 # Copyright 2008-2016 Free Software Foundation, Inc.
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
16 standard_testfile
17
18 if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
19 untested $testfile.exp
20 return -1
21 }
22
23 proc 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
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"
47 return -1
48 }
49 -re "No symbol .* in current context.*$gdb_prompt $" {
50 untested "Disabling randomization is not supported on this GDB platform"
51 return -1
52 }
53 -re "$gdb_prompt $" {
54 pass $test
55 }
56 }
57 gdb_test "show disable-randomization" \
58 "Disabling randomization .* is off." \
59 "show disable-randomization off"
60
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"
66 return -1
67 } else {
68 pass $test
69 }
70
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"
75
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] {
80 pass $test
81 } else {
82 fail $test
83 }