blob: 387198d37321ed0e3c29ce9b23047014ba4c28a8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# Copyright 1997-2021 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. */
# Test the 'section NAME ADDRESS' command.
if { [prepare_for_testing "failed to prepare" "sect-cmd" \
{break.c break1.c} {debug nowarnings}] } {
return -1
}
set srcfile break.c
set srcfile1 break1.c
if ![runto_main] then {
fail "couldn't run to main"
return
}
# Get the address of an executable section. This test was originally
# written for (and only run on) hppa targets. For PA32 programs using
# the SOM file format the code section is (apparently) called $CODE$,
# hence why the patterns here include that as a choice.
#
set address1 ""
set address2 ""
set section_name ""
gdb_test_multiple "info files" "" {
-re -wrap "\\s+($hex) - ($hex) is (\\\$CODE\\\$|\\.text\\S*) in .*" {
set address1 $expect_out(1,string)
set address2 $expect_out(2,string)
set section_name $expect_out(3,string)
pass $gdb_test_name
}
}
# If we don't have the details we need then we can't continue.
#
if { $address1 == "" || $address2 == "" || $section_name == "" } {
unresolved "failed to find required section details"
return
}
# Reset the section to that same starting address, which should be
# harmless (i.e., we just want to exercise the section command).
#
set saw_section_address_line false
gdb_test_multiple "section $section_name $address1" \
"set section $section_name to original address" {
-re ".*$address1 \- $address2 is $section_name in \[^\r\n\]*" {
set saw_section_address_line true
exp_continue
}
-re "Section \[^\r\n\]+ not found\r\n" {
fail "$gdb_test_name (saw not found marker)"
exp_continue
}
-re -wrap "" {
gdb_assert { $saw_section_address_line } $gdb_test_name
}
}
# Verify that GDB responds gracefully to a non-existent section name.
#
gdb_test "section FOOBARBAZ 0x1234" "Section FOOBARBAZ not found"
# Check that GDB can still print the error message when the section
# name is very long. It used to be the case that GDB could only print
# (up to) 100 character section names in this error message, but that
# is no longer the case.
#
set long_sect_name \
"A234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123"
gdb_test "section $long_sect_name 0x1234" \
"Section $long_sect_name not found" \
"non-existent too-long section disallowed"
|