| 1 | # Copyright (C) 1997, 1998, 2007, 2008 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 3 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, see <http://www.gnu.org/licenses/>. |
| 15 | |
| 16 | if $tracelevel then { |
| 17 | strace $tracelevel |
| 18 | } |
| 19 | |
| 20 | set prms_id 0 |
| 21 | set bug_id 0 |
| 22 | |
| 23 | set testfile langs |
| 24 | set binfile ${objdir}/${subdir}/${testfile} |
| 25 | |
| 26 | if [is_remote host] { |
| 27 | remote_download host ${srcdir}/${subdir}/langs1.f |
| 28 | remote_download host ${srcdir}/${subdir}/langs2.cxx |
| 29 | } |
| 30 | |
| 31 | |
| 32 | if { [gdb_compile "${srcdir}/${subdir}/langs0.c" "${binfile}0.o" object {debug}] != "" } { |
| 33 | untested langs.exp |
| 34 | return -1 |
| 35 | } |
| 36 | |
| 37 | if { [gdb_compile "${srcdir}/${subdir}/langs1.c" "${binfile}1.o" object {debug}] != "" } { |
| 38 | untested langs.exp |
| 39 | return -1 |
| 40 | } |
| 41 | |
| 42 | if { [gdb_compile "${srcdir}/${subdir}/langs2.c" "${binfile}2.o" object {debug}] != "" } { |
| 43 | untested langs.exp |
| 44 | return -1 |
| 45 | } |
| 46 | |
| 47 | if { [gdb_compile "${binfile}0.o ${binfile}1.o ${binfile}2.o" ${binfile} executable {debug}] != "" } { |
| 48 | untested langs.exp |
| 49 | return -1 |
| 50 | } |
| 51 | |
| 52 | set oldtimeout $timeout |
| 53 | set timeout 10 |
| 54 | |
| 55 | |
| 56 | |
| 57 | # Create and source the file that provides information about the compiler |
| 58 | # used to compile the test case. |
| 59 | if [get_compiler_info ${binfile}] { |
| 60 | return -1; |
| 61 | } |
| 62 | |
| 63 | gdb_exit |
| 64 | gdb_start |
| 65 | gdb_reinitialize_dir $srcdir/$subdir |
| 66 | gdb_load $binfile |
| 67 | |
| 68 | gdb_test_multiple "b langs0" "break on nonexistent function in langs.exp" { |
| 69 | -re "Function \"langs0\" not defined\..*Make breakpoint pending on future shared library load.*y or .n.. $" { |
| 70 | |
| 71 | gdb_test "n" "" "break on nonexistent function in langs.exp" |
| 72 | } |
| 73 | -re "Breakpoint .* (deferred).*$gdb_prompt $" { |
| 74 | pass "break on nonexistent function in langs.exp" |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | if {$hp_aCC_compiler} { |
| 79 | set isfixed 1 |
| 80 | set lang c\\+\\+ |
| 81 | set ext cxx |
| 82 | set foo_func foo__Fi__Fi |
| 83 | set do_func do::langs0 |
| 84 | } else { |
| 85 | if {$hp_cc_compiler} { |
| 86 | set isfixed 1 |
| 87 | set lang c |
| 88 | set ext c |
| 89 | } else { |
| 90 | set isfixed 0 |
| 91 | } |
| 92 | set foo_func foo__Fi |
| 93 | set do_func langs0__2do |
| 94 | } |
| 95 | |
| 96 | if [runto csub] then { |
| 97 | |
| 98 | if { !$isfixed } { set lang c } |
| 99 | gdb_test "show language" "currently $lang\".*" \ |
| 100 | "show language at csub in langs.exp" |
| 101 | # On some machines, foo doesn't get demangled because the N_SOL for |
| 102 | # langs2.cxx is seen only after the function stab for foo. So |
| 103 | # the following regexps are kludged to accept foo__Fi as well as foo, |
| 104 | # even though only the latter is correct. I haven't tried to xfail it |
| 105 | # because it depends on details of the compiler. |
| 106 | |
| 107 | # Take out xfail. This test has been passing for some time now. |
| 108 | #if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" } |
| 109 | gdb_test "bt" "#0.*csub.*#1.*(foo|$foo_func) \\(.*#2.*cppsub_ .*#3.*fsub.*#4.*$do_func \\(.*#5 \[0-9a-fx\]* in main.*" "backtrace in langs.exp" |
| 110 | |
| 111 | if { !$isfixed } { set lang c\\+\\+; set ext cxx } |
| 112 | if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" } |
| 113 | gdb_test "up" ".* in (foo|$foo_func).* at langs2\\.$ext.*return csub \\(.*" \ |
| 114 | "up to foo in langs.exp" |
| 115 | gdb_test "show language" "currently $lang.*" \ |
| 116 | "show language at foo in langs.exp" |
| 117 | |
| 118 | if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" } |
| 119 | gdb_test "up" ".* in cppsub_ .* at langs2\\.$ext.*return foo \\(.*" \ |
| 120 | "up to cppsub_ in langs.exp" |
| 121 | gdb_test "show language" "currently $lang.*" \ |
| 122 | "show language at cppsub_ in langs.exp" |
| 123 | |
| 124 | if { !$isfixed } { set lang fortran } |
| 125 | if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" } |
| 126 | gdb_test "up" ".* in fsub.* at langs1\\.f.*" \ |
| 127 | "up to fsub in langs.exp" |
| 128 | gdb_test "show language" "currently $lang.*" \ |
| 129 | "show language at fsub in langs.exp" |
| 130 | |
| 131 | # Take out xfail. This test has been passing for sometime now. |
| 132 | #if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" } |
| 133 | if { !$isfixed } { set lang c } |
| 134 | gdb_test "up" ".* in $do_func .* at .*langs0\\.c.*return fsub.*" \ |
| 135 | "up to langs0__2do in langs.exp" |
| 136 | gdb_test "show language" "currently $lang\".*" \ |
| 137 | "show language at langs0__2do in langs.exp" |
| 138 | |
| 139 | gdb_test "up" ".* in main .* at .*langs0\\.c.*if \\(langs0__2do \\(.*" \ |
| 140 | "up to main in langs.exp" |
| 141 | gdb_test "show language" "currently $lang\".*" \ |
| 142 | "show language at main in langs.exp" |
| 143 | |
| 144 | if [target_info exists gdb,noresults] { return } |
| 145 | |
| 146 | if [target_info exists use_gdb_stub] { |
| 147 | gdb_breakpoint "exit" |
| 148 | gdb_test "cont" "Breakpoint .*exit.*" "continue to exit in langs.exp" |
| 149 | } else { |
| 150 | gdb_test "cont" "Program exited normally\\..*" \ |
| 151 | "continue to exit in langs.exp" |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | gdb_exit |
| 156 | gdb_start |
| 157 | gdb_reinitialize_dir $srcdir/$subdir |
| 158 | gdb_load $binfile |
| 159 | |
| 160 | # Try exercising the "minimal" language a bit... |
| 161 | |
| 162 | if [runto csub] then { |
| 163 | gdb_test "set lang minimal" \ |
| 164 | "Warning: the current language does not match this frame." \ |
| 165 | "set lang to minimal" |
| 166 | |
| 167 | gdb_test "print x" " = 5000" "print parameter value" |
| 168 | } |
| 169 | |
| 170 | set timeout $oldtimeout |
| 171 | return 0 |