Add option to objdump/readelf to disable access to debuginfod servers.

* 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.
This commit is contained in:
Nick Clifton 2022-03-10 09:11:40 +00:00
parent d7c448293a
commit bed566bbf6
9 changed files with 105 additions and 12 deletions

View file

@ -109,6 +109,9 @@ int do_debug_cu_index;
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;
@ -11038,7 +11041,7 @@ debuginfod_fetch_separate_debug_info (struct dwarf_section * section,
return false;
}
#endif
#endif /* HAVE_LIBDEBUGINFOD */
static void *
load_separate_debug_info (const char * main_filename,
@ -11157,9 +11160,10 @@ 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. */
@ -11207,13 +11211,15 @@ load_separate_debug_info (const char * main_filename,
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
}
@ -11707,6 +11713,9 @@ dwarf_select_sections_by_names (const char *names)
{ "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 },
@ -11730,6 +11739,9 @@ dwarf_select_sections_by_names (const char *names)
{ "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 }
};
@ -11783,6 +11795,10 @@ dwarf_select_sections_by_letters (const char *letters)
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;