* psymtab.c (psymtab_to_fullname): Use cached copy if it exists.
authorDoug Evans <dje@google.com>
Thu, 10 Nov 2011 22:14:16 +0000 (22:14 +0000)
committerDoug Evans <dje@google.com>
Thu, 10 Nov 2011 22:14:16 +0000 (22:14 +0000)
* source.c (symtab_to_fullname): Ditto.

gdb/ChangeLog
gdb/psymtab.c
gdb/source.c

index 4cdc9ede831195f2b3a8539d26c167922e95481a..63deaf1db5efa38a768176c7281a193e659c393e 100644 (file)
@@ -10,6 +10,9 @@
 
 2011-11-10  Doug Evans  <dje@google.com>
 
+       * psymtab.c (psymtab_to_fullname): Use cached copy if it exists.
+       * source.c (symtab_to_fullname): Ditto.
+
        * defs.h (is_cplus_marker, set_demangling_style): Moved to ...
        * gdb-demangle.h: ... here.  New file.
        * demangle.c: #include "gdb-demangle.h".
index 1f3b3dc64c010d9fe08ecf06b9b25c0be79b8ddd..38adca2e2274cb08e1ee2b7acfe0d10884fa65b4 100644 (file)
@@ -1110,6 +1110,7 @@ int find_and_open_source (const char *filename,
 
    If this function fails to find the file that this partial_symtab represents,
    NULL will be returned and ps->fullname will be set to NULL.  */
+
 static char *
 psymtab_to_fullname (struct partial_symtab *ps)
 {
@@ -1118,8 +1119,12 @@ psymtab_to_fullname (struct partial_symtab *ps)
   if (!ps)
     return NULL;
 
-  /* Don't check ps->fullname here, the file could have been
-     deleted/moved/..., look for it again.  */
+  /* Use cached copy if we have it.
+     We rely on forget_cached_source_info being called appropriately
+     to handle cases like the file being moved.  */
+  if (ps->fullname)
+    return ps->fullname;
+
   r = find_and_open_source (ps->filename, ps->dirname, &ps->fullname);
 
   if (r >= 0)
index 6e29172f601d9372c248fa81062972c982ba8e1b..77df54138f6331ccfcb0851f0cc84b03475cd89f 100644 (file)
@@ -1105,6 +1105,7 @@ open_source_file (struct symtab *s)
 
    If this function fails to find the file that this symtab represents,
    NULL will be returned and s->fullname will be set to NULL.  */
+
 char *
 symtab_to_fullname (struct symtab *s)
 {
@@ -1113,8 +1114,12 @@ symtab_to_fullname (struct symtab *s)
   if (!s)
     return NULL;
 
-  /* Don't check s->fullname here, the file could have been 
-     deleted/moved/..., look for it again.  */
+  /* Use cached copy if we have it.
+     We rely on forget_cached_source_info being called appropriately
+     to handle cases like the file being moved.  */
+  if (s->fullname)
+    return s->fullname;
+
   r = find_and_open_source (s->filename, s->dirname, &s->fullname);
 
   if (r >= 0)