1 |
106 |
markom |
# Copyright (C) 1997 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 ${testfile}.c
|
31 |
|
|
set binfile ${objdir}/${subdir}/${testfile}
|
32 |
|
|
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable ""] != "" } {
|
33 |
|
|
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
|
34 |
|
|
}
|
35 |
|
|
|
36 |
|
|
# Create and source the file that provides information about the compiler
|
37 |
|
|
# used to compile the test case.
|
38 |
|
|
if [get_compiler_info ${binfile}] {
|
39 |
|
|
return -1;
|
40 |
|
|
}
|
41 |
|
|
|
42 |
|
|
source ${binfile}.ci
|
43 |
|
|
|
44 |
|
|
gdb_exit
|
45 |
|
|
gdb_start
|
46 |
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
47 |
|
|
gdb_load $binfile
|
48 |
|
|
|
49 |
|
|
if [runto inner] then {
|
50 |
|
|
|
51 |
|
|
# Expect to find global/local symbols in each of text/data/bss.
|
52 |
|
|
|
53 |
|
|
# The exact format for some of this output is not necessarily
|
54 |
|
|
# ideal, particularly interpreting "p top" requires a fair bit of
|
55 |
|
|
# savvy about gdb's workings and the meaning of the "{}"
|
56 |
|
|
# construct. So the details maybe could be tweaked. But the
|
57 |
|
|
# basic purpose should be maintained, which is (a) users should be
|
58 |
|
|
# able to interact with these variables with some care (they have
|
59 |
|
|
# to know how to interpret them according to their real type,
|
60 |
|
|
# since gdb doesn't know the type), but (b) users should be able
|
61 |
|
|
# to detect that gdb does not know the type, rather than just
|
62 |
|
|
# being told they are ints or functions returning int like old
|
63 |
|
|
# versions of gdb used to do.
|
64 |
|
|
|
65 |
|
|
# On alpha (and other ecoff systems) the native compilers put
|
66 |
|
|
# out debugging info for non-aggregate return values of functions
|
67 |
|
|
# even without -g, which should be accepted.
|
68 |
|
|
# Irix5, even though it is ELF, counts as "ecoff" because it
|
69 |
|
|
# encapsulates ecoff debugging info in a .mdebug section.
|
70 |
|
|
# Irix6 gcc omits no debug info at all for static functions and
|
71 |
|
|
# variables, so all tests involving statics fail.
|
72 |
|
|
|
73 |
|
|
if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix5*" "mips-sgi-irix6*" }
|
74 |
|
|
gdb_test "p top" \
|
75 |
|
|
"\{(<(text variable|function), no debug info>|short \\(int\\)|short \\(\\))\} \[0-9a-fx]* "
|
76 |
|
|
if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix5*" "mips-sgi-irix6*" }
|
77 |
|
|
gdb_test "whatis top" \
|
78 |
|
|
"(<(text variable|function), no debug info>|short \\(int\\)|short \\(\\))"
|
79 |
|
|
if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix6*" }
|
80 |
|
|
gdb_test "ptype top" "(short|int) \\((|void|int||, )\\)"
|
81 |
|
|
|
82 |
|
|
if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix5*" }
|
83 |
|
|
setup_xfail "mips-sgi-irix6*"
|
84 |
|
|
gdb_test "p middle" \
|
85 |
|
|
"\{(<(text variable|function), no debug info>|short \\(int\\)|short \\(\\))\} \[0-9a-fx]* "
|
86 |
|
|
if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix5*" }
|
87 |
|
|
setup_xfail "mips-sgi-irix6*"
|
88 |
|
|
gdb_test "whatis middle" \
|
89 |
|
|
"(<(text variable|function), no debug info>|short \\(int\\)|short \\(\\))"
|
90 |
|
|
setup_xfail "mips-sgi-irix6*"
|
91 |
|
|
gdb_test "ptype middle" "(short|int) \\((|void|int||, )\\)"
|
92 |
|
|
|
93 |
|
|
gdb_test "p dataglobal" "= 3"
|
94 |
|
|
gdb_test "whatis dataglobal" \
|
95 |
|
|
"<(data variable|variable), no debug info>|int"
|
96 |
|
|
gdb_test "ptype dataglobal" "<(data variable|variable), no debug info>|int"
|
97 |
|
|
|
98 |
|
|
# The only symbol xcoff puts out for statics is for the TOC entry.
|
99 |
|
|
# Possible, but hairy, for gdb to deal. Right now it doesn't, it
|
100 |
|
|
# doesn't know the variables exist at all.
|
101 |
|
|
setup_xfail "rs6000*-*-aix*"
|
102 |
|
|
setup_xfail "powerpc*-*-aix*"
|
103 |
|
|
if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
|
104 |
|
|
if {$gcc_compiled} then { setup_xfail "mips-sgi-irix6*" }
|
105 |
|
|
gdb_test "p datalocal" "= 4"
|
106 |
|
|
setup_xfail "rs6000*-*-aix*"
|
107 |
|
|
setup_xfail "powerpc*-*-aix*"
|
108 |
|
|
if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
|
109 |
|
|
if {$gcc_compiled} then { setup_xfail "mips-sgi-irix6*" }
|
110 |
|
|
gdb_test "whatis datalocal" "<(data variable|variable), no debug info>"
|
111 |
|
|
setup_xfail "rs6000*-*-aix*"
|
112 |
|
|
setup_xfail "powerpc*-*-aix*"
|
113 |
|
|
if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
|
114 |
|
|
if {$gcc_compiled} then { setup_xfail "mips-sgi-irix6*" }
|
115 |
|
|
gdb_test "ptype datalocal" "<(data variable|variable), no debug info>"
|
116 |
|
|
|
117 |
|
|
gdb_test "p bssglobal" "= 0"
|
118 |
|
|
gdb_test "whatis bssglobal" "<(data variable|variable), no debug info>|int"
|
119 |
|
|
gdb_test "ptype bssglobal" "<(data variable|variable), no debug info>|int"
|
120 |
|
|
|
121 |
|
|
setup_xfail "rs6000*-*-aix*"
|
122 |
|
|
setup_xfail "powerpc*-*-aix*"
|
123 |
|
|
if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
|
124 |
|
|
if {$gcc_compiled} then { setup_xfail "mips-sgi-irix6*" }
|
125 |
|
|
gdb_test "p bsslocal" "= 0"
|
126 |
|
|
setup_xfail "rs6000*-*-aix*"
|
127 |
|
|
setup_xfail "powerpc*-*-aix*"
|
128 |
|
|
if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
|
129 |
|
|
if {$gcc_compiled} then { setup_xfail "mips-sgi-irix6*" }
|
130 |
|
|
gdb_test "whatis bsslocal" "<(data variable|variable), no debug info>"
|
131 |
|
|
setup_xfail "rs6000*-*-aix*"
|
132 |
|
|
setup_xfail "powerpc*-*-aix*"
|
133 |
|
|
if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
|
134 |
|
|
if {$gcc_compiled} then { setup_xfail "mips-sgi-irix6*" }
|
135 |
|
|
gdb_test "ptype bsslocal" "<(data variable|variable), no debug info>"
|
136 |
|
|
|
137 |
|
|
if {$gcc_compiled} then { setup_xfail "mips-sgi-irix6*" }
|
138 |
|
|
gdb_test "backtrace 10" "#0.*inner.*#1.*middle.*#2.*top.*#3.*main.*" \
|
139 |
|
|
"backtrace from inner in nodebug.exp"
|
140 |
|
|
# Or if that doesn't work, at least hope for the external symbols
|
141 |
|
|
# Commented out because if we aren't going to xfail the above test
|
142 |
|
|
# ever, why bother with a weaker test?
|
143 |
|
|
#gdb_test "backtrace 10" "#0.*inner.*#1.*#2.*top.*#3.*main.*" \
|
144 |
|
|
# "backtrace from inner in nodebug.exp for externals"
|
145 |
|
|
|
146 |
|
|
# This test is not as obscure as it might look. `p getenv ("TERM")'
|
147 |
|
|
# is a real-world example, at least on many systems.
|
148 |
|
|
if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix6*" }
|
149 |
|
|
if [target_info exists gdb,cannot_call_functions] {
|
150 |
|
|
setup_xfail "*-*-*" 2416
|
151 |
|
|
fail "p/c array_index(\"abcdef\",2)"
|
152 |
|
|
} else {
|
153 |
|
|
#
|
154 |
|
|
# On HP-UX, a support function (__d_plt_call) necessary to
|
155 |
|
|
# implement an inferior call is normally only available when
|
156 |
|
|
# the inferior was compiled with -g. Thus, we expect this
|
157 |
|
|
# testpoint to fail on HP-UX.
|
158 |
|
|
if { [istarget "hppa*-hpux*"] } {
|
159 |
|
|
send_gdb "p/c array_index(\"abcdef\",2)\n"
|
160 |
|
|
gdb_expect {
|
161 |
|
|
-re ".*Suggest linking executable with -g.*$gdb_prompt $" { pass "p/c array_index(\"abcdef\",2)" }
|
162 |
|
|
-re ".*Cannot find __wdb_call_dummy in.*end.o.*" { pass "p/c array_index(\"abcdef\",2)" }
|
163 |
|
|
-re ".*99 'c'.*" { pass "p/c array_index(\"abcdef\",2)" }
|
164 |
|
|
timeout { fail "(timeout) p/c array_index" }
|
165 |
|
|
}
|
166 |
|
|
} else {
|
167 |
|
|
# We need to up this because this can be really slow on some boards.
|
168 |
|
|
# (malloc() is called as part of the test).
|
169 |
|
|
set timeout 60;
|
170 |
|
|
gdb_test {p/c array_index("abcdef",2)} " = 99 'c'"
|
171 |
|
|
}
|
172 |
|
|
}
|
173 |
|
|
|
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 {$gcc_compiled} then { setup_xfail "mips-sgi-irix6*" }
|
177 |
|
|
if [runto middle] then {
|
178 |
|
|
gdb_test "backtrace 10" "#0.*middle.*#1.*top.*#2.*main.*" \
|
179 |
|
|
"backtrace from middle in nodebug.exp"
|
180 |
|
|
}
|
181 |
|
|
}
|