* dwarf.c (use_debuginfod): New variable. Set to 1.
(load_separate_debug_info): Only call
debuginfod_fetch_separate_debug_info is use_debuginfod is true.
(dwarf_select_sections_by_names): Add do-not-use-debuginfod and
use-debuginfod options.
(dwarf_select_sections_by_letters): Add D and E options.
* dwarf.h (use_debuginfod): New extern.
* objdump.c (usage): Mention the new options.
* readelf.c (usage): Likewise.
* doc/binutils.texi: Document the new options.
* doc/debug-options.texi: Describe the new options.
* NEWS: Mention the new feature.
* testsuite/binutils-all/debuginfod.exp: Add tests of the new
options.
+2022-03-10 Nick Clifton <nickc@redhat.com>
+
+ * dwarf.c (use_debuginfod): New variable. Set to 1.
+ (load_separate_debug_info): Only call
+ debuginfod_fetch_separate_debug_info is use_debuginfod is true.
+ (dwarf_select_sections_by_names): Add do-not-use-debuginfod and
+ use-debuginfod options.
+ (dwarf_select_sections_by_letters): Add D and E options.
+ * dwarf.h (use_debuginfod): New extern.
+ * objdump.c (usage): Mention the new options.
+ * readelf.c (usage): Likewise.
+ * doc/binutils.texi: Document the new options.
+ * doc/debug-options.texi: Describe the new options.
+ * NEWS: Mention the new feature.
+ * testsuite/binutils-all/debuginfod.exp: Add tests of the new
+ options.
+
2021-03-06 Maciej W. Rozycki <macro@orcam.me.uk>
* testsuite/binutils-all/mips/mips1-branch-alias.d: New test.
-*- text -*-
+* Add an option to objdump and readelf to prevent attempts to access debuginfod
+ servers when following links.
+
Changes in 2.38:
* elfedit: Add --output-abiversion option to update ABIVERSION.
@option{--dwarf}[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=str-offsets,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index,=addr,=cu_index,=links]]
[@option{-WK}|@option{--dwarf=follow-links}]
[@option{-WN}|@option{--dwarf=no-follow-links}]
+ [@option{-wD}|@option{--dwarf=use-debuginfod}]
+ [@option{-wE}|@option{--dwarf=do-not-use-debuginfod}]
[@option{-L}|@option{--process-links}]
[@option{--ctf=}@var{section}]
[@option{-G}|@option{--stabs}]
@option{--debug-dump}[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=str-offsets,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index,=addr,=cu_index,=links]]
[@option{-wK}|@option{--debug-dump=follow-links}]
[@option{-wN}|@option{--debug-dump=no-follow-links}]
+ [@option{-wD}|@option{--debug-dump=use-debuginfod}]
+ [@option{-wE}|@option{--debug-dump=do-not-use-debuginfod}]
[@option{-P}|@option{--process-links}]
[@option{--dwarf-depth=@var{n}}]
[@option{--dwarf-start=@var{n}}]
@cindex separate debug files
debuginfod is a web service that indexes ELF/DWARF debugging resources
-by build-id and serves them over HTTP.
+by build-id and serves them over HTTP. For more information see:
+@emph{https://sourceware.org/elfutils/Debuginfod.html}
Binutils can be built with the debuginfod client library
@code{libdebuginfod} using the @option{--with-debuginfod} configure option.
debuginfod is packaged with elfutils, starting with version 0.178.
You can get the latest version from `https://sourceware.org/elfutils/'.
+The DWARF info dumping tools (@command{readelf} and @command{objdump})
+have options to control when they should access the debuginfod
+servers. By default this access is enabled.
+
@node Reporting Bugs
@chapter Reporting Bugs
@cindex bugs
@option{--enable-follow-debug-links=no} options. If these are not
used then the default is to enable the following of debug links.
+Note - if support for the debuginfod protocol was enabled when the
+binutils were built then this option will also include an attempt to
+contact any debuginfod servers mentioned in the @var{DEBUGINFOD_URLS}
+environment variable. This could take some time to resolve. This
+behaviour can be disabled via the @option{=do-not-use-debuginfod} debug
+option.
+
@item N
@itemx =no-follow-links
Disables the following of links to separate debug info files.
+@item D
+@itemx =use-debuginfod
+Enables contacting debuginfod servers if there is a need to follow
+debug links. This is the default behaviour.
+
+@item E
+@itemx =do-not-use-debuginfod
+Disables contacting debuginfod servers when there is a need to follow
+debug links.
+
@item l
@itemx =rawline
Displays the contents of the @samp{.debug_line} section in a raw
int do_wide;
int do_debug_links;
int do_follow_links = DEFAULT_FOR_FOLLOW_LINKS;
+#ifdef HAVE_LIBDEBUGINFOD
+int use_debuginfod = 1;
+#endif
bool do_checks;
int dwarf_cutoff_level = -1;
return false;
}
-#endif
+#endif /* HAVE_LIBDEBUGINFOD */
static void *
load_separate_debug_info (const char * main_filename,
{
char * tmp_filename;
- if (debuginfod_fetch_separate_debug_info (xlink,
- & tmp_filename,
- file))
+ if (use_debuginfod
+ && debuginfod_fetch_separate_debug_info (xlink,
+ & tmp_filename,
+ file))
{
/* File successfully downloaded from server, replace
debug_filename with the file's path. */
warn (_("tried: %s\n"), debug_filename);
#if HAVE_LIBDEBUGINFOD
- {
- char *urls = getenv (DEBUGINFOD_URLS_ENV_VAR);
- if (urls == NULL)
- urls = "";
+ if (use_debuginfod)
+ {
+ char *urls = getenv (DEBUGINFOD_URLS_ENV_VAR);
- warn (_("tried: DEBUGINFOD_URLS=%s\n"), urls);
- }
+ if (urls == NULL)
+ urls = "";
+
+ warn (_("tried: DEBUGINFOD_URLS=%s\n"), urls);
+ }
#endif
}
{ "aranges", & do_debug_aranges, 1 },
{ "cu_index", & do_debug_cu_index, 1 },
{ "decodedline", & do_debug_lines, FLAG_DEBUG_LINES_DECODED },
+#ifdef HAVE_LIBDEBUGINFOD
+ { "do-not-use-debuginfod", & use_debuginfod, 0 },
+#endif
{ "follow-links", & do_follow_links, 1 },
{ "frames", & do_debug_frames, 1 },
{ "frames-interp", & do_debug_frames_interp, 1 },
{ "trace_abbrev", & do_trace_abbrevs, 1 },
{ "trace_aranges", & do_trace_aranges, 1 },
{ "trace_info", & do_trace_info, 1 },
+#ifdef HAVE_LIBDEBUGINFOD
+ { "use-debuginfod", & use_debuginfod, 1 },
+#endif
{ NULL, NULL, 0 }
};
case 'A': do_debug_addr = 1; break;
case 'a': do_debug_abbrevs = 1; break;
case 'c': do_debug_cu_index = 1; break;
+#ifdef HAVE_LIBDEBUGINFOD
+ case 'D': use_debuginfod = 1; break;
+ case 'E': use_debuginfod = 0; break;
+#endif
case 'F': do_debug_frames_interp = 1; /* Fall through. */
case 'f': do_debug_frames = 1; break;
case 'g': do_gdb_index = 1; break;
extern int do_wide;
extern int do_debug_links;
extern int do_follow_links;
+#ifdef HAVE_LIBDEBUGINFOD
+extern int use_debuginfod;
+#endif
extern bool do_checks;
extern int dwarf_cutoff_level;
-WN,--dwarf=no-follow-links\n\
Do not follow links to separate debug info files\n\
(default)\n"));
+#endif
+#if HAVE_LIBDEBUGINFOD
+ fprintf (stream, _("\
+ -WD --dwarf=use-debuginfod\n\
+ When following links, also query debuginfod servers (default)\n"));
+ fprintf (stream, _("\
+ -WE --dwarf=do-not-use-debuginfod\n\
+ When following links, do not query debuginfod servers\n"));
#endif
fprintf (stream, _("\
-L, --process-links Display the contents of non-debug sections in\n\
-wN --debug-dump=no-follow-links\n\
Do not follow links to separate debug info files\n\
(default)\n"));
+#endif
+#if HAVE_LIBDEBUGINFOD
+ fprintf (stream, _("\
+ -wD --debug-dump=use-debuginfod\n\
+ When following links, also query debuginfod servers (default)\n"));
+ fprintf (stream, _("\
+ -wE --debug-dump=do-not-use-debuginfod\n\
+ When following links, do not query debuginfod servers\n"));
#endif
fprintf (stream, _("\
--dwarf-depth=N Do not display DIEs at depth N or greater\n"));
}
if { [regexp ".*DEBUGINFOD.*" $conf_objdump] } {
- test_fetch_debuglink $OBJDUMP "-W"
+ test_fetch_debuglink $OBJDUMP "-W -WD"
test_fetch_debugaltlink $OBJDUMP "-Wk"
+
+ set test "disabling debuginfod access"
+ setup_xfail *-*-*
+ test_fetch_debuglink $OBJDUMP "-W -WE"
+ set test "debuginfod"
+
} else {
untested "$test (objdump not configured with debuginfod)"
}
if { [regexp ".*DEBUGINFOD.*" $conf_readelf] } {
test_fetch_debuglink $READELF "-w"
test_fetch_debugaltlink $READELF "-wk"
+
+ set test "disabling debuginfod access"
+ setup_xfail *-*-*
+ test_fetch_debuglink $READELF "-w -wE"
+ set test "debuginfod"
+
} else {
untested "$test (readelf not configured with debuginfod)"
}