This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFC PATCH] Finding files in source trees (was Re: Finding source files under Cygwin)
Daniel Jacobowitz wrote:
> This patch needs a lot more testing before I'd be comfortable with it.
> We went to a fair amount of trouble to support finding the right file
> when multiple files have the same name.
>
> For instance, given:
> dir /a:/b
> filename foo/bar.c
>
> files /a/bar.c /b/foo/bar.c
>
> will your patch find /b/foo/bar.c? I don't think it will.
Hmm... I think it will. The patch doesn't replace any of the
existing code in open_source_file() --- it adds an extra
search option at the end of the function. In pseudo-code:
a. return s->fullname if present // Previously resolved name
b. if s->dirname available
replace $cdir in path
c. search for s->filename in path
d. if not found, search for lbasename(s->filename) in path
+ e. if not found, repeatedly lop separators from head
+ of s->filename and search in path
(My addition is indicated with +)
> For instance, given:
> dir /a:/b
> filename foo/bar.c
>
> files /a/bar.c /b/foo/bar.c
>
> will your patch find /b/foo/bar.c? I don't think it will.
In your example, I'm pretty sure foo/bar.c will be found
at step (c).
My patch at step (e) will only triggered as a last resort,
when open_source_file couldn't find the file anywhere else.
Earl