bfd_get_symbol_leading_char instead.
* coffread.c (EXTERNAL_NAME): New macro for removing possible
leading character from names.
(read_coff_symtab): Use BFD's FILE *, don't open a second one.
(read_coff_symtab): Complain() about .bb/.eb mismatch, don't error().
(process_coff_symbol, coff_read_struct_type, coff_read_enum_type):
Replace NAMES_HAVE_UNDERSCORE with EXTERNAL_NAME.
* kdb-start.c (main): Remove NAMES_HAVE_UNDERSCORE.
* minsyms.c (install_minimal_symbols): Replace NAMES_HAVE_UNDERSCORE.
Remove SOME_NAMES_HAVE_DOT support (apparently unused).
* partial-stab.h: Replace NAMES_HAVE_UNDERSCORE.
* solib.c: Replace NAMES_HAVE_UNDERSCORE.
* stabsread.h: Remove NAMES_HAVE_UNDERSCORE and HASH_OFFSET.
* symfile.c (syms_from_objfile): Insert debugging check to test
NAMES_HAVE_UNDERSCORE setting against the BFD support. FIXME,
remove this (and all tm-*.h NAMES_HAVE_UNDERSCORE) soon.
* doc/gdbint.texinfo (Host Conditionals): Remove
NAMES_HAVE_UNDERSCORE, SOME_NAMES_HAVE_DOT, document
MEM_FNS_DECLARED.
(Target Conditionals): Remove all of the above.
+Thu Dec 17 00:44:57 1992 John Gilmore (gnu@cygnus.com)
+
+ Eliminate uses of NAMES_HAVE_UNDERSCORE, using
+ bfd_get_symbol_leading_char instead.
+
+ * coffread.c (EXTERNAL_NAME): New macro for removing possible
+ leading character from names.
+ (read_coff_symtab): Use BFD's FILE *, don't open a second one.
+ (read_coff_symtab): Complain() about .bb/.eb mismatch, don't error().
+ (process_coff_symbol, coff_read_struct_type, coff_read_enum_type):
+ Replace NAMES_HAVE_UNDERSCORE with EXTERNAL_NAME.
+
+ * kdb-start.c (main): Remove NAMES_HAVE_UNDERSCORE.
+ * minsyms.c (install_minimal_symbols): Replace NAMES_HAVE_UNDERSCORE.
+ Remove SOME_NAMES_HAVE_DOT support (apparently unused).
+ * partial-stab.h: Replace NAMES_HAVE_UNDERSCORE.
+ * solib.c: Replace NAMES_HAVE_UNDERSCORE.
+ * stabsread.h: Remove NAMES_HAVE_UNDERSCORE and HASH_OFFSET.
+ * symfile.c (syms_from_objfile): Insert debugging check to test
+ NAMES_HAVE_UNDERSCORE setting against the BFD support. FIXME,
+ remove this (and all tm-*.h NAMES_HAVE_UNDERSCORE) soon.
+
+ * doc/gdbint.texinfo (Host Conditionals): Remove
+ NAMES_HAVE_UNDERSCORE, SOME_NAMES_HAVE_DOT, document
+ MEM_FNS_DECLARED.
+ (Target Conditionals): Remove all of the above.
+
Tue Dec 15 10:05:56 1992 Ian Lance Taylor (ian@cygnus.com)
* coffread.c (decode_type): catch negative tagndx fields generated
/* Read coff symbol tables and convert to internal format, for GDB.
Contributed by David D. Johnson, Brown University (ddj@cs.brown.edu).
- Copyright 1987, 1988, 1989, 1990, 1991 Free Software Foundation, Inc.
+ Copyright 1987, 1988, 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
This file is part of GDB.
#include <string.h>
+#include "libbfd.h" /* FIXME secret internal data from BFD */
#include "coff/internal.h" /* Internal format of COFF symbols in BFD */
#include "libcoff.h" /* FIXME secret internal data from BFD */
+/* Translate an external name string into a user-visible name. */
+#define EXTERNAL_NAME(string, abfd) \
+ (string[0] == bfd_get_symbol_leading_char(abfd)? string+1: string)
+
/* To be an sdb debug type, type must have at least a basic or primary
derived type. Using this rather than checking against T_NULL is
said to prevent core dumps if we try to operate on Michael Bloom
struct complaint tagndx_bad_complaint =
{"Symbol table entry for %s has bad tagndx value", 0, 0};
+struct complaint eb_complaint =
+ {"Mismatched .eb symbol ignored starting at symnum %d", 0, 0};
+
/* Simplified internal version of coff symbol table information */
struct coff_symbol {
struct cleanup *old_chain;
int val;
- stream = fopen (objfile->name, FOPEN_RB);
+ stream = bfd_cache_lookup(objfile->obfd);
if (!stream)
perror_with_name(objfile->name);
if (val < 0)
perror_with_name (objfile->name);
- /* These cleanups will be discarded below if we succeed. */
+ /* This cleanup will be discarded below if we succeed. */
old_chain = make_cleanup (free_objfile, objfile);
- make_cleanup (fclose, stream);
current_objfile = objfile;
nlist_stream_global = stream;
{
new = coff_context_stack;
if (new == 0 || depth != new->depth)
- error ("Invalid symbol data: .bb/.eb symbol mismatch at symbol %d.",
- symnum);
+ {
+ complain (&eb_complaint, (char *)symnum);
+ break;
+ }
if (coff_local_symbols && coff_context_stack->next)
{
/* Make a block for the local symbols within. */
register struct symbol *sym
= (struct symbol *) obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol));
char *name;
-#ifdef NAMES_HAVE_UNDERSCORE
- int offset = 1;
-#else
- int offset = 0;
-#endif
struct type *temptype;
memset (sym, 0, sizeof (struct symbol));
name = cs->c_name;
- name = (name[0] == '_' ? name + offset : name);
+ name = EXTERNAL_NAME (name, objfile->obfd);
SYMBOL_NAME (sym) = obstack_copy0 (&objfile->symbol_obstack, name, strlen (name));
/* default assumptions */
int nfields = 0;
register int n;
char *name;
-#ifdef NAMES_HAVE_UNDERSCORE
- int offset = 1;
-#else
- int offset = 0;
-#endif
struct coff_symbol member_sym;
register struct coff_symbol *ms = &member_sym;
struct internal_syment sub_sym;
{
read_one_sym (ms, &sub_sym, &sub_aux);
name = ms->c_name;
- name = (name[0] == '_' ? name + offset : name);
+ name = EXTERNAL_NAME (name, current_objfile->obfd);
switch (ms->c_sclass)
{
struct coff_pending *osyms, *syms;
register int n;
char *name;
-#ifdef NAMES_HAVE_UNDERSCORE
- int offset = 1;
-#else
- int offset = 0;
-#endif
type = coff_alloc_type (index);
if (within_function)
{
read_one_sym (ms, &sub_sym, &sub_aux);
name = ms->c_name;
- name = (name[0] == '_' ? name + offset : name);
+ name = EXTERNAL_NAME (name, current_objfile->obfd);
switch (ms->c_sclass)
{
/* Main loop for the standalone kernel debugger, for GDB, the GNU Debugger.
- Copyright 1989, 1991 Free Software Foundation, Inc.
+ Copyright 1989, 1991, 1992 Free Software Foundation, Inc.
This file is part of GDB.
start ()
{
-#ifdef NAMES_HAVE_UNDERSCORE
- INIT_STACK (_kdb_stack_beg, _kdb_stack_end);
-#else /* not NAMES_HAVE_UNDERSCORE */
INIT_STACK (kdb_stack_beg, kdb_stack_end);
-#endif /* not NAMES_HAVE_UNDERSCORE */
environ = environment;
register struct msym_bunch *bunch;
register struct minimal_symbol *msymbols;
int alloc_count;
+ register char leading_char;
if (msym_count > 0)
{
each bunch is full. */
mcount = objfile->minimal_symbol_count;
+ leading_char = bfd_get_symbol_leading_char (objfile->obfd);
for (bunch = msym_bunch; bunch != NULL; bunch = bunch -> next)
{
for (bindex = 0; bindex < msym_bunch_index; bindex++, mcount++)
{
msymbols[mcount] = bunch -> contents[bindex];
-#ifdef NAMES_HAVE_UNDERSCORE
- if (msymbols[mcount].name[0] == '_')
+ if (msymbols[mcount].name[0] == leading_char)
{
msymbols[mcount].name++;
}
-#endif
-#ifdef SOME_NAMES_HAVE_DOT
- if (msymbols[mcount].name[0] == '.')
- {
- msymbols[mcount].name++;
- }
-#endif
}
msym_bunch_index = BUNCH_SIZE;
}
SET_NAMESTRING ();
/* Check for __DYNAMIC, which is used by Sun shared libraries.
Record it even if it's local, not global, so we can find it.
- Same with virtual function tables, both global and static. */
- if ((namestring[8] == 'C' && (strcmp ("__DYNAMIC", namestring) == 0))
- || VTBL_PREFIX_P ((namestring+HASH_OFFSET)))
- {
- record_minimal_symbol (namestring, CUR_SYMBOL_VALUE,
- CUR_SYMBOL_TYPE, objfile); /* Always */
- }
+ FIXME: this might want to check for _DYNAMIC and the current
+ symbol_leading_char. */
+ if (namestring[8] == 'C' && !strcmp ("__DYNAMIC", namestring))
+ goto record_it;
+
+ /* Same with virtual function tables, both global and static. */
+ {
+ char *tempstring = namestring;
+ if (tempstring[0] == bfd_get_symbol_leading_char (objfile->obfd))
+ tempstring++;
+ if (VTBL_PREFIX_P ((tempstring)))
+ goto record_it;
+ }
#endif /* DBXREAD_ONLY */
continue;
char so_name[MAX_PATH_SIZE]; /* shared object lib name (FIXME) */
char symbols_loaded; /* flag: symbols read in yet? */
char from_tty; /* flag: print msgs? */
- bfd *so_bfd; /* bfd for so_name */
struct objfile *objfile; /* objfile for loaded lib */
struct section_table *sections;
struct section_table *sections_end;
char *scratch_pathname;
int scratch_chan;
struct section_table *p;
+ struct cleanup *old_chain;
+ bfd *abfd;
filename = tilde_expand (so -> so_name);
- make_cleanup (free, filename);
+ old_chain = make_cleanup (free, filename);
scratch_chan = openp (getenv ("PATH"), 1, filename, O_RDONLY, 0,
&scratch_pathname);
{
perror_with_name (filename);
}
+ make_cleanup (free, scratch_pathname);
- so -> so_bfd = bfd_fdopenr (scratch_pathname, NULL, scratch_chan);
- if (!so -> so_bfd)
+ abfd = bfd_fdopenr (scratch_pathname, NULL, scratch_chan);
+ if (!abfd)
{
+ close (scratch_chan);
error ("Could not open `%s' as an executable file: %s",
scratch_pathname, bfd_errmsg (bfd_error));
}
- if (!bfd_check_format (so -> so_bfd, bfd_object))
+
+ make_cleanup (bfd_close, abfd); /* Zap bfd, close scratch_chan. */
+
+ if (!bfd_check_format (abfd, bfd_object))
{
error ("\"%s\": not in executable format: %s.",
scratch_pathname, bfd_errmsg (bfd_error));
}
- if (build_section_table (so -> so_bfd, &so -> sections, &so -> sections_end))
+ if (build_section_table (abfd, &so -> sections, &so -> sections_end))
{
error ("Can't find the file sections in `%s': %s",
exec_bfd -> filename, bfd_errmsg (bfd_error));
so -> textsection = p;
}
}
+
+ /* Free the file names, close the file now. */
+ do_cleanups (old_chain);
}
/* Read all dynamically loaded common symbol definitions from the inferior
/* Don't enter the symbol twice if the target is re-run. */
-#ifdef NAMES_HAVE_UNDERSCORE
- if (*name == '_')
+ if (name[0] == bfd_get_symbol_leading_char (objfile->obfd))
{
name++;
}
-#endif
+
/* FIXME: Do we really want to exclude symbols which happen
to match symbols for other locations in the inferior's
address space, even when they are in different linkage units? */
/* Get next link map structure from inferior image and build a local
abbreviated load_map structure */
new = (struct so_list *) xmalloc (sizeof (struct so_list));
- (void) memset ((char *) new, 0, sizeof (struct so_list));
+ memset ((char *) new, 0, sizeof (struct so_list));
new -> lmaddr = lm;
/* Add the new node as the next node in the list, or as the root
node if this is the first one. */
if (so -> so_name[0])
{
count = so -> sections_end - so -> sections;
- (void) memcpy ((char *) (target -> to_sections + old),
- so -> sections,
- (sizeof (struct section_table)) * count);
+ memcpy ((char *) (target -> to_sections + old),
+ so -> sections,
+ (sizeof (struct section_table)) * count);
old += count;
}
}
{
free ((PTR)so_list_head -> sections);
}
- if (so_list_head -> so_bfd)
- {
- bfd_close (so_list_head -> so_bfd);
- }
next = so_list_head -> next;
free((PTR)so_list_head);
so_list_head = next;
/* Include file for stabs debugging format support functions.
- Copyright (C) 1986-1992 Free Software Foundation, Inc.
+ Copyright 1986-1991, 1992 Free Software Foundation, Inc.
This file is part of GDB.
Used to detect pairs of N_SO symbols. */
EXTERN int previous_stab_code;
-
-/* Setup a define to deal cleanly with the underscore problem */
-
-#ifdef NAMES_HAVE_UNDERSCORE
-#define HASH_OFFSET 1
-#else
-#define HASH_OFFSET 0
-#endif
-
\f
/* Support for Sun changes to dbx symbol format */
addr -= bfd_section_vma (objfile->obfd, lowest_sect);
}
+ /* Debugging check inserted for testing elimination of NAMES_HAVE_UNDERSCORE.
+ Complain if the dynamic setting of NAMES_HAVE_UNDERSCORE from BFD
+ doesn't match the static setting from the GDB config files.
+ FIXME: Remove this check after a round of testing.
+ -- gnu@cygnus.com, 16dec92 */
+#ifdef NAMES_HAVE_UNDERSCORE
+ if (bfd_get_symbol_leading_char(objfile->obfd) != '_')
+#else
+ if (bfd_get_symbol_leading_char(objfile->obfd) != 0)
+#endif
+ fprintf (stderr,
+ "GDB internal error! NAMES_HAVE_UNDERSCORE set wrong for %s BFD:\n%s\n",
+ objfile->obfd->xvec->name,
+ objfile->obfd->filename);
+ /* End of debugging check. FIXME. */
+
/* Initialize symbol reading routines for this objfile, allow complaints to
appear for this new file, and record how verbose to be, then do the
initial symbol reading for this file. */