From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11970 invoked by alias); 27 Sep 2005 07:42:17 -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 11293 invoked by uid 22791); 27 Sep 2005 07:40:00 -0000 Received: from chfw.preston.net (HELO universe.preston.net) (202.14.89.130) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Tue, 27 Sep 2005 07:40:00 +0000 Received: from norman (norman.preston.net [202.14.10.82]) by universe.preston.net (8.11.6/8.11.6) with ESMTP id j8R7duF06975 for ; Tue, 27 Sep 2005 17:39:56 +1000 Subject: Relative source file search From: Craig Jeffree To: gdb-patches@sources.redhat.com Content-Type: multipart/mixed; boundary="=-iIz/cHsoO2G+CBas0kv8" Date: Tue, 27 Sep 2005 07:42:00 -0000 Message-Id: <1127806796.32709.17.camel@norman> Mime-Version: 1.0 X-SW-Source: 2005-09/txt/msg00246.txt.bz2 --=-iIz/cHsoO2G+CBas0kv8 Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 462 A while ago I reported problems locating source files that are specified with relative paths in the compile line, detailed here: http://sourceware.org/ml/gdb/2005-08/msg00066.html Since then I've had a play around with the code and come up with the attached diff which seems to solve the problem for me. I couldn't see any side effects as a result. Can someone run a second set of eyes over this so that it can get accepted to the mainline. Thanks, Craig. --=-iIz/cHsoO2G+CBas0kv8 Content-Disposition: attachment; filename=relsrcsrch.diff Content-Type: text/x-patch; name=relsrcsrch.diff; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-length: 1657 Index: source.c =================================================================== RCS file: /cvs/src/src/gdb/source.c,v retrieving revision 1.70 diff -c -p -r1.70 source.c *** source.c 29 Aug 2005 12:57:49 -0000 1.70 --- source.c 27 Sep 2005 07:27:26 -0000 *************** find_and_open_source (struct objfile *ob *** 893,901 **** --- 893,917 ---- int open_source_file (struct symtab *s) { + char *filename; + if (!s) return -1; + /* Use the concatenation of dirname and filename if dirname isn't absolute */ + if (s->filename && s->dirname && !IS_ABSOLUTE_PATH (s->dirname)) + { + filename = (char *) + alloca (strlen (s->dirname) + strlen (SLASH_STRING) + + strlen (s->filename) + 1); + + strcpy(filename, s->dirname); + strcat(filename, SLASH_STRING); + strcat(filename, s->filename); + + return find_and_open_source (s->objfile, filename, NULL, &s->fullname); + } + return find_and_open_source (s->objfile, s->filename, s->dirname, &s->fullname); } Index: ChangeLog =================================================================== RCS file: /cvs/src/src/gdb/ChangeLog,v retrieving revision 1.7365 diff -c -p -r1.7365 ChangeLog *** ChangeLog 26 Sep 2005 22:31:16 -0000 1.7365 --- ChangeLog 27 Sep 2005 07:27:31 -0000 *************** *** 1,3 **** --- 1,8 ---- + 2005-09-27 Craig Jeffree + + * source.c (open_source_file): Handle relative dirname during source + file search. + 2005-09-26 Nick Roberts * Makefile.in (HFILES_NO_SRCDIR): Remove minimon.h, symfile-mem.h. --=-iIz/cHsoO2G+CBas0kv8--