Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Craig Jeffree <craig.jeffree@preston.net>
To: Bob Rossi <bob@brasko.net>
Cc: Daniel Jacobowitz <drow@false.org>, gdb-patches@sources.redhat.com
Subject: Re: [PATCH] Relative source file search
Date: Mon, 10 Oct 2005 04:57:00 -0000	[thread overview]
Message-ID: <1128920165.25000.56.camel@norman> (raw)
In-Reply-To: <20051007002522.GA7444@white>

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

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.



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

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);
     }
 

  reply	other threads:[~2005-10-10  4:57 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-27  7:42 Craig Jeffree
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 [this message]
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=1128920165.25000.56.camel@norman \
    --to=craig.jeffree@preston.net \
    --cc=bob@brasko.net \
    --cc=drow@false.org \
    --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