This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Relative source file search


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.

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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]