/* 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 "inferior.h" /* for write_pc */
#include "gdb-stabs.h"
#include "obstack.h"
-#include "completer.h"
-#include <assert.h>
#include <sys/types.h>
#include <fcntl.h>
#include "gdb_string.h"
static void load_command (char *, int);
+static void symbol_file_add_main_1 (char *args, int from_tty, int flags);
+
static void add_symbol_file_command (char *, int);
static void add_shared_symbol_files_command (char *, int);
static void cashier_psymtab (struct partial_symtab *);
-static int compare_psymbols (const void *, const void *);
-
-static int compare_symbols (const void *, const void *);
-
bfd *symfile_bfd_open (char *);
static void find_sym_fns (struct objfile *);
comparison function takes two "void *" pointers. */
static int
-compare_symbols (const PTR s1p, const PTR s2p)
+compare_symbols (const void *s1p, const void *s2p)
{
register struct symbol **s1, **s2;
*/
static int
-compare_psymbols (const PTR s1p, const PTR s2p)
+compare_psymbols (const void *s1p, const void *s2p)
{
register struct partial_symbol **s1, **s2;
register char *st1, *st2;
return (objfile);
}
+/* Call symbol_file_add() with default values and update whatever is
+ affected by the loading of a new main().
+ Used when the file is supplied in the gdb command line
+ and by some targets with special loading requirements.
+ The auxiliary function, symbol_file_add_main_1(), has the flags
+ argument for the switches that can only be specified in the symbol_file
+ command itself. */
+
+void
+symbol_file_add_main (char *args, int from_tty)
+{
+ symbol_file_add_main_1 (args, from_tty, 0);
+}
+
+static void
+symbol_file_add_main_1 (char *args, int from_tty, int flags)
+{
+ symbol_file_add (args, from_tty, NULL, 1, flags);
+
+#ifdef HPUXHPPA
+ RESET_HP_UX_GLOBALS ();
+#endif
+
+ /* Getting new symbols may change our opinion about
+ what is frameless. */
+ reinit_frame_cache ();
+
+ set_initial_language ();
+}
+
+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
{
else
{
name = *argv;
- symbol_file_add (name, from_tty, NULL, 1, flags);
-#ifdef HPUXHPPA
- RESET_HP_UX_GLOBALS ();
-#endif
- /* Getting new symbols may change our opinion about
- what is frameless. */
- reinit_frame_cache ();
- set_initial_language ();
+ symbol_file_add_main_1 (name, from_tty, flags);
}
argv++;
}
{
error ("no symbol file name was specified");
}
- TUIDO (((TuiOpaqueFuncPtr) tuiDisplayMainFunction));
do_cleanups (cleanups);
}
}
/* 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);
} 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 (xfree, filename);
+ make_cleanup (xfree, filename);
}
else
if (argcnt == 1)
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++;
}
/* ext_args, language_str (lang)); */
xfree (filename_language_table[i].ext);
- filename_language_table[i].ext = strsave (ext_args);
+ filename_language_table[i].ext = xstrdup (ext_args);
filename_language_table[i].lang = lang;
}
}