From f079a2e599ced3a094c9b70fb38cb9bdf9d746d1 Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Fri, 5 Apr 2002 16:42:04 +0000 Subject: [PATCH] (lookup_symtab): Use the new xfullpath function, in order to be able to match a filename with either the real filename, or the name of any symbolic link to this file. (lookup_partial_symtab): Ditto. --- gdb/symtab.c | 59 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 13 deletions(-) diff --git a/gdb/symtab.c b/gdb/symtab.c index bf6df51806f..e32dcf761ae 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -144,11 +144,17 @@ lookup_symtab (const char *name) register struct partial_symtab *ps; register struct objfile *objfile; char *real_path = NULL; + char *full_path = NULL; /* Here we are interested in canonicalizing an absolute path, not absolutizing a relative path. */ if (IS_ABSOLUTE_PATH (name)) - real_path = gdb_realpath (name); + { + full_path = xfullpath (name); + make_cleanup (xfree, full_path); + real_path = gdb_realpath (name); + make_cleanup (xfree, real_path); + } got_symtab: @@ -158,24 +164,32 @@ got_symtab: { if (FILENAME_CMP (name, s->filename) == 0) { - xfree (real_path); return s; } + /* If the user gave us an absolute path, try to find the file in this symtab and use its absolute path. */ + + if (full_path != NULL) + { + const char *fp = symtab_to_filename (s); + if (FILENAME_CMP (full_path, fp) == 0) + { + return s; + } + } + if (real_path != NULL) { - char *rp = symtab_to_filename (s); + const char *rp = gdb_realpath (symtab_to_filename (s)); + make_cleanup (xfree, rp); if (FILENAME_CMP (real_path, rp) == 0) { - xfree (real_path); return s; } } } - xfree (real_path); - /* Now, search for a matching tail (only if name doesn't have any dirs) */ if (lbasename (name) == name) @@ -221,36 +235,55 @@ lookup_partial_symtab (const char *name) { register struct partial_symtab *pst; register struct objfile *objfile; + char *full_path = NULL; char *real_path = NULL; /* Here we are interested in canonicalizing an absolute path, not absolutizing a relative path. */ if (IS_ABSOLUTE_PATH (name)) - real_path = gdb_realpath (name); + { + full_path = xfullpath (name); + make_cleanup (xfree, full_path); + real_path = gdb_realpath (name); + make_cleanup (xfree, real_path); + } ALL_PSYMTABS (objfile, pst) { if (FILENAME_CMP (name, pst->filename) == 0) { - xfree (real_path); return (pst); } + /* If the user gave us an absolute path, try to find the file in this symtab and use its absolute path. */ - if (real_path != NULL) + if (full_path != NULL) { if (pst->fullname == NULL) source_full_path_of (pst->filename, &pst->fullname); if (pst->fullname != NULL - && FILENAME_CMP (real_path, pst->fullname) == 0) + && FILENAME_CMP (full_path, pst->fullname) == 0) { - xfree (real_path); return pst; } } - } - xfree (real_path); + if (real_path != NULL) + { + char *rp = NULL; + if (pst->fullname == NULL) + source_full_path_of (pst->filename, &pst->fullname); + if (pst->fullname != NULL) + { + rp = gdb_realpath (pst->fullname); + make_cleanup (xfree, rp); + } + if (rp != NULL && FILENAME_CMP (real_path, rp) == 0) + { + return pst; + } + } + } /* Now, search for a matching tail (only if name doesn't have any dirs) */ -- 2.30.2