Eliminate literal line numbers in dbx.exp
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / execl-update-breakpoints.exp
CommitLineData
13fd3ff3
PA
1# Copyright 2014 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# Test that when following an exec, we don't try to insert breakpoints
17# in the new image at the addresses the symbols had before the exec.
18
19# Remote protocol does not support follow-exec notifications.
20
21if [is_remote target] {
22 continue
23}
24
25standard_testfile
26
27# Build two copies of the program, each linked at a different address.
28# The address of "main" in the first binary should end up being an
29# unmapped address in the second binary.
30
31set exec1 ${testfile}1
32set exec2 ${testfile}2
33set binfile1 ${binfile}1
34set binfile2 ${binfile}2
35
36if { [prepare_for_testing "failed to prepare" ${exec1} "${srcfile}" \
37 [list debug ldflags=-Wl,-Ttext=0x1000000]] } {
38 return -1
39}
40if { [prepare_for_testing "failed to prepare" ${exec2} "${srcfile}" \
41 [list debug ldflags=-Wl,-Ttext=0x2000000]] } {
42 return -1
43}
44
45# First check whether the address of "main" in exec1 is readable in
46# exec2. If it is, then skip the test as unsupported.
47
48clean_restart ${exec1}
49if ![runto_main] then {
50 fail "Couldn't run to main"
51 return -1
52}
53
54set addr ""
55set test "main address first"
56gdb_test_multiple "p/x &main" $test {
57 -re " = (0x\[0-9a-f\]+)\r\n$gdb_prompt $" {
58 set addr $expect_out(1,string)
59 pass $test
60 }
61}
62
63clean_restart ${exec2}
64if ![runto_main] then {
65 fail "Couldn't run to main"
66 return -1
67}
68
69set cannot_access 0
70set test "probe memory access"
71gdb_test_multiple "x $addr" $test {
72 -re "Cannot access memory at address .*$gdb_prompt $" {
73 set cannot_access 1
74 pass $test
75 }
76 -re ".*$gdb_prompt $" {
77 pass $test
78 }
79}
80
81if {!$cannot_access} {
82 unsupported "main address is readable in second binary"
83 return
84}
85
86# The test proper. ALWAYS_INSERTED indicates whether testing in
87# "breakpoint always-inserted" mode.
88
89proc test { always_inserted } {
90 global exec1
91
92 clean_restart ${exec1}
93
94 gdb_test_no_output "set breakpoint always-inserted $always_inserted"
95
96 if ![runto_main] then {
97 fail "Couldn't run to main"
98 return -1
99 }
100
101 # On a buggy GDB, with always-inserted on, we'd see:
102 # (gdb) continue
103 # Continuing.
104 # Warning:
105 # Cannot insert breakpoint 1.
106 # Cannot access memory at address 0x10000ff
107 gdb_test "continue" "Breakpoint 1, main.*" "continue across exec"
108}
109
110foreach always_inserted { "off" "on" } {
111 with_test_prefix "always-inserted $always_inserted" {
112 test $always_inserted
113 }
114}
This page took 0.06444 seconds and 4 git commands to generate.