* configure.ac: Check for memmem declaration.
[deliverable/binutils-gdb.git] / gdb / source.c
index 6e2558b56c51b5987838b2685d00f9e61a9a988e..e0ae0b179fd8c3221b0c09ce10d7200629fa65c7 100644 (file)
@@ -239,7 +239,7 @@ select_source_symtab (struct symtab *s)
 
   /* Make the default place to list be the function `main'
      if one exists.  */
 
   /* Make the default place to list be the function `main'
      if one exists.  */
-  if (lookup_symbol (main_name (), 0, VAR_DOMAIN, 0, NULL))
+  if (lookup_symbol (main_name (), 0, VAR_DOMAIN, 0))
     {
       sals = decode_line_spec (main_name (), 1);
       sal = sals.sals[0];
     {
       sals = decode_line_spec (main_name (), 1);
       sal = sals.sals[0];
@@ -250,7 +250,8 @@ select_source_symtab (struct symtab *s)
        return;
     }
 
        return;
     }
 
-  /* All right; find the last file in the symtab list (ignoring .h's).  */
+  /* Alright; find the last file in the symtab list (ignoring .h's
+     and namespace symtabs).  */
 
   current_source_line = 1;
 
 
   current_source_line = 1;
 
@@ -260,14 +261,15 @@ select_source_symtab (struct symtab *s)
        {
          const char *name = s->filename;
          int len = strlen (name);
        {
          const char *name = s->filename;
          int len = strlen (name);
-         if (!(len > 2 && strcmp(&name[len - 2], ".h") == 0))
+         if (!(len > 2 && (strcmp (&name[len - 2], ".h") == 0
+             || strcmp (name, "<<C++-namespaces>>") == 0)))
            current_source_symtab = s;
        }
     }
   if (current_source_symtab)
     return;
 
            current_source_symtab = s;
        }
     }
   if (current_source_symtab)
     return;
 
-  /* Howabout the partial symbol tables? */
+  /* How about the partial symbol tables?  */
 
   for (ofp = object_files; ofp != NULL; ofp = ofp->next)
     {
 
   for (ofp = object_files; ofp != NULL; ofp = ofp->next)
     {
@@ -275,7 +277,8 @@ select_source_symtab (struct symtab *s)
        {
          const char *name = ps->filename;
          int len = strlen (name);
        {
          const char *name = ps->filename;
          int len = strlen (name);
-         if (!(len > 2 && strcmp (&name[len - 2], ".h") == 0))
+         if (!(len > 2 && (strcmp (&name[len - 2], ".h") == 0
+             || strcmp (name, "<<C++-namespaces>>") == 0)))
            cs_pst = ps;
        }
     }
            cs_pst = ps;
        }
     }
@@ -369,7 +372,7 @@ directory_command (char *dirname, int from_tty)
   /* FIXME, this goes to "delete dir"... */
   if (dirname == 0)
     {
   /* 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 ();
        {
          xfree (source_path);
          init_source_path ();
@@ -927,15 +930,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.
    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.
 
    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.  */
 
    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,
 find_and_open_source (struct objfile *objfile,
                      const char *filename,
                      const char *dirname,
@@ -999,10 +1006,11 @@ find_and_open_source (struct objfile *objfile,
          strcat (path + len, source_path + len + cdir_len);    /* After $cdir */
        }
     }
          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)
       char *rewritten_filename = rewrite_source_path (filename);
 
       if (rewritten_filename != NULL)
@@ -1021,13 +1029,6 @@ find_and_open_source (struct objfile *objfile,
        result = openp (path, OPF_SEARCH_IN_PATH, p, OPEN_MODE, 0, fullname);
     }
 
        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;
 }
 
   return result;
 }
 
@@ -1048,11 +1049,11 @@ open_source_file (struct symtab *s)
 
 /* Finds the fullname that a symtab represents.
 
 
 /* Finds the fullname that a symtab represents.
 
-   If this functions finds the fullname, it will save it in ps->fullname
+   If this functions finds the fullname, it will save it in s->fullname
    and it will also return the value.
 
    If this function fails to find the file that this symtab represents,
    and it will also return the value.
 
    If this function fails to find the file that this symtab represents,
-   NULL will be returned and ps->fullname will be set to NULL.  */
+   NULL will be returned and s->fullname will be set to NULL.  */
 char *
 symtab_to_fullname (struct symtab *s)
 {
 char *
 symtab_to_fullname (struct symtab *s)
 {
@@ -1126,9 +1127,9 @@ find_source_lines (struct symtab *s, int desc)
     perror_with_name (s->filename);
 
   if (s->objfile && s->objfile->obfd)
     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)
   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."));
 
   if (mtime && mtime < st.st_mtime)
     warning (_("Source file is more recent than executable."));
@@ -1423,7 +1424,7 @@ print_source_lines_base (struct symtab *s, int line, int stopline, int noerror)
 }
 \f
 /* Show source lines from the file of symtab S, starting with line
 }
 \f
 /* Show source lines from the file of symtab S, starting with line
-   number LINE and stopping before line number STOPLINE.  If this is the
+   number LINE and stopping before line number STOPLINE.  If this is
    not the command line version, then the source is shown in the source
    window otherwise it is simply printed */
 
    not the command line version, then the source is shown in the source
    window otherwise it is simply printed */
 
This page took 0.026296 seconds and 4 git commands to generate.