* write.c (relax_segment <rs_space>): Calculate growth using
[deliverable/binutils-gdb.git] / gdb / source.c
index 49eb3bce6fe258a463389a2e29aa5f715186814b..c96202a85ce71b61cb0d53fbf8b2be7c3b063f16 100644 (file)
@@ -1,5 +1,6 @@
 /* List lines of source files for GDB, the GNU debugger.
-   Copyright 1986-1989, 1991-1999 Free Software Foundation, Inc.
+   Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
+   1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -38,6 +39,7 @@
 #include "objfiles.h"
 #include "annotate.h"
 #include "gdbtypes.h"
+#include "linespec.h"
 #ifdef UI_OUT
 #include "ui-out.h"
 #endif
@@ -154,7 +156,7 @@ select_source_symtab (register struct symtab *s)
     {
       sals = decode_line_spec ("main", 1);
       sal = sals.sals[0];
-      free (sals.sals);
+      xfree (sals.sals);
       current_source_symtab = sal.symtab;
       current_source_line = max (sal.line - (lines_to_list - 1), 1);
       if (current_source_symtab)
@@ -198,7 +200,9 @@ select_source_symtab (register struct symtab *s)
     {
       if (cs_pst->readin)
        {
-         internal_error ("select_source_symtab: readin pst found and no symtabs.");
+         internal_error (__FILE__, __LINE__,
+                         "select_source_symtab: "
+                         "readin pst found and no symtabs.");
        }
       else
        {
@@ -253,7 +257,7 @@ init_source_path (void)
   char buf[20];
 
   sprintf (buf, "$cdir%c$cwd", DIRNAME_SEPARATOR);
-  source_path = strsave (buf);
+  source_path = xstrdup (buf);
   forget_cached_source_info ();
 }
 
@@ -268,7 +272,7 @@ directory_command (char *dirname, int from_tty)
     {
       if (from_tty && query ("Reinitialize source path to empty? "))
        {
-         free (source_path);
+         xfree (source_path);
          init_source_path ();
        }
     }
@@ -293,8 +297,8 @@ mod_path (char *dirname, char **which_path)
   if (dirname == 0)
     return;
 
-  dirname = strsave (dirname);
-  make_cleanup (free, dirname);
+  dirname = xstrdup (dirname);
+  make_cleanup (xfree, dirname);
 
   do
     {
@@ -327,7 +331,7 @@ mod_path (char *dirname, char **which_path)
       }
 
       if (!(SLASH_P (*name) && p <= name + 1)  /* "/" */
-#if defined(_WIN32) || defined(__MSDOS__)
+#if defined(_WIN32) || defined(__MSDOS__) || defined(__CYGWIN__)
       /* On MS-DOS and MS-Windows, h:\ is different from h: */
          && !(!SLASH_P (*name) && ROOTED_P (name) && p <= name + 3)    /* d:/ */
 #endif
@@ -366,7 +370,7 @@ mod_path (char *dirname, char **which_path)
 
       if (name[0] == '~')
        name = tilde_expand (name);
-#if defined(_WIN32) || defined(__MSDOS__)
+#if defined(_WIN32) || defined(__MSDOS__) || defined(__CYGWIN__)
       else if (ROOTED_P (name) && p == name + 2)       /* "d:" => "d:." */
        name = concat (name, ".", NULL);
 #endif
@@ -374,7 +378,7 @@ mod_path (char *dirname, char **which_path)
        name = concat (current_directory, SLASH_STRING, name, NULL);
       else
        name = savestring (name, p - name);
-      make_cleanup (free, name);
+      make_cleanup (xfree, name);
 
       /* Unless it's a variable, check existence.  */
       if (name[0] != '$')
@@ -447,14 +451,14 @@ mod_path (char *dirname, char **which_path)
                old[prefix] = c;
                *which_path = concat (temp, "", &old[prefix], NULL);
                prefix = strlen (temp);
-               free (temp);
+               xfree (temp);
              }
            else
              {
                *which_path = concat (name, (old[0] ? tinybuf : old), old, NULL);
                prefix = strlen (name);
              }
-           free (old);
+           xfree (old);
            old = *which_path;
          }
       }
@@ -498,7 +502,7 @@ source_info (char *ignore, int from_tty)
    so that "exec-file ./foo" or "symbol-file ./foo" insures that you
    get that particular version of foo or an error message).
 
-   If FILENAMED_OPENED is non-null, set it to a newly allocated string naming
+   If FILENAME_OPENED is non-null, set it to a newly allocated string naming
    the actual file opened (this string will always start with a "/".  We
    have to take special pains to avoid doubling the "/" between the directory
    and the file, sigh!  Emacs gets confuzzed by this when we print the
@@ -522,7 +526,7 @@ openp (char *path, int try_cwd_first, char *string, int mode, int prot,
   if (!path)
     path = ".";
 
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__CYGWIN__)
   mode |= O_BINARY;
 #endif
 
@@ -605,22 +609,22 @@ done:
                                     filename, NULL);
        }
     }
-#ifdef MPW
-  /* This is a debugging hack that can go away when all combinations
-     of Mac and Unix names are handled reasonably.  */
-  {
-    extern int debug_openp;
-
-    if (debug_openp)
-      {
-       printf ("openp on %s, path %s mode %d prot %d\n  returned %d",
-               string, path, mode, prot, fd);
-       if (*filename_opened)
-         printf (" (filename is %s)", *filename_opened);
-       printf ("\n");
-      }
-  }
-#endif /* MPW */
+  /* OBSOLETE #ifdef MPW  */
+  /* OBSOLETE This is a debugging hack that can go away when all combinations */
+  /* OBSOLETE of Mac and Unix names are handled reasonably.  */
+  /* OBSOLETE   { */
+  /* OBSOLETE     extern int debug_openp; */
+  /* OBSOLETE  */
+  /* OBSOLETE     if (debug_openp) */
+  /* OBSOLETE       { */
+  /* OBSOLETE  printf ("openp on %s, path %s mode %d prot %d\n  returned %d", */
+  /* OBSOLETE          string, path, mode, prot, fd); */
+  /* OBSOLETE  if (*filename_opened) */
+  /* OBSOLETE    printf (" (filename is %s)", *filename_opened); */
+  /* OBSOLETE  printf ("\n"); */
+  /* OBSOLETE       } */
+  /* OBSOLETE   } */
+  /* OBSOLETE #endif  *//* MPW */
 
   return fd;
 }
@@ -706,28 +710,28 @@ open_source_file (struct symtab *s)
       if (p != s->filename)
        result = openp (path, 0, p, OPEN_MODE, 0, &s->fullname);
     }
-#ifdef MPW
-  if (result < 0)
-    {
-      /* Didn't work.  Try using just the MPW basename. */
-      p = (char *) mpw_basename (s->filename);
-      if (p != s->filename)
-       result = openp (path, 0, p, OPEN_MODE, 0, &s->fullname);
-    }
-  if (result < 0)
-    {
-      /* Didn't work.  Try using the mixed Unix/MPW basename. */
-      p = (char *) mpw_mixed_basename (s->filename);
-      if (p != s->filename)
-       result = openp (path, 0, p, OPEN_MODE, 0, &s->fullname);
-    }
-#endif /* MPW */
+  /* OBSOLETE #ifdef MPW */
+  /* OBSOLETE   if (result < 0) */
+  /* OBSOLETE     { */
+  /* OBSOLETE        *//* Didn't work.  Try using just the MPW basename. */
+  /* OBSOLETE       p = (char *) mpw_basename (s->filename); */
+  /* OBSOLETE       if (p != s->filename) */
+  /* OBSOLETE  result = openp (path, 0, p, OPEN_MODE, 0, &s->fullname); */
+  /* OBSOLETE     } */
+  /* OBSOLETE   if (result < 0) */
+  /* OBSOLETE     { */
+  /* OBSOLETE        *//* Didn't work.  Try using the mixed Unix/MPW basename. */
+  /* OBSOLETE       p = (char *) mpw_mixed_basename (s->filename); */
+  /* OBSOLETE       if (p != s->filename) */
+  /* OBSOLETE  result = openp (path, 0, p, OPEN_MODE, 0, &s->fullname); */
+  /* OBSOLETE     } */
+  /* OBSOLETE #endif MPW */
 
   if (result >= 0)
     {
       fullname = s->fullname;
       s->fullname = mstrsave (s->objfile->md, s->fullname);
-      free (fullname);
+      xfree (fullname);
     }
   return result;
 }
@@ -828,7 +832,7 @@ find_source_lines (struct symtab *s, int desc)
     /* Use malloc, not alloca, because this may be pretty large, and we may
        run into various kinds of limits on stack size.  */
     data = (char *) xmalloc (size);
-    old_cleanups = make_cleanup (free, data);
+    old_cleanups = make_cleanup (xfree, data);
 
     /* Reassign `size' to result of read for systems where \r\n -> \n.  */
     size = myread (desc, data, size);
@@ -1231,12 +1235,12 @@ list_command (char *arg, int from_tty)
       if (sals.nelts > 1)
        {
          ambiguous_line_spec (&sals);
-         free (sals.sals);
+         xfree (sals.sals);
          return;
        }
 
       sal = sals.sals[0];
-      free (sals.sals);
+      xfree (sals.sals);
     }
 
   /* Record whether the BEG arg is all digits.  */
@@ -1265,11 +1269,11 @@ list_command (char *arg, int from_tty)
          if (sals_end.nelts > 1)
            {
              ambiguous_line_spec (&sals_end);
-             free (sals_end.sals);
+             xfree (sals_end.sals);
              return;
            }
          sal_end = sals_end.sals[0];
-         free (sals_end.sals);
+         xfree (sals_end.sals);
        }
     }
 
@@ -1440,7 +1444,7 @@ line_info (char *arg, int from_tty)
        printf_filtered ("Line number %d is out of range for \"%s\".\n",
                         sal.line, sal.symtab->filename);
     }
-  free (sals.sals);
+  xfree (sals.sals);
 }
 \f
 /* Commands to search the source file for a regexp.  */
This page took 0.028094 seconds and 4 git commands to generate.