From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 571693858409 for ; Wed, 20 Oct 2021 20:34:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 571693858409 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-122-Jk7iZCAoMeG__tCPjR-Jjw-1; Wed, 20 Oct 2021 16:34:36 -0400 X-MC-Unique: Jk7iZCAoMeG__tCPjR-Jjw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0EAA310168D2 for ; Wed, 20 Oct 2021 20:34:36 +0000 (UTC) Received: from [10.3.113.59] (ovpn-113-59.phx2.redhat.com [10.3.113.59]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C972060FB8; Wed, 20 Oct 2021 20:34:32 +0000 (UTC) Message-ID: <7eeed275-d442-fee2-4d5e-352c8ed34ec3@redhat.com> Date: Wed, 20 Oct 2021 13:34:32 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 Subject: Re: [PATCH 1/2] gdb: add set/show commands for managing debuginfod To: Aaron Merey , gdb-patches@sourceware.org References: <20211018230133.265619-1-amerey@redhat.com> <20211018230133.265619-2-amerey@redhat.com> From: Keith Seitz In-Reply-To: <20211018230133.265619-2-amerey@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Oct 2021 20:34:39 -0000 Hi, Thank you for your perseverance with this patch. This is really shaping up as a nice, user-friendly addition. It's also very "gdb-ish." I have just a few things. Nothing major. On 10/18/21 16:01, Aaron Merey wrote: > This GDB supports auto-downloading debuginfo from the following URLs: > ... > Enable debuginfod? (y or [n]) y > Debuginfod has been enabled. > To make this setting permanent, add 'set debuginfod on' to .gdbinit. Very nice! > Also add 'set/show debuginfod-urls' command. Accepts a string of > space-separated debuginfod server URLs to be queried. The default > value is copied from $DEBUGINFOD_URLS. At first I thought this space-separated list as a bit odd, but I see that this is exactly the same format as the environment variable DEBUGINFOD_URLS. I certainly appreciate the consistency. > Finally add 'set debug debuginfod" command to control whether > debuginfod-related debugging output is displayed. This debugging > output is displayed by default. > > (gdb) run > Starting program: /bin/sleep 5 > Download failed: No route to host. Continuing without debug info for /lib64/libc.so.6. Here I have a question. From the patch, it appears that the debugging output consists entirely of error messages? Am I alone thinking we should always print these for the user? > diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c > index 2d626e335a0..1a4a6e1dde0 100644 > --- a/gdb/debuginfod-support.c > +++ b/gdb/debuginfod-support.c > @@ -68,6 +69,63 @@ struct debuginfod_client_deleter > using debuginfod_client_up > = std::unique_ptr; > > +static const char debuginfod_on[] = "on"; > +static const char debuginfod_off[] = "off"; > +static const char debuginfod_ask[] = "ask"; > +static const char *const debuginfod_cmd_names[] = > +{ > + debuginfod_on, > + debuginfod_off, > + debuginfod_ask, > + NULL, > +}; > + > +static const char *debuginfod_enable = debuginfod_ask; > +static std::string debuginfod_urls; > +static bool debuginfod_debug = true; > + > +/* Show whether debuginfod is enabled. */ > + > +static void > +show_debuginfod_command (struct ui_file *file, int from_tty, > + struct cmd_list_element *cmd, const char *value) > +{ > + fprintf_unfiltered (file, _("Debuginfod functionality is currently set " \ > + "to \"%s\".\n"), debuginfod_enable); > +} > + > +/* Set the URLs that debuginfod will query. */ > + > +static void > +set_debuginfod_urls_command (const char *args, int from_tty, > + struct cmd_list_element *c) > +{ > + if (setenv ("DEBUGINFOD_URLS", debuginfod_urls.c_str (), 1) != 0) > + warning (_("Unable to set debuginfod URLs: %s"), strerror (errno)); > I believe we prefer to use safe_strerror (as used elsewhere in this file). > + > +/* Show the URLs that debuginfod will query. */ > + > +static void > +show_debuginfod_urls_command (struct ui_file *file, int from_tty, > + struct cmd_list_element *cmd, const char *value) > +{ > + if (debuginfod_urls.empty ()) > + fprintf_unfiltered (file, _("You have not set debuginfod URLs.\n")); > + else > + fprintf_filtered (file, _("Debuginfod URLs are currently set to:\n%s\n"), > + value); > +} > + > +/* Show whether to display debuginfod debugging output. */ > + > +static void > +show_debuginfod_debug_command (struct ui_file *file, int from_tty, > + struct cmd_list_element *cmd, const char *value) > +{ > + fprintf_filtered (file, _("Debuginfod debugging output is %s.\n"), value); > +} > + > static int > progressfn (debuginfod_client *c, long cur, long total) > { > @@ -195,3 +283,50 @@ debuginfod_debuginfo_query (const unsigned char *build_id, > return fd; > } > #endif > + > +/* Register debuginfod commands. */ > + > +void _initialize_debuginfod (); > +void > +_initialize_debuginfod () > +{ > +#ifdef HAVE_LIBDEBUGINFOD > + char *urls = getenv (DEBUGINFOD_URLS_ENV_VAR); > + > + if (urls != nullptr) > + debuginfod_urls = urls; > + > + add_setshow_enum_cmd ("debuginfod", class_run, debuginfod_cmd_names, > + &debuginfod_enable, _("\ > +Set whether debuginfod is enabled."), _("\ > +Show whether debuginfod is enabled."), _("\ > +Automatically query debuginfod servers for missing debuginfo, executables \ > +or source files. This command accepts the following arguments:\n\ > + on - debuginfod will be enabled\n\ > + off - debuginfod will be disabled\n\ > + ask - an interactive prompt will ask whether to enable debuginfod\n\ > +For interactive sessions, \"ask\" is the default. For non-interactive \ > +sessions, \"off\" is the default."), > + NULL, show_debuginfod_command, &setlist, &showlist); > + > + add_setshow_string_noescape_cmd ("debuginfod-urls", class_run, > + &debuginfod_urls, _("\ > +Set the list of debuginfod server URLs."), _("\ > +Show the list of debuginfod server URLs."), _("\ > +Manage the space-separated list of debuginfod server URLs that GDB will query \ > +when missing debuginfo, executables or source files.\nThe default value is \ > +copied from $DEBUGINFOD_URLS."), > + set_debuginfod_urls_command, > + show_debuginfod_urls_command, > + &setlist, &showlist); > + > + add_setshow_boolean_cmd ("debuginfod", class_maintenance, > + &debuginfod_debug, _("\ > +Set debuginfod debugging."), _("\ > +Show debuginfod debugging."), _("\ > +When set, display debugging output for debuginfod. \ > +Displayed by default"), > + NULL, show_debuginfod_debug_command, > + &setdebuglist, &showdebuglist); > +#endif > +} Just a question for others: Is this the normal style used in GDB? E.g., the python command is always available: (gdb) python print(1) Python scripting is not supported in this copy of GDB. Like command/command-line options, I'd like us to be vigilant of consistency. [Maybe that's just my personal thing, though.] It's just a question -- I am not asking for any changes. With the safe_strerror change, though, I recommend a maintainer review this patch for final approval(s). Keith