/* 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.
#include "objfiles.h"
#include "annotate.h"
#include "gdbtypes.h"
+#include "linespec.h"
#ifdef UI_OUT
#include "ui-out.h"
#endif
{
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)
{
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
{
char buf[20];
sprintf (buf, "$cdir%c$cwd", DIRNAME_SEPARATOR);
- source_path = strsave (buf);
+ source_path = xstrdup (buf);
forget_cached_source_info ();
}
{
if (from_tty && query ("Reinitialize source path to empty? "))
{
- free (source_path);
+ xfree (source_path);
init_source_path ();
}
}
if (dirname == 0)
return;
- dirname = strsave (dirname);
- make_cleanup (free, dirname);
+ dirname = xstrdup (dirname);
+ make_cleanup (xfree, dirname);
do
{
}
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
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
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] != '$')
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;
}
}
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
if (!path)
path = ".";
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__CYGWIN__)
mode |= O_BINARY;
#endif
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;
}
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;
}
/* 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);
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. */
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);
}
}
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. */