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