Re: substitute-path problem

Joel Brobecker
2007-01-12T03:20:33Z

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

> I suspect compiling the file with a full path on the gcc command line
> would reproduce this. Do you think we're applying the substitution
> rule in the wrong place?

I can indeed reproduce. I think that we are just missing one case.
First we try the fullpath if we already know it. Then the dirname
if we have it. But if there is no dirname, then we should try the
filename. Chances are, if the dirname is not specified, the file path
is embedded in the filename.

I will test the attach patch and commit if all is fine. In the meantim,
that might help you out in your work.

(I have wondered many times how much easier it would be for us if
we resolved the filename+dirname into a fullpath name at debug info
reading time, and then only stored that in our data structures - not
sure if it is posssible, but if it is, we would be able to assume in
the rest of the code that symbol->filename is always a fullpath, or
the closest to it we can do based on the information the compiler provided.
But I think that would change the behavior of certain things like source
file search with the dir path. I'm not completely sure yet, I would have
to spend some time researching this)

--
Joel

[-- Attachment #2: subst.diff --]
[-- Type: text/plain, Size: 753 bytes --]

Index: source.c
===================================================================
RCS file: /cvs/src/src/gdb/source.c,v
retrieving revision 1.76
diff -u -p -r1.76 source.c
--- source.c 8 Aug 2006 22:06:06 -0000 1.76
+++ source.c 12 Jan 2007 03:15:55 -0000
@@ -1001,6 +1001,16 @@ find_and_open_source (struct objfile *ob
strcat (path + len, source_path + len + cdir_len); /* After $cdir */
}
}
+ else
+ {
+ char *rewritten_filename = rewrite_source_path (filename);
+
+ if (rewritten_filename != NULL)
+ {
+ make_cleanup (xfree, rewritten_filename);
+ filename = rewritten_filename;
+ }
+ }

result = openp (path, OPF_SEARCH_IN_PATH, filename, OPEN_MODE, 0, fullname);
if (result < 0)