[PING][PATCH] gdb: Print debuginfod first-use notification
Aaron Merey
amerey@redhat.com
Mon Jun 21 22:22:58 GMT 2021
Ping
Thanks,
Aaron
On Wed, May 26, 2021 at 9:27 PM Aaron Merey via Gdb-patches
<gdb-patches@sourceware.org> wrote:
>
> When querying debuginfod servers for the first time, notify the user
> that GDB may automatically download debuginfo. Helps ensure users are
> aware that GDB may be relying on the correct operation of remote
> debuginfod servers.
>
> In order to determine whether debuginfod is being queried for the
> first time, check for the presence of a local debuginfod cache.
> If one cannot be found, the notification will be displayed before
> performing the first query.
>
> ChangeLog/gdb:
>
> * debuginfod-support.c (notify_first_use): New function.
> ---
> gdb/debuginfod-support.c | 41 +++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 40 insertions(+), 1 deletion(-)
>
> diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
> index 2d626e335a0..3d8667d0367 100644
> --- a/gdb/debuginfod-support.c
> +++ b/gdb/debuginfod-support.c
> @@ -104,6 +104,42 @@ progressfn (debuginfod_client *c, long cur, long total)
> return 0;
> }
>
> +/* If this is the first time debuginfod is being used on this system, emit
> + a warning message indicating that GDB may automatically download debuginfo.
> +
> + To determine whether debuginfod is being used for the first time, check for
> + the presence of a debuginfod cache. If it cannot be found, then print the
> + warning. */
> +
> +static void
> +notify_first_use ()
> +{
> + std::string cache_var (getenv (DEBUGINFOD_CACHE_PATH_ENV_VAR) ?: "");
> +
> + if (access (cache_var.c_str (), F_OK) == 0)
> + return;
> +
> + std::string xdg (getenv ("XDG_CACHE_HOME") ?: "");
> +
> + if (!xdg.empty ())
> + {
> + xdg.append ("/debuginfod_client");
> + if (access (xdg.c_str (), F_OK) == 0)
> + return;
> + }
> +
> + std::string home (getenv ("HOME") ?: "/");
> + std::string h1 = home + "/.debuginfod_client_cache";
> + std::string h2 = home + "/.cache/debuginfod_client";
> +
> + if (access (h1.c_str (), F_OK) == 0 || access (h2.c_str (), F_OK) == 0)
> + return;
> +
> + printf_filtered ("\nThis GDB is configured to auto-download debuginfo from:\n%s\n\n",
> + getenv (DEBUGINFOD_URLS_ENV_VAR) ?: "(URLs missing!)");
> + return;
> +}
> +
> static debuginfod_client *
> get_debuginfod_client ()
> {
> @@ -114,7 +150,10 @@ get_debuginfod_client ()
> global_client.reset (debuginfod_begin ());
>
> if (global_client != nullptr)
> - debuginfod_set_progressfn (global_client.get (), progressfn);
> + {
> + notify_first_use ();
> + debuginfod_set_progressfn (global_client.get (), progressfn);
> + }
> }
>
> return global_client.get ();
> --
> 2.31.1
>
More information about the Gdb-patches
mailing list