1# Test that things still (sort of) work when compiled without -g. 2 3if $tracelevel then { 4 strace $tracelevel 5} 6 7set prms_id 0 8set bug_id 0 9 10set testfile nodebug 11set srcfile ${testfile}.c 12set binfile ${objdir}/${subdir}/${testfile} 13 14# Get rid of any -g options (including -gstabs, -gdwarf, etc... 15if [info exists target_info(target,cflags)] { 16 set saved_cflags $target_info(target,cflags) 17 regsub -all -- {[ ]-g[^ ]*} $target_info(target,cflags) { } target_info(target,cflags) 18} 19 20if { [compile "${srcdir}/${subdir}/${srcfile} -o ${binfile}"] != "" } { 21 perror "Couldn't compile ${srcfile}" 22 return -1 23} 24 25# Create and source the file that provides information about the compiler 26# used to compile the test case. 27execute_anywhere "rm -f ${binfile}.ci" 28if { [compile "-E ${srcdir}/${subdir}/compiler.c > ${binfile}.ci"] != "" } { 29 perror "Couldn't make ${binfile}.ci file" 30 return -1 31} 32 33if [info exists target_info(target,cflags)] { 34 set target_info(target,cflags) $saved_cflags 35} 36 37source ${binfile}.ci 38 39gdb_reinitialize_dir $srcdir/$subdir 40gdb_load $binfile 41 42if [runto inner] then { 43 44 # Expect to find global/local symbols in each of text/data/bss. 45 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. 57 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. 61 # Irix5, even though it is ELF, counts as "ecoff" because it 62 # encapsulates ecoff debugging info in a .mdebug section. 63 64 if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix5*" } 65 gdb_test "p top" \ 66 "{(<(text variable|function), no debug info>|short \\(\\))} \[0-9a-fx]* <top>" 67 if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix5*" } 68 gdb_test "whatis top" \ 69 "(<(text variable|function), no debug info>|short \\(\\))" 70 gdb_test "ptype top" "(short|int) \\((|<non-float parameter>|<non-float parameter>, <non-float parameter>)\\)" 71 72 if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix5*" } 73 gdb_test "p middle" \ 74 "{(<(text variable|function), no debug info>|short \\(\\))} \[0-9a-fx]* <middle>" 75 if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix5*" } 76 gdb_test "whatis middle" \ 77 "(<(text variable|function), no debug info>|short \\(\\))" 78 gdb_test "ptype middle" "(short|int) \\((|<non-float parameter>|<non-float parameter>, <non-float parameter>)\\)" 79 80 gdb_test "p dataglobal" "= 3" 81 gdb_test "whatis dataglobal" \ 82 "<(data variable|variable), no debug info>" 83 gdb_test "ptype dataglobal" "<(data variable|variable), no debug info>" 84 85 # The only symbol xcoff puts out for statics is for the TOC entry. 86 # Possible, but hairy, for gdb to deal. Right now it doesn't, it 87 # doesn't know the variables exist at all. 88 setup_xfail "rs6000*-*-aix*" 89 setup_xfail "powerpc*-*-aix*" 90 if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" } 91 gdb_test "p datalocal" "= 4" 92 setup_xfail "rs6000*-*-aix*" 93 setup_xfail "powerpc*-*-aix*" 94 if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" } 95 gdb_test "whatis datalocal" "<(data variable|variable), no debug info>" 96 setup_xfail "rs6000*-*-aix*" 97 setup_xfail "powerpc*-*-aix*" 98 if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" } 99 gdb_test "ptype datalocal" "<(data variable|variable), no debug info>" 100 101 gdb_test "p bssglobal" "= 0" 102 gdb_test "whatis bssglobal" "<(data variable|variable), no debug info>" 103 gdb_test "ptype bssglobal" "<(data variable|variable), no debug info>" 104 105 setup_xfail "rs6000*-*-aix*" 106 setup_xfail "powerpc*-*-aix*" 107 if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" } 108 gdb_test "p bsslocal" "= 0" 109 setup_xfail "rs6000*-*-aix*" 110 setup_xfail "powerpc*-*-aix*" 111 if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" } 112 gdb_test "whatis bsslocal" "<(data variable|variable), no debug info>" 113 setup_xfail "rs6000*-*-aix*" 114 setup_xfail "powerpc*-*-aix*" 115 if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" } 116 gdb_test "ptype bsslocal" "<(data variable|variable), no debug info>" 117 118 gdb_test "backtrace" "#0.*inner.*#1.*middle.*#2.*top.*#3.*main.*" \ 119 "backtrace from inner in nodebug.exp" 120 # Or if that doesn't work, at least hope for the external symbols 121 # Commented out because if we aren't going to xfail the above test 122 # ever, why bother with a weaker test? 123 #gdb_test "backtrace" "#0.*inner.*#1.*#2.*top.*#3.*main.*" \ 124 # "backtrace from inner in nodebug.exp for externals" 125 126 # This test is not as obscure as it might look. `p getenv ("TERM")' 127 # is a real-world example, at least on many systems. 128 setup_xfail "h8300*-*-*" 129 if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" } 130 gdb_test {p/c array_index("abcdef",2)} " = 99 'c'" 131 132 # Now, try that we can give names of file-local symbols which happen 133 # to be unique, and have it still work 134 if [runto middle] then { 135 setup_xfail "h8300*-*-*" 136 gdb_test "backtrace" "#0.*middle.*#1.*top.*#2.*main.*" \ 137 "backtrace from middle in nodebug.exp" 138 } 139} 140