* gdbarch.sh: Document the return_value method. Explain that
[deliverable/binutils-gdb.git] / gdb / source.c
index b1f4ba5835722f83baa8893dd5a02ec73bd5bc45..ceca38bd10a727501cb9e059c2c5b7f53ad4013b 100644 (file)
@@ -1,6 +1,6 @@
 /* List lines of source files for GDB, the GNU debugger.
    Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
-   1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007
+   1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008
    Free Software Foundation, Inc.
 
    This file is part of GDB.
@@ -369,7 +369,7 @@ directory_command (char *dirname, int from_tty)
   /* FIXME, this goes to "delete dir"... */
   if (dirname == 0)
     {
-      if (from_tty && query (_("Reinitialize source path to empty? ")))
+      if (!from_tty || query (_("Reinitialize source path to empty? ")))
        {
          xfree (source_path);
          init_source_path ();
@@ -927,15 +927,19 @@ rewrite_source_path (const char *path)
    DIRNAME is the compilation directory of a particular source file.
            Only some debug formats provide this info.
    FULLNAME can be the last known absolute path to the file in question.
+     Space for the path must have been malloc'd.  If a path substitution
+     is applied we free the old value and set a new one.
 
    On Success 
      A valid file descriptor is returned. ( the return value is positive )
      FULLNAME is set to the absolute path to the file just opened.
+     The caller is responsible for freeing FULLNAME.
 
    On Failure
      An invalid file descriptor is returned. ( the return value is negative ) 
      FULLNAME is set to NULL.  */
-int
+
+static int
 find_and_open_source (struct objfile *objfile,
                      const char *filename,
                      const char *dirname,
@@ -999,10 +1003,11 @@ find_and_open_source (struct objfile *objfile,
          strcat (path + len, source_path + len + cdir_len);    /* After $cdir */
        }
     }
-  else
+
+  if (IS_ABSOLUTE_PATH (filename))
     {
-      /* If dirname is NULL, chances are the path is embedded in
-         the filename.  Try the source path substitution on it.  */
+      /* If filename is absolute path, try the source path
+        substitution on it.  */
       char *rewritten_filename = rewrite_source_path (filename);
 
       if (rewritten_filename != NULL)
@@ -1021,13 +1026,6 @@ find_and_open_source (struct objfile *objfile,
        result = openp (path, OPF_SEARCH_IN_PATH, p, OPEN_MODE, 0, fullname);
     }
 
-  if (result >= 0)
-    {
-      char *tmp_fullname;
-      tmp_fullname = *fullname;
-      *fullname = xstrdup (tmp_fullname);
-      xfree (tmp_fullname);
-    }
   return result;
 }
 
@@ -1126,9 +1124,9 @@ find_source_lines (struct symtab *s, int desc)
     perror_with_name (s->filename);
 
   if (s->objfile && s->objfile->obfd)
-    mtime = bfd_get_mtime (s->objfile->obfd);
+    mtime = s->objfile->mtime;
   else if (exec_bfd)
-    mtime = bfd_get_mtime (exec_bfd);
+    mtime = exec_bfd_mtime;
 
   if (mtime && mtime < st.st_mtime)
     warning (_("Source file is more recent than executable."));
This page took 0.027705 seconds and 4 git commands to generate.