* dbxread.c, buildsym.c, symtab.c, stabsread.c: Add support for

reading stabs extensions for live range information.
	* stabsread.h, partial-stab.h: Add prototypes for new functions.
	* symtab.h: Add structure for storing live range information.
This commit is contained in:
Dawn Perchik 1997-09-08 00:38:19 +00:00
parent 60b570d17a
commit d719efc6d5
8 changed files with 750 additions and 201 deletions

View File

@ -1,3 +1,10 @@
Sun Sep 7 17:26:30 1997 Dawn Perchik <dawn@cygnus.com>
* dbxread.c, buildsym.c, symtab.c, stabsread.c: Add support for
reading stabs extensions for live range information.
* stabsread.h, partial-stab.h: Add prototypes for new functions.
* symtab.h: Add structure for storing live range information.
Wed Sep 3 16:39:39 1997 Andrew Cagney <cagney@b1.cygnus.com>
* top.c (set_arch): New function, update target_architecture.

View File

@ -95,6 +95,11 @@ add_symbol_to_list (symbol, listhead)
struct pending **listhead;
{
register struct pending *link;
/* If this is a reference to/live alias for another symbol, don't add it.
We don't want to be able to look up the live references directly. */
if (symbol->ginfo.name && symbol->ginfo.name[0] == '#')
return;
/* We keep PENDINGSIZE symbols in each link of the list.
If we don't have a link with room in it, add a new link. */

View File

@ -182,6 +182,9 @@ struct complaint lbrac_mismatch_complaint =
struct complaint repeated_header_complaint =
{"\"repeated\" header file %s not previously seen, at symtab pos %d", 0, 0};
struct complaint unclaimed_bincl_complaint =
{"N_BINCL %s not in entries for any file, at symtab pos %d", 0, 0};
/* During initial symbol readin, we need to have a structure to keep
track of which psymtabs have which bincls in them. This structure
@ -770,6 +773,7 @@ struct cont_elem
int sym_idx;
int sym_end;
int symnum;
int (*func) (struct objfile *, struct symbol *, char *);
/* other state dependancies include:
(assumption is that these will not change since process_now FIXME!!)
stringtab_global
@ -777,25 +781,37 @@ struct cont_elem
objfile
symfile_bfd */
};
static struct cont_elem cont_list[100];
static struct cont_elem *cont_list = 0;
static int cont_limit = 0;
static int cont_count = 0;
void
process_later(sym,p)
process_later (sym, p, f)
struct symbol * sym;
char * p;
int (*f) (struct objfile *, struct symbol *, char *);
{
if (cont_count >= cont_limit - 1)
{
cont_limit += 32; /* chunk size */
cont_list = (struct cont_elem *) realloc (cont_list,
cont_limit * sizeof (struct cont_elem));
if (!cont_list)
error ("Virtual memory exhausted\n");
}
/* save state so we can process these stabs later */
cont_list[cont_count].sym_idx = symbuf_idx;
cont_list[cont_count].sym_end = symbuf_end;
cont_list[cont_count].symnum = symnum;
cont_list[cont_count].sym = sym;
cont_list[cont_count].stabs = p;
cont_list[cont_count].func = f;
cont_count++;
}
static void
process_now(objfile)
process_now (objfile)
struct objfile * objfile;
{
int i;
@ -803,14 +819,25 @@ process_now(objfile)
int save_symbuf_idx = symbuf_idx;
int save_symbuf_end = symbuf_end;
int save_symnum = symnum;
struct symbol *sym;
char *stabs;
int err;
int (*func) (struct objfile *, struct symbol *, char *);
for (i=0; i<cont_count; i++)
{
/* set state as if we were parsing stabs strings
/* Set state as if we were parsing stabs strings
for this symbol */
symbuf_idx = cont_list[i].sym_idx; /* statics used by gdb */
symbuf_end = cont_list[i].sym_end;
symnum = cont_list[i].symnum;
resolve_cfront_continuation(objfile,cont_list[i].sym,cont_list[i].stabs);
sym = cont_list[i].sym;
stabs = cont_list[i].stabs;
func = cont_list[i].func;
err = (*func) (objfile, sym, stabs);
if (err)
error ("Internal error: unable to resolve stab.\n");
}
/* restore original state */
symbuf_idx = save_symbuf_idx;
@ -956,8 +983,6 @@ add_bincl_to_list (pst, name, instance)
bincl_list = (struct header_file_location *)
xmrealloc (pst->objfile->md, (char *)bincl_list,
bincls_allocated * sizeof (struct header_file_location));
if (bincl_list == NULL)
fatal ("virtual memory exhausted in add_bincl_to_list ();");
next_bincl = bincl_list + offset;
}
next_bincl->pst = pst;
@ -1782,8 +1807,9 @@ read_ofile_symtab (pst)
pst->symtab = end_symtab (text_offset + text_size, objfile, SECT_OFF_TEXT);
if (ARM_DEMANGLING) /* process incomplete C++ types now */
process_now(objfile);
/* Process items which we had to "process_later" due to dependancies
on other stabs. */
process_now (objfile);
end_stabs ();
}
@ -2337,6 +2363,29 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
break;
}
/* Special GNU C extension for referencing names. */
if (name[0] == '#')
{
/* Initialize symbol reference names and determine if this is
a definition. If symbol reference is being defined, go
ahead and add it. Otherwise, just return sym. */
char *s;
int refnum;
extern int symbol_reference_defined (char **);
extern void ref_add (int, struct symbol *, char *, CORE_ADDR);
extern struct symbol * ref_search (int);
/* If defined, store away a pointer to the symbol;
we'll use it later when we resolve references in
"resolve_symbol_reference". */
s = name;
if (refnum = symbol_reference_defined (&s), refnum)
if (!ref_search (refnum))
ref_add (refnum, 0, name, valu);
name = s; /* Advance past refid. */
}
previous_stab_code = type;
}

View File

@ -666,6 +666,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
case '8':
case '9':
case '-':
case '#': /* for symbol identification (used in live ranges) */
/* added to support cfront stabs strings */
case 'Z': /* for definition continuations */
case 'P': /* for prototypes */

File diff suppressed because it is too large Load Diff

View File

@ -168,7 +168,7 @@ end_stabs PARAMS ((void));
extern void
finish_global_stabs PARAMS ((struct objfile *objfile));
extern void
extern int
resolve_cfront_continuation PARAMS((struct objfile * objfile,
struct symbol * sym, char * p));
@ -236,6 +236,7 @@ extern void stabsect_build_psymtabs
extern void elfstab_offset_sections PARAMS ((struct objfile *,
struct partial_symtab *));
extern void process_later PARAMS ((struct symbol *, char *));
extern void process_later PARAMS ((struct symbol *, char *,
int (*f) (struct objfile *, struct symbol *, char *)));
#undef EXTERN

View File

@ -912,6 +912,7 @@ lookup_block_symbol (block, name, namespace)
const char *name;
const namespace_enum namespace;
{
extern struct symbol *ref_search_val (struct symbol *sym, CORE_ADDR addr);
register int bot, top, inc;
register struct symbol *sym;
register struct symbol *sym_found = NULL;
@ -1017,6 +1018,10 @@ lookup_block_symbol (block, name, namespace)
if (SYMBOL_NAMESPACE (sym) == namespace &&
SYMBOL_MATCHES_NAME (sym, name))
{
/* Given pc, search thu alias list to find the active symbol. */
if (SYMBOL_ALIASES (sym))
sym = ref_search_val (sym, read_pc ());
sym_found = sym;
if (SYMBOL_CLASS (sym) != LOC_ARG &&
SYMBOL_CLASS (sym) != LOC_LOCAL_ARG &&
@ -2080,15 +2085,25 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line, canonical)
}
if (p[0] == ':' || p[0] == ' ' || p[0] == '\t')
break;
if (p[0] == '.' && strchr (p, ':') == NULL) /* Java qualified method. */
{
/* Find the *last* '.', since the others are package qualifiers. */
for (p1 = p; *p1; p1++)
{
if (*p1 == '.')
p = p1;
}
break;
}
}
while (p[0] == ' ' || p[0] == '\t') p++;
if ((p[0] == ':') && !has_parens)
if ((p[0] == ':' || p[0] == '.') && !has_parens)
{
/* C++ */
/* C++ or Java */
if (is_quoted) *argptr = *argptr+1;
if (p[1] ==':')
if (p[0] == '.' || p[1] ==':')
{
/* Extract the class name. */
p1 = p;
@ -2098,7 +2113,7 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line, canonical)
copy[p - *argptr] = 0;
/* Discard the class name from the arg. */
p = p1 + 2;
p = p1 + (p1[0] == ':' ? 2 : 1);
while (*p == ' ' || *p == '\t') p++;
*argptr = p;

View File

@ -84,7 +84,7 @@ struct general_symbol_info
union
{
struct cplus_specific /* For C++ */
struct cplus_specific /* For C++ and Java */
{
char *demangled_name;
} cplus_specific;
@ -135,7 +135,8 @@ extern CORE_ADDR symbol_overlayed_address PARAMS((CORE_ADDR, asection *));
#define SYMBOL_INIT_LANGUAGE_SPECIFIC(symbol,language) \
do { \
SYMBOL_LANGUAGE (symbol) = language; \
if (SYMBOL_LANGUAGE (symbol) == language_cplus) \
if (SYMBOL_LANGUAGE (symbol) == language_cplus \
|| SYMBOL_LANGUAGE (symbol) == language_java) \
{ \
SYMBOL_CPLUS_DEMANGLED_NAME (symbol) = NULL; \
} \
@ -179,6 +180,23 @@ extern CORE_ADDR symbol_overlayed_address PARAMS((CORE_ADDR, asection *));
SYMBOL_CPLUS_DEMANGLED_NAME (symbol) = NULL; \
} \
} \
if (SYMBOL_LANGUAGE (symbol) == language_java) \
{ \
demangled = \
cplus_demangle (SYMBOL_NAME (symbol), \
DMGL_PARAMS | DMGL_ANSI | DMGL_JAVA); \
if (demangled != NULL) \
{ \
SYMBOL_LANGUAGE (symbol) = language_java; \
SYMBOL_CPLUS_DEMANGLED_NAME (symbol) = \
obsavestring (demangled, strlen (demangled), (obstack)); \
free (demangled); \
} \
else \
{ \
SYMBOL_CPLUS_DEMANGLED_NAME (symbol) = NULL; \
} \
} \
if (demangled == NULL \
&& (SYMBOL_LANGUAGE (symbol) == language_chill \
|| SYMBOL_LANGUAGE (symbol) == language_auto)) \
@ -208,6 +226,7 @@ extern CORE_ADDR symbol_overlayed_address PARAMS((CORE_ADDR, asection *));
#define SYMBOL_DEMANGLED_NAME(symbol) \
(SYMBOL_LANGUAGE (symbol) == language_cplus \
|| SYMBOL_LANGUAGE (symbol) == language_java \
? SYMBOL_CPLUS_DEMANGLED_NAME (symbol) \
: (SYMBOL_LANGUAGE (symbol) == language_chill \
? SYMBOL_CHILL_DEMANGLED_NAME (symbol) \
@ -584,6 +603,15 @@ enum address_class
LOC_OPTIMIZED_OUT
};
/* Linked list of symbol's live ranges. */
struct live_range
{
CORE_ADDR start;
CORE_ADDR end;
struct live_range *next;
};
struct symbol
{
@ -623,6 +651,23 @@ struct symbol
short basereg;
}
aux_value;
/* Live range information (if present) for debugging of optimized code.
Gcc extensions were added to stabs to encode live range information.
The syntax for referencing (defining) symbol aliases is "#n" ("#n=")
where n is a number. The syntax for specifying a range is "l(#<m>,#<n>)",
where m and n are numbers.
aliases - list of other symbols which are lexically the same symbol,
but were optimized into different storage classes (eg. for the
local symbol "x", one symbol contains range information where x
is on the stack, while an alias contains the live ranges where x
is in a register).
range - list of instruction ranges where the symbol is live. */
struct live_range_info
{
struct symbol *aliases; /* Link to other aliases for this symbol. */
struct live_range *range; /* Linked list of live ranges. */
} live;
};
#define SYMBOL_NAMESPACE(symbol) (symbol)->namespace
@ -630,6 +675,11 @@ struct symbol
#define SYMBOL_TYPE(symbol) (symbol)->type
#define SYMBOL_LINE(symbol) (symbol)->line
#define SYMBOL_BASEREG(symbol) (symbol)->aux_value.basereg
#define SYMBOL_ALIASES(symbol) (symbol)->live.aliases
#define SYMBOL_RANGE(symbol) (symbol)->live.range
#define SYMBOL_RANGE_START(symbol) (symbol)->live.range->start
#define SYMBOL_RANGE_END(symbol) (symbol)->live.range->end
#define SYMBOL_RANGE_NEXT(symbol) (symbol)->live.range->next
/* A partial_symbol records the name, namespace, and address class of
symbols whose types we have not parsed yet. For functions, it also