This is the mail archive of the gdb-patches@sources.redhat.com 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]

[RFC PATCH] Finding files in source trees (was Re: Finding source files under Cygwin)


Christopher Faylor wrote:
> I'm sorry but it is rarely a good idea to mix functionality like this.
> You're mixing an (arguable) bug fix with an (arguable) gdb enhancement.
> 
> Please submit each as a separate patch.

Ok. This patch allows files to be found in source trees.

The motivation for this addition is to accommodate large projects
where source files are scattered in large source trees. I want to
be able to point gdb at the root of the source tree, rather than have
to specify each leaf directory. Thus I can write:

       gdb> dir /myproject/source

instead of:

       gdb> dir /myproject/source/a/b/c:/myproject/source/z/b/d: etc

Earl

ChangeLog:

        * source.c: Source file lookup changes.
        (open_source_file): If the source file
        /w/x/y/z.c cannot be found, try using w/x/y/z.c,
        x/y/z.c, y/z.c in addition to z.c (the basename).

--- gdb-5.2.1\gdb\source.c      2002-09-16 13:08:17.000000000 -0700
+++ source.c    2002-09-16 13:09:31.000000000 -0700
@@ -753,6 +753,25 @@
        result = openp_1 (path, pathlen, sep, 0, p, OPEN_MODE, 0,
&s->fullname);
     }
 
+  if (result < 0)
+   {
+     /* Didn't work. Try lopping off prefixes from the full name. */
+     p = s->filename;
+
+     do
+       {
+         while (*p && ! IS_DIR_SEPARATOR (*p))
+           p++;
+         if (*p && *++p)
+           {
+             result = openp_1 (path, pathlen, sep, 0,
+                               p, OPEN_MODE, 0, &s->fullname);
+             if (result >= 0)
+                 break;
+           }
+       } while (*p);
+   }
+
   if (result >= 0)
     {
       fullname = s->fullname;


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