From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23748 invoked by alias); 11 Nov 2011 09:00:06 -0000 Received: (qmail 23717 invoked by uid 22791); 11 Nov 2011 09:00:05 -0000 X-SWARE-Spam-Status: No, hits=-3.9 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-qw0-f41.google.com (HELO mail-qw0-f41.google.com) (209.85.216.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 11 Nov 2011 08:59:34 +0000 Received: by qadc11 with SMTP id c11so4238611qad.0 for ; Fri, 11 Nov 2011 00:59:34 -0800 (PST) Received: by 10.224.1.69 with SMTP id 5mr8070920qae.29.1321001607056; Fri, 11 Nov 2011 00:53:27 -0800 (PST) MIME-Version: 1.0 Received: by 10.224.1.69 with SMTP id 5mr8070907qae.29.1321001606708; Fri, 11 Nov 2011 00:53:26 -0800 (PST) Received: by 10.224.6.76 with HTTP; Fri, 11 Nov 2011 00:53:26 -0800 (PST) In-Reply-To: <8362irgi5w.fsf@gnu.org> References: <20111106063053.B56F6246194@ruffy.mtv.corp.google.com> <8362irgi5w.fsf@gnu.org> Date: Fri, 11 Nov 2011 09:00:00 -0000 Message-ID: Subject: Re: [RFA, doc RFA] Avoid calling gdb_realpath if basenames are different From: Doug Evans To: Eli Zaretskii Cc: gdb-patches@sourceware.org, tromey@redhat.com, brobecker@adacore.com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-System-Of-Record: true 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: 2011-11/txt/msg00314.txt.bz2 On Fri, Nov 11, 2011 at 12:47 AM, Eli Zaretskii wrote: >> Date: Thu, 10 Nov 2011 15:58:46 -0800 >> From: Doug Evans >> >> 2011-11-10 =A0Doug Evans =A0 >> >> =A0 =A0 =A0 =A0 * NEWS: Mention new parameter basenames-may-differ. >> =A0 =A0 =A0 =A0 * dwarf2read.c (dw2_lookup_symtab): Avoid calling gdb_re= alpath if >> =A0 =A0 =A0 =A0 ! basenames_may_differ. >> =A0 =A0 =A0 =A0 * psymtab.c (lookup_partial_symtab): Ditto. >> =A0 =A0 =A0 =A0 * symtab.c (lookup_symtab): Ditto. >> =A0 =A0 =A0 =A0 (basenames_may_differ): New global. >> =A0 =A0 =A0 =A0 (_initialize_symtab): New parameter basenames-may-differ. >> =A0 =A0 =A0 =A0 * symtab.h (basenames_may_differ): Declare. >> >> =A0 =A0 =A0 =A0 doc/ >> =A0 =A0 =A0 =A0 * gdb.texinfo (Files): Document basenames-may-differ. > > Thanks. > >> +set basenames-may-differ >> +show basenames-may-differ >> + =A0Set whether a source file may have multiple base names. >> + =A0A "base name" is the name of a file with the directory part removed. >> + =A0Example: The base name of "/home/user/hello.c" is "hello.c". >> + =A0When doing file name based lookups, gdb will canonicalize file names >> + =A0(e.g., expand symlinks) before comparing them, which is an expensive >> + =A0operation. >> + =A0If set, gdb will not assume a file is known by one base name, and t= hus >> + =A0it cannot optimize file name comparisions by skipping the canonical= ization >> + =A0step if the base names are different. >> + =A0If not set, all source files must be known by one base name, >> + =A0and gdb will do file name comparisons more efficiently. > > I suggest to rearrange the text, so as to put together the parts that > describe what happens when the option is set. =A0Like this: > > =A0Set whether a source file may have multiple base names. > =A0(A "base name" is the name of a file with the directory part removed. > =A0Example: The base name of "/home/user/hello.c" is "hello.c".) > =A0If set, GDB will canonicalize file names (e.g., expand symlinks) > =A0before comparing them. =A0Canonicalization is an expensive operation, > =A0but it allows the same file be known by more than one base name. > =A0If not set (the default), all source files are assumed to have just > =A0one base name, and gdb will do file name comparisons more efficiently. > > OK? > >> +When processing file names provided by the user, >> +@value{GDBN} will canonicalize them and remove symbolic links. >> +This ensures that @value{GDBN} will find the right file, >> +even if the debug information specifies an alternate path. >> +However, with large programs this canonicalization can noticeably slow >> +down @value{GDBN}. =A0To compensate, @value{GDBN} will try to avoid >> +this canonicalization wherever possible. =A0One way it can do so >> +is by first comparing the @samp{base name} of a file. >> +The @samp{base name} of a file is simply the file's name without >> +any directory information. =A0For example, the base name of >> +@file{/home/user/hello.c} is @file{hello.c}. >> +By doing this @value{GDBN} can skip, for example, >> +@file{/usr/include/stdio.h} without having to first canonicalize >> +and then compare the directory names. >> +This works great, except when the base name of a file >> +can have multiple names due to symbolic links. >> +For example, if @file{/home/user/bar.c} is a symbolic link to >> +@file{/home/user/foo.c} then @value{GDBN} cannot just look at >> +the base name of two files, it must canonicalize them, expand >> +all symbolic links, and @emph{then} compare the file names >> +to see if they match. >> +Fortunately, having one file known by two different base names >> +does not generally occur in practice. >> +Should it occur, however, @value{GDBN} provides an escape hatch >> +to allow this to work. >> +By setting @code{basenames-may-differ} to @code{true} >> +@value{GDBN} will always canonicalize file names before >> +comparing them, thus ensuring that one file known by multiple >> +base names are treated as the same file. > > This is written as mostly an apology for having this option. =A0That is > a wrong angle for describing features in a user manual, because the > user generally trusts the developers by default to DTRT. =A0So I would > reword it > > =A0When processing file names provided by the user, @value{GDBN} > =A0frequently needs to compare them to the file names recorded in the > =A0program's debug info. =A0Normally, @value{GDBN} compares just the > =A0@dfn{base names} of the files as strings, which is reasonably fast > =A0even for very large programs. =A0(The base name of a file is the last > =A0portion of its name, after stripping all the leading directories.) > =A0This shortcut in comparison is based upon the assumption that files > =A0cannot have more than one base name. =A0This is usually true, but > =A0references to files that use symlinks or similar filesystem > =A0facilities violate that assumption. =A0If your program records files > =A0using such facilities, or if you provide file names to @value{GDBN} > =A0using symlinks etc., you can set @code{basenames-may-differ} to > =A0@code{true} to instruct @value{GDBN} to completely canonicalize each > =A0pair of file names it needs to compare. =A0This will make file-name > =A0comparisons accurate, but at a price of a significant slowdown. > > Do you agree with this wording? > I'm happy if you're happy. Thanks for the suggested wording.