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