]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/sect-cmd.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / sect-cmd.exp
CommitLineData
213516ef 1# Copyright 1997-2023 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
b91919ac 16# Test the 'section NAME ADDRESS' command.
c906108c 17
b91919ac
AB
18if { [prepare_for_testing "failed to prepare" "sect-cmd" \
19 {break.c break1.c} {debug nowarnings}] } {
20 return -1
c906108c 21}
aa81e255
JK
22set srcfile break.c
23set srcfile1 break1.c
850742db 24
65a33d75 25if {![runto_main]} {
b91919ac 26 return
850742db
MC
27}
28
b91919ac
AB
29# Get the address of an executable section. This test was originally
30# written for (and only run on) hppa targets. For PA32 programs using
31# the SOM file format the code section is (apparently) called $CODE$,
32# hence why the patterns here include that as a choice.
33#
34set address1 ""
35set address2 ""
36set section_name ""
850742db 37
b91919ac
AB
38gdb_test_multiple "info files" "" {
39 -re -wrap "\\s+($hex) - ($hex) is (\\\$CODE\\\$|\\.text\\S*) in .*" {
40 set address1 $expect_out(1,string)
41 set address2 $expect_out(2,string)
42 set section_name $expect_out(3,string)
43 pass $gdb_test_name
44 }
c906108c
SS
45}
46
b91919ac 47# If we don't have the details we need then we can't continue.
c906108c 48#
b91919ac
AB
49if { $address1 == "" || $address2 == "" || $section_name == "" } {
50 unresolved "failed to find required section details"
51 return
c906108c
SS
52}
53
54# Reset the section to that same starting address, which should be
55# harmless (i.e., we just want to exercise the section command).
56#
b91919ac
AB
57set saw_section_address_line false
58gdb_test_multiple "section $section_name $address1" \
59 "set section $section_name to original address" {
25ff4de7 60 -re ".*$address1 \- $address2 is $section_name in \[^\r\n\]*" {
b91919ac
AB
61 set saw_section_address_line true
62 exp_continue
63 }
64 -re "Section \[^\r\n\]+ not found\r\n" {
ac6c175e 65 fail "$gdb_test_name (saw not found marker)"
b91919ac
AB
66 exp_continue
67 }
ac6c175e 68 -re -wrap "" {
b91919ac
AB
69 gdb_assert { $saw_section_address_line } $gdb_test_name
70 }
71 }
c906108c
SS
72
73# Verify that GDB responds gracefully to a non-existent section name.
74#
ac6c175e 75gdb_test "section FOOBARBAZ 0x1234" "Section FOOBARBAZ not found"
c906108c 76
dd80d750
AB
77# Check that GDB can still print the error message when the section
78# name is very long. It used to be the case that GDB could only print
79# (up to) 100 character section names in this error message, but that
80# is no longer the case.
c906108c 81#
dd80d750
AB
82set long_sect_name \
83 "A234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123"
ac6c175e
TV
84gdb_test "section $long_sect_name 0x1234" \
85 "Section $long_sect_name not found" \
86 "non-existent too-long section disallowed"