From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12560 invoked by alias); 29 Jan 2013 22:10:43 -0000 Received: (qmail 12547 invoked by uid 22791); 29 Jan 2013 22:10:42 -0000 X-SWARE-Spam-Status: No, hits=-6.5 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 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; Tue, 29 Jan 2013 22:10:33 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r0TMATHm023159 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 29 Jan 2013 17:10:33 -0500 Received: from host2.jankratochvil.net (ovpn-116-88.ams2.redhat.com [10.36.116.88]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r0TMAJoW014371 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Tue, 29 Jan 2013 17:10:27 -0500 Date: Tue, 29 Jan 2013 22:10:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Subject: [patchv2 12/11] New options {relative,basename}-with-system-absolute Message-ID: <20130129221019.GA27463@host2.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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-01/txt/msg00700.txt.bz2 Hi, to make {this,a} patchset practically useful it needs to be enabled by default. But making "set filename-display absolute" the default is probably not great: #8 0x0000000000735ed2 in captured_main (data=0x7fffffffdaa0) at main.c:1033 #9 0x00000000007324ef in catch_errors (func=0x734cae , func_args=0x7fffffffdaa0, errstring=0xfa2e54 "", mask=6) at exceptions.c:546 #10 0x0000000000735f1e in gdb_main (args=0x7fffffffdaa0) at main.c:1042 #11 0x000000000048cd66 in main (argc=1, argv=0x7fffffffdba8) at gdb.c:34 -> #8 0x0000000000735ed2 in captured_main (data=0x7fffffffdaa0) at /home/jkratoch/redhat/archer-jankratochvil-absdir/gdb/main.c:1033 #9 0x00000000007324ef in catch_errors (func=0x734cae , func_args=0x7fffffffdaa0, errstring=0xfa2e54 "", mask=6) at /home/jkratoch/redhat/archer-jankratochvil-absdir/gdb/exceptions.c:546 #10 0x0000000000735f1e in gdb_main (args=0x7fffffffdaa0) at /home/jkratoch/redhat/archer-jankratochvil-absdir/gdb/main.c:1042 #11 0x000000000048cd66 in main (argc=1, argv=0x7fffffffdba8) at /home/jkratoch/redhat/archer-jankratochvil-absdir/gdb/gdb.c:34 OTOH this output I find wrong and the "absolute" change is a win for it: #0 0x00007ffff63773d0 in __poll_nocancel () at ../sysdeps/unix/syscall-template.S:81 -> #0 0x00007ffff63773d0 in __poll_nocancel () at /usr/src/debug/glibc-2.17-c758a686/sysdeps/unix/syscall-template.S:81 So a combination of absolute filenames for system component and relative filenames for user binaries should be the best of both choices. This applies then also for the main executable, if it comes from system: #3 0x00000000004016e4 in main (argc=, argv=) at src/sleep.c:145 -> #3 0x00000000004016e4 in main (argc=, argv=) at /usr/src/debug/coreutils-8.20/src/sleep.c:145 All these patches are unrelated if *-debuginfo.rpm (or equivalent) is not installed for the system component as in such case GDB has always displayed: #0 0x00007ffff63773d0 in __poll_nocancel () from /lib64/libc.so.6 In fact I would personally prefer "basename" instead of "relative" for user binaries when we have "ambiguous linespec" already implemented. But I do not find there a big difference so it would be mostly a needless user interface change. Such relative* -> basename* change is in fact unrelated to this proposal and it can be still made in the future. This patch does not yet make the change of the default. Thanks, Jan gdb/ 2013-01-29 Jan Kratochvil * source.c (filename_display_relative_with_system_absolute) (filename_display_basename_with_system_absolute): New. (filename_display_kind_names): Add them. (symtab_to_filename): Use them. (_initialize_source): Describe them for "set filename-display". gdb/doc/ 2013-01-29 Jan Kratochvil * gdb.texinfo (Backtrace): Add new set filename-display options relative-with-system-absolute and basename-with-system-absolute. --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -6549,6 +6549,16 @@ Display only basename of a filename. @item set filename-display absolute Display an absolute filename. +@item set filename-display relative-with-system-absolute +Determine whether a source filename comes from file having separate debug +information file. In such case display the source filename as absolute one. +Otherwise display it relative to the compilation directory. + +@item set filename-display basename-with-system-absolute +Determine whether a source filename comes from file having separate debug +information file. In such case display the source filename as absolute one. +Otherwise display only basename of the filename. + @item show filename-display Show the current way to display filenames. @end table --- a/gdb/source.c +++ b/gdb/source.c @@ -113,11 +113,17 @@ show_lines_to_list (struct ui_file *file, int from_tty, static const char filename_display_basename[] = "basename"; static const char filename_display_relative[] = "relative"; static const char filename_display_absolute[] = "absolute"; +static const char filename_display_relative_with_system_absolute[] = + "relative-with-system-absolute"; +static const char filename_display_basename_with_system_absolute[] = + "basename-with-system-absolute"; static const char *const filename_display_kind_names[] = { filename_display_basename, filename_display_relative, filename_display_absolute, + filename_display_relative_with_system_absolute, + filename_display_basename_with_system_absolute, NULL }; @@ -1144,8 +1150,16 @@ symtab_to_filename (struct symtab *symtab) return symtab_to_fullname (symtab); else if (filename_display_string == filename_display_relative) return symtab->filename; - else - internal_error (__FILE__, __LINE__, _("invalid filename_display_string")); + + if (symtab->objfile->separate_debug_objfile != NULL + || symtab->objfile->separate_debug_objfile_backlink != NULL) + return symtab_to_fullname (symtab); + + if (filename_display_string == filename_display_relative_with_system_absolute) + return symtab->filename; + if (filename_display_string == filename_display_basename_with_system_absolute) + return lbasename (symtab->filename); + internal_error (__FILE__, __LINE__, _("invalid filename_display_string")); } /* Create and initialize the table S->line_charpos that records @@ -2065,6 +2079,13 @@ 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\ + relative-with-system-absolute - display filenames from files with separate\n\ + debug info files as absolute, other files\n\ + display relative to the compilation directory\ +\n\ + basename-with-system-absolute - display filenames from files with separate\n\ + debug info files as absolute, other files\n\ + display only with basename of the filename\n\ By default, relative filenames are displayed."), NULL, show_filename_display_string,