aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2001-12-21 22:32:37 +0000
committerTom Tromey <tromey@redhat.com>2001-12-21 22:32:37 +0000
commit58d370e0e6b0b1cc1df5b587ca39a14e975f5850 (patch)
treea9f4b92ec61a2199bbe1ee7d60063c67ce99263c
parenta532ca62825cc3e09712af03d0dfaaf4ae96ffbf (diff)
downloadfsf-binutils-gdb-58d370e0e6b0b1cc1df5b587ca39a14e975f5850.zip
fsf-binutils-gdb-58d370e0e6b0b1cc1df5b587ca39a14e975f5850.tar.gz
fsf-binutils-gdb-58d370e0e6b0b1cc1df5b587ca39a14e975f5850.tar.bz2
* configure, config.in: Rebuilt.
* configure.in: Check for realpath. * defs.h (gdb_realpath): Declare. * symtab.h (partial_symtab): Added fullname field. * source.c (openp): Use gdb_realpath. (forget_cached_source_info): Clear full name of each partial symtab. * utils.c (gdb_realpath): New function. * symtab.c (lookup_symtab): Removed. (lookup_symtab_1): Renamed to lookup_symtab. (lookup_symtab): Look for real path. (lookup_partial_symtab): Likewise.
-rw-r--r--gdb/ChangeLog15
-rw-r--r--gdb/config.in3
-rwxr-xr-xgdb/configure2
-rw-r--r--gdb/configure.in2
-rw-r--r--gdb/defs.h2
-rw-r--r--gdb/source.c16
-rw-r--r--gdb/symtab.c48
-rw-r--r--gdb/symtab.h4
-rw-r--r--gdb/utils.c12
9 files changed, 99 insertions, 5 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a3bbbdc..c2202bf 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,18 @@
+2001-12-21 Tom Tromey <tromey@redhat.com>
+
+ * configure, config.in: Rebuilt.
+ * configure.in: Check for realpath.
+ * defs.h (gdb_realpath): Declare.
+ * symtab.h (partial_symtab): Added fullname field.
+ * source.c (openp): Use gdb_realpath.
+ (forget_cached_source_info): Clear full name of each partial
+ symtab.
+ * utils.c (gdb_realpath): New function.
+ * symtab.c (lookup_symtab): Removed.
+ (lookup_symtab_1): Renamed to lookup_symtab.
+ (lookup_symtab): Look for real path.
+ (lookup_partial_symtab): Likewise.
+
2001-12-21 Michael Snyder <msnyder@redhat.com>
* maint.c (match_substring): New function. Tokenizer for
diff --git a/gdb/config.in b/gdb/config.in
index c80d8a8..faca85e 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -220,6 +220,9 @@
/* Define if you have the putenv function. */
#undef HAVE_PUTENV
+/* Define if you have the realpath function. */
+#undef HAVE_REALPATH
+
/* Define if you have the sbrk function. */
#undef HAVE_SBRK
diff --git a/gdb/configure b/gdb/configure
index dcb5ce2..e1881ff 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -3582,7 +3582,7 @@ EOF
fi
-for ac_func in bcopy btowc bzero isascii poll sbrk setpgid setpgrp \
+for ac_func in bcopy btowc bzero isascii poll realpath sbrk setpgid setpgrp \
sigaction sigprocmask sigsetmask
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
diff --git a/gdb/configure.in b/gdb/configure.in
index 8df5c87..43a5c0e 100644
--- a/gdb/configure.in
+++ b/gdb/configure.in
@@ -131,7 +131,7 @@ AC_HEADER_STAT
AC_C_CONST
-AC_CHECK_FUNCS(bcopy btowc bzero isascii poll sbrk setpgid setpgrp \
+AC_CHECK_FUNCS(bcopy btowc bzero isascii poll realpath sbrk setpgid setpgrp \
sigaction sigprocmask sigsetmask)
AC_FUNC_ALLOCA
AC_FUNC_VFORK
diff --git a/gdb/defs.h b/gdb/defs.h
index 48adef51..e573854 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -575,6 +575,8 @@ extern void init_page_info (void);
extern CORE_ADDR host_pointer_to_address (void *ptr);
extern void *address_to_host_pointer (CORE_ADDR addr);
+extern char *gdb_realpath (const char *);
+
/* From demangle.c */
extern void set_demangling_style (char *);
diff --git a/gdb/source.c b/gdb/source.c
index d04f886..dab794f 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -234,6 +234,7 @@ forget_cached_source_info (void)
{
register struct symtab *s;
register struct objfile *objfile;
+ struct partial_symtab *pst;
for (objfile = object_files; objfile != NULL; objfile = objfile->next)
{
@@ -250,6 +251,15 @@ forget_cached_source_info (void)
s->fullname = NULL;
}
}
+
+ ALL_OBJFILE_PSYMTABS (objfile, pst)
+ {
+ if (pst->fullname != NULL)
+ {
+ xfree (pst->fullname);
+ pst->fullname = NULL;
+ }
+ }
}
}
@@ -603,15 +613,17 @@ done:
if (fd < 0)
*filename_opened = NULL;
else if (IS_ABSOLUTE_PATH (filename))
- *filename_opened = savestring (filename, strlen (filename));
+ *filename_opened = gdb_realpath (filename);
else
{
/* Beware the // my son, the Emacs barfs, the botch that catch... */
- *filename_opened = concat (current_directory,
+ char *f = concat (current_directory,
IS_DIR_SEPARATOR (current_directory[strlen (current_directory) - 1])
? "" : SLASH_STRING,
filename, NULL);
+ *filename_opened = gdb_realpath (f);
+ xfree (f);
}
}
/* OBSOLETE #ifdef MPW */
diff --git a/gdb/symtab.c b/gdb/symtab.c
index d11daba..2353ae5 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -141,14 +141,38 @@ lookup_symtab (const char *name)
register struct symtab *s;
register struct partial_symtab *ps;
register struct objfile *objfile;
+ 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);
got_symtab:
/* First, search for an exact match */
ALL_SYMTABS (objfile, s)
+ {
if (FILENAME_CMP (name, s->filename) == 0)
- return s;
+ {
+ 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 (real_path != NULL)
+ {
+ char *rp = symtab_to_filename (s);
+ 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) */
@@ -195,15 +219,37 @@ lookup_partial_symtab (const char *name)
{
register struct partial_symtab *pst;
register struct objfile *objfile;
+ 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);
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 (pst->fullname == NULL)
+ source_full_path_of (pst->filename, &pst->fullname);
+ if (pst->fullname != NULL
+ && FILENAME_CMP (real_path, pst->fullname) == 0)
+ {
+ xfree (real_path);
+ return pst;
+ }
+ }
}
+ xfree (real_path);
+
/* Now, search for a matching tail (only if name doesn't have any dirs) */
if (lbasename (name) == name)
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 841da4d..f01cbbe 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -967,6 +967,10 @@ struct partial_symtab
char *filename;
+ /* Full path of the source file. NULL if not known. */
+
+ char *fullname;
+
/* Information about the object file from which symbols should be read. */
struct objfile *objfile;
diff --git a/gdb/utils.c b/gdb/utils.c
index 4d12c39..a5ff555 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -2544,3 +2544,15 @@ string_to_core_addr (const char *my_string)
}
return addr;
}
+
+char *
+gdb_realpath (const char *filename)
+{
+#ifdef HAVE_REALPATH
+ char buf[PATH_MAX];
+ char *rp = realpath (filename, buf);
+ return xstrdup (rp ? rp : filename);
+#else
+ return xstrdup (filename);
+#endif
+}