From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1545 invoked by alias); 27 Apr 2005 15:52:10 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 301 invoked from network); 27 Apr 2005 15:50:48 -0000 Received: from unknown (HELO romy.inter.net.il) (192.114.186.66) by sourceware.org with SMTP; 27 Apr 2005 15:50:48 -0000 Received: from zaretski (IGLD-80-230-41-251.inter.net.il [80.230.41.251]) by romy.inter.net.il (MOS 3.5.6-GR) with ESMTP id BBY17588 (AUTH halo1); Wed, 27 Apr 2005 18:50:30 +0300 (IDT) Date: Wed, 27 Apr 2005 15:52:00 -0000 From: "Eli Zaretskii" To: bug-gdb@rich-paul.net Message-ID: <01c54b40$Blat.v2.4$be3bafe0@zahav.net.il> Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=ISO-8859-1 CC: bug-gdb@gnu.org, gdb-patches@sources.redhat.com In-reply-to: <20050427143620.GA1686@nevyn.them.org> (message from Daniel Jacobowitz on Wed, 27 Apr 2005 10:36:20 -0400) Subject: Re: [RFA] Fix file name generation in edit_command (was: Ver 6.3 edit command failing) Reply-to: Eli Zaretskii References: <01c54b35$Blat.v2.4$c3f52520@zahav.net.il> <20050427143620.GA1686@nevyn.them.org> X-SW-Source: 2005-04/txt/msg00361.txt.bz2 > Date: Wed, 27 Apr 2005 10:36:20 -0400 > From: Daniel Jacobowitz > Cc: bug-gdb@rich-paul.net, bug-gdb@gnu.org, gdb-patches@sources.redhat.com > > I can simplify this a whole lot further :-) > > You should use symtab_to_fullname. Then all the fallback logic is > unnecessary; if symtab_to_fullname fails, GDB does not know where the > file is. Thanks for the tip. Here's the revised patch: 2005-04-27 Eli Zaretskii * cli/cli-cmds.c (edit_command): If symtab->fullname is not yet set, use symtab_to_fullname , instead of trying to do its job. --- gdb/cli/cli-cmds.c~0 2005-03-26 16:18:14.000000000 +0300 +++ gdb/cli/cli-cmds.c 2005-04-27 18:37:34.000000000 +0300 @@ -554,7 +554,7 @@ edit_command (char *arg, int from_tty) int cmdlen, log10; unsigned m; char *editor; - char *p; + char *p, *fn; /* Pull in the current default source line if necessary */ if (arg == 0) @@ -627,23 +627,26 @@ edit_command (char *arg, int from_tty) if ((editor = (char *) getenv ("EDITOR")) == NULL) editor = "/bin/ex"; - + /* Approximate base-10 log of line to 1 unit for digit count */ for(log10=32, m=0x80000000; !(sal.line & m) && log10>0; log10--, m=m>>1); log10 = 1 + (int)((log10 + (0 == ((m-1) & sal.line)))/3.32192809); - cmdlen = strlen(editor) + 1 - + (NULL == sal.symtab->dirname ? 0 : strlen(sal.symtab->dirname) + 1) - + (NULL == sal.symtab->filename? 0 : strlen(sal.symtab->filename)+ 1) - + log10 + 2; - + /* If we don't already know the full absolute file name of the + source file, find it now. */ + if (NULL == sal.symtab->fullname) + { + fn = symtab_to_fullname (sal.symtab); + if (NULL == fn) + fn = "unknown"; + } + else + fn = sal.symtab->fullname; + + /* $EDITOR blank +NN blank file \0 */ + cmdlen = strlen(editor) + 1 + log10 + 2 + strlen(fn) + 1; p = xmalloc(cmdlen); - sprintf(p,"%s +%d %s%s",editor,sal.line, - (NULL == sal.symtab->dirname ? "./" : - (NULL != sal.symtab->filename && *(sal.symtab->filename) != '/') ? - sal.symtab->dirname : ""), - (NULL == sal.symtab->filename ? "unknown" : sal.symtab->filename) - ); + sprintf (p, "%s +%d %s", editor, sal.line, fn); shell_escape(p, from_tty); xfree(p);