blob: e1f0475bc48a27c7680a6c4b03bc5aeaa6e061c5 [file] [log] [blame]
# Copyright 2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Print std::string::npos using c++ pretty-printer. Todo: convert this to a
# DWARF assembly test-case, such that the regression test also works for clang.
standard_testfile .cc
set opts {}
lappend opts debug
lappend opts c++
if {[have_compile_flag -fno-eliminate-unused-debug-symbols]} {
lappend opts additional_flags=-fno-eliminate-unused-debug-symbols
# Work around clang warning -Wunused-command-line-argument.
lappend opts nowarnings
}
if {[prepare_for_testing "failed to prepare" $testfile $srcfile $opts]} {
return
}
gdb_test_no_output "source $srcdir/$subdir/pretty-print.py" \
"load libstdc++ pretty printers"
gdb_test_no_output \
"python register_type_printers(gdb.current_objfile())" \
"register libstdc++ pretty printers"
gdb_test "whatis std::string" \
"std::string"
# Regression test for PR c++/33480. GDB used to hang, at least if the GDB
# build optimization flags triggered some uninitialized variables in the right
# way. I was not able to reproduce the hang with clang, due to different
# debug info.
#
# Prints different strings due to different debug info:
# - std::string::size_type with gcc, and
# - size_type with clang
gdb_test "whatis std::string::npos" \
"(std::string::)?size_type"