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