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