Commit | Line | Data |
---|---|---|
ed6df200 | 1 | # Copyright 1997, 1999, 2004, 2005 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 | |
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 | |
ed6df200 PG |
30 | set srcfile $srcdir/$subdir/$testfile.c |
31 | set binfile $objdir/$subdir/$testfile | |
c906108c | 32 | |
c906108c SS |
33 | if [get_compiler_info ${binfile}] { |
34 | return -1; | |
35 | } | |
36 | ||
ed6df200 PG |
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 | ||
c906108c SS |
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. | |
b2ce2854 | 78 | # Irix6 gcc emits no debug info at all for static functions and |
c906108c SS |
79 | # variables, so all tests involving statics fail. |
80 | ||
ed6df200 | 81 | if {![test_compiler_info "gcc-*"]} then { setup_xfail "mips-sgi-irix5*" "mips-sgi-irix6*" } |
c906108c | 82 | gdb_test "p top" \ |
085dd6e6 | 83 | "\{(<(text variable|function), no debug info>|short \\(int\\)|short \\(\\))\} \[0-9a-fx]* <top(\\(int\\)|)>" |
ed6df200 | 84 | if {![test_compiler_info "gcc-*"]} then { setup_xfail "mips-sgi-irix5*" "mips-sgi-irix6*" } |
c906108c | 85 | gdb_test "whatis top" \ |
085dd6e6 | 86 | "(<(text variable|function), no debug info>|short \\(int\\)|short \\(\\))" |
ed6df200 | 87 | if {![test_compiler_info "gcc-*"]} then { setup_xfail "mips-sgi-irix6*" } |
085dd6e6 | 88 | gdb_test "ptype top" "(short|int) \\((|void|int|<non-float parameter>|<non-float parameter>, <non-float parameter>)\\)" |
c906108c | 89 | |
ed6df200 | 90 | if {![test_compiler_info "gcc-*"]} then { setup_xfail "mips-sgi-irix5*" } |
c906108c SS |
91 | setup_xfail "mips-sgi-irix6*" |
92 | gdb_test "p middle" \ | |
085dd6e6 | 93 | "\{(<(text variable|function), no debug info>|short \\(int\\)|short \\(\\))\} \[0-9a-fx]* <middle(\\(int\\)|)>" |
ed6df200 | 94 | if {![test_compiler_info "gcc-*"]} then { setup_xfail "mips-sgi-irix5*" } |
c906108c SS |
95 | setup_xfail "mips-sgi-irix6*" |
96 | gdb_test "whatis middle" \ | |
085dd6e6 | 97 | "(<(text variable|function), no debug info>|short \\(int\\)|short \\(\\))" |
c906108c | 98 | setup_xfail "mips-sgi-irix6*" |
085dd6e6 | 99 | gdb_test "ptype middle" "(short|int) \\((|void|int|<non-float parameter>|<non-float parameter>, <non-float parameter>)\\)" |
c906108c SS |
100 | |
101 | gdb_test "p dataglobal" "= 3" | |
102 | gdb_test "whatis dataglobal" \ | |
085dd6e6 JM |
103 | "<(data variable|variable), no debug info>|int" |
104 | gdb_test "ptype dataglobal" "<(data variable|variable), no debug info>|int" | |
c906108c SS |
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*" | |
ed6df200 PG |
111 | if [test_compiler_info "gcc-*"] { |
112 | setup_xfail "mips-sgi-irix6*" | |
113 | } else { | |
114 | setup_xfail "hppa*-*-hpux*" | |
115 | } | |
116 | ||
c906108c | 117 | gdb_test "p datalocal" "= 4" |
ed6df200 | 118 | |
c906108c SS |
119 | setup_xfail "rs6000*-*-aix*" |
120 | setup_xfail "powerpc*-*-aix*" | |
ed6df200 PG |
121 | if [test_compiler_info "gcc-*"] { |
122 | setup_xfail "mips-sgi-irix6*" | |
123 | } else { | |
124 | setup_xfail "hppa*-*-hpux*" | |
125 | } | |
126 | ||
c906108c | 127 | gdb_test "whatis datalocal" "<(data variable|variable), no debug info>" |
ed6df200 | 128 | |
c906108c SS |
129 | setup_xfail "rs6000*-*-aix*" |
130 | setup_xfail "powerpc*-*-aix*" | |
ed6df200 PG |
131 | if [test_compiler_info "gcc-*"] { |
132 | setup_xfail "mips-sgi-irix6*" | |
133 | } else { | |
134 | setup_xfail "hppa*-*-hpux*" | |
135 | } | |
136 | ||
c906108c | 137 | gdb_test "ptype datalocal" "<(data variable|variable), no debug info>" |
c906108c | 138 | gdb_test "p bssglobal" "= 0" |
085dd6e6 JM |
139 | gdb_test "whatis bssglobal" "<(data variable|variable), no debug info>|int" |
140 | gdb_test "ptype bssglobal" "<(data variable|variable), no debug info>|int" | |
c906108c SS |
141 | |
142 | setup_xfail "rs6000*-*-aix*" | |
143 | setup_xfail "powerpc*-*-aix*" | |
ed6df200 PG |
144 | if [test_compiler_info "gcc-*"] { |
145 | setup_xfail "mips-sgi-irix6*" | |
146 | } else { | |
147 | setup_xfail "hppa*-*-hpux*" | |
148 | } | |
149 | ||
c906108c | 150 | gdb_test "p bsslocal" "= 0" |
ed6df200 | 151 | |
c906108c SS |
152 | setup_xfail "rs6000*-*-aix*" |
153 | setup_xfail "powerpc*-*-aix*" | |
ed6df200 PG |
154 | if [test_compiler_info "gcc-*"] { |
155 | setup_xfail "mips-sgi-irix6*" | |
156 | } else { | |
157 | setup_xfail "hppa*-*-hpux*" | |
158 | } | |
159 | ||
c906108c | 160 | gdb_test "whatis bsslocal" "<(data variable|variable), no debug info>" |
ed6df200 | 161 | |
c906108c SS |
162 | setup_xfail "rs6000*-*-aix*" |
163 | setup_xfail "powerpc*-*-aix*" | |
ed6df200 PG |
164 | if [test_compiler_info "gcc-*"] { |
165 | setup_xfail "mips-sgi-irix6*" | |
166 | } else { | |
167 | setup_xfail "hppa*-*-hpux*" | |
168 | } | |
c906108c SS |
169 | gdb_test "ptype bsslocal" "<(data variable|variable), no debug info>" |
170 | ||
ed6df200 PG |
171 | if [test_compiler_info "gcc-*"] { |
172 | setup_xfail "mips-sgi-irix6*" | |
173 | } | |
174 | ||
c906108c SS |
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. | |
ed6df200 PG |
185 | if { ! [test_compiler_info "gcc-*"]} { |
186 | setup_xfail "mips-sgi-irix6*" | |
187 | } | |
c906108c SS |
188 | if [target_info exists gdb,cannot_call_functions] { |
189 | setup_xfail "*-*-*" 2416 | |
190 | fail "p/c array_index(\"abcdef\",2)" | |
191 | } else { | |
085dd6e6 JM |
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 { | |
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). | |
208 | set timeout 60; | |
085dd6e6 JM |
209 | gdb_test {p/c array_index("abcdef",2)} " = 99 'c'" |
210 | } | |
c906108c SS |
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 | |
ed6df200 PG |
215 | if [test_compiler_info "gcc-*"] { |
216 | setup_xfail "mips-sgi-irix6*" | |
217 | } | |
c906108c SS |
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 | } |