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