aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorJohn Gilmore <gnu@cygnus>1992-12-17 09:15:10 +0000
committerJohn Gilmore <gnu@cygnus>1992-12-17 09:15:10 +0000
commitde9bef49be9432334e7806405b33cd0d0a69d754 (patch)
treef808a8de6709a41ca1a6d7c0f8fe51f991c7c1a9 /gdb
parent8cedeccaa84f502883f22f613fee7bf814db8af3 (diff)
downloadgdb-de9bef49be9432334e7806405b33cd0d0a69d754.zip
gdb-de9bef49be9432334e7806405b33cd0d0a69d754.tar.gz
gdb-de9bef49be9432334e7806405b33cd0d0a69d754.tar.bz2
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.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog27
-rw-r--r--gdb/coffread.c42
-rw-r--r--gdb/kdb-start.c6
-rw-r--r--gdb/minsyms.c12
-rw-r--r--gdb/partial-stab.h20
-rw-r--r--gdb/solib.c38
-rw-r--r--gdb/stabsread.h11
-rw-r--r--gdb/symfile.c16
8 files changed, 100 insertions, 72 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 9fe5999..7992c75 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,30 @@
+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
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 6078b63..6e35c5b 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -1,6 +1,6 @@
/* 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.
@@ -31,9 +31,14 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#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
@@ -190,6 +195,9 @@ struct complaint misordered_blocks_complaint =
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 {
@@ -901,7 +909,7 @@ read_coff_symtab (symtab_offset, nsyms, objfile)
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);
@@ -910,9 +918,8 @@ read_coff_symtab (symtab_offset, nsyms, objfile)
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;
@@ -1148,8 +1155,10 @@ read_coff_symtab (symtab_offset, nsyms, objfile)
{
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. */
@@ -1567,16 +1576,11 @@ process_coff_symbol (cs, aux, objfile)
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 */
@@ -1976,11 +1980,6 @@ coff_read_struct_type (index, length, lastsym)
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;
@@ -1996,7 +1995,7 @@ coff_read_struct_type (index, length, lastsym)
{
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)
{
@@ -2074,11 +2073,6 @@ coff_read_enum_type (index, length, lastsym)
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)
@@ -2091,7 +2085,7 @@ coff_read_enum_type (index, length, lastsym)
{
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)
{
diff --git a/gdb/kdb-start.c b/gdb/kdb-start.c
index e4e0ea2..17332f6 100644
--- a/gdb/kdb-start.c
+++ b/gdb/kdb-start.c
@@ -1,5 +1,5 @@
/* 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.
@@ -27,11 +27,7 @@ char **environ;
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;
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index b904f23..269d568 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -424,6 +424,7 @@ install_minimal_symbols (objfile)
register struct msym_bunch *bunch;
register struct minimal_symbol *msymbols;
int alloc_count;
+ register char leading_char;
if (msym_count > 0)
{
@@ -451,24 +452,17 @@ install_minimal_symbols (objfile)
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;
}
diff --git a/gdb/partial-stab.h b/gdb/partial-stab.h
index b7fc445..06adc8f 100644
--- a/gdb/partial-stab.h
+++ b/gdb/partial-stab.h
@@ -117,13 +117,19 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
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;
diff --git a/gdb/solib.c b/gdb/solib.c
index d9ec318..4b050de 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -90,7 +90,6 @@ struct so_list {
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;
@@ -186,9 +185,11 @@ solib_map_sections (so)
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);
@@ -201,19 +202,24 @@ solib_map_sections (so)
{
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));
@@ -232,6 +238,9 @@ solib_map_sections (so)
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
@@ -273,12 +282,11 @@ solib_add_common_symbols (rtc_symp, objfile)
/* 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? */
@@ -634,7 +642,7 @@ find_solib (so_list_ptr)
/* 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. */
@@ -774,9 +782,9 @@ solib_add (arg_string, from_tty, target)
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;
}
}
@@ -892,10 +900,6 @@ clear_solib()
{
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;
diff --git a/gdb/stabsread.h b/gdb/stabsread.h
index 422747e..da69c82 100644
--- a/gdb/stabsread.h
+++ b/gdb/stabsread.h
@@ -1,5 +1,5 @@
/* 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.
@@ -68,15 +68,6 @@ EXTERN int common_block_i;
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
-
/* Support for Sun changes to dbx symbol format */
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 908ff09..f01ae36 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -439,6 +439,22 @@ syms_from_objfile (objfile, addr, mainline, verbo)
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. */