]>
Commit | Line | Data |
---|---|---|
1 | # Copyright 1997-2023 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 the 'section NAME ADDRESS' command. | |
17 | ||
18 | if { [prepare_for_testing "failed to prepare" "sect-cmd" \ | |
19 | {break.c break1.c} {debug nowarnings}] } { | |
20 | return -1 | |
21 | } | |
22 | set srcfile break.c | |
23 | set srcfile1 break1.c | |
24 | ||
25 | if {![runto_main]} { | |
26 | return | |
27 | } | |
28 | ||
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 | # | |
34 | set address1 "" | |
35 | set address2 "" | |
36 | set section_name "" | |
37 | ||
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) | |
43 | pass $gdb_test_name | |
44 | } | |
45 | } | |
46 | ||
47 | # If we don't have the details we need then we can't continue. | |
48 | # | |
49 | if { $address1 == "" || $address2 == "" || $section_name == "" } { | |
50 | unresolved "failed to find required section details" | |
51 | return | |
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 | # | |
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 | |
62 | exp_continue | |
63 | } | |
64 | -re "Section \[^\r\n\]+ not found\r\n" { | |
65 | fail "$gdb_test_name (saw not found marker)" | |
66 | exp_continue | |
67 | } | |
68 | -re -wrap "" { | |
69 | gdb_assert { $saw_section_address_line } $gdb_test_name | |
70 | } | |
71 | } | |
72 | ||
73 | # Verify that GDB responds gracefully to a non-existent section name. | |
74 | # | |
75 | gdb_test "section FOOBARBAZ 0x1234" "Section FOOBARBAZ not found" | |
76 | ||
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. | |
81 | # | |
82 | set long_sect_name \ | |
83 | "A234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" | |
84 | gdb_test "section $long_sect_name 0x1234" \ | |
85 | "Section $long_sect_name not found" \ | |
86 | "non-existent too-long section disallowed" |