1 # Copyright 1997-2014 Free Software Foundation, Inc.
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 3 of the License, or
6 # (at your option) any later version.
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.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 # Test that things still (sort of) work when compiled without -g.
21 if [get_compiler_info] {
25 if [test_compiler_info "xlc-*"] {
26 # By default, IBM'x xlc compiler doesn't add static variables into the symtab.
27 # Use "-qstatsym" to do so.
28 set exec_opts additional_flags=-qstatsym
33 if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != "" } {
34 untested "Couldn't compile $srcfile."
38 # Start with a fresh gdb.
40 clean_restart $binfile
42 if [runto inner] then {
44 # Expect to find global/local symbols in each of text/data/bss.
46 # The exact format for some of this output is not necessarily
47 # ideal, particularly interpreting "p top" requires a fair bit of
48 # savvy about gdb's workings and the meaning of the "{}"
49 # construct. So the details maybe could be tweaked. But the
50 # basic purpose should be maintained, which is (a) users should be
51 # able to interact with these variables with some care (they have
52 # to know how to interpret them according to their real type,
53 # since gdb doesn't know the type), but (b) users should be able
54 # to detect that gdb does not know the type, rather than just
55 # being told they are ints or functions returning int like old
56 # versions of gdb used to do.
58 # On alpha (and other ecoff systems) the native compilers put
59 # out debugging info for non-aggregate return values of functions
60 # even without -g, which should be accepted.
63 "\{(<(text variable|function), no debug info>|short \\(int\\)|short \\(\\))\} \[0-9a-fx]* <\\.?top(\\(int\\)|)>"
64 gdb_test "whatis top" \
65 "(<(text variable|function), no debug info>|short \\(int\\)|short \\(\\))"
66 gdb_test "ptype top" "(short|int) \\((|void|int|<non-float parameter>|<non-float parameter>, <non-float parameter>)\\)"
69 "\{(<(text variable|function), no debug info>|short \\(int\\)|short \\(\\))\} \[0-9a-fx]* <\\.?middle(\\(int\\)|)>"
70 gdb_test "whatis middle" \
71 "(<(text variable|function), no debug info>|short \\(int\\)|short \\(\\))"
72 gdb_test "ptype middle" "(short|int) \\((|void|int|<non-float parameter>|<non-float parameter>, <non-float parameter>)\\)"
74 gdb_test "p dataglobal" "= 3"
75 gdb_test "whatis dataglobal" \
76 "<(data variable|variable), no debug info>|int"
77 gdb_test "ptype dataglobal" "<(data variable|variable), no debug info>|int"
79 # The only symbol xcoff puts out for statics is for the TOC entry.
80 # Possible, but hairy, for gdb to deal. Right now it doesn't, it
81 # doesn't know the variables exist at all.
82 setup_xfail "rs6000*-*-aix*"
83 setup_xfail "powerpc*-*-aix*"
84 if ![test_compiler_info "gcc-*"] {
85 setup_xfail "hppa*-*-hpux*"
88 gdb_test "p datalocal" "= 4"
90 setup_xfail "rs6000*-*-aix*"
91 setup_xfail "powerpc*-*-aix*"
92 if ![test_compiler_info "gcc-*"] {
93 setup_xfail "hppa*-*-hpux*"
96 gdb_test "whatis datalocal" "<(data variable|variable), no debug info>"
98 setup_xfail "rs6000*-*-aix*"
99 setup_xfail "powerpc*-*-aix*"
100 if ![test_compiler_info "gcc-*"] {
101 setup_xfail "hppa*-*-hpux*"
104 gdb_test "ptype datalocal" "<(data variable|variable), no debug info>"
105 gdb_test "p bssglobal" "= 0"
106 gdb_test "whatis bssglobal" "<(data variable|variable), no debug info>|int"
107 gdb_test "ptype bssglobal" "<(data variable|variable), no debug info>|int"
109 setup_xfail "rs6000*-*-aix*"
110 setup_xfail "powerpc*-*-aix*"
111 if ![test_compiler_info "gcc-*"] {
112 setup_xfail "hppa*-*-hpux*"
115 gdb_test "p bsslocal" "= 0"
117 setup_xfail "rs6000*-*-aix*"
118 setup_xfail "powerpc*-*-aix*"
119 if ![test_compiler_info "gcc-*"] {
120 setup_xfail "hppa*-*-hpux*"
123 gdb_test "whatis bsslocal" "<(data variable|variable), no debug info>"
125 setup_xfail "rs6000*-*-aix*"
126 setup_xfail "powerpc*-*-aix*"
127 if ![test_compiler_info "gcc-*"] {
128 setup_xfail "hppa*-*-hpux*"
130 gdb_test "ptype bsslocal" "<(data variable|variable), no debug info>"
132 gdb_test "backtrace 10" "#0.*inner.*#1.*middle.*#2.*top.*#3.*main.*" \
133 "backtrace from inner in nodebug.exp"
134 # Or if that doesn't work, at least hope for the external symbols
135 # Commented out because if we aren't going to xfail the above test
136 # ever, why bother with a weaker test?
137 #gdb_test "backtrace 10" "#0.*inner.*#1.*#2.*top.*#3.*main.*" \
138 # "backtrace from inner in nodebug.exp for externals"
140 # This test is not as obscure as it might look. `p getenv ("TERM")'
141 # is a real-world example, at least on many systems.
142 if [target_info exists gdb,cannot_call_functions] {
143 setup_xfail "*-*-*" 2416
144 fail "p/c array_index(\"abcdef\",2)"
147 # On HP-UX, a support function (__d_plt_call) necessary to
148 # implement an inferior call is normally only available when
149 # the inferior was compiled with -g. Thus, we expect this
150 # testpoint to fail on HP-UX.
151 if { [istarget "hppa*-hpux*"] } {
152 gdb_test_multiple "p/c array_index(\"abcdef\",2)" \
153 "p/c array_index(\"abcdef\",2)" {
154 -re ".*Suggest linking executable with -g.*$gdb_prompt $" {
155 pass "p/c array_index(\"abcdef\",2)"
157 -re ".*Cannot find __wdb_call_dummy in.*end.o.*" {
158 pass "p/c array_index(\"abcdef\",2)"
161 pass "p/c array_index(\"abcdef\",2)"
165 # We need to up this because this can be really slow on some boards.
166 # (malloc() is called as part of the test).
167 set prev_timeout $timeout
169 gdb_test {p/c array_index("abcdef",2)} " = 99 'c'"
170 set timeout $prev_timeout
174 # Now, try that we can give names of file-local symbols which happen
175 # to be unique, and have it still work
176 if [runto middle] then {
177 gdb_test "backtrace 10" "#0.*middle.*#1.*top.*#2.*main.*" \
178 "backtrace from middle in nodebug.exp"