Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Craig Jeffree <craig.jeffree@preston.net>
To: gdb-patches@sources.redhat.com
Subject: Relative source file search
Date: Tue, 27 Sep 2005 07:42:00 -0000	[thread overview]
Message-ID: <1127806796.32709.17.camel@norman> (raw)

[-- Attachment #1: Type: text/plain, Size: 462 bytes --]

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.


[-- Attachment #2: relsrcsrch.diff --]
[-- Type: text/x-patch, Size: 1657 bytes --]

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 <craig.jeffree@preston.net>
+ 
+ 	* source.c (open_source_file): Handle relative dirname during source
+         file search.
+ 
  2005-09-26  Nick Roberts  <nickrob@snap.net.nz>
  
  	* Makefile.in (HFILES_NO_SRCDIR): Remove minimon.h, symfile-mem.h.

             reply	other threads:[~2005-09-27  7:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-27  7:42 Craig Jeffree [this message]
2005-10-04  1:24 ` [PATCH] " Craig Jeffree
2005-10-04  1:35   ` Daniel Jacobowitz
2005-10-06  0:57     ` Craig Jeffree
2005-10-06  2:16       ` Bob Rossi
2005-10-06  2:49         ` Craig Jeffree
2005-10-06 13:00           ` Bob Rossi
2005-10-06 23:33             ` Craig Jeffree
2005-10-07  0:25               ` Bob Rossi
2005-10-10  4:57                 ` Craig Jeffree
2005-10-10 10:46                   ` Bob Rossi
2005-10-10 16:46                   ` Bob Rossi
2005-10-10 16:47                   ` Daniel Jacobowitz
2005-10-10 23:15                     ` Craig Jeffree

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1127806796.32709.17.camel@norman \
    --to=craig.jeffree@preston.net \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox