Home | History | Annotate | Line # | Download | only in gdb.base
      1 # -*- coding: utf-8 -*- */
      2 
      3 # This testcase is part of GDB, the GNU debugger.
      4 
      5 # Copyright 2017-2024 Free Software Foundation, Inc.
      6 
      7 # This program is free software; you can redistribute it and/or modify
      8 # it under the terms of the GNU General Public License as published by
      9 # the Free Software Foundation; either version 3 of the License, or
     10 # (at your option) any later version.
     11 #
     12 # This program is distributed in the hope that it will be useful,
     13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 # GNU General Public License for more details.
     16 #
     17 # You should have received a copy of the GNU General Public License
     18 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
     19 
     20 # Test GDB's support for UTF-8 C/C++ identifiers.
     21 
     22 load_lib completion-support.exp
     23 
     24 if { [is_c_compiler_gcc] } {
     25     # Gcc fully supports fextended-identifiers starting GCC 5.
     26     require {expr [gcc_major_version] >= 5}
     27 }
     28 require {have_host_locale C.UTF-8}
     29 
     30 standard_testfile
     31 
     32 # Enable basic use of UTF-8.  LC_ALL gets reset for each testfile.
     33 setenv LC_ALL C.UTF-8
     34 
     35 if { [prepare_for_testing "failed to prepare" ${testfile} [list $srcfile]] } {
     36     return -1
     37 }
     38 
     39 if ![runto done] {
     40     return
     41 }
     42 
     43 # Test expressions.
     44 gdb_test "print g_s.num_" " = 1000"
     45 gdb_test "print num_" " = 2000"
     46 
     47 # Test linespecs/breakpoints.
     48 gdb_test "break funo2" "Breakpoint $decimal at .*$srcfile.*"
     49 
     50 set test "info breakpoints"
     51 gdb_test_multiple $test $test {
     52     -re "in funo2 at .*$srcfile.*$gdb_prompt $" {
     53 	pass $test
     54     }
     55 }
     56 
     57 gdb_test "continue" \
     58     "Breakpoint $decimal, funo2 \\(\\) at .*$srcfile.*"
     59 
     60 # Unload symbols from shared libraries to avoid random symbol and file
     61 # names getting in the way of completion.
     62 gdb_test_no_output "nosharedlibrary"
     63 
     64 # Tests below are about tab-completion, which doesn't work if readline
     65 # library isn't used.  Check it first.
     66 
     67 if { ![readline_is_used] } {
     68     untested "no tab completion support without readline"
     69     return -1
     70 }
     71 
     72 # Test linespec completion.
     73 
     74 # A unique completion.
     75 test_gdb_complete_unique "break my_fun" "break my_funo"
     76 
     77 # A multiple-matches completion:
     78 
     79 # kfailed because gdb/readline display the completion match list like
     80 # this, with no separating space:
     81 #
     82 #  (gdb) break funo[TAB]
     83 #  funo1funo2
     84 #
     85 # ... which is bogus.
     86 setup_kfail "gdb/23211" "*-*-*"
     87 test_gdb_complete_multiple "break " "fun" "o" {"funo1" "funo2"}
     88 
     89 # Test expression completion.
     90 test_gdb_complete_unique "print g_s.num" "print g_s.num_"
     91