along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
+#include "diagnostics.h"
#include <errno.h>
#include "gdbsupport/scoped_fd.h"
#include "debuginfod-support.h"
static bool
debuginfod_is_enabled ()
{
- const char *urls = getenv (DEBUGINFOD_URLS_ENV_VAR);
+ const char *urls = skip_spaces (getenv (DEBUGINFOD_URLS_ENV_VAR));
- if (urls == nullptr || urls[0] == '\0'
- || debuginfod_enabled == debuginfod_off)
+ if (debuginfod_enabled == debuginfod_off
+ || urls == nullptr
+ || *urls == '\0')
return false;
if (debuginfod_enabled == debuginfod_ask)
gdb::string_view url_view (urls);
while (true)
{
- url_view = url_view.substr (url_view.find_first_not_of (' '));
- if (url_view.empty ())
+ size_t off = url_view.find_first_not_of (' ');
+ if (off == gdb::string_view::npos)
break;
- size_t off = url_view.find_first_of (' ');
+ url_view = url_view.substr (off);
+ /* g++ 11.2.1 on s390x, g++ 11.3.1 on ppc64le and g++ 11 on
+ hppa seem convinced url_view might be of SIZE_MAX length.
+ And so complains because the length of an array can only
+ be PTRDIFF_MAX. */
+ DIAGNOSTIC_PUSH
+ DIAGNOSTIC_IGNORE_STRINGOP_OVERREAD
+ off = url_view.find_first_of (' ');
+ DIAGNOSTIC_POP
gdb_printf
(_(" <%ps>\n"),
styled_string (file_name_style.style (),
&dname));
debuginfod_set_user_data (c, nullptr);
- if (debuginfod_verbose > 0 && fd.get () < 0 && fd.get () != -ENOENT)
+ if (fd.get () < 0 && fd.get () != -ENOENT)
gdb_printf (_("Download failed: %s. Continuing without source file %ps.\n"),
safe_strerror (-fd.get ()),
styled_string (file_name_style.style (), srcpath));
&dname));
debuginfod_set_user_data (c, nullptr);
- if (debuginfod_verbose > 0 && fd.get () < 0 && fd.get () != -ENOENT)
+ if (fd.get () < 0 && fd.get () != -ENOENT)
gdb_printf (_("Download failed: %s. Continuing without debug info for %ps.\n"),
safe_strerror (-fd.get ()),
styled_string (file_name_style.style (), filename));
scoped_fd fd (debuginfod_find_executable (c, build_id, build_id_len, &dname));
debuginfod_set_user_data (c, nullptr);
- if (debuginfod_verbose > 0 && fd.get () < 0 && fd.get () != -ENOENT)
+ if (fd.get () < 0 && fd.get () != -ENOENT)
gdb_printf (_("Download failed: %s. " \
"Continuing without executable for %ps.\n"),
safe_strerror (-fd.get ()),
#if defined(HAVE_LIBDEBUGINFOD)
debuginfod_enabled = value;
#else
- error (NO_IMPL);
+ /* Disabling debuginfod when gdb is not built with it is a no-op. */
+ if (value != debuginfod_off)
+ error (NO_IMPL);
#endif
}