1 # Copyright
1997-2023 Free Software Foundation
, Inc.
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.
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.
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
/>.
*/
16 # Test the
'section NAME ADDRESS' command.
18 if { [prepare_for_testing
"failed to prepare" "sect-cmd" \
19 {break.c break1.c
} {debug nowarnings
}] } {
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.
38 gdb_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
)
47 #
If we don
't have the details we need then we can't
continue.
49 if { $address1
== "" || $address2 == "" || $section_name == "" } {
50 unresolved
"failed to find required section details"
54 # Reset the section to that same starting address
, which should be
55 # harmless
(i.e.
, we just want to exercise the section command
).
57 set saw_section_address_line false
58 gdb_test_multiple
"section $section_name $address1" \
59 "set section $section_name to original address" {
60 -re
".*$address1 \- $address2 is $section_name in \[^\r\n\]*" {
61 set saw_section_address_line true
64 -re
"Section \[^\r\n\]+ not found\r\n" {
65 fail
"$gdb_test_name (saw not found marker)"
69 gdb_assert
{ $saw_section_address_line
} $gdb_test_name
73 # Verify that GDB responds gracefully to a non
-existent section
name.
75 gdb_test
"section FOOBARBAZ 0x1234" "Section FOOBARBAZ not found"
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.
83 "A234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123"
84 gdb_test
"section $long_sect_name 0x1234" \
85 "Section $long_sect_name not found" \
86 "non-existent too-long section disallowed"