From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2073 invoked by alias); 10 Oct 2005 04:57:00 -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 2066 invoked by uid 22791); 10 Oct 2005 04:56:57 -0000 Received: from 220-245-201-253.static.tpgi.com.au (HELO universe.preston.net) (220.245.201.253) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Mon, 10 Oct 2005 04:56:57 +0000 Received: from norman (norman.preston.net [202.14.10.82]) by universe.preston.net (8.11.6/8.11.6) with ESMTP id j9A4u5h01785; Mon, 10 Oct 2005 14:56:20 +1000 Subject: Re: [PATCH] Relative source file search From: Craig Jeffree To: Bob Rossi Cc: Daniel Jacobowitz , gdb-patches@sources.redhat.com In-Reply-To: <20051007002522.GA7444@white> References: <1127806796.32709.17.camel@norman> <1128389039.32709.128.camel@norman> <20051004013535.GA24000@nevyn.them.org> <1128560230.18954.14.camel@norman> <20051006021548.GA5232@white> <1128566917.18954.39.camel@norman> <20051006130035.GA6184@white> <1128641520.18954.63.camel@norman> <20051007002522.GA7444@white> Content-Type: multipart/mixed; boundary="=-37a6w/RW1vL/+6TBqlMo" Date: Mon, 10 Oct 2005 04:57:00 -0000 Message-Id: <1128920165.25000.56.camel@norman> Mime-Version: 1.0 X-SW-Source: 2005-10/txt/msg00092.txt.bz2 --=-37a6w/RW1vL/+6TBqlMo Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 831 On Thu, 2005-10-06 at 20:25 -0400, Bob Rossi wrote: > Craig, you should be able to put your patch into > source.c:find_and_open_source in the part where it checks for > if (dirname != NULL) > { > ... > } > > instead of appending to the source_path, simply change the filename and > leave the source_path alone. Run this through the testsuite, are there > any errors? Attached is a new patch with the change in find_and_open_source. I haven't had any luck with the testsuite though, I kept getting a build error, then I did a cvs update to make sure I had the latest, now the whole thing won't build. Does the cvs head build today? I'm getting make[4]: Entering directory `/staff/cjeffree/gdb/gdb-cvs/src/opcodes/po' make[4]: *** No rule to make target `ga.po', needed by `ga.gmo'. Stop. Cheers, Craig. --=-37a6w/RW1vL/+6TBqlMo Content-Disposition: attachment; filename=relsrcsrch2.diff Content-Type: text/x-patch; name=relsrcsrch2.diff; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-length: 2929 Index: gdb/source.c =================================================================== RCS file: /cvs/src/src/gdb/source.c,v retrieving revision 1.70 diff -u -r1.70 source.c --- gdb/source.c 29 Aug 2005 12:57:49 -0000 1.70 +++ gdb/source.c 10 Oct 2005 03:53:53 -0000 @@ -831,6 +831,7 @@ char **fullname) { char *path = source_path; + char *file = filename; const char *p; int result; @@ -847,31 +848,45 @@ if (dirname != NULL) { - /* Replace a path entry of $cdir with the compilation directory name */ + if (IS_ABSOLUTE_PATH(dirname)) + { + /* Replace a path entry of $cdir with the compilation directory name */ #define cdir_len 5 - /* We cast strstr's result in case an ANSIhole has made it const, - which produces a "required warning" when assigned to a nonconst. */ - p = (char *) strstr (source_path, "$cdir"); - if (p && (p == path || p[-1] == DIRNAME_SEPARATOR) - && (p[cdir_len] == DIRNAME_SEPARATOR || p[cdir_len] == '\0')) - { - int len; - - path = (char *) - alloca (strlen (source_path) + 1 + strlen (dirname) + 1); - len = p - source_path; - strncpy (path, source_path, len); /* Before $cdir */ - strcpy (path + len, dirname); /* new stuff */ - strcat (path + len, source_path + len + cdir_len); /* After $cdir */ - } + /* We cast strstr's result in case an ANSIhole has made it const, + which produces a "required warning" when assigned to a nonconst. */ + p = (char *) strstr (source_path, "$cdir"); + if (p && (p == path || p[-1] == DIRNAME_SEPARATOR) + && (p[cdir_len] == DIRNAME_SEPARATOR || p[cdir_len] == '\0')) + { + int len; + + path = (char *) + alloca (strlen (source_path) + 1 + strlen (dirname) + 1); + len = p - source_path; + strncpy (path, source_path, len); /* Before $cdir */ + strcpy (path + len, dirname); /* new stuff */ + strcat (path + len, source_path + len + cdir_len); /* After $cdir */ + } + } + else + { + /* Use the concatenation of dirname and filename if dirname isn't absolute */ + file = (char *) + alloca (strlen (dirname) + strlen (SLASH_STRING) + + strlen (filename) + 1); + + strcpy(file, dirname); + strcat(file, SLASH_STRING); + strcat(file, filename); + } } - result = openp (path, OPF_SEARCH_IN_PATH, filename, OPEN_MODE, 0, fullname); + result = openp (path, OPF_SEARCH_IN_PATH, file, OPEN_MODE, 0, fullname); if (result < 0) { /* Didn't work. Try using just the basename. */ - p = lbasename (filename); - if (p != filename) + p = lbasename (file); + if (p != file) result = openp (path, OPF_SEARCH_IN_PATH, p, OPEN_MODE, 0, fullname); } --=-37a6w/RW1vL/+6TBqlMo--