/* Generic symbol file reading for the GNU debugger, GDB.
- Copyright 1990-1996, 1998, 2000 Free Software Foundation, Inc.
+ Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+ 2000, 2001 Free Software Foundation, Inc.
Contributed by Cygnus Support, using pieces from other GDB modules.
This file is part of GDB.
#include "gdb-stabs.h"
#include "obstack.h"
-#include <assert.h>
#include <sys/types.h>
#include <fcntl.h>
#include "gdb_string.h"
s1 = (struct symbol **) s1p;
s2 = (struct symbol **) s2p;
- return (STRCMP (SYMBOL_SOURCE_NAME (*s1), SYMBOL_SOURCE_NAME (*s2)));
+ return (strcmp (SYMBOL_SOURCE_NAME (*s1), SYMBOL_SOURCE_NAME (*s2)));
}
/*
}
else
{
- /* Note: I replaced the STRCMP line (commented out below)
- * with a simpler "strcmp()" which compares the 2 strings
- * from the beginning. (STRCMP is a macro which first compares
- * the initial characters, then falls back on strcmp).
- * The reason is that the STRCMP line was tickling a C compiler
- * bug on HP-UX 10.30, which is avoided with the simpler
- * code. The performance gain from the more complicated code
- * is negligible, given that we have already checked the
- * initial 2 characters above. I reported the compiler bug,
- * and once it is fixed the original line can be put back. RT
- */
- /* return ( STRCMP (st1 + 2, st2 + 2)); */
return (strcmp (st1, st2));
}
}
for (idx = 0; idx < MAX_SECTIONS; idx++)
if (sap->other[idx].name)
- free (sap->other[idx].name);
- free (sap);
+ xfree (sap->other[idx].name);
+ xfree (sap);
}
return (objfile);
}
+/* Just call the above with default values.
+ Used when the file is supplied in the gdb command line. */
+
+void
+symbol_file_add_main (char *args, int from_tty)
+{
+ symbol_file_add (args, from_tty, NULL, 1, 0);
+}
+
+void
+symbol_file_clear (int from_tty)
+{
+ if ((have_full_symbols () || have_partial_symbols ())
+ && from_tty
+ && !query ("Discard symbol table from `%s'? ",
+ symfile_objfile->name))
+ error ("Not confirmed.");
+ free_all_objfiles ();
+
+ /* solib descriptors may have handles to objfiles. Since their
+ storage has just been released, we'd better wipe the solib
+ descriptors as well.
+ */
+#if defined(SOLIB_RESTART)
+ SOLIB_RESTART ();
+#endif
+
+ symfile_objfile = NULL;
+ if (from_tty)
+ printf_unfiltered ("No symbol file now.\n");
+#ifdef HPUXHPPA
+ RESET_HP_UX_GLOBALS ();
+#endif
+}
+
/* This is the symbol-file command. Read the file, analyze its
symbols, and add a struct symtab to a symtab list. The syntax of
the command is rather bizarre--(1) buildargv implements various
if (args == NULL)
{
- if ((have_full_symbols () || have_partial_symbols ())
- && from_tty
- && !query ("Discard symbol table from `%s'? ",
- symfile_objfile->name))
- error ("Not confirmed.");
- free_all_objfiles ();
-
- /* solib descriptors may have handles to objfiles. Since their
- storage has just been released, we'd better wipe the solib
- descriptors as well.
- */
-#if defined(SOLIB_RESTART)
- SOLIB_RESTART ();
-#endif
-
- symfile_objfile = NULL;
- if (from_tty)
- printf_unfiltered ("No symbol file now.\n");
-#ifdef HPUXHPPA
- RESET_HP_UX_GLOBALS ();
-#endif
+ symbol_file_clear (from_tty);
}
else
{
/* Look down path for it, allocate 2nd new malloc'd copy. */
desc = openp (getenv ("PATH"), 1, name, O_RDONLY | O_BINARY, 0, &absolute_name);
-#if defined(__GO32__) || defined(_WIN32)
+#if defined(__GO32__) || defined(_WIN32) || defined (__CYGWIN__)
if (desc < 0)
{
char *exename = alloca (strlen (name) + 5);
#endif
if (desc < 0)
{
- make_cleanup (free, name);
+ make_cleanup (xfree, name);
perror_with_name (name);
}
- free (name); /* Free 1st new malloc'd copy */
+ xfree (name); /* Free 1st new malloc'd copy */
name = absolute_name; /* Keep 2nd malloc'd copy in bfd */
/* It'll be freed in free_objfile(). */
if (!sym_bfd)
{
close (desc);
- make_cleanup (free, name);
+ make_cleanup (xfree, name);
error ("\"%s\": can't open to read symbols: %s.", name,
bfd_errmsg (bfd_get_error ()));
}
on error it does not free all the storage associated with the
bfd). */
bfd_close (sym_bfd); /* This also closes desc */
- make_cleanup (free, name);
+ make_cleanup (xfree, name);
error ("\"%s\": can't read symbols: %s.", name,
bfd_errmsg (bfd_get_error ()));
}
/* Parse the input argument - the user can specify a load offset as
a second argument. */
filename = xmalloc (strlen (args) + 1);
- old_cleanups = make_cleanup (free, filename);
+ old_cleanups = make_cleanup (xfree, filename);
strcpy (filename, args);
offptr = strchr (filename, ' ');
if (offptr != NULL)
block_size = size;
buffer = xmalloc (size);
- old_chain = make_cleanup (free, buffer);
+ old_chain = make_cleanup (xfree, buffer);
/* Is this really necessary? I guess it gives the user something
to look at during a long download. */
that. remote.c could implement that method
using the ``qCRC'' packet. */
char *check = xmalloc (len);
- struct cleanup *verify_cleanups = make_cleanup (free, check);
+ struct cleanup *verify_cleanups = make_cleanup (xfree, check);
if (target_read_memory (lma, check, len) != 0)
error ("Download verify read failed at 0x%s",
paddr (lma));
} sect_opts[SECT_OFF_MAX];
struct section_addr_info section_addrs;
- struct cleanup *my_cleanups;
+ struct cleanup *my_cleanups = make_cleanup (null_cleanup, NULL);
dont_repeat ();
{
/* The first argument is the file name. */
filename = tilde_expand (arg);
- my_cleanups = make_cleanup (free, filename);
+ make_cleanup (xfree, filename);
}
else
if (argcnt == 1)
/* obstack_specify_allocation also initializes the obstack so
it is empty. */
obstack_specify_allocation (&objfile->psymbol_cache.cache, 0, 0,
- xmalloc, free);
+ xmalloc, xfree);
obstack_specify_allocation (&objfile->psymbol_obstack, 0, 0,
- xmalloc, free);
+ xmalloc, xfree);
obstack_specify_allocation (&objfile->symbol_obstack, 0, 0,
- xmalloc, free);
+ xmalloc, xfree);
obstack_specify_allocation (&objfile->type_obstack, 0, 0,
- xmalloc, free);
+ xmalloc, xfree);
if (build_objfile_section_table (objfile))
{
error ("Can't find the file sections in `%s': %s",
if (fl_table_next >= fl_table_size)
{
fl_table_size += 10;
- filename_language_table = realloc (filename_language_table,
- fl_table_size);
+ filename_language_table = xrealloc (filename_language_table,
+ fl_table_size);
}
- filename_language_table[fl_table_next].ext = strsave (ext);
+ filename_language_table[fl_table_next].ext = xstrdup (ext);
filename_language_table[fl_table_next].lang = lang;
fl_table_next++;
}
/* query ("Really make files of type %s '%s'?", */
/* ext_args, language_str (lang)); */
- free (filename_language_table[i].ext);
- filename_language_table[i].ext = strsave (ext_args);
+ xfree (filename_language_table[i].ext);
+ filename_language_table[i].ext = xstrdup (ext_args);
filename_language_table[i].lang = lang;
}
}
it is not called for subsidiary files such as .h files.
Return value is 1 if we blew away the environment, 0 if not.
- FIXME. The return valu appears to never be used.
+ FIXME. The return value appears to never be used.
FIXME. I think this is not the best way to do this. We should
work on being gentler to the environment while still cleaning up
simple_free_overlay_table (void)
{
if (cache_ovly_table)
- free (cache_ovly_table);
+ xfree (cache_ovly_table);
cache_novlys = 0;
cache_ovly_table = NULL;
cache_ovly_table_base = 0;
simple_free_overlay_region_table (void)
{
if (cache_ovly_region_table)
- free (cache_ovly_region_table);
+ xfree (cache_ovly_region_table);
cache_novly_regions = 0;
cache_ovly_region_table = NULL;
cache_ovly_region_table_base = 0;