]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/nodebug.exp
Updated copyright notices for most files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / nodebug.exp
CommitLineData
0fb0cc75
JB
1# Copyright 1997, 1999, 2004, 2005, 2007, 2008, 2009
2# Free Software Foundation, Inc.
c906108c
SS
3
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
e22f8b7c 6# the Free Software Foundation; either version 3 of the License, or
c906108c 7# (at your option) any later version.
e22f8b7c 8#
c906108c
SS
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
e22f8b7c 13#
c906108c 14# You should have received a copy of the GNU General Public License
e22f8b7c 15# along with this program. If not, see <http://www.gnu.org/licenses/>.
c906108c 16
c906108c
SS
17# Test that things still (sort of) work when compiled without -g.
18
19if $tracelevel then {
20 strace $tracelevel
21}
22
23set prms_id 0
24set bug_id 0
25
26set testfile nodebug
ed6df200
PG
27set srcfile $srcdir/$subdir/$testfile.c
28set binfile $objdir/$subdir/$testfile
c906108c 29
c906108c
SS
30if [get_compiler_info ${binfile}] {
31 return -1;
32}
33
ed6df200
PG
34if [test_compiler_info "xlc-*"] {
35 # By default, IBM'x xlc compiler doesn't add static variables into the symtab.
36 # Use "-qstatsym" to do so.
37 set exec_opts additional_flags=-qstatsym
38} else {
39 set exec_opts ""
40}
41
42if { [gdb_compile $srcfile $binfile executable $exec_opts] != "" } {
43 untested "Couldn't compile $srcfile."
44 return -1
45}
46
47# Start with a fresh gdb.
48
c906108c
SS
49gdb_exit
50gdb_start
51gdb_reinitialize_dir $srcdir/$subdir
52gdb_load $binfile
53
54if [runto inner] then {
55
56 # Expect to find global/local symbols in each of text/data/bss.
57
58 # The exact format for some of this output is not necessarily
59 # ideal, particularly interpreting "p top" requires a fair bit of
60 # savvy about gdb's workings and the meaning of the "{}"
61 # construct. So the details maybe could be tweaked. But the
62 # basic purpose should be maintained, which is (a) users should be
63 # able to interact with these variables with some care (they have
64 # to know how to interpret them according to their real type,
65 # since gdb doesn't know the type), but (b) users should be able
66 # to detect that gdb does not know the type, rather than just
67 # being told they are ints or functions returning int like old
68 # versions of gdb used to do.
69
70 # On alpha (and other ecoff systems) the native compilers put
71 # out debugging info for non-aggregate return values of functions
72 # even without -g, which should be accepted.
73 # Irix5, even though it is ELF, counts as "ecoff" because it
74 # encapsulates ecoff debugging info in a .mdebug section.
b2ce2854 75 # Irix6 gcc emits no debug info at all for static functions and
c906108c
SS
76 # variables, so all tests involving statics fail.
77
ed6df200 78 if {![test_compiler_info "gcc-*"]} then { setup_xfail "mips-sgi-irix5*" "mips-sgi-irix6*" }
c906108c 79 gdb_test "p top" \
085dd6e6 80 "\{(<(text variable|function), no debug info>|short \\(int\\)|short \\(\\))\} \[0-9a-fx]* <top(\\(int\\)|)>"
ed6df200 81 if {![test_compiler_info "gcc-*"]} then { setup_xfail "mips-sgi-irix5*" "mips-sgi-irix6*" }
c906108c 82 gdb_test "whatis top" \
085dd6e6 83 "(<(text variable|function), no debug info>|short \\(int\\)|short \\(\\))"
ed6df200 84 if {![test_compiler_info "gcc-*"]} then { setup_xfail "mips-sgi-irix6*" }
085dd6e6 85 gdb_test "ptype top" "(short|int) \\((|void|int|<non-float parameter>|<non-float parameter>, <non-float parameter>)\\)"
c906108c 86
ed6df200 87 if {![test_compiler_info "gcc-*"]} then { setup_xfail "mips-sgi-irix5*" }
c906108c
SS
88 setup_xfail "mips-sgi-irix6*"
89 gdb_test "p middle" \
085dd6e6 90 "\{(<(text variable|function), no debug info>|short \\(int\\)|short \\(\\))\} \[0-9a-fx]* <middle(\\(int\\)|)>"
ed6df200 91 if {![test_compiler_info "gcc-*"]} then { setup_xfail "mips-sgi-irix5*" }
c906108c
SS
92 setup_xfail "mips-sgi-irix6*"
93 gdb_test "whatis middle" \
085dd6e6 94 "(<(text variable|function), no debug info>|short \\(int\\)|short \\(\\))"
c906108c 95 setup_xfail "mips-sgi-irix6*"
085dd6e6 96 gdb_test "ptype middle" "(short|int) \\((|void|int|<non-float parameter>|<non-float parameter>, <non-float parameter>)\\)"
c906108c
SS
97
98 gdb_test "p dataglobal" "= 3"
99 gdb_test "whatis dataglobal" \
085dd6e6
JM
100 "<(data variable|variable), no debug info>|int"
101 gdb_test "ptype dataglobal" "<(data variable|variable), no debug info>|int"
c906108c
SS
102
103 # The only symbol xcoff puts out for statics is for the TOC entry.
104 # Possible, but hairy, for gdb to deal. Right now it doesn't, it
105 # doesn't know the variables exist at all.
106 setup_xfail "rs6000*-*-aix*"
107 setup_xfail "powerpc*-*-aix*"
ed6df200
PG
108 if [test_compiler_info "gcc-*"] {
109 setup_xfail "mips-sgi-irix6*"
110 } else {
111 setup_xfail "hppa*-*-hpux*"
112 }
113
c906108c 114 gdb_test "p datalocal" "= 4"
ed6df200 115
c906108c
SS
116 setup_xfail "rs6000*-*-aix*"
117 setup_xfail "powerpc*-*-aix*"
ed6df200
PG
118 if [test_compiler_info "gcc-*"] {
119 setup_xfail "mips-sgi-irix6*"
120 } else {
121 setup_xfail "hppa*-*-hpux*"
122 }
123
c906108c 124 gdb_test "whatis datalocal" "<(data variable|variable), no debug info>"
ed6df200 125
c906108c
SS
126 setup_xfail "rs6000*-*-aix*"
127 setup_xfail "powerpc*-*-aix*"
ed6df200
PG
128 if [test_compiler_info "gcc-*"] {
129 setup_xfail "mips-sgi-irix6*"
130 } else {
131 setup_xfail "hppa*-*-hpux*"
132 }
133
c906108c 134 gdb_test "ptype datalocal" "<(data variable|variable), no debug info>"
c906108c 135 gdb_test "p bssglobal" "= 0"
085dd6e6
JM
136 gdb_test "whatis bssglobal" "<(data variable|variable), no debug info>|int"
137 gdb_test "ptype bssglobal" "<(data variable|variable), no debug info>|int"
c906108c
SS
138
139 setup_xfail "rs6000*-*-aix*"
140 setup_xfail "powerpc*-*-aix*"
ed6df200
PG
141 if [test_compiler_info "gcc-*"] {
142 setup_xfail "mips-sgi-irix6*"
143 } else {
144 setup_xfail "hppa*-*-hpux*"
145 }
146
c906108c 147 gdb_test "p bsslocal" "= 0"
ed6df200 148
c906108c
SS
149 setup_xfail "rs6000*-*-aix*"
150 setup_xfail "powerpc*-*-aix*"
ed6df200
PG
151 if [test_compiler_info "gcc-*"] {
152 setup_xfail "mips-sgi-irix6*"
153 } else {
154 setup_xfail "hppa*-*-hpux*"
155 }
156
c906108c 157 gdb_test "whatis bsslocal" "<(data variable|variable), no debug info>"
ed6df200 158
c906108c
SS
159 setup_xfail "rs6000*-*-aix*"
160 setup_xfail "powerpc*-*-aix*"
ed6df200
PG
161 if [test_compiler_info "gcc-*"] {
162 setup_xfail "mips-sgi-irix6*"
163 } else {
164 setup_xfail "hppa*-*-hpux*"
165 }
c906108c
SS
166 gdb_test "ptype bsslocal" "<(data variable|variable), no debug info>"
167
ed6df200
PG
168 if [test_compiler_info "gcc-*"] {
169 setup_xfail "mips-sgi-irix6*"
170 }
171
c906108c
SS
172 gdb_test "backtrace 10" "#0.*inner.*#1.*middle.*#2.*top.*#3.*main.*" \
173 "backtrace from inner in nodebug.exp"
174 # Or if that doesn't work, at least hope for the external symbols
175 # Commented out because if we aren't going to xfail the above test
176 # ever, why bother with a weaker test?
177 #gdb_test "backtrace 10" "#0.*inner.*#1.*#2.*top.*#3.*main.*" \
178 # "backtrace from inner in nodebug.exp for externals"
179
180 # This test is not as obscure as it might look. `p getenv ("TERM")'
181 # is a real-world example, at least on many systems.
ed6df200
PG
182 if { ! [test_compiler_info "gcc-*"]} {
183 setup_xfail "mips-sgi-irix6*"
184 }
c906108c
SS
185 if [target_info exists gdb,cannot_call_functions] {
186 setup_xfail "*-*-*" 2416
187 fail "p/c array_index(\"abcdef\",2)"
188 } else {
085dd6e6
JM
189 #
190 # On HP-UX, a support function (__d_plt_call) necessary to
191 # implement an inferior call is normally only available when
192 # the inferior was compiled with -g. Thus, we expect this
193 # testpoint to fail on HP-UX.
194 if { [istarget "hppa*-hpux*"] } {
195 send_gdb "p/c array_index(\"abcdef\",2)\n"
196 gdb_expect {
197 -re ".*Suggest linking executable with -g.*$gdb_prompt $" { pass "p/c array_index(\"abcdef\",2)" }
198 -re ".*Cannot find __wdb_call_dummy in.*end.o.*" { pass "p/c array_index(\"abcdef\",2)" }
199 -re ".*99 'c'.*" { pass "p/c array_index(\"abcdef\",2)" }
200 timeout { fail "(timeout) p/c array_index" }
201 }
202 } else {
9846de1b
JM
203 # We need to up this because this can be really slow on some boards.
204 # (malloc() is called as part of the test).
205 set timeout 60;
085dd6e6
JM
206 gdb_test {p/c array_index("abcdef",2)} " = 99 'c'"
207 }
c906108c
SS
208 }
209
210 # Now, try that we can give names of file-local symbols which happen
211 # to be unique, and have it still work
ed6df200
PG
212 if [test_compiler_info "gcc-*"] {
213 setup_xfail "mips-sgi-irix6*"
214 }
c906108c
SS
215 if [runto middle] then {
216 gdb_test "backtrace 10" "#0.*middle.*#1.*top.*#2.*main.*" \
217 "backtrace from middle in nodebug.exp"
218 }
219}