Oodles of changes. The most important is adding support for stabs

encapsulated in mips ecoff.  See ChangeLog for the gory details.
This commit is contained in:
Per Bothner 1991-12-23 23:16:58 +00:00
parent 3e60a6b1d3
commit 7e258d18e0
18 changed files with 1645 additions and 1499 deletions

View File

@ -109,7 +109,6 @@ kdb-start.c
language.c
language.h
m2-exp.y
m68k-opcode.h
m68k-pinsn.c
m68k-stub.c
m68k-tdep.c
@ -122,7 +121,6 @@ main.c
mcheck.c
mem-break.c
minimon.h
mips-opcode.h
mips-pinsn.c
mips-tdep.c
mips-xdep.c
@ -138,6 +136,7 @@ ns32k-opcode.h
ns32k-pinsn.c
parse.c
parser-defs.h
partial-stab.h
pn-opcode.h
printcmd.c
procfs.c
@ -165,7 +164,6 @@ signame.c
signame.h
solib.c
source.c
sparc-opcode.h
sparc-pinsn.c
sparc-tdep.c
sparc-xdep.c

View File

@ -1,3 +1,55 @@
Mon Dec 23 13:54:35 1991 Per Bothner (bothner at cygnus.com)
* m68k-opcode.h, mips-opcode.h, sparc-opcode.h: Deleted.
* m68k-pinsn.c, mips-pinsn.c, sparc-pinsn.c:
Include <opcode/FOO.h> instead of <FOO-opcode.h>.
* symtab.h, symtab.c, coffread.c, dwarfread.c, symmisc.c,
dbxread.c: The TYPE_CPLUS_SPECIFIC structure is now only
allocated when it is needed. Until it is needed, it points
to a shared statically allocated structure.
* buildsym.h, buildsym.c, dbxread.c: Remove the kludgy code
in read_ofile_symtab to recognize two initial N_SO stabs,
and let process_on_symbol handle it. This is cleaner, more
efficient, and lets mipsread.c share the same code.
* symfile.h, partial-stab.h: Move ADD_PSYMBOL_VT_TO_LIST
and related macros to here ...
* dbxread.c: ... from here.
* symmisc.c: Move the "overflow" handling from
ADD_PSYMBOL_VT_TO_LIST macro into new function extend_psymbol_list.
* dwarfread.c: Re-write add_psymbol_to_list to use
ADD_PSYMBOL_VT_TO_LIST macro.
* mipsread.c: Extend mipsread.c to handle stabs-style symbols
encapsulated in ecoff symbols. This enable full g++ debugging.
* partial-stab.h: Move the code for pre-scanning symbols
and building psymtabs to an include file, out from dbxread.c.
This way, the same code can also be used by mipsread.c.
* dbxread.c, buildsym.h: Various changes to allow some functions
to be used by mipsread.c (also some arguable stylistic changes).
* tm-mips.h: Define BLOCK_ADDRESS_ABSOLUTE, at least for now,
since mips-tfile puts relocatable addresses into LBRAC/RBRAC
stabs.
* mipsread.c: Replace code to handle ambiguous tag blocks.
Instead of allocating a TYPE_CODE_UNDEF, guess (by looking
at types and offsets) if a tag is a struct, union, or enum.
Still patch it later if we find out for sure.
* mipsread.c: In various ways, replace Forin's
ideo-syncratic code by code that fits better with the
rest of gdb, for both stabs-based and ecoff-based symtabs.
E.g. use end_psymtab; don't do extra passes over FDR table to
pre-partition global data; don't use external symbols to
create static/global symbols (just put them in the
misc_vector); use ADD_PSYMBOL_TO_LIST macro; don't
sort psymtabs or symtabs; use obstacks more.
* symtab.c, mipsread.c, dbxread.c, buildsym.c:
ANSIfy: Replace bcopy by memcpy, bzero by memset.
Sun Dec 22 19:31:04 1991 Fred Fish (fnf at cygnus.com)
* solib.c (locate_base): Fix uninitialized variable that was

View File

@ -808,6 +808,7 @@ end_symtab (end_addr, sort_pending, sort_linevec, objfile)
last_source_file = 0;
current_subfile = 0;
previous_stab_code = 0;
return symtab;
}
@ -1063,7 +1064,7 @@ define_symbol (valu, string, desc, type)
SYMBOL_TYPE (sym) = builtin_type_double;
dbl_valu =
(char *) obstack_alloc (symbol_obstack, sizeof (double));
bcopy (&d, dbl_valu, sizeof (double));
memcpy (dbl_valu, &d, sizeof (double));
SWAP_TARGET_AND_HOST (dbl_valu, sizeof (double));
SYMBOL_VALUE_BYTES (sym) = dbl_valu;
SYMBOL_CLASS (sym) = LOC_CONST_BYTES;
@ -1447,7 +1448,7 @@ cleanup_undefined_types ()
&& (TYPE_CODE (SYMBOL_TYPE (sym)) ==
TYPE_CODE (*type))
&& !strcmp (SYMBOL_NAME (sym), typename))
bcopy (SYMBOL_TYPE (sym), *type, sizeof (struct type));
memcpy (*type, SYMBOL_TYPE (sym), sizeof (struct type));
}
}
else
@ -1703,13 +1704,7 @@ read_type (pp)
type = dbx_alloc_type (typenums);
TYPE_CODE (type) = code;
TYPE_NAME (type) = type_name;
if (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION)
{
TYPE_CPLUS_SPECIFIC (type)
= (struct cplus_struct_type *) obstack_alloc (symbol_obstack, sizeof (struct cplus_struct_type));
bzero (TYPE_CPLUS_SPECIFIC (type), sizeof (struct cplus_struct_type));
}
TYPE_CPLUS_SPECIFIC(type) = &cplus_struct_default;
TYPE_FLAGS (type) |= TYPE_FLAG_STUB;
add_undefined_type (type);
@ -1919,15 +1914,14 @@ read_struct_type (pp, type)
struct nextfield *new;
register char *p;
int nfields = 0;
int non_public_fields = 0;
register int n;
register struct next_fnfieldlist *mainlist = 0;
int nfn_fields = 0;
TYPE_CODE (type) = TYPE_CODE_STRUCT;
TYPE_CPLUS_SPECIFIC (type)
= (struct cplus_struct_type *) obstack_alloc (symbol_obstack, sizeof (struct cplus_struct_type));
bzero (TYPE_CPLUS_SPECIFIC (type), sizeof (struct cplus_struct_type));
TYPE_CPLUS_SPECIFIC(type) = &cplus_struct_default;
/* First comes the total size in bytes. */
@ -1956,6 +1950,8 @@ read_struct_type (pp, type)
*pp += 1;
ALLOCATE_CPLUS_STRUCT_TYPE(type);
n_baseclasses = read_number (pp, ',');
TYPE_FIELD_VIRTUAL_BITS (type) =
(B_TYPE *) obstack_alloc (symbol_obstack, B_BYTES (n_baseclasses));
@ -1984,6 +1980,7 @@ read_struct_type (pp, type)
{
case '0':
via_public = 0;
non_public_fields++;
break;
case '2':
via_public = 2;
@ -2081,6 +2078,8 @@ read_struct_type (pp, type)
list->field.bitpos = read_number (pp, ';');
/* This field is unpacked. */
list->field.bitsize = 0;
list->visibility = 0; /* private */
non_public_fields++;
}
/* GNU C++ anonymous type. */
else if (*p == '_')
@ -2108,11 +2107,13 @@ read_struct_type (pp, type)
{
case '0':
list->visibility = 0; /* private */
non_public_fields++;
*pp += 1;
break;
case '1':
list->visibility = 1; /* protected */
non_public_fields++;
*pp += 1;
break;
@ -2209,13 +2210,18 @@ read_struct_type (pp, type)
TYPE_FIELDS (type) = (struct field *) obstack_alloc (symbol_obstack,
sizeof (struct field) * nfields);
TYPE_FIELD_PRIVATE_BITS (type) =
(B_TYPE *) obstack_alloc (symbol_obstack, B_BYTES (nfields));
B_CLRALL (TYPE_FIELD_PRIVATE_BITS (type), nfields);
if (non_public_fields)
{
ALLOCATE_CPLUS_STRUCT_TYPE (type);
TYPE_FIELD_PROTECTED_BITS (type) =
(B_TYPE *) obstack_alloc (symbol_obstack, B_BYTES (nfields));
B_CLRALL (TYPE_FIELD_PROTECTED_BITS (type), nfields);
TYPE_FIELD_PRIVATE_BITS (type) =
(B_TYPE *) obstack_alloc (symbol_obstack, B_BYTES (nfields));
B_CLRALL (TYPE_FIELD_PRIVATE_BITS (type), nfields);
TYPE_FIELD_PROTECTED_BITS (type) =
(B_TYPE *) obstack_alloc (symbol_obstack, B_BYTES (nfields));
B_CLRALL (TYPE_FIELD_PROTECTED_BITS (type), nfields);
}
/* Copy the saved-up fields into the field vector. */
@ -2243,6 +2249,7 @@ read_struct_type (pp, type)
"unread" the name that has been read, so that we can
start from the top. */
ALLOCATE_CPLUS_STRUCT_TYPE (type);
/* For each list of method lists... */
do
{
@ -2447,12 +2454,15 @@ read_struct_type (pp, type)
*pp += 1;
TYPE_FN_FIELDLISTS (type) =
(struct fn_fieldlist *) obstack_alloc (symbol_obstack,
sizeof (struct fn_fieldlist) * nfn_fields);
TYPE_NFN_FIELDS (type) = nfn_fields;
TYPE_NFN_FIELDS_TOTAL (type) = total_length;
if (nfn_fields)
{
TYPE_FN_FIELDLISTS (type) = (struct fn_fieldlist *)
obstack_alloc (symbol_obstack,
sizeof (struct fn_fieldlist) * nfn_fields);
TYPE_NFN_FIELDS (type) = nfn_fields;
TYPE_NFN_FIELDS_TOTAL (type) = total_length;
}
{
int i;
@ -3143,7 +3153,7 @@ read_args (pp, end)
{
rval = (struct type **) xmalloc (n * sizeof (struct type *));
}
bcopy (types, rval, n * sizeof (struct type *));
memcpy (rval, types, n * sizeof (struct type *));
return rval;
}

View File

@ -59,6 +59,9 @@ extern struct context_stack *push_context ();
extern void record_line ();
extern void start_symtab ();
extern struct symbol *define_symbol ();
extern struct partial_symtab *start_psymtab ();
extern void end_psymtab();
/* Convert stab register number (from `r' declaration) to a gdb REGNUM. */
@ -218,6 +221,11 @@ extern CORE_ADDR startup_file_end; /* From blockframe.c */
EXTERN unsigned char processing_gcc_compilation;
/* The type code that process_one_symbol saw on its previous invocation.
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

View File

@ -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 (C) 1987-1991 Free Software Foundation, Inc.
Copyright 1987, 1988, 1989, 1990, 1991 Free Software Foundation, Inc.
This file is part of GDB.
@ -217,12 +217,20 @@ extern CORE_ADDR startup_file_end; /* From blockframe.c */
struct complaint ef_complaint =
{"Unmatched .ef symbol(s) ignored starting at symnum %d", 0, 0};
struct complaint no_aux_complaint =
{"symbol %d without one aux entry", 0, 0};
struct complaint bf_no_aux_complaint =
{"`.bf' symbol %d has no aux entry", 0, 0};
struct complaint ef_no_aux_complaint =
{"`.ef' symbol %d has no aux entry", 0, 0};
struct complaint lineno_complaint =
{"Line number pointer %d lower than start of line numbers", 0, 0};
struct complaint unexpected_type_complaint =
{"Unexpected type for symbol %s", 0, 0};
struct complaint bad_sclass_complaint =
{"Bad n_sclass for symbol %s", 0, 0};
/* Look up a coff type-number index. Return the address of the slot
where the type for that index is stored.
@ -885,7 +893,7 @@ read_coff_symtab (desc, nsyms, objfile)
case C_LINE:
case C_ALIAS:
case C_HIDDEN:
printf ("Bad n_sclass = %d\n", cs->c_sclass);
complain (&bad_sclass_complaint, cs->c_name);
break;
case C_FILE:
@ -969,7 +977,7 @@ read_coff_symtab (desc, nsyms, objfile)
/* main_aux.x_sym.x_misc.x_lnsz.x_lnno
contains line number of '{' } */
if (cs->c_naux != 1)
complain (no_aux_complaint, cs->c_symnum);
complain (&bf_no_aux_complaint, cs->c_symnum);
fcn_first_line = main_aux.x_sym.x_misc.x_lnsz.x_lnno;
new = (struct context_stack *)
@ -999,7 +1007,7 @@ read_coff_symtab (desc, nsyms, objfile)
break;
}
if (cs->c_naux != 1) {
complain (no_aux_complaint, cs->c_symnum);
complain (&ef_no_aux_complaint, cs->c_symnum);
fcn_last_line = 0x7FFFFFFF;
} else {
fcn_last_line = main_aux.x_sym.x_misc.x_lnsz.x_lnno;
@ -1408,7 +1416,7 @@ patch_type (type, real_type)
}
}
/* Patch up all appropriate typdef symbols in the opaque_type_chains
/* Patch up all appropriate typedef symbols in the opaque_type_chains
so that they can be used to print out opaque data structures properly */
static void
@ -1471,10 +1479,6 @@ patch_opaque_types ()
}
}
#if defined (clipper)
#define BELIEVE_PCC_PROMOTION 1
#endif
static struct symbol *
process_coff_symbol (cs, aux)
register struct coff_symbol *cs;
@ -1570,7 +1574,7 @@ process_coff_symbol (cs, aux)
case C_ARG:
SYMBOL_CLASS (sym) = LOC_ARG;
#if 0
/* FIXME: This has not bee tested. */
/* FIXME: This has not been tested. */
/* Add parameter to function. */
add_param_to_type(&in_function_type,sym);
#endif
@ -1578,12 +1582,12 @@ process_coff_symbol (cs, aux)
#if !defined (BELIEVE_PCC_PROMOTION)
/* If PCC says a parameter is a short or a char,
it is really an int. */
if (SYMBOL_TYPE (sym) == builtin_type_char
|| SYMBOL_TYPE (sym) == builtin_type_short)
SYMBOL_TYPE (sym) = builtin_type_int;
else if (SYMBOL_TYPE (sym) == builtin_type_unsigned_char
|| SYMBOL_TYPE (sym) == builtin_type_unsigned_short)
SYMBOL_TYPE (sym) = builtin_type_unsigned_int;
if (TYPE_LENGTH (SYMBOL_TYPE (sym)) < TYPE_LENGTH (builtin_type_int)
&& TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_INT) {
SYMBOL_TYPE (sym) = TYPE_UNSIGNED (SYMBOL_TYPE (sym))?
builtin_type_unsigned_int:
builtin_type_int;
}
#endif
break;
@ -1594,12 +1598,12 @@ process_coff_symbol (cs, aux)
#if !defined (BELIEVE_PCC_PROMOTION)
/* If PCC says a parameter is a short or a char,
it is really an int. */
if (SYMBOL_TYPE (sym) == builtin_type_char
|| SYMBOL_TYPE (sym) == builtin_type_short)
SYMBOL_TYPE (sym) = builtin_type_int;
else if (SYMBOL_TYPE (sym) == builtin_type_unsigned_char
|| SYMBOL_TYPE (sym) == builtin_type_unsigned_short)
SYMBOL_TYPE (sym) = builtin_type_unsigned_int;
if (TYPE_LENGTH (SYMBOL_TYPE (sym)) < TYPE_LENGTH (builtin_type_int)
&& TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_INT) {
SYMBOL_TYPE (sym) = TYPE_UNSIGNED (SYMBOL_TYPE (sym))?
builtin_type_unsigned_int:
builtin_type_int;
}
#endif
break;
@ -1791,9 +1795,7 @@ decode_base_type (cs, c_type, aux)
type = coff_alloc_type (cs->c_symnum);
TYPE_CODE (type) = TYPE_CODE_STRUCT;
TYPE_NAME (type) = concat ("struct ", "<opaque>", NULL);
TYPE_CPLUS_SPECIFIC (type)
= (struct cplus_struct_type *) obstack_alloc (symbol_obstack, sizeof (struct cplus_struct_type));
bzero (TYPE_CPLUS_SPECIFIC (type), sizeof (struct cplus_struct_type));
TYPE_CPLUS_SPECIFIC(type) = &cplus_struct_default;
TYPE_LENGTH (type) = 0;
TYPE_FIELDS (type) = 0;
TYPE_NFIELDS (type) = 0;
@ -1812,9 +1814,7 @@ decode_base_type (cs, c_type, aux)
/* anonymous union type */
type = coff_alloc_type (cs->c_symnum);
TYPE_NAME (type) = concat ("union ", "<opaque>", NULL);
TYPE_CPLUS_SPECIFIC (type) = (struct cplus_struct_type *)
obstack_alloc (symbol_obstack, sizeof (struct cplus_struct_type));
bzero (TYPE_CPLUS_SPECIFIC (type), sizeof (struct cplus_struct_type));
TYPE_CPLUS_SPECIFIC(type) = &cplus_struct_default;
TYPE_LENGTH (type) = 0;
TYPE_LENGTH (type) = 0;
TYPE_FIELDS (type) = 0;
@ -1850,7 +1850,7 @@ decode_base_type (cs, c_type, aux)
case T_ULONG:
return builtin_type_unsigned_long;
}
printf ("unexpected type %d at symnum %d\n", c_type, cs->c_symnum);
complain (&unexpected_type_complaint, cs->c_name);
return builtin_type_void;
}
@ -1890,9 +1890,7 @@ read_struct_type (index, length, lastsym)
type = coff_alloc_type (index);
TYPE_CODE (type) = TYPE_CODE_STRUCT;
TYPE_CPLUS_SPECIFIC (type)
= (struct cplus_struct_type *) obstack_alloc (symbol_obstack, sizeof (struct cplus_struct_type));
bzero (TYPE_CPLUS_SPECIFIC (type), sizeof (struct cplus_struct_type));
TYPE_CPLUS_SPECIFIC(type) = &cplus_struct_default;
TYPE_LENGTH (type) = length;
while (!done && symnum < lastsym && symnum < nlist_nsyms_global)

View File

@ -56,8 +56,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "symfile.h"
#include "buildsym.h"
#include "aout64.h"
#include "stab.gnu.h" /* We always use GNU stabs, not native, now */
#include "aout/aout64.h"
#include "aout/stab_gnu.h" /* We always use GNU stabs, not native, now */
/* Information is passed among various dbxread routines for accessing
symbol files. A pointer to this structure is kept in the sym_private
@ -98,7 +98,7 @@ extern double atof ();
static void read_dbx_symtab ();
static void init_psymbol_list ();
static void process_one_symbol ();
extern void process_one_symbol ();
void start_subfile ();
int hashname ();
static struct pending *copy_pending ();
@ -560,6 +560,9 @@ fill_symbuf (sym_bfd)
(a \ at the end of the text of a name)
call this function to get the continuation. */
#ifdef READ_MIPS_FORMAT
extern char *next_symbol_text ();
#else
char *
next_symbol_text ()
{
@ -569,6 +572,7 @@ next_symbol_text ()
SWAP_SYMBOL(&symbuf[symbuf_idx], symfile_bfd);
return symbuf[symbuf_idx++].n_strx + stringtab_global;
}
#endif
/* Initializes storage for all of the partial symbols that will be
created by read_dbx_symtab and subsidiaries. */
@ -656,55 +660,35 @@ free_bincl_list ()
bincls_allocated = 0;
}
static struct partial_symtab *start_psymtab ();
static void end_psymtab();
#ifdef DEBUG
/* This is normally a macro defined in read_dbx_symtab, but this
is a lot easier to debug. */
ADD_PSYMBOL_TO_PLIST(NAME, NAMELENGTH, NAMESPACE, CLASS, PLIST, VALUE)
char *NAME;
int NAMELENGTH;
enum namespace NAMESPACE;
enum address_class CLASS;
struct psymbol_allocation_list *PLIST;
unsigned long VALUE;
void
add_psymbol_to_plist(name, namelength, namespace, class, plist, value)
char *name;
int namelength;
enum namespace namespace;
enum address_class class;
struct psymbol_allocation_list *plist;
unsigned long value;
{
register struct partial_symbol *psym;
#define LIST *PLIST
do {
if ((LIST).next >=
(LIST).list + (LIST).size)
{
(LIST).list = (struct partial_symbol *)
xrealloc ((LIST).list,
((LIST).size * 2
* sizeof (struct partial_symbol)));
/* Next assumes we only went one over. Should be good if
program works correctly */
(LIST).next =
(LIST).list + (LIST).size;
(LIST).size *= 2;
}
psym = (LIST).next++;
#undef LIST
SYMBOL_NAME (psym) = (char *) obstack_alloc (psymbol_obstack,
(NAMELENGTH) + 1);
strncpy (SYMBOL_NAME (psym), (NAME), (NAMELENGTH));
SYMBOL_NAME (psym)[(NAMELENGTH)] = '\0';
SYMBOL_NAMESPACE (psym) = (NAMESPACE);
SYMBOL_CLASS (psym) = (CLASS);
SYMBOL_VALUE (psym) = (VALUE);
} while (0);
ADD_PSYMBOL_VT_TO_LIST(name, namelength, namespace,
class, *plist, value, SYMBOL_VALUE);
}
/* Since one arg is a struct, we have to pass in a ptr and deref it (sigh) */
#define ADD_PSYMBOL_TO_LIST(NAME, NAMELENGTH, NAMESPACE, CLASS, LIST, VALUE) \
ADD_PSYMBOL_TO_PLIST(NAME, NAMELENGTH, NAMESPACE, CLASS, &LIST, VALUE)
void
add_psymbol_addr_to_plist(name, namelength, namespace, class, plist, value)
char *name;
int namelength;
enum namespace namespace;
enum address_class class;
struct psymbol_allocation_list *plist;
CORE_ADDR value;
{
ADD_PSYMBOL_VT_TO_LIST(name, namelength, namespace,
class, *plist, value, SYMBOL_VALUE_ADDRESS);
}
#endif /* DEBUG */
/* Given pointers to an a.out symbol table in core containing dbx
@ -728,12 +712,10 @@ read_dbx_symtab (addr, objfile, stringtab, stringtab_size, nlistlen,
{
register struct internal_nlist *bufp;
register char *namestring;
register struct partial_symbol *psym;
int nsl;
int past_first_source_file = 0;
CORE_ADDR last_o_file_start = 0;
struct cleanup *old_chain;
char *p;
bfd *abfd;
/* End of the text segment of the executable file. */
@ -821,579 +803,27 @@ read_dbx_symtab (addr, objfile, stringtab, stringtab_size, nlistlen,
} else \
namestring = bufp->n_strx + stringtab
/* Add a symbol with an integer value to a psymtab. */
/* This is a macro unless we're debugging. See above this function. */
#ifndef DEBUG
# define ADD_PSYMBOL_TO_LIST(NAME, NAMELENGTH, NAMESPACE, CLASS, LIST, VALUE) \
ADD_PSYMBOL_VT_TO_LIST(NAME, NAMELENGTH, NAMESPACE, CLASS, LIST, VALUE, \
SYMBOL_VALUE)
#endif /* DEBUG */
/* Add a symbol with a CORE_ADDR value to a psymtab. */
#define ADD_PSYMBOL_ADDR_TO_LIST(NAME, NAMELENGTH, NAMESPACE, CLASS, LIST, VALUE) \
ADD_PSYMBOL_VT_TO_LIST(NAME, NAMELENGTH, NAMESPACE, CLASS, LIST, VALUE, \
SYMBOL_VALUE_ADDRESS)
/* Add any kind of symbol to a psymtab. */
#define ADD_PSYMBOL_VT_TO_LIST(NAME, NAMELENGTH, NAMESPACE, CLASS, LIST, VALUE, VT)\
do { \
if ((LIST).next >= \
(LIST).list + (LIST).size) \
{ \
(LIST).list = (struct partial_symbol *) \
xrealloc ((LIST).list, \
((LIST).size * 2 \
* sizeof (struct partial_symbol))); \
/* Next assumes we only went one over. Should be good if \
program works correctly */ \
(LIST).next = \
(LIST).list + (LIST).size; \
(LIST).size *= 2; \
} \
psym = (LIST).next++; \
\
SYMBOL_NAME (psym) = (char *) obstack_alloc (psymbol_obstack, \
(NAMELENGTH) + 1); \
strncpy (SYMBOL_NAME (psym), (NAME), (NAMELENGTH)); \
SYMBOL_NAME (psym)[(NAMELENGTH)] = '\0'; \
SYMBOL_NAMESPACE (psym) = (NAMESPACE); \
SYMBOL_CLASS (psym) = (CLASS); \
VT (psym) = (VALUE); \
} while (0);
/* End of macro definitions, now let's handle them symbols! */
switch (bufp->n_type)
{
/*
* Standard, external, non-debugger, symbols
*/
case N_TEXT | N_EXT:
case N_NBTEXT | N_EXT:
case N_NBDATA | N_EXT:
case N_NBBSS | N_EXT:
case N_SETV | N_EXT:
case N_ABS | N_EXT:
case N_DATA | N_EXT:
case N_BSS | N_EXT:
bufp->n_value += addr; /* Relocate */
SET_NAMESTRING();
bss_ext_symbol:
record_misc_function (namestring, bufp->n_value,
bufp->n_type); /* Always */
continue;
/* Standard, local, non-debugger, symbols */
case N_NBTEXT:
/* We need to be able to deal with both N_FN or N_TEXT,
because we have no way of knowing whether the sys-supplied ld
or GNU ld was used to make the executable. Sequents throw
in another wrinkle -- they renumbered N_FN. */
case N_FN:
case N_FN_SEQ:
case N_TEXT:
bufp->n_value += addr; /* Relocate */
SET_NAMESTRING();
if ((namestring[0] == '-' && namestring[1] == 'l')
|| (namestring [(nsl = strlen (namestring)) - 1] == 'o'
&& namestring [nsl - 2] == '.'))
{
if (entry_point < bufp->n_value
&& entry_point >= last_o_file_start
&& addr == 0) /* FIXME nogood nomore */
{
startup_file_start = last_o_file_start;
startup_file_end = bufp->n_value;
}
if (past_first_source_file && pst
/* The gould NP1 uses low values for .o and -l symbols
which are not the address. */
&& bufp->n_value > pst->textlow)
{
end_psymtab (pst, psymtab_include_list, includes_used,
symnum * symbol_size, bufp->n_value,
dependency_list, dependencies_used,
global_psymbols.next, static_psymbols.next);
pst = (struct partial_symtab *) 0;
includes_used = 0;
dependencies_used = 0;
}
else
past_first_source_file = 1;
last_o_file_start = bufp->n_value;
#define CUR_SYMBOL_TYPE bufp->n_type
#define CUR_SYMBOL_VALUE bufp->n_value
#define DBXREAD_ONLY
#define CHECK_SECOND_N_SO() \
if (symbuf_idx == symbuf_end) \
fill_symbuf (abfd);\
bufp = &symbuf[symbuf_idx];\
/* n_type is only a char, so swapping swapping is irrelevant. */\
if (CUR_SYMBOL_TYPE == (unsigned char)N_SO)\
{\
SWAP_SYMBOL (bufp, abfd);\
SET_NAMESTRING ();\
valu = CUR_SYMBOL_VALUE;\
symbuf_idx++;\
symnum++;\
}
continue;
case N_DATA:
bufp->n_value += addr; /* Relocate */
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)))
{
/* Not really a function here, but... */
record_misc_function (namestring, bufp->n_value,
bufp->n_type); /* Always */
}
continue;
case N_UNDF | N_EXT:
if (bufp->n_value != 0) {
/* This is a "Fortran COMMON" symbol. See if the target
environment knows where it has been relocated to. */
CORE_ADDR reladdr;
SET_NAMESTRING();
if (target_lookup_symbol (namestring, &reladdr)) {
continue; /* Error in lookup; ignore symbol for now. */
}
bufp->n_type ^= (N_BSS^N_UNDF); /* Define it as a bss-symbol */
bufp->n_value = reladdr;
goto bss_ext_symbol;
}
continue; /* Just undefined, not COMMON */
/* Lots of symbol types we can just ignore. */
case N_UNDF:
case N_ABS:
case N_BSS:
case N_NBDATA:
case N_NBBSS:
continue;
/* Keep going . . .*/
/*
* Special symbol types for GNU
*/
case N_INDR:
case N_INDR | N_EXT:
case N_SETA:
case N_SETA | N_EXT:
case N_SETT:
case N_SETT | N_EXT:
case N_SETD:
case N_SETD | N_EXT:
case N_SETB:
case N_SETB | N_EXT:
case N_SETV:
continue;
/*
* Debugger symbols
*/
case N_SO: {
unsigned long valu = bufp->n_value;
/* Symbol number of the first symbol of this file (i.e. the N_SO
if there is just one, or the first if we have a pair). */
int first_symnum = symnum;
/* End the current partial symtab and start a new one */
SET_NAMESTRING();
/* Peek at the next symbol. If it is also an N_SO, the
first one just indicates the directory. */
if (symbuf_idx == symbuf_end)
fill_symbuf (abfd);
bufp = &symbuf[symbuf_idx];
/* n_type is only a char, so swapping swapping is irrelevant. */
if (bufp->n_type == (unsigned char)N_SO)
{
SWAP_SYMBOL (bufp, abfd);
SET_NAMESTRING ();
valu = bufp->n_value;
symbuf_idx++;
symnum++;
}
valu += addr; /* Relocate */
if (pst && past_first_source_file)
{
end_psymtab (pst, psymtab_include_list, includes_used,
first_symnum * symbol_size, valu,
dependency_list, dependencies_used,
global_psymbols.next, static_psymbols.next);
pst = (struct partial_symtab *) 0;
includes_used = 0;
dependencies_used = 0;
}
else
past_first_source_file = 1;
pst = start_psymtab (objfile, addr,
namestring, valu,
first_symnum * symbol_size,
global_psymbols.next, static_psymbols.next);
continue;
}
case N_BINCL:
/* Add this bincl to the bincl_list for future EXCLs. No
need to save the string; it'll be around until
read_dbx_symtab function returns */
SET_NAMESTRING();
add_bincl_to_list (pst, namestring, bufp->n_value);
/* Mark down an include file in the current psymtab */
psymtab_include_list[includes_used++] = namestring;
if (includes_used >= includes_allocated)
{
char **orig = psymtab_include_list;
psymtab_include_list = (char **)
alloca ((includes_allocated *= 2) *
sizeof (char *));
bcopy (orig, psymtab_include_list,
includes_used * sizeof (char *));
}
continue;
case N_SOL:
/* Mark down an include file in the current psymtab */
SET_NAMESTRING();
/* In C++, one may expect the same filename to come round many
times, when code is coming alternately from the main file
and from inline functions in other files. So I check to see
if this is a file we've seen before -- either the main
source file, or a previously included file.
This seems to be a lot of time to be spending on N_SOL, but
things like "break c-exp.y:435" need to work (I
suppose the psymtab_include_list could be hashed or put
in a binary tree, if profiling shows this is a major hog). */
if (pst && !strcmp (namestring, pst->filename))
continue;
{
register int i;
for (i = 0; i < includes_used; i++)
if (!strcmp (namestring, psymtab_include_list[i]))
{
i = -1;
break;
}
if (i == -1)
continue;
}
psymtab_include_list[includes_used++] = namestring;
if (includes_used >= includes_allocated)
{
char **orig = psymtab_include_list;
psymtab_include_list = (char **)
alloca ((includes_allocated *= 2) *
sizeof (char *));
bcopy (orig, psymtab_include_list,
includes_used * sizeof (char *));
}
continue;
case N_LSYM: /* Typedef or automatic variable. */
case N_STSYM: /* Data seg var -- static */
case N_LCSYM: /* BSS " */
case N_NBSTS: /* Gould nobase. */
case N_NBLCS: /* symbols. */
SET_NAMESTRING();
p = (char *) strchr (namestring, ':');
/* Skip if there is no :. */
if (!p) continue;
switch (p[1])
{
case 'T':
ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
STRUCT_NAMESPACE, LOC_TYPEDEF,
static_psymbols, bufp->n_value);
if (p[2] == 't')
{
/* Also a typedef with the same name. */
ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
VAR_NAMESPACE, LOC_TYPEDEF,
static_psymbols, bufp->n_value);
p += 1;
}
goto check_enum;
case 't':
ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
VAR_NAMESPACE, LOC_TYPEDEF,
static_psymbols, bufp->n_value);
check_enum:
/* If this is an enumerated type, we need to
add all the enum constants to the partial symbol
table. This does not cover enums without names, e.g.
"enum {a, b} c;" in C, but fortunately those are
rare. There is no way for GDB to find those from the
enum type without spending too much time on it. Thus
to solve this problem, the compiler needs to put out separate
constant symbols ('c' N_LSYMS) for enum constants in
enums without names, or put out a dummy type. */
/* We are looking for something of the form
<name> ":" ("t" | "T") [<number> "="] "e"
{<constant> ":" <value> ","} ";". */
/* Skip over the colon and the 't' or 'T'. */
p += 2;
/* This type may be given a number. Skip over it. */
while ((*p >= '0' && *p <= '9')
|| *p == '=')
p++;
if (*p++ == 'e')
{
/* We have found an enumerated type. */
/* According to comments in read_enum_type
a comma could end it instead of a semicolon.
I don't know where that happens.
Accept either. */
while (*p && *p != ';' && *p != ',')
{
char *q;
/* Check for and handle cretinous dbx symbol name
continuation! */
if (*p == '\\')
p = next_symbol_text ();
/* Point to the character after the name
of the enum constant. */
for (q = p; *q && *q != ':'; q++)
;
/* Note that the value doesn't matter for
enum constants in psymtabs, just in symtabs. */
ADD_PSYMBOL_TO_LIST (p, q - p,
VAR_NAMESPACE, LOC_CONST,
static_psymbols, 0);
/* Point past the name. */
p = q;
/* Skip over the value. */
while (*p && *p != ',')
p++;
/* Advance past the comma. */
if (*p)
p++;
}
}
continue;
case 'c':
/* Constant, e.g. from "const" in Pascal. */
ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
VAR_NAMESPACE, LOC_CONST,
static_psymbols, bufp->n_value);
continue;
default:
/* Skip if the thing following the : is
not a letter (which indicates declaration of a local
variable, which we aren't interested in). */
continue;
}
case N_FUN:
case N_GSYM: /* Global (extern) variable; can be
data or bss (sigh). */
/* Following may probably be ignored; I'll leave them here
for now (until I do Pascal and Modula 2 extensions). */
case N_PC: /* I may or may not need this; I
suspect not. */
case N_M2C: /* I suspect that I can ignore this here. */
case N_SCOPE: /* Same. */
SET_NAMESTRING();
p = (char *) strchr (namestring, ':');
if (!p)
continue; /* Not a debugging symbol. */
/* Main processing section for debugging symbols which
the initial read through the symbol tables needs to worry
about. If we reach this point, the symbol which we are
considering is definitely one we are interested in.
p must also contain the (valid) index into the namestring
which indicates the debugging type symbol. */
switch (p[1])
{
case 'c':
ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
VAR_NAMESPACE, LOC_CONST,
static_psymbols, bufp->n_value);
continue;
case 'S':
bufp->n_value += addr; /* Relocate */
ADD_PSYMBOL_ADDR_TO_LIST (namestring, p - namestring,
VAR_NAMESPACE, LOC_STATIC,
static_psymbols, bufp->n_value);
continue;
case 'G':
bufp->n_value += addr; /* Relocate */
/* The addresses in these entries are reported to be
wrong. See the code that reads 'G's for symtabs. */
ADD_PSYMBOL_ADDR_TO_LIST (namestring, p - namestring,
VAR_NAMESPACE, LOC_STATIC,
global_psymbols, bufp->n_value);
continue;
case 't':
ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
VAR_NAMESPACE, LOC_TYPEDEF,
static_psymbols, bufp->n_value);
continue;
case 'f':
ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
VAR_NAMESPACE, LOC_BLOCK,
static_psymbols, bufp->n_value);
continue;
/* Global functions were ignored here, but now they
are put into the global psymtab like one would expect.
They're also in the misc fn vector...
FIXME, why did it used to ignore these? That broke
"i fun" on these functions. */
case 'F':
ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
VAR_NAMESPACE, LOC_BLOCK,
global_psymbols, bufp->n_value);
continue;
/* Two things show up here (hopefully); static symbols of
local scope (static used inside braces) or extensions
of structure symbols. We can ignore both. */
case 'V':
case '(':
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
continue;
default:
/* Unexpected symbol. Ignore it; perhaps it is an extension
that we don't know about.
Someone says sun cc puts out symbols like
/foo/baz/maclib::/usr/local/bin/maclib,
which would get here with a symbol type of ':'. */
continue;
}
case N_EXCL:
SET_NAMESTRING();
/* Find the corresponding bincl and mark that psymtab on the
psymtab dependency list */
{
struct partial_symtab *needed_pst =
find_corresponding_bincl_psymtab (namestring, bufp->n_value);
/* If this include file was defined earlier in this file,
leave it alone. */
if (needed_pst == pst) continue;
if (needed_pst)
{
int i;
int found = 0;
for (i = 0; i < dependencies_used; i++)
if (dependency_list[i] == needed_pst)
{
found = 1;
break;
}
/* If it's already in the list, skip the rest. */
if (found) continue;
dependency_list[dependencies_used++] = needed_pst;
if (dependencies_used >= dependencies_allocated)
{
struct partial_symtab **orig = dependency_list;
dependency_list =
(struct partial_symtab **)
alloca ((dependencies_allocated *= 2)
* sizeof (struct partial_symtab *));
bcopy (orig, dependency_list,
(dependencies_used
* sizeof (struct partial_symtab *)));
#ifdef DEBUG_INFO
fprintf (stderr, "Had to reallocate dependency list.\n");
fprintf (stderr, "New dependencies allocated: %d\n",
dependencies_allocated);
#endif
}
}
else
error ("Invalid symbol data: \"repeated\" header file not previously seen, at symtab pos %d.",
symnum);
}
continue;
case N_EINCL:
case N_DSLINE:
case N_BSLINE:
case N_SSYM: /* Claim: Structure or union element.
Hopefully, I can ignore this. */
case N_ENTRY: /* Alternate entry point; can ignore. */
case N_MAIN: /* Can definitely ignore this. */
case N_CATCH: /* These are GNU C++ extensions */
case N_EHDECL: /* that can safely be ignored here. */
case N_LENG:
case N_BCOMM:
case N_ECOMM:
case N_ECOML:
case N_FNAME:
case N_SLINE:
case N_RSYM:
case N_PSYM:
case N_LBRAC:
case N_RBRAC:
case N_NSYMS: /* Ultrix 4.0: symbol count */
case N_DEFD: /* GNU Modula-2 */
/* These symbols aren't interesting; don't worry about them */
continue;
default:
/* If we haven't found it yet, ignore it. It's probably some
new type we don't know about yet. */
complain (&unknown_symtype_complaint, local_hex_string(bufp->n_type));
continue;
}
#define START_PSYMTAB(ofile,addr,fname,low,symoff,global_syms,static_syms)\
start_psymtab(ofile, addr, fname, low, symoff, global_syms, static_syms)
#define END_PSYMTAB(pst,ilist,ninc,c_off,c_text,dep_list,n_deps)\
end_psymtab(pst,ilist,ninc,c_off,c_text,dep_list,n_deps)
#include "partial-stab.h"
}
/* If there's stuff to be cleaned up, clean it up. */
@ -1409,11 +839,7 @@ read_dbx_symtab (addr, objfile, stringtab, stringtab_size, nlistlen,
{
end_psymtab (pst, psymtab_include_list, includes_used,
symnum * symbol_size, end_of_text_addr,
dependency_list, dependencies_used,
global_psymbols.next, static_psymbols.next);
includes_used = 0;
dependencies_used = 0;
pst = (struct partial_symtab *) 0;
dependency_list, dependencies_used);
}
free_bincl_list ();
@ -1428,7 +854,7 @@ read_dbx_symtab (addr, objfile, stringtab, stringtab_size, nlistlen,
(normal). */
static struct partial_symtab *
struct partial_symtab *
start_psymtab (objfile, addr,
filename, textlow, ldsymoff, global_syms, static_syms)
struct objfile *objfile;
@ -1453,7 +879,8 @@ start_psymtab (objfile, addr,
result->textlow = textlow;
result->read_symtab_private = (char *) obstack_alloc (psymbol_obstack,
sizeof (struct symloc));
LDSYMOFF(result) = ldsymoff;
if (ldsymoff != -1)
LDSYMOFF(result) = ldsymoff;
result->readin = 0;
result->symtab = 0;
@ -1485,10 +912,9 @@ compare_psymbols (s1, s2)
return st1[0] - st2[0];
if (st1[1] - st2[1])
return st1[1] - st2[1];
return strcmp (st1 + 1, st2 + 1);
return strcmp (st1 + 2, st2 + 2);
}
/* Close off the current usage of a partial_symbol table entry. This
involves setting the correct number of includes (with a realloc),
setting the high text mark, setting the symbol length in the
@ -1500,10 +926,9 @@ compare_psymbols (s1, s2)
Then the partial symtab is put on the global list.
*** List variables and peculiarities of same. ***
*/
static void
void
end_psymtab (pst, include_list, num_includes, capping_symbol_offset,
capping_text, dependency_list, number_dependencies,
capping_global, capping_static)
capping_text, dependency_list, number_dependencies)
struct partial_symtab *pst;
char **include_list;
int num_includes;
@ -1511,17 +936,18 @@ end_psymtab (pst, include_list, num_includes, capping_symbol_offset,
CORE_ADDR capping_text;
struct partial_symtab **dependency_list;
int number_dependencies;
struct partial_symbol *capping_global, *capping_static;
/* struct partial_symbol *capping_global, *capping_static;*/
{
int i;
LDSYMLEN(pst) = capping_symbol_offset - LDSYMOFF(pst);
if (capping_symbol_offset != -1)
LDSYMLEN(pst) = capping_symbol_offset - LDSYMOFF(pst);
pst->texthigh = capping_text;
pst->n_global_syms =
capping_global - (global_psymbols.list + pst->globals_offset);
global_psymbols.next - (global_psymbols.list + pst->globals_offset);
pst->n_static_syms =
capping_static - (static_psymbols.list + pst->statics_offset);
static_psymbols.next - (static_psymbols.list + pst->statics_offset);
pst->number_of_dependencies = number_dependencies;
if (number_dependencies)
@ -1529,7 +955,7 @@ end_psymtab (pst, include_list, num_includes, capping_symbol_offset,
pst->dependencies = (struct partial_symtab **)
obstack_alloc (psymbol_obstack,
number_dependencies * sizeof (struct partial_symtab *));
bcopy (dependency_list, pst->dependencies,
memcpy (pst->dependencies, dependency_list,
number_dependencies * sizeof (struct partial_symtab *));
}
else
@ -1876,46 +1302,9 @@ read_ofile_symtab (objfile, stringtab, stringtab_size, sym_offset,
SET_NAMESTRING ();
if (type & N_STAB) {
/* Check for a pair of N_SO symbols, which give both a new
source file name (second) and its directory (first). */
if (type == (unsigned char)N_SO) {
/* Save the outer values */
short bufp_n_desc = bufp->n_desc;
unsigned long valu = bufp->n_value;
process_one_symbol (type, bufp->n_desc, bufp->n_value, namestring);
/* our_objfile is an implicit parameter. */
if (symbuf_idx == symbuf_end)
fill_symbuf (abfd);
bufp = &symbuf[symbuf_idx];
if (bufp->n_type == (unsigned char)N_SO) {
char *namestring1 = namestring;
SWAP_SYMBOL (bufp, abfd);
bufp->n_value += offset; /* Relocate */
symbuf_idx++;
symnum++;
SET_NAMESTRING ();
/* No need to check PCC_SOL_BROKEN, on the assumption that
such broken PCC's don't put out N_SO pairs. */
if (last_source_file)
(void)end_symtab (bufp->n_value, 0, 0, objfile);
start_symtab (namestring, namestring1, bufp->n_value);
} else {
/* N_SO without a following N_SO */
process_one_symbol(type, bufp_n_desc, valu, namestring);
/* our_objfile is an implicit parameter. */
}
} else {
/* Ordinary symbol
HERE IS WHERE THE REAL WORK GETS DONE!
*/
process_one_symbol (type, bufp->n_desc, bufp->n_value,
namestring);
/* our_objfile is an implicit parameter. */
}
}
/* We skip checking for a new .o or -l file; that should never
happen in this routine. */
@ -1970,7 +1359,7 @@ hashname (name)
}
static void
void
process_one_symbol (type, desc, valu, name)
int type, desc;
CORE_ADDR valu;
@ -2151,7 +1540,22 @@ process_one_symbol (type, desc, valu, name)
}
#endif
if (last_source_file)
(void)end_symtab (valu, 0, 0);
{
/* Check if previous symbol was also an N_SO (with some
sanity checks). If so, that one was actually the directory
name, and the current one is the real file name.
Patch things up. */
if (previous_stab_code == N_SO
&& current_subfile && current_subfile->dirname == NULL
&& current_subfile->name != NULL
&& current_subfile->name[strlen(current_subfile->name)-1] == '/')
{
current_subfile->dirname = current_subfile->name;
current_subfile->name = obsavestring (name, strlen (name));
break;
}
(void)end_symtab (valu, 0, 0);
}
start_symtab (name, NULL, valu);
break;
@ -2226,6 +1630,8 @@ process_one_symbol (type, desc, valu, name)
if (name)
define_symbol (valu, name, desc, type);
}
previous_stab_code = type;
}
/* Copy a pending list, used to record the contents of a common

View File

@ -52,7 +52,7 @@ cplus-dem.o : cplus-dem.c defs.h xm.h config.status tm.h config.status
dbxread.o : dbxread.c defs.h xm.h config.status tm.h config.status symtab.h breakpoint.h value.h \
command.h target.h ${srcdir}/../include/bfd.h ${srcdir}/../include/ansidecl.h gdbcore.h \
${srcdir}/../bfd/libaout.h symfile.h buildsym.h ${srcdir}/../include/aout/aout64.h \
${srcdir}/../include/aout/stab_gnu.h ${srcdir}/../include/aout/stab.def
${srcdir}/../include/aout/stab_gnu.h ${srcdir}/../include/aout/stab.def partial-stab.h
dwarfread.o : dwarfread.c defs.h xm.h config.status tm.h config.status ${srcdir}/../include/bfd.h \
${srcdir}/../include/ansidecl.h ${srcdir}/../include/obstack.h symtab.h symfile.h \
${srcdir}/../include/elf/dwarf.h ansidecl.h
@ -119,8 +119,8 @@ m2-exp.tab.o : m2-exp.tab.c ${srcdir}/defs.h xm.h config.status tm.h config.stat
${srcdir}/../include/obstack.h ${srcdir}/frame.h ${srcdir}/expression.h ${srcdir}/language.h ${srcdir}/value.h \
${srcdir}/parser-defs.h
m68k-pinsn.o : m68k-pinsn.c defs.h xm.h config.status tm.h config.status symtab.h \
${srcdir}/../include/obstack.h m68k-opcode.h gdbcore.h ${srcdir}/../include/bfd.h \
${srcdir}/../include/ansidecl.h
${srcdir}/../include/obstack.h ${srcdir}/../include/opcode/m68k.h gdbcore.h \
${srcdir}/../include/bfd.h ${srcdir}/../include/ansidecl.h
m68k-tdep.o : m68k-tdep.c defs.h xm.h config.status tm.h config.status ieee-float.h frame.h symtab.h \
${srcdir}/../include/obstack.h
m88k-pinsn.o : m88k-pinsn.c m88k-opcode.h defs.h xm.h config.status tm.h config.status symtab.h \
@ -141,7 +141,7 @@ main.o : main.c defs.h xm.h config.status tm.h config.status gdbcmd.h command.h
${srcdir}/../readline/chardefs.h ${srcdir}/../readline/history.h
mem-break.o : mem-break.c defs.h xm.h config.status tm.h config.status
mips-pinsn.o : mips-pinsn.c defs.h xm.h config.status tm.h config.status symtab.h \
${srcdir}/../include/obstack.h mips-opcode.h
${srcdir}/../include/obstack.h ${srcdir}/../include/opcode/mips.h
mips-tdep.o : mips-tdep.c defs.h xm.h config.status tm.h config.status frame.h inferior.h breakpoint.h \
value.h symtab.h ${srcdir}/../include/obstack.h gdbcmd.h command.h language.h \
gdbcore.h ${srcdir}/../include/bfd.h ${srcdir}/../include/ansidecl.h
@ -149,8 +149,9 @@ mips-xdep.o : mips-xdep.c defs.h xm.h config.status tm.h config.status frame.h i
value.h symtab.h ${srcdir}/../include/obstack.h gdbcore.h ${srcdir}/../include/bfd.h \
${srcdir}/../include/ansidecl.h
mipsread.o : mipsread.c defs.h xm.h config.status tm.h config.status symtab.h ${srcdir}/../include/obstack.h \
gdbcore.h ${srcdir}/../include/bfd.h ${srcdir}/../include/ansidecl.h symfile.h \
${srcdir}/../include/coff/mips.h
gdbcore.h ${srcdir}/../include/bfd.h ${srcdir}/../include/ansidecl.h symfile.h buildsym.h \
${srcdir}/../include/coff/mips.h ${srcdir}/../bfd/libaout.h ${srcdir}/../include/aout/aout64.h \
${srcdir}/../include/aout/stab_gnu.h ${srcdir}/../include/aout/stab.def partial-stab.h
news-xdep.o : news-xdep.c
Onindy.o : ${srcdir}/nindy-share/Onindy.c ${srcdir}/nindy-share/ttycntl.h \
${srcdir}/nindy-share/block_io.h ${srcdir}/../include/wait.h ${srcdir}/nindy-share/env.h \
@ -181,7 +182,7 @@ remote-adapt.o : remote-adapt.c defs.h xm.h config.status tm.h config.status inf
terminal.h target.h ${srcdir}/../include/bfd.h ${srcdir}/../include/ansidecl.h gdbcore.h
remote-eb.o : remote-eb.c defs.h xm.h config.status tm-29k.h inferior.h breakpoint.h \
value.h symtab.h ${srcdir}/../include/obstack.h frame.h ${srcdir}/../include/wait.h \
terminal.h target.h ${srcdir}/../include/bfd.h ${srcdir}/../include/ansidecl.h
terminal.h target.h ${srcdir}/../include/bfd.h ${srcdir}/../include/ansidecl.h gdbcore.h
remote-mm.o : remote-mm.c defs.h xm.h config.status tm.h config.status inferior.h breakpoint.h value.h \
symtab.h ${srcdir}/../include/obstack.h frame.h ${srcdir}/../include/wait.h terminal.h \
minimon.h target.h ${srcdir}/../include/bfd.h ${srcdir}/../include/ansidecl.h
@ -213,8 +214,8 @@ source.o : source.c defs.h xm.h config.status tm.h config.status symtab.h ${srcd
language.h command.h gdbcmd.h frame.h gdbcore.h ${srcdir}/../include/bfd.h \
${srcdir}/../include/ansidecl.h regex.h
sparc-pinsn.o : sparc-pinsn.c defs.h xm.h config.status tm.h config.status symtab.h \
${srcdir}/../include/obstack.h sparc-opcode.h gdbcore.h ${srcdir}/../include/bfd.h \
${srcdir}/../include/ansidecl.h /usr/include/string.h target.h
${srcdir}/../include/obstack.h ${srcdir}/../include/opcode/sparc.h gdbcore.h \
${srcdir}/../include/bfd.h ${srcdir}/../include/ansidecl.h /usr/include/string.h target.h
sparc-tdep.o : sparc-tdep.c defs.h xm.h config.status tm.h config.status frame.h inferior.h \
breakpoint.h value.h symtab.h ${srcdir}/../include/obstack.h signame.h target.h \
${srcdir}/../include/bfd.h ${srcdir}/../include/ansidecl.h ieee-float.h gdbcore.h

View File

@ -331,11 +331,24 @@ EXFUN(start_psymtab, (struct objfile *objfile AND CORE_ADDR addr
static void
EXFUN(add_partial_symbol, (struct dieinfo *dip));
#ifdef DEBUG
static void
EXFUN(add_psymbol_to_list,
(struct psymbol_allocation_list *listp AND char *name
AND enum namespace space AND enum address_class class
AND CORE_ADDR value));
DEFUN(add_psymbol_to_list,
(listp, name, space, class, value),
struct psymbol_allocation_list *listp AND
char *name AND
enum namespace space AND
enum address_class class AND
CORE_ADDR value)
{
ADD_PSYMBOL_VT_TO_LIST(name, strlen(name), space, class,
listp, value, SYMBOL_VALUE);
}
#else
#define add_psymbol_to_list(listp, name, space, class, value) \
ADD_PSYMBOL_VT_TO_LIST(name, strlen(name), space, class, \
*(listp), value, SYMBOL_VALUE)
#endif
static void
EXFUN(init_psymbol_list, (int total_symbols));
@ -913,10 +926,7 @@ DEFUN(struct_type, (dip, thisdie, enddie, objfile),
/* No forward references created an empty type, so install one now */
type = alloc_utype (dip -> dieref, NULL);
}
TYPE_CPLUS_SPECIFIC (type) = (struct cplus_struct_type *)
obstack_alloc (symbol_obstack, sizeof (struct cplus_struct_type));
(void) memset (TYPE_CPLUS_SPECIFIC (type), 0,
sizeof (struct cplus_struct_type));
TYPE_CPLUS_SPECIFIC(type) = &cplus_struct_default;
switch (dip -> dietag)
{
case TAG_structure_type:
@ -2655,6 +2665,7 @@ DEFUN(start_psymtab,
return result;
}
#if 0
/*
LOCAL FUNCTION
@ -2696,6 +2707,7 @@ DEFUN(add_psymbol_to_list,
SYMBOL_CLASS (psym) = class;
SYMBOL_VALUE (psym) = value;
}
#endif
/*

View File

@ -21,7 +21,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "defs.h"
#include "symtab.h"
#include "m68k-opcode.h"
#include "opcode/m68k.h"
#include "gdbcore.h"
/* 68k instructions are never longer than this many bytes. */

View File

@ -22,7 +22,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "defs.h"
#include "symtab.h"
#include "mips-opcode.h"
#include "opcode/mips.h"
/* Mips instructions are never longer than this many bytes. */
#define MAXLEN 4

File diff suppressed because it is too large Load Diff

576
gdb/partial-stab.h Normal file
View File

@ -0,0 +1,576 @@
/* Shared code to pre-read a stab (dbx-style), when building a psymtab.
Copyright (C) 1986-1991 Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* The following need to be defined:
SET_NAMESTRING() --Set namestring to name of symbol.
CUR_SYMBOL_TYPE --Type code of current symbol.
CUR_SYMBOL_VALUE --Value field of current symbol. May be adjusted here.
*/
#ifdef DEBUG
/* Since one arg is a struct, we have to pass in a ptr and deref it (sigh) */
#define ADD_PSYMBOL_TO_LIST(NAME, NAMELENGTH, NAMESPACE, CLASS, LIST, VALUE) \
add_psymbol_to_plist(NAME, NAMELENGTH, NAMESPACE, CLASS, &LIST, VALUE)
#define ADD_PSYMBOL_ADDR_TO_LIST(NAME, NAMELENGTH, NAMESPACE, CLASS, LIST, VALUE) \
add_psymbol_to_plist(NAME, NAMELENGTH, NAMESPACE, CLASS, &LIST, VALUE)
#else
/* Add a symbol with an integer value to a psymtab. */
#define ADD_PSYMBOL_TO_LIST(NAME, NAMELENGTH, NAMESPACE, CLASS, LIST, VALUE) \
ADD_PSYMBOL_VT_TO_LIST(NAME, NAMELENGTH, NAMESPACE, CLASS, LIST, VALUE, SYMBOL_VALUE)
/* Add a symbol with a CORE_ADDR value to a psymtab. */
#define ADD_PSYMBOL_ADDR_TO_LIST(NAME,NAMELENGTH, NAMESPACE,CLASS, LIST,VALUE)\
ADD_PSYMBOL_VT_TO_LIST(NAME, NAMELENGTH, NAMESPACE, CLASS, LIST, VALUE, SYMBOL_VALUE_ADDRESS)
#endif
/* End of macro definitions, now let's handle them symbols! */
switch (CUR_SYMBOL_TYPE)
{
char *p;
/*
* Standard, external, non-debugger, symbols
*/
#ifdef DBXREAD_ONLY
case N_TEXT | N_EXT:
case N_NBTEXT | N_EXT:
case N_NBDATA | N_EXT:
case N_NBBSS | N_EXT:
case N_SETV | N_EXT:
case N_ABS | N_EXT:
case N_DATA | N_EXT:
case N_BSS | N_EXT:
CUR_SYMBOL_VALUE += addr; /* Relocate */
SET_NAMESTRING();
bss_ext_symbol:
record_misc_function (namestring, CUR_SYMBOL_VALUE,
CUR_SYMBOL_TYPE); /* Always */
continue;
/* Standard, local, non-debugger, symbols */
case N_NBTEXT:
/* We need to be able to deal with both N_FN or N_TEXT,
because we have no way of knowing whether the sys-supplied ld
or GNU ld was used to make the executable. Sequents throw
in another wrinkle -- they renumbered N_FN. */
case N_FN:
case N_FN_SEQ:
case N_TEXT:
CUR_SYMBOL_VALUE += addr; /* Relocate */
SET_NAMESTRING();
if ((namestring[0] == '-' && namestring[1] == 'l')
|| (namestring [(nsl = strlen (namestring)) - 1] == 'o'
&& namestring [nsl - 2] == '.'))
{
if (entry_point < CUR_SYMBOL_VALUE
&& entry_point >= last_o_file_start
&& addr == 0) /* FIXME nogood nomore */
{
startup_file_start = last_o_file_start;
startup_file_end = CUR_SYMBOL_VALUE;
}
if (past_first_source_file && pst
/* The gould NP1 uses low values for .o and -l symbols
which are not the address. */
&& CUR_SYMBOL_VALUE > pst->textlow)
{
END_PSYMTAB (pst, psymtab_include_list, includes_used,
symnum * symbol_size, CUR_SYMBOL_VALUE,
dependency_list, dependencies_used);
pst = (struct partial_symtab *) 0;
includes_used = 0;
dependencies_used = 0;
}
else
past_first_source_file = 1;
last_o_file_start = CUR_SYMBOL_VALUE;
}
continue;
case N_DATA:
CUR_SYMBOL_VALUE += addr; /* Relocate */
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)))
{
/* Not really a function here, but... */
record_misc_function (namestring, CUR_SYMBOL_VALUE,
CUR_SYMBOL_TYPE); /* Always */
}
continue;
case N_UNDF | N_EXT:
if (CUR_SYMBOL_VALUE != 0) {
/* This is a "Fortran COMMON" symbol. See if the target
environment knows where it has been relocated to. */
CORE_ADDR reladdr;
SET_NAMESTRING();
if (target_lookup_symbol (namestring, &reladdr)) {
continue; /* Error in lookup; ignore symbol for now. */
}
CUR_SYMBOL_TYPE ^= (N_BSS^N_UNDF); /* Define it as a bss-symbol */
CUR_SYMBOL_VALUE = reladdr;
goto bss_ext_symbol;
}
continue; /* Just undefined, not COMMON */
#endif
/* Lots of symbol types we can just ignore. */
case N_UNDF:
case N_ABS:
case N_BSS:
case N_NBDATA:
case N_NBBSS:
continue;
/* Keep going . . .*/
/*
* Special symbol types for GNU
*/
case N_INDR:
case N_INDR | N_EXT:
case N_SETA:
case N_SETA | N_EXT:
case N_SETT:
case N_SETT | N_EXT:
case N_SETD:
case N_SETD | N_EXT:
case N_SETB:
case N_SETB | N_EXT:
case N_SETV:
continue;
/*
* Debugger symbols
*/
case N_SO: {
unsigned long valu = CUR_SYMBOL_VALUE;
/* Symbol number of the first symbol of this file (i.e. the N_SO
if there is just one, or the first if we have a pair). */
int first_symnum = symnum;
/* End the current partial symtab and start a new one */
SET_NAMESTRING();
/* Peek at the next symbol. If it is also an N_SO, the
first one just indicates the directory. */
CHECK_SECOND_N_SO();
valu += addr; /* Relocate */
if (pst && past_first_source_file)
{
END_PSYMTAB (pst, psymtab_include_list, includes_used,
first_symnum * symbol_size, valu,
dependency_list, dependencies_used);
pst = (struct partial_symtab *) 0;
includes_used = 0;
dependencies_used = 0;
}
else
past_first_source_file = 1;
pst = START_PSYMTAB (objfile, addr,
namestring, valu,
first_symnum * symbol_size,
global_psymbols.next, static_psymbols.next);
continue;
}
#ifdef DBXREAD_ONLY
case N_BINCL:
/* Add this bincl to the bincl_list for future EXCLs. No
need to save the string; it'll be around until
read_dbx_symtab function returns */
SET_NAMESTRING();
add_bincl_to_list (pst, namestring, CUR_SYMBOL_VALUE);
/* Mark down an include file in the current psymtab */
psymtab_include_list[includes_used++] = namestring;
if (includes_used >= includes_allocated)
{
char **orig = psymtab_include_list;
psymtab_include_list = (char **)
alloca ((includes_allocated *= 2) *
sizeof (char *));
bcopy (orig, psymtab_include_list,
includes_used * sizeof (char *));
}
continue;
#endif
case N_SOL:
/* Mark down an include file in the current psymtab */
SET_NAMESTRING();
/* In C++, one may expect the same filename to come round many
times, when code is coming alternately from the main file
and from inline functions in other files. So I check to see
if this is a file we've seen before -- either the main
source file, or a previously included file.
This seems to be a lot of time to be spending on N_SOL, but
things like "break c-exp.y:435" need to work (I
suppose the psymtab_include_list could be hashed or put
in a binary tree, if profiling shows this is a major hog). */
if (pst && !strcmp (namestring, pst->filename))
continue;
{
register int i;
for (i = 0; i < includes_used; i++)
if (!strcmp (namestring, psymtab_include_list[i]))
{
i = -1;
break;
}
if (i == -1)
continue;
}
psymtab_include_list[includes_used++] = namestring;
if (includes_used >= includes_allocated)
{
char **orig = psymtab_include_list;
psymtab_include_list = (char **)
alloca ((includes_allocated *= 2) *
sizeof (char *));
bcopy (orig, psymtab_include_list,
includes_used * sizeof (char *));
}
continue;
case N_LSYM: /* Typedef or automatic variable. */
case N_STSYM: /* Data seg var -- static */
case N_LCSYM: /* BSS " */
case N_NBSTS: /* Gould nobase. */
case N_NBLCS: /* symbols. */
SET_NAMESTRING();
p = (char *) strchr (namestring, ':');
/* Skip if there is no :. */
if (!p) continue;
switch (p[1])
{
case 'T':
ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
STRUCT_NAMESPACE, LOC_TYPEDEF,
static_psymbols, CUR_SYMBOL_VALUE);
if (p[2] == 't')
{
/* Also a typedef with the same name. */
ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
VAR_NAMESPACE, LOC_TYPEDEF,
static_psymbols, CUR_SYMBOL_VALUE);
p += 1;
}
goto check_enum;
case 't':
ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
VAR_NAMESPACE, LOC_TYPEDEF,
static_psymbols, CUR_SYMBOL_VALUE);
check_enum:
#ifdef DBXREAD_ONLY
/* If this is an enumerated type, we need to
add all the enum constants to the partial symbol
table. This does not cover enums without names, e.g.
"enum {a, b} c;" in C, but fortunately those are
rare. There is no way for GDB to find those from the
enum type without spending too much time on it. Thus
to solve this problem, the compiler needs to put out separate
constant symbols ('c' N_LSYMS) for enum constants in
enums without names, or put out a dummy type. */
/* We are looking for something of the form
<name> ":" ("t" | "T") [<number> "="] "e"
{<constant> ":" <value> ","} ";". */
/* Skip over the colon and the 't' or 'T'. */
p += 2;
/* This type may be given a number. Also, numbers can come
in pairs like (0,26). Skip over it. */
while ((*p >= '0' && *p <= '9')
|| *p == '(' || *p == ',' || *p == ')'
|| *p == '=')
p++;
if (*p++ == 'e')
{
/* We have found an enumerated type. */
/* According to comments in read_enum_type
a comma could end it instead of a semicolon.
I don't know where that happens.
Accept either. */
while (*p && *p != ';' && *p != ',')
{
char *q;
/* Check for and handle cretinous dbx symbol name
continuation! */
if (*p == '\\')
p = next_symbol_text ();
/* Point to the character after the name
of the enum constant. */
for (q = p; *q && *q != ':'; q++)
;
/* Note that the value doesn't matter for
enum constants in psymtabs, just in symtabs. */
ADD_PSYMBOL_TO_LIST (p, q - p,
VAR_NAMESPACE, LOC_CONST,
static_psymbols, 0);
/* Point past the name. */
p = q;
/* Skip over the value. */
while (*p && *p != ',')
p++;
/* Advance past the comma. */
if (*p)
p++;
}
}
#endif
continue;
case 'c':
/* Constant, e.g. from "const" in Pascal. */
ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
VAR_NAMESPACE, LOC_CONST,
static_psymbols, CUR_SYMBOL_VALUE);
continue;
default:
/* Skip if the thing following the : is
not a letter (which indicates declaration of a local
variable, which we aren't interested in). */
continue;
}
case N_FUN:
case N_GSYM: /* Global (extern) variable; can be
data or bss (sigh). */
/* Following may probably be ignored; I'll leave them here
for now (until I do Pascal and Modula 2 extensions). */
case N_PC: /* I may or may not need this; I
suspect not. */
case N_M2C: /* I suspect that I can ignore this here. */
case N_SCOPE: /* Same. */
SET_NAMESTRING();
p = (char *) strchr (namestring, ':');
if (!p)
continue; /* Not a debugging symbol. */
/* Main processing section for debugging symbols which
the initial read through the symbol tables needs to worry
about. If we reach this point, the symbol which we are
considering is definitely one we are interested in.
p must also contain the (valid) index into the namestring
which indicates the debugging type symbol. */
switch (p[1])
{
case 'c':
ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
VAR_NAMESPACE, LOC_CONST,
static_psymbols, CUR_SYMBOL_VALUE);
continue;
case 'S':
CUR_SYMBOL_VALUE += addr; /* Relocate */
ADD_PSYMBOL_ADDR_TO_LIST (namestring, p - namestring,
VAR_NAMESPACE, LOC_STATIC,
static_psymbols, CUR_SYMBOL_VALUE);
continue;
case 'G':
CUR_SYMBOL_VALUE += addr; /* Relocate */
/* The addresses in these entries are reported to be
wrong. See the code that reads 'G's for symtabs. */
ADD_PSYMBOL_ADDR_TO_LIST (namestring, p - namestring,
VAR_NAMESPACE, LOC_STATIC,
global_psymbols, CUR_SYMBOL_VALUE);
continue;
case 't':
ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
VAR_NAMESPACE, LOC_TYPEDEF,
static_psymbols, CUR_SYMBOL_VALUE);
continue;
case 'f':
ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
VAR_NAMESPACE, LOC_BLOCK,
static_psymbols, CUR_SYMBOL_VALUE);
continue;
/* Global functions were ignored here, but now they
are put into the global psymtab like one would expect.
They're also in the misc fn vector...
FIXME, why did it used to ignore these? That broke
"i fun" on these functions. */
case 'F':
ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
VAR_NAMESPACE, LOC_BLOCK,
global_psymbols, CUR_SYMBOL_VALUE);
continue;
/* Two things show up here (hopefully); static symbols of
local scope (static used inside braces) or extensions
of structure symbols. We can ignore both. */
case 'V':
case '(':
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
continue;
default:
/* Unexpected symbol. Ignore it; perhaps it is an extension
that we don't know about.
Someone says sun cc puts out symbols like
/foo/baz/maclib::/usr/local/bin/maclib,
which would get here with a symbol type of ':'. */
continue;
}
#ifdef DBXREAD_ONLY
case N_EXCL:
SET_NAMESTRING();
/* Find the corresponding bincl and mark that psymtab on the
psymtab dependency list */
{
struct partial_symtab *needed_pst =
find_corresponding_bincl_psymtab (namestring, CUR_SYMBOL_VALUE);
/* If this include file was defined earlier in this file,
leave it alone. */
if (needed_pst == pst) continue;
if (needed_pst)
{
int i;
int found = 0;
for (i = 0; i < dependencies_used; i++)
if (dependency_list[i] == needed_pst)
{
found = 1;
break;
}
/* If it's already in the list, skip the rest. */
if (found) continue;
dependency_list[dependencies_used++] = needed_pst;
if (dependencies_used >= dependencies_allocated)
{
struct partial_symtab **orig = dependency_list;
dependency_list =
(struct partial_symtab **)
alloca ((dependencies_allocated *= 2)
* sizeof (struct partial_symtab *));
bcopy (orig, dependency_list,
(dependencies_used
* sizeof (struct partial_symtab *)));
#ifdef DEBUG_INFO
fprintf (stderr, "Had to reallocate dependency list.\n");
fprintf (stderr, "New dependencies allocated: %d\n",
dependencies_allocated);
#endif
}
}
else
error ("Invalid symbol data: \"repeated\" header file not previously seen, at symtab pos %d.",
symnum);
}
continue;
#endif
case N_RBRAC:
#ifdef HANDLE_RBRAC
HANDLE_RBRAC(CUR_SYMBOL_VALUE);
#endif
case N_EINCL:
case N_DSLINE:
case N_BSLINE:
case N_SSYM: /* Claim: Structure or union element.
Hopefully, I can ignore this. */
case N_ENTRY: /* Alternate entry point; can ignore. */
case N_MAIN: /* Can definitely ignore this. */
case N_CATCH: /* These are GNU C++ extensions */
case N_EHDECL: /* that can safely be ignored here. */
case N_LENG:
case N_BCOMM:
case N_ECOMM:
case N_ECOML:
case N_FNAME:
case N_SLINE:
case N_RSYM:
case N_PSYM:
case N_LBRAC:
case N_NSYMS: /* Ultrix 4.0: symbol count */
case N_DEFD: /* GNU Modula-2 */
/* These symbols aren't interesting; don't worry about them */
continue;
default:
#ifdef DBXREAD_ONLY
/* If we haven't found it yet, ignore it. It's probably some
new type we don't know about yet. */
complain (&unknown_symtype_complaint, local_hex_string(CUR_SYMBOL_TYPE));
#endif
continue;
}

View File

@ -21,7 +21,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "defs.h"
#include "symtab.h"
#include "sparc-opcode.h"
#include "opcode/sparc.h"
#include "gdbcore.h"
#include "string.h"
#include "target.h"

View File

@ -1,5 +1,5 @@
/* Definitions for reading symbol files into GDB.
Copyright (C) 1990 Free Software Foundation, Inc.
Copyright (C) 1990, 1991 Free Software Foundation, Inc.
This file is part of GDB.
@ -19,8 +19,36 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* This file requires that you first include "bfd.h". */
/* Data structures and function definitions for dealing with
symbol table reading from files. */
/* Structure for keeping track of object files.
One of these is allocated for each object file we access, e.g. the
exec_file, symbol_file, and any shared library object files. */
struct objfile {
/* All struct objfile's are chained together by their next pointers. */
struct objfile *next;
/* Each objfile points to a chain of struct symtabs derived from this
object file. They are chained by their objfile_chain pointers, and
each one points back to this struct objfile. */
struct symtab *symtabs;
/* Ditto for psymtabs. */
struct partial_symtab *psymtabs;
/* The object file's name. Malloc'd; free it if you free this struct. */
char *name;
/* The object file's BFD. Can be null, in which case bfd_open (name) and
put the result here. */
bfd *obfd;
/* The modification timestamp of the object file, as of the last time
we read its symbols. */
long mtime;
};
/* Structure to keep track of symbol reading functions for various
object file types. */
@ -83,14 +111,41 @@ struct sym_fns {
in whatever module implements the functions pointed to; an
initializer calls add_symtab_fns to add them to the global chain. */
struct sym_fns *next;
/* objfile
is the "struct objfile" for the object file being read. */
struct objfile *objfile;
};
extern void extend_psymbol_list();
/* Add any kind of symbol to a psymbol_allocation_list. */
#define ADD_PSYMBOL_VT_TO_LIST(NAME, NAMELENGTH, NAMESPACE, CLASS, LIST, VALUE, VT)\
do { \
register struct partial_symbol *psym; \
if ((LIST).next >= (LIST).list + (LIST).size) \
extend_psymbol_list(&(LIST)); \
psym = (LIST).next++; \
\
SYMBOL_NAME (psym) = (char *) obstack_alloc (psymbol_obstack, \
(NAMELENGTH) + 1); \
strncpy (SYMBOL_NAME (psym), (NAME), (NAMELENGTH)); \
SYMBOL_NAME (psym)[(NAMELENGTH)] = '\0'; \
SYMBOL_NAMESPACE (psym) = (NAMESPACE); \
SYMBOL_CLASS (psym) = (CLASS); \
VT (psym) = (VALUE); \
} while (0);
/* Functions */
extern struct symtab *allocate_symtab ();
extern struct objfile *allocate_objfile ();
extern void free_objfile ();
extern int free_named_symtabs ();
extern void fill_in_vptr_fieldno ();
extern void add_symtab_fns ();
extern void syms_from_objfile ();
/* Functions for dealing with the misc "function" vector, really a misc
address<->symbol mapping vector for things we don't have debug symbols
@ -121,13 +176,18 @@ extern char *obconcat ();
/* Variables */
/* File name symbols were loaded from. */
/* The object file that the main symbol table was loaded from (e.g. the
argument to the "symbol-file" or "file" command). */
extern char *symfile;
extern struct objfile *symfile_objfile;
/* The modification date of the file when they were loaded. */
/* Where execution starts in symfile */
extern long /* really time_t */ symfile_mtime;
CORE_ADDR entry_point;
/* Root of object file struct chain. */
struct objfile *object_files;
/* Vectors of all partial symbols read in from file. */
@ -156,5 +216,5 @@ extern struct complaint complaint_root[1];
/* Functions that handle complaints. (in symfile.c) */
int complain();
void complain();
void clear_complaints();

View File

@ -1,5 +1,5 @@
/* Do various things to symbol tables (other than lookup)), for GDB.
Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc.
/* Do various things to symbol tables (other than lookup), for GDB.
Copyright 1986, 1987, 1989, 1991 Free Software Foundation, Inc.
This file is part of GDB.
@ -20,52 +20,15 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <stdio.h>
#include "defs.h"
#include "param.h"
#include "symtab.h"
#include "bfd.h"
#include "symfile.h"
#include "breakpoint.h"
#include "command.h"
#include "obstack.h"
#include <obstack.h>
#include <string.h>
/* Free all the symtabs that are currently installed,
and all storage associated with them.
Leaves us in a consistent state with no symtabs installed. */
void
free_all_symtabs ()
{
register struct symtab *s, *snext;
/* All values will be invalid because their types will be! */
clear_value_history ();
clear_displays ();
clear_internalvars ();
#if defined (CLEAR_SOLIB)
CLEAR_SOLIB ();
#endif
set_default_breakpoint (0, 0, 0, 0);
current_source_symtab = 0;
for (s = symtab_list; s; s = snext)
{
snext = s->next;
free_symtab (s);
}
symtab_list = 0;
obstack_free (symbol_obstack, 0);
obstack_init (symbol_obstack);
if (misc_function_vector)
free (misc_function_vector);
misc_function_count = 0;
misc_function_vector = 0;
clear_pc_function_cache();
}
/* Free a struct block <- B and all the symbols defined in that block. */
static void
@ -119,9 +82,10 @@ free_symtab (s)
case free_linetable:
/* Everything will be freed either by our `free_ptr'
or by some other symbatb, except for our linetable.
or by some other symtab, except for our linetable.
Free that now. */
free (LINETABLE (s));
if (LINETABLE (s))
free (LINETABLE (s));
break;
}
@ -142,7 +106,7 @@ static void print_symbol ();
static void print_partial_symbol ();
void
print_symtabs (filename)
printsyms_command (filename)
char *filename;
{
FILE *outfile;
@ -155,10 +119,16 @@ print_symtabs (filename)
int depth;
struct cleanup *cleanups;
extern int fclose();
char *symname;
if (filename == 0)
error_no_arg ("file to write symbol data in");
/* If a second arg is supplied, it is a source file name to match on */
symname = strchr (filename, ' ');
if (symname)
*symname++ = '\0';
filename = tilde_expand (filename);
make_cleanup (free, filename);
@ -171,8 +141,16 @@ print_symtabs (filename)
for (s = symtab_list; s; s = s->next)
{
/* First print the line table. */
/* If source file name is specified, reject all but that one. */
if (symname)
if (0 != strncmp (symname, s->filename, strlen (symname)))
continue;
fprintf (outfile, "Symtab for file %s\n", s->filename);
fprintf (outfile, "Read from object file %s (%x)\n", s->objfile->name,
s->objfile);
/* First print the line table. */
l = LINETABLE (s);
if (l) {
fprintf (outfile, "\nLine table:\n\n");
@ -324,17 +302,23 @@ print_symbol (symbol, depth, outfile)
}
void
print_partial_symtabs (filename)
printpsyms_command (filename)
char *filename;
{
FILE *outfile;
struct partial_symtab *p;
struct cleanup *cleanups;
extern int fclose();
char *symname;
if (filename == 0)
error_no_arg ("file to write partial symbol data in");
/* If a second arg is supplied, it is a source file name to match on */
symname = strchr (filename, ' ');
if (symname)
*symname++ = '\0';
filename = tilde_expand (filename);
make_cleanup (free, filename);
@ -347,14 +331,19 @@ print_partial_symtabs (filename)
for (p = partial_symtab_list; p; p = p->next)
{
/* If source file name is specified, reject all but that one. */
if (symname)
if (0 != strncmp (symname, p->filename, strlen (symname)))
continue;
fprintf_filtered (outfile, "Partial symtab for source file %s ",
p->filename);
fprintf_filtered (outfile, "(object 0x%x)\n\n", p);
fprintf_filtered (outfile, " Full symbol table %s been read from %s\n",
p->readin ? "has" : "has not yet",
p->symfile_name);
fprintf (outfile, " Read from object file %s (0x%x)\n", p->objfile->name,
p->objfile);
if (p->readin)
fprintf_filtered (outfile, " Was read into symtab at 0x%x by function at 0x%x\n",
fprintf_filtered (outfile, " Full symtab was read (at 0x%x by function at 0x%x)\n",
p->symtab, p->read_symtab);
fprintf_filtered (outfile, " Relocate symbols by 0x%x\n", p->addr);
fprintf_filtered (outfile, " Symbols cover text addresses 0x%x-0x%x\n",
@ -381,8 +370,6 @@ int count;
char *what;
FILE *outfile;
{
char *space;
char *class;
fprintf_filtered (outfile, " %s partial symbols:\n", what);
while (count-- > 0)
@ -468,26 +455,131 @@ block_depth (block)
return i;
}
/*
* Free all partial_symtab storage.
*/
void
free_all_psymtabs()
static void
printobjfiles_command ()
{
obstack_free (psymbol_obstack, 0);
obstack_init (psymbol_obstack);
partial_symtab_list = (struct partial_symtab *) 0;
struct objfile *objfile;
struct symtab *symtab;
struct partial_symtab *psymtab;
int first;
for (objfile = object_files; objfile; objfile = objfile->next) {
printf_filtered ("\nObject file %s: ", objfile->name);
printf_filtered ("Objfile at %x, bfd at %x\n\n", objfile, objfile->obfd);
if (objfile->psymtabs) {
printf_filtered ("Psymtabs:\n");
for (psymtab = objfile->psymtabs;
psymtab;
psymtab = psymtab->objfile_chain) {
printf_filtered ("%s at %x, ", psymtab->filename, psymtab);
if (psymtab->objfile != objfile)
printf_filtered ("NOT ON CHAIN! ");
wrap_here (" ");
}
printf_filtered ("\n\n");
}
if (objfile->symtabs) {
printf_filtered ("Symtabs:\n");
for (symtab = objfile->symtabs;
symtab;
symtab = symtab->objfile_chain) {
printf_filtered ("%s at %x, ", symtab->filename, symtab);
if (symtab->objfile != objfile)
printf_filtered ("NOT ON CHAIN! ");
wrap_here (" ");
}
printf_filtered ("\n\n");
}
}
/* Now check for psymtabs that aren't owned by an objfile. */
first = 1;
for (psymtab = partial_symtab_list; psymtab; psymtab = psymtab->next) {
for (objfile = object_files; objfile; objfile = objfile->next) {
if (psymtab->objfile == objfile)
goto next;
}
if (first)
printf_filtered ("Psymtabs that aren't owned by any objfile:\n");
first = 0;
printf_filtered (" %s at %x, psymtab->objfile %x\n", psymtab->filename,
psymtab, psymtab->objfile);
next: ;
}
/* Now check for symtabs that aren't owned by an objfile. */
first = 1;
for (symtab = symtab_list; symtab; symtab = symtab->next) {
for (objfile = object_files; objfile; objfile = objfile->next) {
if (symtab->objfile == objfile)
goto next2;
}
if (first)
printf_filtered ("Symtabs that aren't owned by any objfile:\n");
first = 0;
printf_filtered (" %s at %x, symtab->objfile %x\n", symtab->filename,
symtab, symtab->objfile);
next2: ;
}
}
struct cplus_struct_type cplus_struct_default;
void
allocate_cplus_struct_type (type)
struct type *type;
{
if (!HAVE_CPLUS_STRUCT (type))
{
int nfields = TYPE_NFIELDS (type);
TYPE_CPLUS_SPECIFIC (type) = (struct cplus_struct_type *)
obstack_alloc (symbol_obstack, sizeof (struct cplus_struct_type));
*(TYPE_CPLUS_SPECIFIC(type)) = cplus_struct_default;
}
}
/* Increase the space allocated for LISTP. */
void
extend_psymbol_list(listp)
register struct psymbol_allocation_list *listp;
{
int new_size;
if (listp->size == 0)
{
new_size = 255;
listp->list = (struct partial_symbol *)
xmalloc (new_size * sizeof (struct partial_symbol));
}
else
{
new_size = listp->size * 2;
listp->list = (struct partial_symbol *)
xrealloc (listp->list, new_size * sizeof (struct partial_symbol));
}
/* Next assumes we only went one over. Should be good if
program works correctly */
listp->next = listp->list + listp->size;
listp->size = new_size;
}
void
_initialize_symmisc ()
{
symtab_list = (struct symtab *) 0;
partial_symtab_list = (struct partial_symtab *) 0;
add_com ("printsyms", class_obscure, print_symtabs,
"Print dump of current symbol definitions to file OUTFILE.");
add_com ("printpsyms", class_obscure, print_partial_symtabs,
"Print dump of current partial symbol definitions to file OUTFILE.");
add_com ("printsyms", class_obscure, printsyms_command,
"Print dump of current symbol definitions to file OUTFILE.\n\
If a SOURCE file is specified, dump only that file's symbols.");
add_com ("printpsyms", class_obscure, printpsyms_command,
"Print dump of current partial symbol definitions to file OUTFILE.\n\
If a SOURCE file is specified, dump only that file's partial symbols.");
add_com ("printobjfiles", class_obscure, printobjfiles_command,
"Print dump of current object file definitions.");
}

View File

@ -218,7 +218,7 @@ check_stub_type(type)
sym = lookup_symbol (name, 0, STRUCT_NAMESPACE, 0,
(struct symtab **)NULL);
if (sym)
bcopy (SYMBOL_TYPE(sym), type, sizeof (struct type));
memcpy (type, SYMBOL_TYPE(sym), sizeof (struct type));
}
}
@ -636,6 +636,7 @@ check_stub_method (type, i, j)
TYPE_DOMAIN_TYPE (mtype) = type;
TYPE_ARG_TYPES (mtype) = argtypes;
TYPE_FLAGS (mtype) &= ~TYPE_FLAG_STUB;
TYPE_FN_FIELD_STUB (f, j) = 0;
}
/* Given a type TYPE, return a type of functions that return that type.
@ -1704,7 +1705,7 @@ operator_chars (p, end)
*/
int
find_methods(t, name, physnames, sym_arr)
find_methods (t, name, physnames, sym_arr)
struct type *t;
char *name;
char **physnames;
@ -1756,7 +1757,7 @@ find_methods(t, name, physnames, sym_arr)
--field_counter)
{
char *phys_name;
if (TYPE_FLAGS (TYPE_FN_FIELD_TYPE (f, field_counter)) & TYPE_FLAG_STUB)
if (TYPE_FN_FIELD_STUB (f, field_counter))
check_stub_method (t, method_counter, field_counter);
phys_name = TYPE_FN_FIELD_PHYSNAME (f, field_counter);
physnames[i1] = (char*) alloca (strlen (phys_name) + 1);
@ -2685,12 +2686,7 @@ init_type (code, length, uns, name)
/* C++ fancies. */
if (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION)
{
TYPE_CPLUS_SPECIFIC (type)
= (struct cplus_struct_type *) xmalloc (sizeof (struct cplus_struct_type));
TYPE_NFN_FIELDS (type) = 0;
TYPE_N_BASECLASSES (type) = 0;
}
TYPE_CPLUS_SPECIFIC(type) = &cplus_struct_default;
return type;
}

View File

@ -197,7 +197,7 @@ struct type
/* Slot to point to additional language-specific fields of this type. */
union type_specific
{
/* ARG_TYPES is for TYPE_CODE_METHOD and TYPE_CODE_FUNCTION. */
/* ARG_TYPES is for TYPE_CODE_METHOD and TYPE_CODE_FUNC. */
struct type **arg_types;
/* CPLUS_STUFF is for TYPE_CODE_STRUCT. */
struct cplus_struct_type *cplus_stuff;
@ -262,6 +262,16 @@ struct cplus_struct_type
unsigned char via_protected;
unsigned char via_public;
};
/* The default value of TYPE_CPLUS_SPECIFIC(T) points to the
this shared static structure. */
extern struct cplus_struct_type cplus_struct_default;
extern void allocate_cplus_struct_type ();
#define ALLOCATE_CPLUS_STRUCT_TYPE(type) allocate_cplus_struct_type (type)
#define HAVE_CPLUS_STRUCT(type) \
(TYPE_CPLUS_SPECIFIC(type) != &cplus_struct_default)
/* All of the name-scope contours of the program
are represented by `struct block' objects.
@ -710,9 +720,11 @@ int current_source_line;
#define SET_TYPE_FIELD_VIRTUAL(thistype, n) \
B_SET (TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (n))
#define TYPE_FIELD_PRIVATE(thistype, n) \
B_TST(TYPE_CPLUS_SPECIFIC(thistype)->private_field_bits, (n))
(TYPE_CPLUS_SPECIFIC(thistype)->private_field_bits == NULL ? 0 \
: B_TST(TYPE_CPLUS_SPECIFIC(thistype)->private_field_bits, (n)))
#define TYPE_FIELD_PROTECTED(thistype, n) \
B_TST(TYPE_CPLUS_SPECIFIC(thistype)->protected_field_bits, (n))
(TYPE_CPLUS_SPECIFIC(thistype)->protected_field_bits == NULL ? 0 \
: B_TST(TYPE_CPLUS_SPECIFIC(thistype)->protected_field_bits, (n)))
#define TYPE_FIELD_VIRTUAL(thistype, n) \
B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (n))

View File

@ -31,6 +31,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/*#define NAMES_HAVE_UNDERSCORE*/
/* Address of blocks in N_LBRAC and N_RBRAC symbols are absolute addresses,
not relative to start of source address. */
#define BLOCK_ADDRESS_ABSOLUTE
/* Debugger information will be in mips' format */
#define READ_MIPS_FORMAT