1 # Copyright (C) 2016-2024 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 # Test name lookup. 17 18 load_lib rust-support.exp 19 require allow_rust_tests 20 require {can_compile rust} 21 22 standard_testfile .rs 23 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug rust}]} { 24 return -1 25 } 26 27 set line [gdb_get_line_number "set breakpoint here"] 28 if {![runto ${srcfile}:$line]} { 29 untested "could not run to breakpoint" 30 return -1 31 } 32 33 # Currently a closure type is not described by rustc. 34 # https://github.com/rust-lang/rust/issues/33121 35 # gdb_test "call f2()" "lambda f2" 36 37 if ![target_info exists gdb,noinferiorio] { 38 gdb_test_stdio "call f3()" "mod1::inner::innest::f3" 39 gdb_test_stdio "call self::f2()" "mod1::inner::innest::f2" 40 gdb_test_stdio "call self::super::f2()" "mod1::inner::f2" 41 gdb_test_stdio "call super::f2()" "mod1::inner::f2" 42 gdb_test_stdio "call self::super::super::f2()" "mod1::f2" 43 gdb_test_stdio "call super::super::f2()" "mod1::f2" 44 gdb_test_stdio "call ::f2()" "::f2" 45 gdb_test_stdio "call extern modules::mod1::f2()" "mod1::f2" 46 } 47 gdb_test "call super::super::super::f2()" \ 48 "Too many super:: uses from 'modules::mod1::inner::innest'" 49 50 gdb_test_sequence "ptype ::Generic::<::Generic<::Type> >" "" { 51 "type = struct modules::Generic<modules::Generic<modules::Type>> \\(" 52 " modules::Generic<modules::Type>," 53 "\\)" 54 } 55 56 gdb_test_sequence "ptype ::Generic::<::Generic<extern modules::Type> >" "" { 57 "type = struct modules::Generic<modules::Generic<modules::Type>> \\(" 58 " modules::Generic<modules::Type>," 59 "\\)" 60 } 61 62 gdb_test_sequence "ptype ::Generic::<::Generic<::mod1::Type>>" "" { 63 "type = struct modules::Generic<modules::Generic<modules::mod1::Type>> \\(" 64 " modules::Generic<modules::mod1::Type>," 65 "\\)" 66 } 67 68 gdb_test_sequence "ptype ::Generic::<::Generic<super::Type>>" "" { 69 "type = struct modules::Generic<modules::Generic<modules::mod1::inner::Type>> \\(" 70 " modules::Generic<modules::mod1::inner::Type>," 71 "\\)" 72 } 73 74 gdb_test_sequence "ptype ::Generic::<::Generic<self::Type>>" "" { 75 "type = struct modules::Generic<modules::Generic<modules::mod1::inner::innest::Type>> \\(" 76 " modules::Generic<modules::mod1::inner::innest::Type>," 77 "\\)" 78 } 79 80 # Not working yet. 81 # gdb_test_sequence "ptype ::Generic<Type>" "" ... 82 83 # Some basic linespec tests. 84 foreach mod {mod1::inner::innest mod1::inner mod1 {}} { 85 if {$mod != ""} { 86 append mod :: 87 } 88 gdb_breakpoint modules::${mod}f2 message 89 gdb_breakpoint "*::${mod}f2" message 90 } 91 92 gdb_test "print ::TWENTY_THREE" " = 23" 93 94 gdb_test "print super TWENTY_THREE" "'::' expected" 95 gdb_test "print super::23" "identifier expected" 96 gdb_test "ptype ::Generic::<::Generic<self::Type" "'>' expected" 97