From: Aaron Merey Date: Mon, 9 May 2022 20:56:23 +0000 (-0400) Subject: Add --enabled-debuginfod command line option X-Git-Tag: VALGRIND_3_20_0~71 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d4eb6be2050e34fd396315335235dcd8ce96f5f;p=thirdparty%2Fvalgrind.git Add --enabled-debuginfod command line option Currently debuginfod is enabled in Valgrind when the $DEBUGINFOD_URLS environment variable is set and disabled when it isn't set. This patch adds an --enable-debuginfod= command line option to provide another level of control over whether Valgrind attempts to download debuginfo. "yes" is the default value. $DEBUGINFOD_URLS must still contain debuginfod server URLs in order for this feature to work when --enable-debuginfod=yes. https://bugs.kde.org/show_bug.cgi?id=453602 --- diff --git a/NEWS b/NEWS index 4bf76608b7..a0cf73eaff 100644 --- a/NEWS +++ b/NEWS @@ -40,6 +40,7 @@ are not entered into bugzilla tend to get forgotten about or ignored. 452274 memcheck crashes with Assertion 'sci->status.what == SsIdle' failed 452779 Valgrind fails to build on FreeBSD 13.0 with llvm-devel (15.0.0) 453055 shared_timed_mutex drd test fails with "Lock shared failed" message +453602 Missing command line option to enable/disable debuginfod To see details of a given bug, visit https://bugs.kde.org/show_bug.cgi?id=XXXXXX diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c index 998bc08fab..ea9c80415b 100644 --- a/coregrind/m_debuginfo/readelf.c +++ b/coregrind/m_debuginfo/readelf.c @@ -1595,7 +1595,7 @@ DiImage* find_debug_file( struct _DebugInfo* di, } # if defined(VGO_linux) - if (dimg == NULL) + if (VG_(clo_enable_debuginfod) && dimg == NULL) dimg = find_debug_file_debuginfod(objpath, &debugpath, buildid, crc, rel_ok); # endif diff --git a/coregrind/m_main.c b/coregrind/m_main.c index 2a7712b3ce..d0fbc0c56c 100644 --- a/coregrind/m_main.c +++ b/coregrind/m_main.c @@ -116,6 +116,10 @@ static void usage_NORETURN ( int need_help ) " --log-fd= log messages to file descriptor [2=stderr]\n" " --log-file= log messages to \n" " --log-socket=ipaddr:port log messages to socket ipaddr:port\n" +#if defined(VGO_linux) +" --enable-debuginfod=no|yes query debuginfod servers for missing\n" +" debuginfo [yes]\n" +#endif "\n" " user options for Valgrind tools that report errors:\n" " --xml=yes emit error output in XML (some tools only)\n" @@ -600,6 +604,9 @@ static void process_option (Clo_Mode mode, else if VG_BOOL_CLO(arg, "--run-cxx-freeres", VG_(clo_run_cxx_freeres)) {} else if VG_BOOL_CLOM(cloPD, arg, "--show-below-main", VG_(clo_show_below_main)) {} else if VG_BOOL_CLO(arg, "--keep-debuginfo", VG_(clo_keep_debuginfo)) {} +#if defined(VGO_linux) + else if VG_BOOL_CLO(arg, "--enable-debuginfod", VG_(clo_enable_debuginfod)) {} +#endif else if VG_BOOL_CLOM(cloPD, arg, "--time-stamp", VG_(clo_time_stamp)) {} else if VG_STR_CLO(arg, "--track-fds", tmp_str) { if (VG_(strcmp)(tmp_str, "yes") == 0) diff --git a/coregrind/m_options.c b/coregrind/m_options.c index 688523324e..c35d0aa1dd 100644 --- a/coregrind/m_options.c +++ b/coregrind/m_options.c @@ -162,6 +162,9 @@ VgXTMemory VG_(clo_xtree_memory) = Vg_XTMemory_None; const HChar* VG_(clo_xtree_memory_file) = "xtmemory.kcg.%p"; Bool VG_(clo_xtree_compress_strings) = True; +#if defined(VGO_linux) +Bool VG_(clo_enable_debuginfod) = True; +#endif Int VG_(clo_dump_error) = 0; Int VG_(clo_backtrace_size) = 12; Int VG_(clo_merge_recursive_frames) = 0; // default value: no merge diff --git a/coregrind/pub_core_options.h b/coregrind/pub_core_options.h index 5dd01addcc..22875c824b 100644 --- a/coregrind/pub_core_options.h +++ b/coregrind/pub_core_options.h @@ -126,6 +126,12 @@ extern const HChar* VG_(clo_trace_children_skip_by_arg); after the subsequent exec(). */ extern Bool VG_(clo_child_silent_after_fork); +#if defined(VGO_linux) +/* If True, valgrind will attempt to query debuginfod servers for + any missing debuginfo. */ +extern Bool VG_(clo_enable_debuginfod); +#endif + /* If the user specified --log-file=STR and/or --xml-file=STR, these hold STR before expansion. */ extern const HChar *VG_(clo_log_fname_unexpanded); diff --git a/docs/xml/manual-core.xml b/docs/xml/manual-core.xml index dc33e12696..1cb4e8e579 100644 --- a/docs/xml/manual-core.xml +++ b/docs/xml/manual-core.xml @@ -599,19 +599,20 @@ to malloc.. Valgrind supports the downloading of debuginfo files via debuginfod, an HTTP server for distributing ELF/DWARF debugging information. When a debuginfo file cannot be found locally, Valgrind is able -to query debuginfod servers for the file using its build-id. +to query debuginfod servers for the file using the file's build-id. In order to use this feature -debuginfod-find must be installed and -$DEBUGINFOD_URLS must contain URLs of -debuginfod servers. Valgrind does not support +debuginfod-find must be installed and the +$DEBUGINFOD_URLS environment variable must +contain space-separated URLs of debuginfod servers. Valgrind does not support debuginfod-find verbose output that is normally enabled with $DEBUGINFOD_PROGRESS and $DEBUGINFOD_VERBOSE. These environment -variables will be ignored. +variables will be ignored. This feature is supported on Linux only. For more information regarding debuginfod, see -https://sourceware.org/elfutils/Debuginfod.html +Elfutils Debuginfod +. @@ -989,6 +990,21 @@ in most cases. We group the available options by rough categories. + + + + + + When enabled Valgrind will attempt to download missing debuginfo + from debuginfod servers if space-separated server URLs are present + in the $DEBUGINFOD_URLS environment + variable. This option is supported on Linux only. + + + + diff --git a/none/tests/cmdline1.stdout.exp b/none/tests/cmdline1.stdout.exp index 7f05709548..ca74f7bd89 100644 --- a/none/tests/cmdline1.stdout.exp +++ b/none/tests/cmdline1.stdout.exp @@ -31,6 +31,8 @@ usage: valgrind [options] prog-and-args --log-fd= log messages to file descriptor [2=stderr] --log-file= log messages to --log-socket=ipaddr:port log messages to socket ipaddr:port + --enable-debuginfod=no|yes query debuginfod servers for missing + debuginfo [yes] user options for Valgrind tools that report errors: --xml=yes emit error output in XML (some tools only) diff --git a/none/tests/cmdline2.stdout.exp b/none/tests/cmdline2.stdout.exp index 7c8a23f8b0..0da944f5a0 100644 --- a/none/tests/cmdline2.stdout.exp +++ b/none/tests/cmdline2.stdout.exp @@ -31,6 +31,8 @@ usage: valgrind [options] prog-and-args --log-fd= log messages to file descriptor [2=stderr] --log-file= log messages to --log-socket=ipaddr:port log messages to socket ipaddr:port + --enable-debuginfod=no|yes query debuginfod servers for missing + debuginfo [yes] user options for Valgrind tools that report errors: --xml=yes emit error output in XML (some tools only)