1 # Copyright 2025 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 # Print std::string::npos using c++ pretty-printer. Todo: convert this to a 17 # DWARF assembly test-case, such that the regression test also works for clang. 18 19 standard_testfile .cc 20 21 set opts {} 22 lappend opts debug 23 lappend opts c++ 24 if {[have_compile_flag -fno-eliminate-unused-debug-symbols]} { 25 lappend opts additional_flags=-fno-eliminate-unused-debug-symbols 26 # Work around clang warning -Wunused-command-line-argument. 27 lappend opts nowarnings 28 } 29 30 if {[prepare_for_testing "failed to prepare" $testfile $srcfile $opts]} { 31 return 32 } 33 34 gdb_test_no_output "source $srcdir/$subdir/pretty-print.py" \ 35 "load libstdc++ pretty printers" 36 37 gdb_test_no_output \ 38 "python register_type_printers(gdb.current_objfile())" \ 39 "register libstdc++ pretty printers" 40 41 gdb_test "whatis std::string" \ 42 "std::string" 43 44 # Regression test for PR c++/33480. GDB used to hang, at least if the GDB 45 # build optimization flags triggered some uninitialized variables in the right 46 # way. I was not able to reproduce the hang with clang, due to different 47 # debug info. 48 # 49 # Prints different strings due to different debug info: 50 # - std::string::size_type with gcc, and 51 # - size_type with clang 52 gdb_test "whatis std::string::npos" \ 53 "(std::string::)?size_type" 54