1 # Copyright 1998-2021 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 just for the 'maintenance info sections' command.
18 standard_testfile break.c break1.c
20 if {[prepare_for_testing "failed to prepare" $testfile \
21 [list $srcfile $srcfile2] {debug nowarnings}]} {
25 if ![runto_main] then {
26 untested "maint info sections"
30 # Check that 'maint info sections' output looks correct. When
31 # checking the lines for each section we reject section names starting
32 # with a '*' character, the internal *COM*, *UND*, *ABS*, and *IND*
33 # sections should not be displayed in this output.
35 set seen_a_section false
36 gdb_test_multiple "maint info sections" "general output check" {
37 -re "Exec file:\r\n\[\t ]+`\[^'\]+', file type \[^.\]+\.\r\n" {
41 -re "^ \\\[\[0-9\]+\\\]\[\t \]+$hex->$hex at $hex: \[^*\r\]+\r\n" {
42 set seen_a_section true
45 -re "^$gdb_prompt $" {
46 gdb_assert { $seen_header && $seen_a_section }
51 # It'd be nice to check for every possible section. However, that's
52 # problematic, since the relative ordering wanders from release to
53 # release of the compilers. Instead, we'll just check for two
54 # sections which appear to always come out in the same relative
55 # order. (If that changes, then we should just check for one
58 # And by the way: This testpoint will break for PA64, where a.out's
62 set text_section ".text"
63 set data_section ".data"
65 gdb_test_multiple "maint info sections" "" {
66 -re -wrap "Exec file:\r\n.*${binfile}., file type.*ER_RO.*" {
67 # Looks like RealView which uses different section names.
68 set text_section ER_RO
69 set data_section ER_RW
70 pass "maint info sections"
72 -re -wrap "Exec file:\r\n.*${binfile}., file type.*neardata.*" {
73 # c6x doesn't have .data section. It has .neardata and .fardata section.
74 set data_section ".neardata"
75 pass "maint info sections"
77 -re -wrap "Exec file:\r\n.*${binfile}., file type.*" {
78 pass "maint info sections"
82 # Test for new option: maint info sections <section name>
83 # If you don't have a .text section, this will require tweaking.
85 gdb_test_multiple "maint info sections $text_section" "" {
86 -re -wrap " \\.bss .*" {
89 -re -wrap " $data_section .*" {
92 -re -wrap " $text_section .*" {
97 # Test for new option: CODE section flag
98 # If your data section is tagged CODE, xfail this test.
100 gdb_test_multiple "maint info sections CODE" "" {
101 -re -wrap " $data_section .*" {
104 -re -wrap " $text_section .*" {
109 # Test for new option: DATA section flag
110 # If your text section is tagged DATA, xfail this test.
112 # The "maint info sections DATA" test is marked for XFAIL on Windows,
113 # because Windows has text sections marked DATA.
114 setup_xfail "*-*-*cygwin*"
115 setup_xfail "*-*-*mingw*"
117 gdb_test_multiple "maint info sections DATA" "" {
118 -re -wrap " $text_section .*" {
121 -re -wrap " $data_section .*" {
124 -re -wrap " .rodata .*" {