]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/sect-cmd.exp
Update copyright year range in all GDB files
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / sect-cmd.exp
CommitLineData
e2882c85 1# Copyright 1997-2018 Free Software Foundation, Inc.
c906108c
SS
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
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
c906108c 6# (at your option) any later version.
e22f8b7c 7#
c906108c
SS
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.
e22f8b7c 12#
c906108c 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>. */
c906108c 15
c906108c
SS
16#
17# test running programs
18#
c906108c
SS
19
20# This test exists solely to exercise the "section" command for
21# code-coverage on HP-UX. (So far as I can tell, the "section"
22# command isn't needed on HP-UX, but probably is for embedded
23# apps.)
24#
25if ![istarget "hppa*-*-hpux*"] then {
26 return
27}
28
aa81e255
JK
29set testfile "sect-cmd"
30set srcfile break.c
31set srcfile1 break1.c
c906108c 32set binfile ${objdir}/${subdir}/${testfile}
850742db 33
fc91c6c2 34if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } {
5b362f04 35 untested "failed to compile"
b60f0898 36 return -1
850742db
MC
37}
38
fc91c6c2 39if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } {
5b362f04 40 untested "failed to compile"
b60f0898 41 return -1
850742db
MC
42}
43
fc91c6c2 44if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } {
5b362f04 45 untested "failed to compile"
b60f0898 46 return -1
c906108c
SS
47}
48
49gdb_exit
50gdb_start
51gdb_reinitialize_dir $srcdir/$subdir
52gdb_load ${binfile}
53
54if ![runto_main] then { fail "section command tests suppressed" }
55
56# Get the $CODE$ section's starting address.
57#
58# (Note that this works for PA32 programs, which use the SOM file
59# format. PA64 uses ELF, and when support for that is added, it's
60# not clear that there'll be a section named "$CODE$" in such
61# programs.)
62#
085dd6e6
JM
63
64set address1 ""
65set address2 ""
c906108c
SS
66send_gdb "info files\n"
67gdb_expect {
085dd6e6
JM
68 -re ".*(0x\[0-9a-fA-F\]*) - (0x\[0-9a-fA-F\]*) is .(CODE|text).*$gdb_prompt $"\
69 {pass "info files"
70 set address1 $expect_out(1,string)
71 set address2 $expect_out(2,string)}
c906108c
SS
72 -re "$gdb_prompt $"\
73 {fail "info files"}
74 timeout {fail "(timeout) info files"}
75}
76
77# Reset the section to that same starting address, which should be
78# harmless (i.e., we just want to exercise the section command).
79#
085dd6e6
JM
80if [istarget "hppa2.0w-*-*"] then {
81 send_gdb "section \.text $address1\n"
82 gdb_expect {
83 -re ".*$address1 \- $address2 is .text.*$gdb_prompt $"\
84 {pass "set section command"}
85 -re "$gdb_prompt $"\
86 {fail "set section command"}
87 timeout {fail "(timeout) set section command"}
88 }
89} else {
90 send_gdb "section \$CODE\$ $address1\n"
91 gdb_expect {
92 -re ".*$address1 \- $address2 is .CODE..*$gdb_prompt $"\
93 {pass "set section command"}
94 -re "$gdb_prompt $"\
95 {fail "set section command"}
96 timeout {fail "(timeout) set section command"}
97 }
c906108c
SS
98}
99
100# Verify that GDB responds gracefully to a non-existent section name.
101#
102send_gdb "section FOOBARBAZ 0x1234\n"
103gdb_expect {
104 -re "Section FOOBARBAZ not found\r\n$gdb_prompt $"\
105 {pass "non-existent section disallowed"}
106 -re "$gdb_prompt $"\
107 {fail "non-existent section disallowed"}
108 timeout {fail "(timeout) non-existent section disallowed"}
109}
110
111# We "happen to know" that GDB uses a fixed size character buffer to
112# parse the section name into, and the buffer is declared to be 100
113# characters in length. Verify that GDB gracefully handles section
114# names longer than that. (The section is also non-existent.)
115#
116send_gdb "section A234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123 0x1234\n"
117gdb_expect {
118 -re "Section A23456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 not found\r\n$gdb_prompt $"\
119 {pass "non-existent too-long section disallowed"}
120 -re "$gdb_prompt $"\
121 {fail "non-existent too-long section disallowed"}
122 timeout {fail "(timeout) non-existent too-long section disallowed"}
123}
124
125gdb_exit
126return 0