[Ada] Re-implement `info tasks' command using ui-out
[deliverable/binutils-gdb.git] / gdb / source.c
index 5710f14d3d3a6bda7ad4e278d496a4d94eed59f7..d01dff4e5381c0d04d45ee6302c8cb223d4418e8 100644 (file)
@@ -335,6 +335,32 @@ show_directories_command (struct ui_file *file, int from_tty,
   show_directories_1 (NULL, from_tty);
 }
 
+/* Forget line positions and file names for the symtabs in a
+   particular objfile.  */
+
+void
+forget_cached_source_info_for_objfile (struct objfile *objfile)
+{
+  struct symtab *s;
+
+  ALL_OBJFILE_SYMTABS (objfile, s)
+    {
+      if (s->line_charpos != NULL)
+       {
+         xfree (s->line_charpos);
+         s->line_charpos = NULL;
+       }
+      if (s->fullname != NULL)
+       {
+         xfree (s->fullname);
+         s->fullname = NULL;
+       }
+
+      if (objfile->sf)
+       objfile->sf->qf->forget_cached_source_info (objfile);
+    }
+}
+
 /* Forget what we learned about line positions in source files, and
    which directories contain them; must check again now since files
    may be found in a different directory now.  */
@@ -349,22 +375,7 @@ forget_cached_source_info (void)
   ALL_PSPACES (pspace)
     ALL_PSPACE_OBJFILES (pspace, objfile)
     {
-      for (s = objfile->symtabs; s != NULL; s = s->next)
-       {
-         if (s->line_charpos != NULL)
-           {
-             xfree (s->line_charpos);
-             s->line_charpos = NULL;
-           }
-         if (s->fullname != NULL)
-           {
-             xfree (s->fullname);
-             s->fullname = NULL;
-           }
-       }
-
-      if (objfile->sf)
-       objfile->sf->qf->forget_cached_source_info (objfile);
+      forget_cached_source_info_for_objfile (objfile);
     }
 
   last_source_visited = NULL;
@@ -1145,30 +1156,6 @@ find_source_lines (struct symtab *s, int desc)
   if (mtime && mtime < st.st_mtime)
     warning (_("Source file is more recent than executable."));
 
-#ifdef LSEEK_NOT_LINEAR
-  {
-    char c;
-
-    /* Have to read it byte by byte to find out where the chars live.  */
-
-    line_charpos[0] = lseek (desc, 0, SEEK_CUR);
-    nlines = 1;
-    while (myread (desc, &c, 1) > 0)
-      {
-       if (c == '\n')
-         {
-           if (nlines == lines_allocated)
-             {
-               lines_allocated *= 2;
-               line_charpos =
-                 (int *) xrealloc ((char *) line_charpos,
-                                   sizeof (int) * lines_allocated);
-             }
-           line_charpos[nlines++] = lseek (desc, 0, SEEK_CUR);
-         }
-      }
-  }
-#else /* lseek linear.  */
   {
     struct cleanup *old_cleanups;
 
@@ -1207,53 +1194,13 @@ find_source_lines (struct symtab *s, int desc)
       }
     do_cleanups (old_cleanups);
   }
-#endif /* lseek linear.  */
+
   s->nlines = nlines;
   s->line_charpos =
     (int *) xrealloc ((char *) line_charpos, nlines * sizeof (int));
 
 }
 
-/* Return the character position of a line LINE in symtab S.
-   Return 0 if anything is invalid.  */
-
-#if 0                          /* Currently unused */
-
-int
-source_line_charpos (struct symtab *s, int line)
-{
-  if (!s)
-    return 0;
-  if (!s->line_charpos || line <= 0)
-    return 0;
-  if (line > s->nlines)
-    line = s->nlines;
-  return s->line_charpos[line - 1];
-}
-
-/* Return the line number of character position POS in symtab S.  */
-
-int
-source_charpos_line (struct symtab *s, int chr)
-{
-  int line = 0;
-  int *lnp;
-
-  if (s == 0 || s->line_charpos == 0)
-    return 0;
-  lnp = s->line_charpos;
-  /* Files are usually short, so sequential search is Ok.  */
-  while (line < s->nlines && *lnp <= chr)
-    {
-      line++;
-      lnp++;
-    }
-  if (line >= s->nlines)
-    line = s->nlines;
-  return line;
-}
-
-#endif /* 0 */
 \f
 
 /* Get full pathname and line number positions for a symtab.
@@ -1330,6 +1277,7 @@ print_source_lines_base (struct symtab *s, int line, int stopline, int noerror)
   FILE *stream;
   int nlines = stopline - line;
   struct cleanup *cleanup;
+  struct ui_out *uiout = current_uiout;
 
   /* Regardless of whether we can open the file, set current_source_symtab.  */
   current_source_symtab = s;
This page took 0.026843 seconds and 4 git commands to generate.