From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22918 invoked by alias); 18 Feb 2013 14:33:06 -0000 Received: (qmail 22806 invoked by uid 22791); 18 Feb 2013 14:33:01 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_SPAMHAUS_DROP,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS,TW_BJ X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 18 Feb 2013 14:32:44 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r1IEWhNh018563 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 18 Feb 2013 09:32:43 -0500 Received: from host2.jankratochvil.net (ovpn-116-18.ams2.redhat.com [10.36.116.18]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r1IEWYkX000882 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Mon, 18 Feb 2013 09:32:37 -0500 Date: Mon, 18 Feb 2013 14:33:00 -0000 From: Jan Kratochvil To: Eli Zaretskii Cc: gdb-patches@sourceware.org Subject: Re: [patch+doc 1/2] filename-display: 1->4 options {inferior,libs}{,-sepdebug} Message-ID: <20130218143234.GA11919@host2.jankratochvil.net> References: <20130215202536.GA20435@host2.jankratochvil.net> <83ehggslp9.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <83ehggslp9.fsf@gnu.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2013-02/txt/msg00454.txt.bz2 On Sat, 16 Feb 2013 09:32:34 +0100, Eli Zaretskii wrote: > Here and elsewhere, I think, instead of a separate sentence saying "FOO > has to use BAR debug info", it is better to say "... when FOO uses BAR > debug info" in the same sentence. For example: > > Set how to display filenames coming from the inferior executable, as > set by the @ref{file command}, when the inferior executable uses > embedded debug info as found in binaries compiled normally. Done; the changed parts may need a new review. Thanks, Jan gdb/ 2013-02-15 Jan Kratochvil * NEWS (set filename-display executable) (set filename-display libraries) (set filename-display executable-with-separate-debug-info) (set filename-display libraries-with-separate-debug-info) (show filename-display executable) (show filename-display libraries) (show filename-display executable-with-separate-debug-info) (show filename-display libraries-with-separate-debug-info): New. Also say for all the options. * source.c: Include cli/cli-decode.h and cli/cli-setshow.h. (filename_display_string): Remove. (filename_display_executable_string) (filename_display_libraries_string) (filename_display_executable_sepdebug_string) (filename_display_libraries_sepdebug_string): New. (show_filename_display_string): Remove. (show_filename_display_executable_string) (show_filename_display_libraries_string) (show_filename_display_executable_sepdebug_string) (show_filename_display_libraries_sepdebug_string): New. (symtab_to_filename_for_display): Follow the new variables. (filename_display_set_cmdlist, filename_display_show_cmdlist) (set_filename_display_cmd, set_filename_display_1) (set_filename_display_basename_string) (set_filename_display_relative_string) (set_filename_display_absolute_string, show_filename_display_cmd): New. (_initialize_source): New variables filename_display_doc and doc. Initialize filename_display_doc. Remove add_setshow_enum_cmd for filename-display. Add filename_display_set_cmdlist and filename_display_show_cmdlist initializations by add_prefix_cmd. Add add_setshow_enum_cmd for executable, libraries, executable-with-separate-debug-info and libraries-with-separate-debug-info. Add add_cmd for basename, relative and absolute. gdb/doc/ 2013-02-18 Jan Kratochvil * gdb.texinfo (Backtrace): Extend the show filename-display description. New description for set filename-display executable, set filename-display libraries, set filename-display executable-with-separate-debug-info, set filename-display libraries-with-separate-debug-info, show filename-display executable, show filename-display libraries, show filename-display executable-with-separate-debug-info and show filename-display libraries-with-separate-debug-info. (Files): New anchor file command. --- a/gdb/NEWS +++ b/gdb/NEWS @@ -123,9 +123,20 @@ show print type typedefs The default is to show them. set filename-display basename|relative|absolute +set filename-display executable basename|relative|absolute +set filename-display libraries basename|relative|absolute +set filename-display executable-with-separate-debug-info basename|relative + |absolute +set filename-display libraries-with-separate-debug-info basename|relative + |absolute show filename-display +show filename-display executable +show filename-display libraries +show filename-display executable-with-separate-debug-info +show filename-display libraries-with-separate-debug-info Control the way in which filenames is displayed. - The default is "relative", which preserves previous behavior. + The default is "relative" for all the options, which preserves previous + behavior. * MI changes --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -6539,7 +6539,11 @@ You can control how file names are displayed. @table @code @item set filename-display -@itemx set filename-display relative +Set how to display filenames coming from any file. One can make this setting +more specific to the inferior file kind below. Using this command will set the +same value for all the four kinds of inferior files as described below. + +@item set filename-display relative @cindex filename-display Display file names relative to the compilation directory. This is the default. @@ -6550,7 +6554,53 @@ Display only basename of a filename. Display an absolute filename. @item show filename-display -Show the current way to display filenames. +Show the current way to display filenames. Setting for each of the four kinds +of inferior files (as described below) will be displayed. +@end table + +If you want to set the displayed filenames kind more specifically you can use +the following option. + +Files having separate debug information file usually come from system shared +libraries where may be more appropriate to display filenames in their absolute +form. + +@table @code +@item set filename-display executable @{relative|basename|absolute@} +Set how to display filenames coming from the inferior executable, as set by the +@ref{file command}, when the inferior executable uses embedded debug info as +found in binaries compiled normally. + +@item show filename-display executable +Show the current way to display filenames coming from the inferior executable +with embedded debug info. + +@item set filename-display libraries @{relative|basename|absolute@} +Set how to display filenames coming from inferior shared libraries, when the +shared libraries use embedded debug info as found in binaries compiled +normally. + +@item show filename-display libraries +Show the current way to display filenames coming from the inferior shared +libraries with embedded debug info. + +@item set filename-display executable-with-separate-debug-info @{@dots{}@} +Set how to display filenames coming from the inferior executable, as set by the +@ref{file command}, when the inferior executable uses separate debug info file +which is usually optionally provided by operating system debug info packages. + +@item show filename-display executable-with-separate-debug-info +Show the current way to display filenames coming from the inferior executable +with separate debug info file. + +@item set filename-display libraries-with-separate-debug-info @{@dots{}@} +Set how to display filenames coming from inferior shared libraries, when the +shared libraries use separate debug info files which are usually optionally +provided by operating system debug info packages. + +@item show filename-display libraries-with-separate-debug-info +Show the current way to display filenames coming from the inferior shared +libraries with separate debug info file. @end table @node Selection @@ -15941,6 +15991,7 @@ Program}). In these situations the @value{GDBN} commands to specify new files are useful. @table @code +@anchor{file command} @cindex executable file @kindex file @item file @var{filename} --- a/gdb/source.c +++ b/gdb/source.c @@ -43,6 +43,8 @@ #include "completer.h" #include "ui-out.h" #include "readline/readline.h" +#include "cli/cli-decode.h" +#include "cli/cli-setshow.h" #include "psymtab.h" @@ -121,13 +123,72 @@ static const char *const filename_display_kind_names[] = { NULL }; -static const char *filename_display_string = filename_display_relative; +/* Setting for "set filename-display executable". */ +static const char *filename_display_executable_string = + filename_display_relative; + +/* Setting for "set filename-display libraries". */ +static const char *filename_display_libraries_string = + filename_display_relative; + +/* Setting for "set filename-display executable-with-separate-debug-info". */ +static const char *filename_display_executable_sepdebug_string = + filename_display_relative; + +/* Setting for "set filename-display libraries-with-separate-debug-info". */ +static const char *filename_display_libraries_sepdebug_string = + filename_display_relative; + +/* Implement command "show filename-display executable". */ + +static void +show_filename_display_executable_string (struct ui_file *file, int from_tty, + struct cmd_list_element *c, + const char *value) +{ + fprintf_filtered (file, _("Filenames in executable with embedded " + "debug info are displayed as \"%s\".\n"), + value); +} + +/* Implement command "show filename-display libraries". */ static void -show_filename_display_string (struct ui_file *file, int from_tty, - struct cmd_list_element *c, const char *value) +show_filename_display_libraries_string (struct ui_file *file, int from_tty, + struct cmd_list_element *c, + const char *value) { - fprintf_filtered (file, _("Filenames are displayed as \"%s\".\n"), value); + fprintf_filtered (file, _("Filenames in shared libraries with embedded " + "debug info are displayed as \"%s\".\n"), + value); +} + +/* Implement command + "show filename-display executable-with-separate-debug-info". */ + +static void +show_filename_display_executable_sepdebug_string (struct ui_file *file, + int from_tty, + struct cmd_list_element *c, + const char *value) +{ + fprintf_filtered (file, _("Filenames in executable with separate " + "debug info are displayed as \"%s\".\n"), + value); +} + +/* Implement command + "show filename-display libraries-with-separate-debug-info". */ + +static void +show_filename_display_libraries_sepdebug_string (struct ui_file *file, + int from_tty, + struct cmd_list_element *c, + const char *value) +{ + fprintf_filtered (file, _("Filenames in shared libraries with separate " + "debug info are displayed as \"%s\".\n"), + value); } /* Line number of last line printed. Default for various commands. @@ -1138,14 +1199,34 @@ symtab_to_fullname (struct symtab *s) const char * symtab_to_filename_for_display (struct symtab *symtab) { - if (filename_display_string == filename_display_basename) + struct objfile *objfile = symtab->objfile; + int has_sepdebug, is_executable; + const char *setting; + + if (objfile->separate_debug_objfile_backlink != NULL) + objfile = objfile->separate_debug_objfile_backlink; + has_sepdebug = objfile->separate_debug_objfile != NULL; + is_executable = objfile == symfile_objfile; + + if (is_executable && !has_sepdebug) + setting = filename_display_executable_string; + if (!is_executable && !has_sepdebug) + setting = filename_display_libraries_string; + if (is_executable && has_sepdebug) + setting = filename_display_executable_sepdebug_string; + if (!is_executable && has_sepdebug) + setting = filename_display_libraries_sepdebug_string; + if (setting == NULL) + internal_error (__FILE__, __LINE__, + _("symtab_to_filename_for_display setting == NULL")); + + if (setting == filename_display_basename) return lbasename (symtab->filename); - else if (filename_display_string == filename_display_absolute) + else if (setting == filename_display_absolute) return symtab_to_fullname (symtab); - else if (filename_display_string == filename_display_relative) + else if (setting == filename_display_relative) return symtab->filename; - else - internal_error (__FILE__, __LINE__, _("invalid filename_display_string")); + internal_error (__FILE__, __LINE__, _("invalid filename_display_string")); } /* Create and initialize the table S->line_charpos that records @@ -1945,11 +2026,85 @@ set_substitute_path_command (char *args, int from_tty) forget_cached_source_info (); } +/* The list of commands prefixed by "set filename-display". */ +static struct cmd_list_element *filename_display_set_cmdlist; + +/* The list of commands prefixed by "show filename-display". */ +static struct cmd_list_element *filename_display_show_cmdlist; + +/* Implement command "set filename-display" itself. */ + +static void +set_filename_display_cmd (char *args, int from_tty) +{ + error (_("Value \"basename\", \"relative\" or \"absolute\" set for all " + "sub-categories expected.\n" + "More specific category \"executable\", \"libraries\", " + "\"executable-with-separate-debug-info\" or " + "\"libraries-with-separate-debug-info\" may be also specified.")); +} + +/* Set all sub-values of the "set filename-display" setting to KIND. */ + +static void +set_filename_display_1 (const char *kind, int from_tty) +{ + struct cmd_list_element *list; + + for (list = filename_display_set_cmdlist; list != NULL; list = list->next) + if (list->type == set_cmd) + do_set_command ((char *) kind, from_tty, list); +} + +/* Implement command "set filename-display basename". */ + +static void +set_filename_display_basename_string (char *args, int from_tty) +{ + if (args != NULL && *args != 0) + error (_("Command has no parameters.")); + + set_filename_display_1 ("basename", from_tty); +} + +/* Implement command "set filename-display relative". */ + +static void +set_filename_display_relative_string (char *args, int from_tty) +{ + if (args != NULL && *args != 0) + error (_("Command has no parameters.")); + + set_filename_display_1 ("relative", from_tty); +} + +/* Implement command "set filename-display absolute". */ + +static void +set_filename_display_absolute_string (char *args, int from_tty) +{ + if (args != NULL && *args != 0) + error (_("Command has no parameters.")); + + set_filename_display_1 ("absolute", from_tty); +} + +/* Command "show filename-display" displays summary of all the current + "show filename-display " settings. */ + +static void +show_filename_display_cmd (char *args, int from_tty) +{ + cmd_show_list (filename_display_show_cmdlist, from_tty, ""); +} + void _initialize_source (void) { struct cmd_list_element *c; + const char *filename_display_doc; + char *doc; current_source_symtab = 0; init_source_path (); @@ -2062,18 +2217,87 @@ Print the rule for substituting FROM in source file names. If FROM\n\ is not specified, print all substitution rules."), &showlist); - add_setshow_enum_cmd ("filename-display", class_files, - filename_display_kind_names, - &filename_display_string, _("\ -Set how to display filenames."), _("\ -Show how to display filenames."), _("\ + filename_display_doc = _("\ filename-display can be:\n\ basename - display only basename of a filename\n\ relative - display a filename relative to the compilation directory\n\ absolute - display an absolute filename\n\ By default, relative filenames are displayed."), - NULL, - show_filename_display_string, - &setlist, &showlist); + doc = xstrprintf (_("\ +Set how to display filenames for all categories of files.\n\ +%s"), + filename_display_doc); + add_prefix_cmd ("filename-display", class_files, set_filename_display_cmd, + doc, &filename_display_set_cmdlist, "set filename-display ", + 0/*allow-unknown*/, &setlist); + xfree (doc); + + doc = xstrprintf (_("\ +Show how to display filenames for all categories of files.\n\ +%s"), + filename_display_doc); + add_prefix_cmd ("filename-display", class_files, show_filename_display_cmd, + doc, &filename_display_show_cmdlist, "show filename-display ", + 0/*allow-unknown*/, &showlist); + xfree (doc); + + add_setshow_enum_cmd ("executable", class_files, + filename_display_kind_names, + &filename_display_executable_string, _("\ +Set how to display filenames in executable with embedded debug info."), _("\ +Show how to display filenames in executable with embedded debug info."), + filename_display_doc, NULL, + show_filename_display_executable_string, + &filename_display_set_cmdlist, + &filename_display_show_cmdlist); + + add_setshow_enum_cmd ("libraries", class_files, + filename_display_kind_names, + &filename_display_libraries_string, _("\ +Set how to display filenames in libraries with embedded debug info."), _("\ +Show how to display filenames in libraries with embedded debug info."), + filename_display_doc, NULL, + show_filename_display_libraries_string, + &filename_display_set_cmdlist, + &filename_display_show_cmdlist); + + add_setshow_enum_cmd ("executable-with-separate-debug-info", class_files, + filename_display_kind_names, + &filename_display_executable_sepdebug_string, _("\ +Set how to display filenames in executable with separate debug info."), _("\ +Show how to display filenames in executable with separate debug info."), + filename_display_doc, NULL, + show_filename_display_executable_sepdebug_string, + &filename_display_set_cmdlist, + &filename_display_show_cmdlist); + + add_setshow_enum_cmd ("libraries-with-separate-debug-info", class_files, + filename_display_kind_names, + &filename_display_libraries_sepdebug_string, _("\ +Set how to display filenames in libraries with separate debug info."), _("\ +Show how to display filenames in libraries with separate debug info."), + filename_display_doc, NULL, + show_filename_display_libraries_sepdebug_string, + &filename_display_set_cmdlist, + &filename_display_show_cmdlist); + + add_cmd ("basename", class_files, set_filename_display_basename_string, + _("\ +Set displaying of filenames to basename for all categories of files.\n\ +See \"help set display-filename\" for other options of this setting."), + &filename_display_set_cmdlist); + + add_cmd ("relative", class_files, set_filename_display_relative_string, + _("\ +Set displaying of filenames as relative for all categories of files.\n\ +Filename is displayed relative to the compilation directory\n\ +See \"help set display-filename\" for other options of this setting."), + &filename_display_set_cmdlist); + + add_cmd ("absolute", class_files, set_filename_display_absolute_string, + _("\ +Set displaying of filenames as absolute for all categories of files.\n\ +See \"help set display-filename\" for other options of this setting."), + &filename_display_set_cmdlist); }