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