mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-28 01:50:48 +00:00
Two commits ago, in the commit titled:
gdb: make get_chars_per_line return an unsigned value
A bodge was added in cli-out.c so that progress bars (as seen when
debuginfod downloads a file) would be disabled when the output
terminal had unlimited width.
The hack was added because this previous commit fixed a bug such that
progress bars could now be displayed in very wide, or even on
unlimited width output terminals. By fixing this bug, progress bars
were now being displayed when running the testsuite, as the testsuite
sets the output terminal to unlimited width.
To avoid breaking the tests, this previous commit added a bodge such
that on unlimited width output terminals, progress bars would always
be disabled. This got the tests passing again, but isn't an ideal
solution.
This commit cleans things up. We now have a new setting:
set progress-bars enabled on|off
show progress-bars enabled
This setting allows progress bars to be turned off. The tests are
then updated to explicitly turn off progress bars. The bodge from the
earlier commit is then removed.
Now, progress bars should display correctly on any width of output
terminal over 50 characters, the minimum required. And the debuginfod
tests should all pass as they turn off progress bars.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Tom Tromey <tom@tromey.com>
157 lines
5.7 KiB
Plaintext
157 lines
5.7 KiB
Plaintext
# Copyright 2022-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/>.
|
|
#
|
|
# This test triggers the "separate debug info file has no debug info" warning by replacing
|
|
# the build-id based .debug file with the stripped binary and then loading it to gdb.
|
|
# It then also sets up local debuginfod server with the correct debug file to download
|
|
# to make sure no warnings are emitted.
|
|
|
|
|
|
standard_testfile
|
|
|
|
load_lib debuginfod-support.exp
|
|
|
|
require allow_debuginfod_tests
|
|
|
|
if {[build_executable "build executable" ${testfile} ${srcfile} \
|
|
{debug build-id}] == -1} {
|
|
return -1
|
|
}
|
|
|
|
# Split debug information from BINFILE into BINFILE.debug.
|
|
#
|
|
# By passing the "no-debuglink" flag we prevent this proc from adding
|
|
# a .gnu_debuglink section to BINFILE. Any lookup of the debug
|
|
# information by GDB will need to be done based on the build-id.
|
|
if {[gdb_gnu_strip_debug $binfile no-debuglink]} {
|
|
unsupported "cannot produce separate debug info files"
|
|
return -1
|
|
}
|
|
|
|
# Get the .build-id/PREFIX/SUFFIX.debug file name, and convert it to
|
|
# an absolute path, this is where we will place the debug information.
|
|
set build_id_debug_file \
|
|
[standard_output_file [build_id_debug_filename_get $binfile]]
|
|
|
|
# Get the BINFILE.debug filename. This is the file we should be
|
|
# moving to the BUILD_ID_DEBUG_FILE location, but we won't, we're going
|
|
# to move something else there instead.
|
|
set debugfile [standard_output_file "${binfile}.debug"]
|
|
|
|
# Move debugfile to the directory to be used by the debuginfod
|
|
# server.
|
|
set debuginfod_debugdir [standard_output_file "debug"]
|
|
remote_exec build "mkdir $debuginfod_debugdir"
|
|
remote_exec build "mv $debugfile $debuginfod_debugdir"
|
|
|
|
# Create the .build-id/PREFIX directory name from
|
|
# .build-id/PREFIX/SUFFIX.debug filename.
|
|
set debugdir [file dirname ${build_id_debug_file}]
|
|
remote_exec build "mkdir -p $debugdir"
|
|
|
|
# Now move the stripped executable into the .build-id directory
|
|
# instead of the debug information. Later on we're going to try and
|
|
# load this into GDB. GDB will then try to find the separate debug
|
|
# information, which will point back at this file, which also doesn't
|
|
# have debug information, which could cause a loop. But GDB will spot
|
|
# this and give a warning.
|
|
remote_exec build "mv ${binfile} ${build_id_debug_file}"
|
|
|
|
# Now start GDB.
|
|
clean_restart
|
|
|
|
# Tell GDB where to look for the .build-id directory.
|
|
set debug_file_directory [standard_output_file ""]
|
|
gdb_test_no_output "set debug-file-directory ${debug_file_directory}" \
|
|
"set debug-file-directory"
|
|
|
|
# Now load the file into GDB, and look for the warning.
|
|
set debug_file_re [string_to_regexp $build_id_debug_file]
|
|
gdb_test "file ${build_id_debug_file}" \
|
|
[multi_line \
|
|
"Reading symbols from $debug_file_re\\.\\.\\." \
|
|
"warning: \"$debug_file_re\": separate debug info file has no debug info" \
|
|
"\\(No debugging symbols found in \[^\r\n\]+\\)"] \
|
|
"load test file, expect a warning"
|
|
|
|
# Do the same thing again, but this time check that the styling is
|
|
# correct.
|
|
with_test_prefix "check styling" {
|
|
with_ansi_styling_terminal {
|
|
clean_restart
|
|
|
|
gdb_test_no_output "set debug-file-directory ${debug_file_directory}" \
|
|
"set debug-file-directory"
|
|
|
|
# Now load the file into GDB, and look for the warning.
|
|
set debug_file_re [style [string_to_regexp $build_id_debug_file] file]
|
|
|
|
gdb_test "file ${build_id_debug_file}" \
|
|
[multi_line \
|
|
"Reading symbols from $debug_file_re\\.\\.\\." \
|
|
"warning: \"$debug_file_re\": separate debug info file has no debug info" \
|
|
"\\(No debugging symbols found in \[^\r\n\]+\\)"] \
|
|
"load test file, expect a warning"
|
|
}
|
|
}
|
|
|
|
# Now we should close GDB.
|
|
gdb_exit
|
|
|
|
# Create CACHE and DB directories ready for debuginfod to use.
|
|
prepare_for_debuginfod cache db
|
|
|
|
# Start debuginfod server and test debuginfo is downloaded from
|
|
# it and we can se no warnings anymore.
|
|
proc_with_prefix local_debuginfod { } {
|
|
global db debuginfod_debugdir cache build_id_debug_file
|
|
|
|
set url [start_debuginfod $db $debuginfod_debugdir]
|
|
if {$url eq ""} {
|
|
unresolved "failed to start debuginfod server"
|
|
return
|
|
}
|
|
|
|
# Point the client to the server.
|
|
setenv DEBUGINFOD_URLS $url
|
|
|
|
# GDB should now find the symbol and source files.
|
|
clean_restart
|
|
|
|
# Enable debuginfod and fetch the debuginfo.
|
|
gdb_test_no_output "set debuginfod enabled on"
|
|
gdb_test_no_output "set progress-bars enabled off"
|
|
|
|
# "separate debug info file has no debug info" warning should not be
|
|
# reported now because the correct debuginfo should be fetched from
|
|
# debuginfod.
|
|
gdb_test "file ${build_id_debug_file}" \
|
|
[multi_line \
|
|
"Reading symbols from ${build_id_debug_file}\\.\\.\\." \
|
|
"Downloading\[^\r\n\]*separate debug info for ${build_id_debug_file}\\.\\.\\." \
|
|
"Reading symbols from ${cache}/\[^\r\n\]+\\.\\.\\.(?:\r\nExpanding full symbols from \[^\r\n\]+)*"] \
|
|
"debuginfod running, info downloaded, no warnings"
|
|
}
|
|
|
|
# Restart GDB, and load the file, this time we should correctly get
|
|
# the debug symbols from the server, and should not see the warning.
|
|
with_debuginfod_env $cache {
|
|
local_debuginfod
|
|
}
|
|
|
|
stop_debuginfod
|
|
# Spare debug files may confuse testsuite runs in the future.
|
|
remote_exec build "rm -f $debugfile"
|