#include "defs.h"
#include "symtab.h"
#include "gdbtypes.h"
#include "gdbcore.h"
#include "objfiles.h"
#include "gdb_obstack.h"
#include "buildsym.h"
#include "stabsread.h"
#include "complaints.h"
#include "demangle.h"
#include "gdb_assert.h"
#include "block.h"
#include "dictionary.h"
#include "mdebugread.h"
#include "gdb_stat.h"
#include "gdb_string.h"
#include "bfd.h"
#include "coff/ecoff.h"
#include "libaout.h"
#include "aout/aout64.h"
#include "aout/stab_gnu.h"
#include "expression.h"
extern void _initialize_mdebugread (void);
#define ECOFF_IN_ELF(bfd) (bfd_get_flavour (bfd) == bfd_target_elf_flavour \
&& bfd_get_section_by_name (bfd, ".mdebug") != NULL)
struct symloc
{
int fdr_idx;
bfd *cur_bfd;
const struct ecoff_debug_swap *debug_swap;
struct ecoff_debug_info *debug_info;
struct mdebug_pending **pending_list;
EXTR *extern_tab;
int extern_count;
enum language pst_language;
};
#define PST_PRIVATE(p) ((struct symloc *)(p)->read_symtab_private)
#define FDR_IDX(p) (PST_PRIVATE(p)->fdr_idx)
#define CUR_BFD(p) (PST_PRIVATE(p)->cur_bfd)
#define DEBUG_SWAP(p) (PST_PRIVATE(p)->debug_swap)
#define DEBUG_INFO(p) (PST_PRIVATE(p)->debug_info)
#define PENDING_LIST(p) (PST_PRIVATE(p)->pending_list)
#define SC_IS_TEXT(sc) ((sc) == scText \
|| (sc) == scRConst \
|| (sc) == scInit \
|| (sc) == scFini)
#define SC_IS_DATA(sc) ((sc) == scData \
|| (sc) == scSData \
|| (sc) == scRData \
|| (sc) == scPData \
|| (sc) == scXData)
#define SC_IS_COMMON(sc) ((sc) == scCommon || (sc) == scSCommon)
#define SC_IS_BSS(sc) ((sc) == scBss)
#define SC_IS_SBSS(sc) ((sc) == scSBss)
#define SC_IS_UNDEF(sc) ((sc) == scUndefined || (sc) == scSUndefined)
static void
index_complaint (const char *arg1)
{
complaint (&symfile_complaints, _("bad aux index at symbol %s"), arg1);
}
static void
unknown_ext_complaint (const char *arg1)
{
complaint (&symfile_complaints, _("unknown external symbol %s"), arg1);
}
static void
basic_type_complaint (int arg1, const char *arg2)
{
complaint (&symfile_complaints, _("cannot map ECOFF basic type 0x%x for %s"),
arg1, arg2);
}
static void
bad_tag_guess_complaint (const char *arg1)
{
complaint (&symfile_complaints, _("guessed tag type of %s incorrectly"), arg1);
}
static void
bad_rfd_entry_complaint (const char *arg1, int arg2, int arg3)
{
complaint (&symfile_complaints, _("bad rfd entry for %s: file %d, index %d"),
arg1, arg2, arg3);
}
static void
unexpected_type_code_complaint (const char *arg1)
{
complaint (&symfile_complaints, _("unexpected type code for %s"), arg1);
}
#define MIN_GLEVEL GLEVEL_0
#define compare_glevel(a,b) \
(((a) == GLEVEL_3) ? ((b) < GLEVEL_3) : \
((b) == GLEVEL_3) ? -1 : (int)((b) - (a)))
static enum language psymtab_language = language_unknown;
static bfd *cur_bfd;
static const struct ecoff_debug_swap *debug_swap;
static struct ecoff_debug_info *debug_info;
static FDR *cur_fdr;
static int cur_fd;
static int cur_sdx;
static int max_gdbinfo;
static int max_glevel;
static int n_undef_symbols, n_undef_labels, n_undef_vars, n_undef_procs;
static char stabs_symbol[] = STABS_SYMBOL;
static struct type *mdebug_type_void;
static struct type *mdebug_type_char;
static struct type *mdebug_type_short;
static struct type *mdebug_type_int_32;
#define mdebug_type_int mdebug_type_int_32
static struct type *mdebug_type_int_64;
static struct type *mdebug_type_long_32;
static struct type *mdebug_type_long_64;
static struct type *mdebug_type_long_long_64;
static struct type *mdebug_type_unsigned_char;
static struct type *mdebug_type_unsigned_short;
static struct type *mdebug_type_unsigned_int_32;
static struct type *mdebug_type_unsigned_int_64;
static struct type *mdebug_type_unsigned_long_32;
static struct type *mdebug_type_unsigned_long_64;
static struct type *mdebug_type_unsigned_long_long_64;
static struct type *mdebug_type_adr_32;
static struct type *mdebug_type_adr_64;
static struct type *mdebug_type_float;
static struct type *mdebug_type_double;
static struct type *mdebug_type_complex;
static struct type *mdebug_type_double_complex;
static struct type *mdebug_type_fixed_dec;
static struct type *mdebug_type_float_dec;
static struct type *mdebug_type_string;
static struct type *nodebug_func_symbol_type;
static struct type *nodebug_var_symbol_type;
static int found_ecoff_debugging_info;
static int upgrade_type (int, struct type **, int, union aux_ext *,
int, char *);
static void parse_partial_symbols (struct objfile *);
static int has_opaque_xref (FDR *, SYMR *);
static int cross_ref (int, union aux_ext *, struct type **, enum type_code,
char **, int, char *);
static struct symbol *new_symbol (char *);
static struct type *new_type (char *);
enum block_type { FUNCTION_BLOCK, NON_FUNCTION_BLOCK };
static struct block *new_block (enum block_type);
static struct symtab *new_symtab (char *, int, struct objfile *);
static struct linetable *new_linetable (int);
static struct blockvector *new_bvect (int);
static struct type *parse_type (int, union aux_ext *, unsigned int, int *,
int, char *);
static struct symbol *mylookup_symbol (char *, struct block *, domain_enum,
enum address_class);
static void sort_blocks (struct symtab *);
static struct partial_symtab *new_psymtab (char *, struct objfile *);
static void psymtab_to_symtab_1 (struct partial_symtab *, char *);
static void add_block (struct block *, struct symtab *);
static void add_symbol (struct symbol *, struct block *);
static int add_line (struct linetable *, int, CORE_ADDR, int);
static struct linetable *shrink_linetable (struct linetable *);
static void handle_psymbol_enumerators (struct objfile *, FDR *, int,
CORE_ADDR);
static char *mdebug_next_symbol_text (struct objfile *);
static void
mdebug_psymtab_to_symtab (struct partial_symtab *pst)
{
if (!pst)
return;
if (info_verbose)
{
printf_filtered (_("Reading in symbols for %s..."), pst->filename);
gdb_flush (gdb_stdout);
}
next_symbol_text_func = mdebug_next_symbol_text;
psymtab_to_symtab_1 (pst, pst->filename);
scan_file_globals (pst->objfile);
if (info_verbose)
printf_filtered (_("done.\n"));
}
static FDR *
get_rfd (int cf, int rf)
{
FDR *fdrs;
FDR *f;
RFDT rfd;
fdrs = debug_info->fdr;
f = fdrs + cf;
if (f->rfdBase == 0)
return fdrs + rf;
(*debug_swap->swap_rfd_in) (cur_bfd,
((char *) debug_info->external_rfd
+ ((f->rfdBase + rf)
* debug_swap->external_rfd_size)),
&rfd);
return fdrs + rfd;
}
static char *
fdr_name (FDR *f)
{
if (f->rss == -1)
return "<stripped file>";
if (f->rss == 0)
return "<NFY>";
return debug_info->ss + f->issBase + f->rss;
}
void
mdebug_build_psymtabs (struct objfile *objfile,
const struct ecoff_debug_swap *swap,
struct ecoff_debug_info *info)
{
cur_bfd = objfile->obfd;
debug_swap = swap;
debug_info = info;
stabsread_new_init ();
buildsym_new_init ();
free_header_files ();
init_header_files ();
if (info->fdr == (FDR *) NULL)
{
char *fdr_src;
char *fdr_end;
FDR *fdr_ptr;
info->fdr = (FDR *) obstack_alloc (&objfile->objfile_obstack,
(info->symbolic_header.ifdMax
* sizeof (FDR)));
fdr_src = info->external_fdr;
fdr_end = (fdr_src
+ info->symbolic_header.ifdMax * swap->external_fdr_size);
fdr_ptr = info->fdr;
for (; fdr_src < fdr_end; fdr_src += swap->external_fdr_size, fdr_ptr++)
(*swap->swap_fdr_in) (objfile->obfd, fdr_src, fdr_ptr);
}
parse_partial_symbols (objfile);
#if 0
if (compare_glevel (max_glevel, GLEVEL_2) < 0)
{
if (max_gdbinfo == 0)
printf_unfiltered (_("\n%s not compiled with -g, debugging support is limited.\n"),
objfile->name);
printf_unfiltered (_("You should compile with -g2 or -g3 for best debugging support.\n"));
gdb_flush (gdb_stdout);
}
#endif
}
struct pst_map
{
struct partial_symtab *pst;
long n_globals;
long globals_offset;
};
static struct parse_stack
{
struct parse_stack *next, *prev;
struct symtab *cur_st;
struct block *cur_block;
int blocktype;
struct type *cur_type;
int cur_field;
CORE_ADDR procadr;
int numargs;
}
*top_stack;
static void
push_parse_stack (void)
{
struct parse_stack *new;
if (top_stack && top_stack->prev)
new = top_stack->prev;
else
new = (struct parse_stack *) xzalloc (sizeof (struct parse_stack));
if (top_stack)
{
struct parse_stack *prev = new->prev;
*new = *top_stack;
top_stack->prev = new;
new->prev = prev;
new->next = top_stack;
}
top_stack = new;
}
static void
pop_parse_stack (void)
{
if (!top_stack)
return;
if (top_stack->next)
top_stack = top_stack->next;
}
struct mdebug_pending
{
struct mdebug_pending *next;
char *s;
struct type *t;
};
static struct mdebug_pending **pending_list;
static struct mdebug_pending *
is_pending_symbol (FDR *fh, char *sh)
{
int f_idx = fh - debug_info->fdr;
struct mdebug_pending *p;
for (p = pending_list[f_idx]; p; p = p->next)
if (p->s == sh)
break;
return p;
}
static void
add_pending (FDR *fh, char *sh, struct type *t)
{
int f_idx = fh - debug_info->fdr;
struct mdebug_pending *p = is_pending_symbol (fh, sh);
if (!p)
{
p = ((struct mdebug_pending *)
obstack_alloc (¤t_objfile->objfile_obstack,
sizeof (struct mdebug_pending)));
p->s = sh;
p->t = t;
p->next = pending_list[f_idx];
pending_list[f_idx] = p;
}
}
static int
parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
struct section_offsets *section_offsets, struct objfile *objfile)
{
const bfd_size_type external_sym_size = debug_swap->external_sym_size;
void (*const swap_sym_in) (bfd *, void *, SYMR *) = debug_swap->swap_sym_in;
char *name;
struct symbol *s;
struct block *b;
struct mdebug_pending *pend;
struct type *t;
struct field *f;
int count = 1;
enum address_class class;
TIR tir;
long svalue = sh->value;
int bitsize;
if (ext_sh == (char *) NULL)
name = debug_info->ssext + sh->iss;
else
name = debug_info->ss + cur_fdr->issBase + sh->iss;
switch (sh->sc)
{
case scText:
case scRConst:
if (sh->st != stEnd && sh->st != stBlock)
sh->value += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
break;
case scData:
case scSData:
case scRData:
case scPData:
case scXData:
sh->value += ANOFFSET (section_offsets, SECT_OFF_DATA (objfile));
break;
case scBss:
case scSBss:
sh->value += ANOFFSET (section_offsets, SECT_OFF_BSS (objfile));
break;
}
switch (sh->st)
{
case stNil:
break;
case stGlobal:
class = LOC_STATIC;
b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (top_stack->cur_st),
GLOBAL_BLOCK);
s = new_symbol (name);
SYMBOL_VALUE_ADDRESS (s) = (CORE_ADDR) sh->value;
goto data;
case stStatic:
class = LOC_STATIC;
b = top_stack->cur_block;
s = new_symbol (name);
if (SC_IS_COMMON (sh->sc))
{
int bucket = hashname (DEPRECATED_SYMBOL_NAME (s));
SYMBOL_VALUE_CHAIN (s) = global_sym_chain[bucket];
global_sym_chain[bucket] = s;
}
else
SYMBOL_VALUE_ADDRESS (s) = (CORE_ADDR) sh->value;
goto data;
case stLocal:
if (sh->sc == scRegister)
{
class = LOC_REGISTER;
svalue = ECOFF_REG_TO_REGNUM (svalue);
}
else
class = LOC_LOCAL;
b = top_stack->cur_block;
s = new_symbol (name);
SYMBOL_VALUE (s) = svalue;
data:
SYMBOL_DOMAIN (s) = VAR_DOMAIN;
SYMBOL_CLASS (s) = class;
add_symbol (s, b);
if (SC_IS_UNDEF (sh->sc)
|| sh->sc == scNil || sh->index == indexNil)
SYMBOL_TYPE (s) = nodebug_var_symbol_type;
else
SYMBOL_TYPE (s) = parse_type (cur_fd, ax, sh->index, 0, bigend, name);
break;
case stParam:
max_gdbinfo++;
found_ecoff_debugging_info = 1;
top_stack->numargs++;
if (is_cplus_marker (name[0]) && name[1] == 't' && name[2] == 0)
name = "this";
s = new_symbol (name);
SYMBOL_DOMAIN (s) = VAR_DOMAIN;
switch (sh->sc)
{
case scRegister:
SYMBOL_CLASS (s) = LOC_REGPARM;
svalue = ECOFF_REG_TO_REGNUM (svalue);
break;
case scVar:
SYMBOL_CLASS (s) = LOC_REF_ARG;
break;
case scVarRegister:
SYMBOL_CLASS (s) = LOC_REGPARM_ADDR;
svalue = ECOFF_REG_TO_REGNUM (svalue);
break;
default:
SYMBOL_CLASS (s) = LOC_ARG;
break;
}
SYMBOL_VALUE (s) = svalue;
SYMBOL_TYPE (s) = parse_type (cur_fd, ax, sh->index, 0, bigend, name);
add_symbol (s, top_stack->cur_block);
break;
case stLabel:
s = new_symbol (name);
SYMBOL_DOMAIN (s) = VAR_DOMAIN;
SYMBOL_CLASS (s) = LOC_LABEL;
SYMBOL_VALUE_ADDRESS (s) = (CORE_ADDR) sh->value;
SYMBOL_TYPE (s) = mdebug_type_int;
add_symbol (s, top_stack->cur_block);
break;
case stProc:
case stStaticProc:
if (sh->st == stProc && sh->sc != scText)
{
char *ext_tsym = ext_sh;
int keep_counting = 1;
SYMR tsym;
while (keep_counting)
{
ext_tsym += external_sym_size;
(*swap_sym_in) (cur_bfd, ext_tsym, &tsym);
count++;
switch (tsym.st)
{
case stParam:
break;
case stEnd:
keep_counting = 0;
break;
default:
complaint (&symfile_complaints,
_("unknown symbol type 0x%x"), sh->st);
break;
}
}
break;
}
s = new_symbol (name);
SYMBOL_DOMAIN (s) = VAR_DOMAIN;
SYMBOL_CLASS (s) = LOC_BLOCK;
if (SC_IS_UNDEF (sh->sc) || sh->sc == scNil)
t = mdebug_type_int;
else
{
t = parse_type (cur_fd, ax, sh->index + 1, 0, bigend, name);
if (strcmp (name, "malloc") == 0
&& TYPE_CODE (t) == TYPE_CODE_VOID)
{
t = make_pointer_type (t, NULL);
}
}
b = top_stack->cur_block;
if (sh->st == stProc)
{
struct blockvector *bv = BLOCKVECTOR (top_stack->cur_st);
if (b == BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK))
b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
else if (sh->value == top_stack->procadr)
b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
}
add_symbol (s, b);
SYMBOL_TYPE (s) = lookup_function_type (t);
if (SYMBOL_LANGUAGE (s) == language_cplus)
TYPE_FLAGS (SYMBOL_TYPE (s)) |= TYPE_FLAG_PROTOTYPED;
b = new_block (FUNCTION_BLOCK);
SYMBOL_BLOCK_VALUE (s) = b;
BLOCK_FUNCTION (b) = s;
BLOCK_START (b) = BLOCK_END (b) = sh->value;
BLOCK_SUPERBLOCK (b) = top_stack->cur_block;
add_block (b, top_stack->cur_st);
if (SC_IS_UNDEF (sh->sc) || sh->sc == scNil)
break;
push_parse_stack ();
top_stack->cur_block = b;
top_stack->blocktype = sh->st;
top_stack->cur_type = SYMBOL_TYPE (s);
top_stack->cur_field = -1;
top_stack->procadr = sh->value;
top_stack->numargs = 0;
break;
{
enum type_code type_code;
char *ext_tsym;
int nfields;
long max_value;
struct field *f;
case stStruct:
type_code = TYPE_CODE_STRUCT;
goto structured_common;
case stUnion:
type_code = TYPE_CODE_UNION;
goto structured_common;
case stEnum:
type_code = TYPE_CODE_ENUM;
goto structured_common;
case stBlock:
if (sh->sc != scInfo && !SC_IS_COMMON (sh->sc))
goto case_stBlock_code;
type_code = TYPE_CODE_UNDEF;
structured_common:
found_ecoff_debugging_info = 1;
push_parse_stack ();
top_stack->blocktype = stBlock;
nfields = 0;
max_value = 0;
for (ext_tsym = ext_sh + external_sym_size;
;
ext_tsym += external_sym_size)
{
SYMR tsym;
(*swap_sym_in) (cur_bfd, ext_tsym, &tsym);
switch (tsym.st)
{
case stEnd:
if (tsym.iss == issNull
|| strcmp (debug_info->ss + cur_fdr->issBase + tsym.iss,
name) == 0)
goto end_of_fields;
break;
case stMember:
if (nfields == 0 && type_code == TYPE_CODE_UNDEF)
{
if (tsym.index == indexNil
|| (tsym.index == 0 && sh->value == 0))
type_code = TYPE_CODE_ENUM;
else
{
(*debug_swap->swap_tir_in) (bigend,
&ax[tsym.index].a_ti,
&tir);
if ((tir.bt == btNil || tir.bt == btVoid
|| (tir.bt == btEnum && sh->value == 0))
&& tir.tq0 == tqNil)
type_code = TYPE_CODE_ENUM;
}
}
nfields++;
if (tsym.value > max_value)
max_value = tsym.value;
break;
case stBlock:
case stUnion:
case stEnum:
case stStruct:
{
#if 0
if (tsym.sc == scVariant);
#endif
if (tsym.index != 0)
{
ext_tsym = ((char *) debug_info->external_sym
+ ((cur_fdr->isymBase + tsym.index - 1)
* external_sym_size));
}
}
break;
case stTypedef:
break;
case stIndirect:
break;
default:
complaint (&symfile_complaints,
_("declaration block contains unhandled symbol type %d"),
tsym.st);
}
}
end_of_fields:;
if (type_code == TYPE_CODE_UNDEF)
{
if (nfields > 1 && max_value == 0)
type_code = TYPE_CODE_UNION;
else
type_code = TYPE_CODE_STRUCT;
}
pend = is_pending_symbol (cur_fdr, ext_sh);
if (pend == (struct mdebug_pending *) NULL)
{
t = new_type (NULL);
add_pending (cur_fdr, ext_sh, t);
}
else
t = pend->t;
if (sh->iss == 0 || name[0] == '.' || name[0] == '\0')
TYPE_TAG_NAME (t) = NULL;
else
TYPE_TAG_NAME (t) = obconcat (¤t_objfile->objfile_obstack,
"", "", name);
TYPE_CODE (t) = type_code;
TYPE_LENGTH (t) = sh->value;
TYPE_NFIELDS (t) = nfields;
TYPE_FIELDS (t) = f = ((struct field *)
TYPE_ALLOC (t,
nfields * sizeof (struct field)));
if (type_code == TYPE_CODE_ENUM)
{
int unsigned_enum = 1;
if (TYPE_LENGTH (t) == TYPE_NFIELDS (t)
|| TYPE_LENGTH (t) == 0)
TYPE_LENGTH (t) = TARGET_INT_BIT / HOST_CHAR_BIT;
for (ext_tsym = ext_sh + external_sym_size;
;
ext_tsym += external_sym_size)
{
SYMR tsym;
struct symbol *enum_sym;
(*swap_sym_in) (cur_bfd, ext_tsym, &tsym);
if (tsym.st != stMember)
break;
FIELD_BITPOS (*f) = tsym.value;
FIELD_TYPE (*f) = t;
FIELD_NAME (*f) = debug_info->ss + cur_fdr->issBase + tsym.iss;
FIELD_BITSIZE (*f) = 0;
FIELD_STATIC_KIND (*f) = 0;
enum_sym = ((struct symbol *)
obstack_alloc (¤t_objfile->objfile_obstack,
sizeof (struct symbol)));
memset (enum_sym, 0, sizeof (struct symbol));
DEPRECATED_SYMBOL_NAME (enum_sym) =
obsavestring (f->name, strlen (f->name),
¤t_objfile->objfile_obstack);
SYMBOL_CLASS (enum_sym) = LOC_CONST;
SYMBOL_TYPE (enum_sym) = t;
SYMBOL_DOMAIN (enum_sym) = VAR_DOMAIN;
SYMBOL_VALUE (enum_sym) = tsym.value;
if (SYMBOL_VALUE (enum_sym) < 0)
unsigned_enum = 0;
add_symbol (enum_sym, top_stack->cur_block);
count++;
f++;
}
if (unsigned_enum)
TYPE_FLAGS (t) |= TYPE_FLAG_UNSIGNED;
}
top_stack->cur_type = t;
top_stack->cur_field = 0;
if (sh->iss == 0)
break;
if (TYPE_NFIELDS (t) == 0)
{
TYPE_FLAGS (t) |= TYPE_FLAG_STUB;
break;
}
s = new_symbol (name);
SYMBOL_DOMAIN (s) = STRUCT_DOMAIN;
SYMBOL_CLASS (s) = LOC_TYPEDEF;
SYMBOL_VALUE (s) = 0;
SYMBOL_TYPE (s) = t;
add_symbol (s, top_stack->cur_block);
break;
}
case_stBlock_code:
found_ecoff_debugging_info = 1;
push_parse_stack ();
if (top_stack->blocktype == stProc
|| top_stack->blocktype == stStaticProc)
{
top_stack->blocktype = stNil;
break;
}
top_stack->blocktype = stBlock;
b = new_block (NON_FUNCTION_BLOCK);
BLOCK_START (b) = sh->value + top_stack->procadr;
BLOCK_SUPERBLOCK (b) = top_stack->cur_block;
top_stack->cur_block = b;
add_block (b, top_stack->cur_st);
break;
case stEnd:
if (sh->sc == scInfo || SC_IS_COMMON (sh->sc))
{
top_stack->cur_type = 0;
}
else if (sh->sc == scText &&
(top_stack->blocktype == stProc ||
top_stack->blocktype == stStaticProc))
{
struct blockvector *bv = BLOCKVECTOR (top_stack->cur_st);
struct mdebug_extra_func_info *e;
struct block *b = top_stack->cur_block;
struct type *ftype = top_stack->cur_type;
int i;
BLOCK_END (top_stack->cur_block) += sh->value;
s = new_symbol (MDEBUG_EFI_SYMBOL_NAME);
SYMBOL_DOMAIN (s) = LABEL_DOMAIN;
SYMBOL_CLASS (s) = LOC_CONST;
SYMBOL_TYPE (s) = mdebug_type_void;
e = ((struct mdebug_extra_func_info *)
obstack_alloc (¤t_objfile->objfile_obstack,
sizeof (struct mdebug_extra_func_info)));
memset (e, 0, sizeof (struct mdebug_extra_func_info));
SYMBOL_VALUE (s) = (long) e;
e->numargs = top_stack->numargs;
e->pdr.framereg = -1;
add_symbol (s, top_stack->cur_block);
for (i = 0; i < BLOCKVECTOR_NBLOCKS (bv); i++)
{
struct block *b_bad = BLOCKVECTOR_BLOCK (bv, i);
if (BLOCK_SUPERBLOCK (b_bad) == b
&& BLOCK_START (b_bad) == top_stack->procadr
&& BLOCK_END (b_bad) == top_stack->procadr)
{
BLOCK_START (b_bad) = BLOCK_START (b);
BLOCK_END (b_bad) = BLOCK_END (b);
}
}
if (TYPE_NFIELDS (ftype) <= 0)
{
int nparams = top_stack->numargs;
int iparams;
struct symbol *sym;
if (nparams > 0)
{
struct dict_iterator iter;
TYPE_NFIELDS (ftype) = nparams;
TYPE_FIELDS (ftype) = (struct field *)
TYPE_ALLOC (ftype, nparams * sizeof (struct field));
iparams = 0;
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
if (iparams == nparams)
break;
switch (SYMBOL_CLASS (sym))
{
case LOC_ARG:
case LOC_REF_ARG:
case LOC_REGPARM:
case LOC_REGPARM_ADDR:
TYPE_FIELD_TYPE (ftype, iparams) = SYMBOL_TYPE (sym);
TYPE_FIELD_ARTIFICIAL (ftype, iparams) = 0;
iparams++;
break;
default:
break;
}
}
}
}
}
else if (sh->sc == scText && top_stack->blocktype == stBlock)
{
BLOCK_END (top_stack->cur_block) = sh->value + top_stack->procadr;
}
else if (sh->sc == scText && top_stack->blocktype == stNil)
{
;
}
else if (sh->sc == scText && top_stack->blocktype == stFile)
{
;
}
else
complaint (&symfile_complaints,
_("stEnd with storage class %d not handled"), sh->sc);
pop_parse_stack ();
break;
case stMember:
f = &TYPE_FIELDS (top_stack->cur_type)[top_stack->cur_field++];
FIELD_NAME (*f) = name;
FIELD_BITPOS (*f) = sh->value;
bitsize = 0;
FIELD_TYPE (*f) = parse_type (cur_fd, ax, sh->index, &bitsize, bigend, name);
FIELD_BITSIZE (*f) = bitsize;
FIELD_STATIC_KIND (*f) = 0;
break;
case stIndirect:
break;
case stTypedef:
found_ecoff_debugging_info = 1;
if (sh->iss == 0)
break;
pend = is_pending_symbol (cur_fdr, ext_sh);
if (pend == (struct mdebug_pending *) NULL)
{
t = parse_type (cur_fd, ax, sh->index, (int *) NULL, bigend, name);
add_pending (cur_fdr, ext_sh, t);
}
else
t = pend->t;
if (has_opaque_xref (cur_fdr, sh))
break;
s = new_symbol (name);
SYMBOL_DOMAIN (s) = VAR_DOMAIN;
SYMBOL_CLASS (s) = LOC_TYPEDEF;
SYMBOL_BLOCK_VALUE (s) = top_stack->cur_block;
SYMBOL_TYPE (s) = t;
add_symbol (s, top_stack->cur_block);
if (TYPE_NAME (SYMBOL_TYPE (s)) == NULL
&& (TYPE_NFIELDS (SYMBOL_TYPE (s)) != 0
|| (TYPE_CODE (SYMBOL_TYPE (s)) != TYPE_CODE_STRUCT
&& TYPE_CODE (SYMBOL_TYPE (s)) != TYPE_CODE_UNION)))
{
if (TYPE_CODE (SYMBOL_TYPE (s)) == TYPE_CODE_PTR
|| TYPE_CODE (SYMBOL_TYPE (s)) == TYPE_CODE_FUNC)
{
}
else
TYPE_NAME (SYMBOL_TYPE (s)) = DEPRECATED_SYMBOL_NAME (s);
}
break;
case stFile:
push_parse_stack ();
top_stack->blocktype = sh->st;
break;
case stRegReloc:
break;
case stForward:
break;
case stConstant:
break;
default:
complaint (&symfile_complaints, _("unknown symbol type 0x%x"), sh->st);
break;
}
return count;
}
static struct type *
parse_type (int fd, union aux_ext *ax, unsigned int aux_index, int *bs,
int bigend, char *sym_name)
{
static struct type **map_bt[] =
{
&mdebug_type_void,
&mdebug_type_adr_32,
&mdebug_type_char,
&mdebug_type_unsigned_char,
&mdebug_type_short,
&mdebug_type_unsigned_short,
&mdebug_type_int_32,
&mdebug_type_unsigned_int_32,
&mdebug_type_long_32,
&mdebug_type_unsigned_long_32,
&mdebug_type_float,
&mdebug_type_double,
0,
0,
0,
0,
0,
0,
&mdebug_type_complex,
&mdebug_type_double_complex,
0,
&mdebug_type_fixed_dec,
&mdebug_type_float_dec,
&mdebug_type_string,
0,
0,
&mdebug_type_void,
0,
0,
0,
&mdebug_type_long_64,
&mdebug_type_unsigned_long_64,
&mdebug_type_long_long_64,
&mdebug_type_unsigned_long_long_64,
&mdebug_type_adr_64,
&mdebug_type_int_64,
&mdebug_type_unsigned_int_64,
};
TIR t[1];
struct type *tp = 0;
enum type_code type_code = TYPE_CODE_UNDEF;
if (aux_index == indexNil)
return mdebug_type_int;
if (aux_index >= (debug_info->fdr + fd)->caux)
{
index_complaint (sym_name);
return mdebug_type_int;
}
ax += aux_index;
(*debug_swap->swap_tir_in) (bigend, &ax->a_ti, t);
if (t->bt >= (sizeof (map_bt) / sizeof (*map_bt)))
{
basic_type_complaint (t->bt, sym_name);
return mdebug_type_int;
}
if (map_bt[t->bt])
{
tp = *map_bt[t->bt];
}
else
{
tp = NULL;
switch (t->bt)
{
case btStruct:
type_code = TYPE_CODE_STRUCT;
break;
case btUnion:
type_code = TYPE_CODE_UNION;
break;
case btEnum:
type_code = TYPE_CODE_ENUM;
break;
case btRange:
type_code = TYPE_CODE_RANGE;
break;
case btSet:
type_code = TYPE_CODE_SET;
break;
case btIndirect:
type_code = TYPE_CODE_ERROR;
break;
case btTypedef:
type_code = TYPE_CODE_ERROR;
break;
default:
basic_type_complaint (t->bt, sym_name);
return mdebug_type_int;
}
}
ax++;
if (t->fBitfield)
{
int width = AUX_GET_WIDTH (bigend, ax);
if (bs == (int *) NULL)
{
if (t->bt == btShort && width == 8)
tp = mdebug_type_char;
else if (t->bt == btUShort && width == 8)
tp = mdebug_type_unsigned_char;
else if (t->bt == btEnum)
;
else
complaint (&symfile_complaints, _("can't handle TIR fBitfield for %s"),
sym_name);
}
else
*bs = width;
ax++;
}
if (t->bt == btIndirect)
{
RNDXR rn[1];
int rf;
FDR *xref_fh;
int xref_fd;
(*debug_swap->swap_rndx_in) (bigend, &ax->a_rndx, rn);
ax++;
if (rn->rfd == 0xfff)
{
rf = AUX_GET_ISYM (bigend, ax);
ax++;
}
else
rf = rn->rfd;
if (rf == -1)
{
complaint (&symfile_complaints,
_("unable to cross ref btIndirect for %s"), sym_name);
return mdebug_type_int;
}
xref_fh = get_rfd (fd, rf);
xref_fd = xref_fh - debug_info->fdr;
tp = parse_type (xref_fd, debug_info->external_aux + xref_fh->iauxBase,
rn->index, (int *) NULL, xref_fh->fBigendian, sym_name);
}
if (t->bt == btStruct ||
t->bt == btUnion ||
t->bt == btEnum ||
t->bt == btSet)
{
char *name;
ax += cross_ref (fd, ax, &tp, type_code, &name, bigend, sym_name);
if (tp == (struct type *) NULL)
tp = init_type (type_code, 0, 0, (char *) NULL, current_objfile);
while (TYPE_CODE (tp) == TYPE_CODE_PTR
|| TYPE_CODE (tp) == TYPE_CODE_ARRAY)
tp = TYPE_TARGET_TYPE (tp);
if (TYPE_CODE (tp) != TYPE_CODE_STRUCT
&& TYPE_CODE (tp) != TYPE_CODE_UNION
&& TYPE_CODE (tp) != TYPE_CODE_ENUM)
{
unexpected_type_code_complaint (sym_name);
}
else
{
if ((TYPE_CODE (tp) == TYPE_CODE_ENUM
&& type_code != TYPE_CODE_ENUM)
|| (TYPE_CODE (tp) != TYPE_CODE_ENUM
&& type_code == TYPE_CODE_ENUM))
{
bad_tag_guess_complaint (sym_name);
}
if (TYPE_CODE (tp) != type_code)
{
TYPE_CODE (tp) = type_code;
}
if (name[0] == '.' || name[0] == '\0')
TYPE_TAG_NAME (tp) = NULL;
else if (TYPE_TAG_NAME (tp) == NULL
|| strcmp (TYPE_TAG_NAME (tp), name) != 0)
TYPE_TAG_NAME (tp) = obsavestring (name, strlen (name),
¤t_objfile->objfile_obstack);
}
}
if (t->bt == btRange)
{
char *name;
ax += cross_ref (fd, ax, &tp, type_code, &name, bigend, sym_name);
if (tp == (struct type *) NULL)
tp = init_type (type_code, 0, 0, (char *) NULL, current_objfile);
if (TYPE_CODE (tp) != TYPE_CODE_RANGE)
{
unexpected_type_code_complaint (sym_name);
}
else
{
if (TYPE_CODE (tp) != type_code)
{
bad_tag_guess_complaint (sym_name);
TYPE_CODE (tp) = type_code;
}
if (TYPE_NAME (tp) == NULL
|| strcmp (TYPE_NAME (tp), name) != 0)
TYPE_NAME (tp) = obsavestring (name, strlen (name),
¤t_objfile->objfile_obstack);
}
}
if (t->bt == btTypedef)
{
char *name;
ax += cross_ref (fd, ax, &tp, type_code, &name, bigend, sym_name);
if (tp == (struct type *) NULL)
{
complaint (&symfile_complaints,
_("unable to cross ref btTypedef for %s"), sym_name);
tp = mdebug_type_int;
}
}
if (t->bt == btRange)
{
TYPE_NFIELDS (tp) = 2;
TYPE_FIELDS (tp) = ((struct field *)
TYPE_ALLOC (tp, 2 * sizeof (struct field)));
TYPE_FIELD_NAME (tp, 0) = obsavestring ("Low", strlen ("Low"),
¤t_objfile->objfile_obstack);
TYPE_FIELD_BITPOS (tp, 0) = AUX_GET_DNLOW (bigend, ax);
ax++;
TYPE_FIELD_NAME (tp, 1) = obsavestring ("High", strlen ("High"),
¤t_objfile->objfile_obstack);
TYPE_FIELD_BITPOS (tp, 1) = AUX_GET_DNHIGH (bigend, ax);
ax++;
}
while (1)
{
#define PARSE_TQ(tq) \
if (t->tq != tqNil) \
ax += upgrade_type(fd, &tp, t->tq, ax, bigend, sym_name); \
else \
break;
PARSE_TQ (tq0);
PARSE_TQ (tq1);
PARSE_TQ (tq2);
PARSE_TQ (tq3);
PARSE_TQ (tq4);
PARSE_TQ (tq5);
#undef PARSE_TQ
if (!t->continued)
break;
(*debug_swap->swap_tir_in) (bigend, &ax->a_ti, t);
ax++;
}
if (t->continued)
complaint (&symfile_complaints, _("illegal TIR continued for %s"), sym_name);
return tp;
}
static int
upgrade_type (int fd, struct type **tpp, int tq, union aux_ext *ax, int bigend,
char *sym_name)
{
int off;
struct type *t;
int rf, id;
FDR *fh;
struct type *range;
struct type *indx;
int lower, upper;
RNDXR rndx;
switch (tq)
{
case tqPtr:
t = lookup_pointer_type (*tpp);
*tpp = t;
return 0;
case tqProc:
t = lookup_function_type (*tpp);
*tpp = t;
return 0;
case tqArray:
off = 0;
(*debug_swap->swap_rndx_in) (bigend, &ax->a_rndx, &rndx);
id = rndx.index;
rf = rndx.rfd;
if (rf == 0xfff)
{
ax++;
rf = AUX_GET_ISYM (bigend, ax);
off++;
}
fh = get_rfd (fd, rf);
indx = parse_type (fh - debug_info->fdr,
debug_info->external_aux + fh->iauxBase,
id, (int *) NULL, bigend, sym_name);
if (TYPE_CODE (indx) != TYPE_CODE_INT)
{
complaint (&symfile_complaints,
_("illegal array index type for %s, assuming int"), sym_name);
indx = mdebug_type_int;
}
ax++;
lower = AUX_GET_DNLOW (bigend, ax);
ax++;
upper = AUX_GET_DNHIGH (bigend, ax);
ax++;
rf = AUX_GET_WIDTH (bigend, ax);
range = create_range_type ((struct type *) NULL, indx,
lower, upper);
t = create_array_type ((struct type *) NULL, *tpp, range);
if (TYPE_LENGTH (*tpp) == 0)
{
TYPE_FLAGS (t) |= TYPE_FLAG_TARGET_STUB;
}
*tpp = t;
return 4 + off;
case tqVol:
return 0;
case tqConst:
return 0;
default:
complaint (&symfile_complaints, _("unknown type qualifier 0x%x"), tq);
return 0;
}
}
static void parse_procedure (PDR *, struct symtab *, struct partial_symtab *);
static void
parse_procedure (PDR *pr, struct symtab *search_symtab,
struct partial_symtab *pst)
{
struct symbol *s, *i;
struct block *b;
struct mdebug_extra_func_info *e;
char *sh_name;
if (cur_fdr->rss == -1)
{
if (pr->isym == -1)
{
complaint (&symfile_complaints,
_("can't handle PDR for static proc at 0x%lx"),
(unsigned long) pr->adr);
return;
}
else
{
EXTR she;
(*debug_swap->swap_ext_in) (cur_bfd,
((char *) debug_info->external_ext
+ (pr->isym
* debug_swap->external_ext_size)),
&she);
sh_name = debug_info->ssext + she.asym.iss;
}
}
else
{
SYMR sh;
(*debug_swap->swap_sym_in) (cur_bfd,
((char *) debug_info->external_sym
+ ((cur_fdr->isymBase + pr->isym)
* debug_swap->external_sym_size)),
&sh);
sh_name = debug_info->ss + cur_fdr->issBase + sh.iss;
}
if (search_symtab != NULL)
{
#if 0
FDR *save_cur_fdr = cur_fdr;
s = lookup_symbol (sh_name, NULL, VAR_DOMAIN, 0, NULL);
cur_fdr = save_cur_fdr;
#else
s = mylookup_symbol
(sh_name,
BLOCKVECTOR_BLOCK (BLOCKVECTOR (search_symtab), STATIC_BLOCK),
VAR_DOMAIN,
LOC_BLOCK);
#endif
}
else
s = mylookup_symbol (sh_name, top_stack->cur_block,
VAR_DOMAIN, LOC_BLOCK);
if (s != 0)
{
b = SYMBOL_BLOCK_VALUE (s);
}
else
{
complaint (&symfile_complaints, _("PDR for %s, but no symbol"), sh_name);
#if 1
return;
#else
s = new_symbol (sh_name);
SYMBOL_DOMAIN (s) = VAR_DOMAIN;
SYMBOL_CLASS (s) = LOC_BLOCK;
SYMBOL_TYPE (s) = lookup_function_type (mdebug_type_int);
add_symbol (s, top_stack->cur_block);
b = new_block (2);
SYMBOL_BLOCK_VALUE (s) = b;
BLOCK_FUNCTION (b) = s;
BLOCK_START (b) = pr->adr;
BLOCK_END (b) = bound;
BLOCK_SUPERBLOCK (b) = top_stack->cur_block;
add_block (b, top_stack->cur_st);
#endif
}
i = mylookup_symbol (MDEBUG_EFI_SYMBOL_NAME, b, LABEL_DOMAIN, LOC_CONST);
if (i)
{
e = (struct mdebug_extra_func_info *) SYMBOL_VALUE (i);
e->pdr = *pr;
e->pdr.isym = (long) s;
e->pdr.adr = BLOCK_START (b);
if (e->pdr.pcreg == 0
&& strcmp (sh_name, "setjmp") == 0)
{
complaint (&symfile_complaints, _("fixing bad setjmp PDR from libc"));
#ifdef RA_REGNUM
e->pdr.pcreg = RA_REGNUM;
#else
e->pdr.pcreg = 0;
#endif
e->pdr.regmask = 0x80000000;
e->pdr.regoffset = -4;
}
}
if (processing_gcc_compilation == 0
&& found_ecoff_debugging_info == 0
&& TYPE_CODE (TYPE_TARGET_TYPE (SYMBOL_TYPE (s))) == TYPE_CODE_VOID)
SYMBOL_TYPE (s) = nodebug_func_symbol_type;
}
static void parse_external (EXTR *, int, struct section_offsets *,
struct objfile *);
static void
parse_external (EXTR *es, int bigend, struct section_offsets *section_offsets,
struct objfile *objfile)
{
union aux_ext *ax;
if (es->ifd != ifdNil)
{
cur_fd = es->ifd;
cur_fdr = debug_info->fdr + cur_fd;
ax = debug_info->external_aux + cur_fdr->iauxBase;
}
else
{
cur_fdr = debug_info->fdr;
ax = 0;
}
if (SC_IS_UNDEF (es->asym.sc) || es->asym.sc == scNil)
{
char *what;
switch (es->asym.st)
{
case stNil:
return;
case stStaticProc:
case stProc:
what = "procedure";
n_undef_procs++;
break;
case stGlobal:
what = "variable";
n_undef_vars++;
break;
case stLabel:
what = "label";
n_undef_labels++;
break;
default:
what = "symbol";
break;
}
n_undef_symbols++;
if (info_verbose)
printf_filtered (_("Warning: %s `%s' is undefined (in %s)\n"),
what, debug_info->ssext + es->asym.iss,
fdr_name (cur_fdr));
return;
}
switch (es->asym.st)
{
case stProc:
case stStaticProc:
break;
case stGlobal:
case stLabel:
if (SC_IS_COMMON (es->asym.sc))
break;
parse_symbol (&es->asym, ax, (char *) NULL, bigend, section_offsets, objfile);
break;
default:
break;
}
}
static void parse_lines (FDR *, PDR *, struct linetable *, int,
struct partial_symtab *, CORE_ADDR);
static void
parse_lines (FDR *fh, PDR *pr, struct linetable *lt, int maxlines,
struct partial_symtab *pst, CORE_ADDR lowest_pdr_addr)
{
unsigned char *base;
int j, k;
int delta, count, lineno = 0;
if (fh->cbLine == 0)
return;
k = 0;
for (j = 0; j < fh->cpd; j++, pr++)
{
CORE_ADDR l;
CORE_ADDR adr;
unsigned char *halt;
if (pr->iline == ilineNil ||
pr->lnLow == -1 || pr->lnHigh == -1)
continue;
base = debug_info->line + fh->cbLineOffset;
if (j != (fh->cpd - 1))
halt = base + pr[1].cbLineOffset;
else
halt = base + fh->cbLine;
base += pr->cbLineOffset;
adr = pst->textlow + pr->adr - lowest_pdr_addr;
l = adr >> 2;
for (lineno = pr->lnLow; base < halt;)
{
count = *base & 0x0f;
delta = *base++ >> 4;
if (delta >= 8)
delta -= 16;
if (delta == -8)
{
delta = (base[0] << 8) | base[1];
if (delta >= 0x8000)
delta -= 0x10000;
base += 2;
}
lineno += delta;
if (lt->nitems >= maxlines)
{
complaint (&symfile_complaints,
_("guessed size of linetable for %s incorrectly"),
fdr_name (fh));
break;
}
k = add_line (lt, lineno, l, k);
l += count + 1;
}
}
}
static void
function_outside_compilation_unit_complaint (const char *arg1)
{
complaint (&symfile_complaints,
_("function `%s' appears to be defined outside of all compilation units"),
arg1);
}
static void
record_minimal_symbol (const char *name, const CORE_ADDR address,
enum minimal_symbol_type ms_type, int storage_class,
struct objfile *objfile)
{
int section;
asection *bfd_section;
switch (storage_class)
{
case scText:
section = SECT_OFF_TEXT (objfile);
bfd_section = bfd_get_section_by_name (cur_bfd, ".text");
break;
case scData:
section = SECT_OFF_DATA (objfile);
bfd_section = bfd_get_section_by_name (cur_bfd, ".data");
break;
case scBss:
section = SECT_OFF_BSS (objfile);
bfd_section = bfd_get_section_by_name (cur_bfd, ".bss");
break;
case scSData:
section = get_section_index (objfile, ".sdata");
bfd_section = bfd_get_section_by_name (cur_bfd, ".sdata");
break;
case scSBss:
section = get_section_index (objfile, ".sbss");
bfd_section = bfd_get_section_by_name (cur_bfd, ".sbss");
break;
case scRData:
section = get_section_index (objfile, ".rdata");
bfd_section = bfd_get_section_by_name (cur_bfd, ".rdata");
break;
case scInit:
section = get_section_index (objfile, ".init");
bfd_section = bfd_get_section_by_name (cur_bfd, ".init");
break;
case scXData:
section = get_section_index (objfile, ".xdata");
bfd_section = bfd_get_section_by_name (cur_bfd, ".xdata");
break;
case scPData:
section = get_section_index (objfile, ".pdata");
bfd_section = bfd_get_section_by_name (cur_bfd, ".pdata");
break;
case scFini:
section = get_section_index (objfile, ".fini");
bfd_section = bfd_get_section_by_name (cur_bfd, ".fini");
break;
case scRConst:
section = get_section_index (objfile, ".rconst");
bfd_section = bfd_get_section_by_name (cur_bfd, ".rconst");
break;
#ifdef scTlsData
case scTlsData:
section = get_section_index (objfile, ".tlsdata");
bfd_section = bfd_get_section_by_name (cur_bfd, ".tlsdata");
break;
#endif
#ifdef scTlsBss
case scTlsBss:
section = get_section_index (objfile, ".tlsbss");
bfd_section = bfd_get_section_by_name (cur_bfd, ".tlsbss");
break;
#endif
default:
section = -1;
bfd_section = NULL;
}
prim_record_minimal_symbol_and_info (name, address, ms_type, NULL,
section, bfd_section, objfile);
}
static void
parse_partial_symbols (struct objfile *objfile)
{
const bfd_size_type external_sym_size = debug_swap->external_sym_size;
const bfd_size_type external_rfd_size = debug_swap->external_rfd_size;
const bfd_size_type external_ext_size = debug_swap->external_ext_size;
void (*const swap_ext_in) (bfd *, void *, EXTR *) = debug_swap->swap_ext_in;
void (*const swap_sym_in) (bfd *, void *, SYMR *) = debug_swap->swap_sym_in;
void (*const swap_rfd_in) (bfd *, void *, RFDT *) = debug_swap->swap_rfd_in;
int f_idx, s_idx;
HDRR *hdr = &debug_info->symbolic_header;
FDR *fh;
char *ext_out;
char *ext_out_end;
EXTR *ext_block;
EXTR *ext_in;
EXTR *ext_in_end;
SYMR sh;
struct partial_symtab *pst;
int textlow_not_set = 1;
int past_first_source_file = 0;
char **psymtab_include_list;
int includes_allocated;
int includes_used;
EXTR *extern_tab;
struct pst_map *fdr_to_pst;
struct partial_symtab **dependency_list;
int dependencies_used, dependencies_allocated;
struct cleanup *old_chain;
char *name;
enum language prev_language;
asection *text_sect;
int relocatable = 0;
text_sect = bfd_get_section_by_name (cur_bfd, ".text");
if (text_sect != NULL
&& (bfd_get_section_flags (cur_bfd, text_sect) & SEC_RELOC))
relocatable = 1;
extern_tab = (EXTR *) obstack_alloc (&objfile->objfile_obstack,
sizeof (EXTR) * hdr->iextMax);
includes_allocated = 30;
includes_used = 0;
psymtab_include_list = (char **) alloca (includes_allocated *
sizeof (char *));
next_symbol_text_func = mdebug_next_symbol_text;
dependencies_allocated = 30;
dependencies_used = 0;
dependency_list =
(struct partial_symtab **) alloca (dependencies_allocated *
sizeof (struct partial_symtab *));
last_source_file = NULL;
max_gdbinfo = 0;
max_glevel = MIN_GLEVEL;
fdr_to_pst = (struct pst_map *) xzalloc ((hdr->ifdMax + 1) * sizeof *fdr_to_pst);
old_chain = make_cleanup (xfree, fdr_to_pst);
fdr_to_pst++;
{
struct partial_symtab *pst = new_psymtab ("", objfile);
fdr_to_pst[-1].pst = pst;
FDR_IDX (pst) = -1;
}
pending_list =
((struct mdebug_pending **)
obstack_alloc (&objfile->objfile_obstack,
hdr->ifdMax * sizeof (struct mdebug_pending *)));
memset (pending_list, 0,
hdr->ifdMax * sizeof (struct mdebug_pending *));
ext_block = (EXTR *) xmalloc (hdr->iextMax * sizeof (EXTR));
make_cleanup (xfree, ext_block);
ext_out = (char *) debug_info->external_ext;
ext_out_end = ext_out + hdr->iextMax * external_ext_size;
ext_in = ext_block;
for (; ext_out < ext_out_end; ext_out += external_ext_size, ext_in++)
(*swap_ext_in) (cur_bfd, ext_out, ext_in);
ext_in = ext_block;
ext_in_end = ext_in + hdr->iextMax;
for (; ext_in < ext_in_end; ext_in++)
{
if (ext_in->ifd >= -1
&& ext_in->ifd < hdr->ifdMax
&& ext_in->asym.iss >= 0
&& ext_in->asym.iss < hdr->issExtMax)
fdr_to_pst[ext_in->ifd].n_globals++;
}
s_idx = 0;
for (f_idx = -1; f_idx < hdr->ifdMax; f_idx++)
{
fdr_to_pst[f_idx].globals_offset = s_idx;
s_idx += fdr_to_pst[f_idx].n_globals;
fdr_to_pst[f_idx].n_globals = 0;
}
ext_in = ext_block;
ext_in_end = ext_in + hdr->iextMax;
for (; ext_in < ext_in_end; ext_in++)
{
enum minimal_symbol_type ms_type = mst_text;
CORE_ADDR svalue = ext_in->asym.value;
if (ext_in->ifd < -1 || ext_in->ifd >= hdr->ifdMax)
{
complaint (&symfile_complaints,
_("bad ifd for external symbol: %d (max %ld)"), ext_in->ifd,
hdr->ifdMax);
continue;
}
if (ext_in->asym.iss < 0 || ext_in->asym.iss >= hdr->issExtMax)
{
complaint (&symfile_complaints,
_("bad iss for external symbol: %ld (max %ld)"),
ext_in->asym.iss, hdr->issExtMax);
continue;
}
extern_tab[fdr_to_pst[ext_in->ifd].globals_offset
+ fdr_to_pst[ext_in->ifd].n_globals++] = *ext_in;
if (SC_IS_UNDEF (ext_in->asym.sc) || ext_in->asym.sc == scNil)
continue;
name = debug_info->ssext + ext_in->asym.iss;
switch (ext_in->asym.st)
{
case stProc:
svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
break;
case stStaticProc:
ms_type = mst_file_text;
svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
break;
case stGlobal:
if (SC_IS_COMMON (ext_in->asym.sc))
{
continue;
}
else if (SC_IS_DATA (ext_in->asym.sc))
{
ms_type = mst_data;
svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
}
else if (SC_IS_BSS (ext_in->asym.sc))
{
ms_type = mst_bss;
svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS (objfile));
}
else if (SC_IS_SBSS (ext_in->asym.sc))
{
ms_type = mst_bss;
svalue += ANOFFSET (objfile->section_offsets,
get_section_index (objfile, ".sbss"));
}
else
ms_type = mst_abs;
break;
case stLabel:
if (SC_IS_TEXT (ext_in->asym.sc))
{
if (objfile->sect_index_text == -1)
continue;
ms_type = mst_file_text;
svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
}
else if (SC_IS_DATA (ext_in->asym.sc))
{
if (objfile->sect_index_data == -1)
continue;
ms_type = mst_file_data;
svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
}
else if (SC_IS_BSS (ext_in->asym.sc))
{
if (objfile->sect_index_bss == -1)
continue;
ms_type = mst_file_bss;
svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS (objfile));
}
else if (SC_IS_SBSS (ext_in->asym.sc))
{
const int sbss_sect_index = get_section_index (objfile, ".sbss");
if (sbss_sect_index == -1)
continue;
ms_type = mst_file_bss;
svalue += ANOFFSET (objfile->section_offsets, sbss_sect_index);
}
else
ms_type = mst_abs;
break;
case stLocal:
case stNil:
if (name[0] == '.')
continue;
default:
ms_type = mst_unknown;
unknown_ext_complaint (name);
}
if (!ECOFF_IN_ELF (cur_bfd))
record_minimal_symbol (name, svalue, ms_type, ext_in->asym.sc,
objfile);
}
for (f_idx = 0; f_idx < hdr->ifdMax; f_idx++)
{
struct partial_symtab *save_pst;
EXTR *ext_ptr;
CORE_ADDR textlow;
cur_fdr = fh = debug_info->fdr + f_idx;
if (fh->csym == 0)
{
fdr_to_pst[f_idx].pst = NULL;
continue;
}
if (fh->cpd)
{
textlow = fh->adr;
if (relocatable || textlow != 0)
textlow += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
}
else
textlow = 0;
pst = start_psymtab_common (objfile, objfile->section_offsets,
fdr_name (fh),
textlow,
objfile->global_psymbols.next,
objfile->static_psymbols.next);
pst->read_symtab_private = ((char *)
obstack_alloc (&objfile->objfile_obstack,
sizeof (struct symloc)));
memset (pst->read_symtab_private, 0, sizeof (struct symloc));
save_pst = pst;
FDR_IDX (pst) = f_idx;
CUR_BFD (pst) = cur_bfd;
DEBUG_SWAP (pst) = debug_swap;
DEBUG_INFO (pst) = debug_info;
PENDING_LIST (pst) = pending_list;
pst->read_symtab = mdebug_psymtab_to_symtab;
prev_language = psymtab_language;
switch (fh->lang)
{
case langCplusplusV2:
psymtab_language = language_cplus;
break;
default:
psymtab_language = deduce_language_from_filename (fdr_name (fh));
break;
}
if (psymtab_language == language_unknown)
psymtab_language = prev_language;
PST_PRIVATE (pst)->pst_language = psymtab_language;
pst->texthigh = pst->textlow;
processing_gcc_compilation = 0;
if (fh->csym >= 2)
{
(*swap_sym_in) (cur_bfd,
((char *) debug_info->external_sym
+ (fh->isymBase + 1) * external_sym_size),
&sh);
if (strcmp (debug_info->ss + fh->issBase + sh.iss,
stabs_symbol) == 0)
processing_gcc_compilation = 2;
}
if (processing_gcc_compilation != 0)
{
for (cur_sdx = 2; cur_sdx < fh->csym; cur_sdx++)
{
int type_code;
char *namestring;
(*swap_sym_in) (cur_bfd,
(((char *) debug_info->external_sym)
+ (fh->isymBase + cur_sdx) * external_sym_size),
&sh);
type_code = ECOFF_UNMARK_STAB (sh.index);
if (!ECOFF_IS_STAB (&sh))
{
if (sh.st == stProc || sh.st == stStaticProc)
{
CORE_ADDR procaddr;
long isym;
sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
if (sh.st == stStaticProc)
{
namestring = debug_info->ss + fh->issBase + sh.iss;
record_minimal_symbol (namestring, sh.value,
mst_file_text, sh.sc,
objfile);
}
procaddr = sh.value;
isym = AUX_GET_ISYM (fh->fBigendian,
(debug_info->external_aux
+ fh->iauxBase
+ sh.index));
(*swap_sym_in) (cur_bfd,
((char *) debug_info->external_sym
+ ((fh->isymBase + isym - 1)
* external_sym_size)),
&sh);
if (sh.st == stEnd)
{
CORE_ADDR high = procaddr + sh.value;
if (!relocatable
&& (pst->textlow == 0 || procaddr < pst->textlow))
pst->textlow = procaddr;
if (high > pst->texthigh)
pst->texthigh = high;
}
}
else if (sh.st == stStatic)
{
switch (sh.sc)
{
case scUndefined:
case scSUndefined:
case scNil:
case scAbs:
break;
case scData:
case scSData:
case scRData:
case scPData:
case scXData:
namestring = debug_info->ss + fh->issBase + sh.iss;
sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
record_minimal_symbol (namestring, sh.value,
mst_file_data, sh.sc,
objfile);
break;
default:
namestring = debug_info->ss + fh->issBase + sh.iss;
sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS (objfile));
record_minimal_symbol (namestring, sh.value,
mst_file_bss, sh.sc,
objfile);
break;
}
}
continue;
}
{
char *stabstring = debug_info->ss + fh->issBase + sh.iss;
int len = strlen (stabstring);
while (stabstring[len - 1] == '\\')
{
SYMR sh2;
char *stabstring1 = stabstring;
char *stabstring2;
int len2;
len--;
cur_sdx++;
(*swap_sym_in) (cur_bfd,
(((char *) debug_info->external_sym)
+ (fh->isymBase + cur_sdx)
* external_sym_size),
&sh2);
stabstring2 = debug_info->ss + fh->issBase + sh2.iss;
len2 = strlen (stabstring2);
if (stabstring
&& stabstring != debug_info->ss + fh->issBase + sh.iss)
stabstring = xrealloc (stabstring, len + len2 + 1);
else
{
stabstring = xmalloc (len + len2 + 1);
strcpy (stabstring, stabstring1);
}
strcpy (stabstring + len, stabstring2);
len += len2;
}
switch (type_code)
{
char *p;
case N_TEXT | N_EXT:
case N_NBTEXT | N_EXT:
sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
goto record_it;
case N_DATA | N_EXT:
case N_NBDATA | N_EXT:
sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
goto record_it;
case N_BSS:
case N_BSS | N_EXT:
case N_NBBSS | N_EXT:
case N_SETV | N_EXT:
sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS (objfile));
goto record_it;
case N_ABS | N_EXT:
record_it:
continue;
case N_NBTEXT:
case N_FN:
case N_FN_SEQ:
case N_TEXT:
continue;
case N_DATA:
sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
goto record_it;
case N_UNDF | N_EXT:
continue;
case N_UNDF:
continue;
case N_ABS:
case N_NBDATA:
case N_NBBSS:
continue;
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;
case N_SO:
{
CORE_ADDR valu;
static int prev_so_symnum = -10;
static int first_so_symnum;
char *p;
int prev_textlow_not_set;
valu = sh.value + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
prev_textlow_not_set = textlow_not_set;
#ifdef SOFUN_ADDRESS_MAYBE_MISSING
if (sh.value == 0)
{
textlow_not_set = 1;
valu = 0;
}
else
textlow_not_set = 0;
#else
textlow_not_set = 0;
#endif
past_first_source_file = 1;
if (prev_so_symnum != symnum - 1)
{
first_so_symnum = symnum;
if (pst)
{
pst = (struct partial_symtab *) 0;
includes_used = 0;
dependencies_used = 0;
}
}
prev_so_symnum = symnum;
namestring = stabstring;
if (*namestring == '\000')
continue;
p = strrchr (namestring, '/');
if (p && *(p + 1) == '\000')
continue;
if (!pst)
pst = save_pst;
continue;
}
case N_BINCL:
continue;
case N_SOL:
{
enum language tmp_language;
namestring = stabstring;
tmp_language = deduce_language_from_filename (namestring);
if (tmp_language != language_unknown
&& (tmp_language != language_c
|| psymtab_language != language_cplus))
psymtab_language = tmp_language;
if (pst && strcmp (namestring, pst->filename) == 0)
continue;
{
int i;
for (i = 0; i < includes_used; i++)
if (strcmp (namestring,
psymtab_include_list[i]) == 0)
{
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 *));
memcpy (psymtab_include_list, orig,
includes_used * sizeof (char *));
}
continue;
}
case N_LSYM:
case N_STSYM:
case N_LCSYM:
case N_ROSYM:
case N_NBSTS:
case N_NBLCS:
case N_FUN:
case N_GSYM:
case N_PC:
case N_M2C:
case N_SCOPE:
namestring = stabstring;
p = (char *) strchr (namestring, ':');
if (!p)
continue;
switch (p[1])
{
case 'S':
sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
#ifdef STATIC_TRANSFORM_NAME
namestring = STATIC_TRANSFORM_NAME (namestring);
#endif
add_psymbol_to_list (namestring, p - namestring,
VAR_DOMAIN, LOC_STATIC,
&objfile->static_psymbols,
0, sh.value,
psymtab_language, objfile);
continue;
case 'G':
sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
add_psymbol_to_list (namestring, p - namestring,
VAR_DOMAIN, LOC_STATIC,
&objfile->global_psymbols,
0, sh.value,
psymtab_language, objfile);
continue;
case 'T':
if (p >= namestring + 2
|| (p == namestring + 1
&& namestring[0] != ' '))
{
add_psymbol_to_list (namestring, p - namestring,
STRUCT_DOMAIN, LOC_TYPEDEF,
&objfile->static_psymbols,
sh.value, 0,
psymtab_language, objfile);
if (p[2] == 't')
{
add_psymbol_to_list (namestring, p - namestring,
VAR_DOMAIN, LOC_TYPEDEF,
&objfile->static_psymbols,
sh.value, 0,
psymtab_language, objfile);
p += 1;
}
}
goto check_enum;
case 't':
if (p != namestring)
{
add_psymbol_to_list (namestring, p - namestring,
VAR_DOMAIN, LOC_TYPEDEF,
&objfile->static_psymbols,
sh.value, 0,
psymtab_language, objfile);
}
check_enum:
p += 2;
while ((*p >= '0' && *p <= '9')
|| *p == '(' || *p == ',' || *p == ')'
|| *p == '=')
p++;
if (*p++ == 'e')
{
if (*p == '-')
{
while (*p != ':')
p++;
p++;
}
while (*p && *p != ';' && *p != ',')
{
char *q;
if (*p == '\\' || (*p == '?' && p[1] == '\0'))
p = next_symbol_text (objfile);
for (q = p; *q && *q != ':'; q++)
;
add_psymbol_to_list (p, q - p,
VAR_DOMAIN, LOC_CONST,
&objfile->static_psymbols, 0,
0, psymtab_language, objfile);
p = q;
while (*p && *p != ',')
p++;
if (*p)
p++;
}
}
continue;
case 'c':
add_psymbol_to_list (namestring, p - namestring,
VAR_DOMAIN, LOC_CONST,
&objfile->static_psymbols, sh.value,
0, psymtab_language, objfile);
continue;
case 'f':
if (! pst)
{
int name_len = p - namestring;
char *name = xmalloc (name_len + 1);
memcpy (name, namestring, name_len);
name[name_len] = '\0';
function_outside_compilation_unit_complaint (name);
xfree (name);
}
sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
add_psymbol_to_list (namestring, p - namestring,
VAR_DOMAIN, LOC_BLOCK,
&objfile->static_psymbols,
0, sh.value,
psymtab_language, objfile);
continue;
case 'F':
if (! pst)
{
int name_len = p - namestring;
char *name = xmalloc (name_len + 1);
memcpy (name, namestring, name_len);
name[name_len] = '\0';
function_outside_compilation_unit_complaint (name);
xfree (name);
}
sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
add_psymbol_to_list (namestring, p - namestring,
VAR_DOMAIN, LOC_BLOCK,
&objfile->global_psymbols,
0, sh.value,
psymtab_language, objfile);
continue;
case 'V':
case '(':
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case '-':
case '#':
continue;
case ':':
continue;
default:
complaint (&symfile_complaints,
_("unknown symbol descriptor `%c'"), p[1]);
continue;
}
case N_EXCL:
continue;
case N_ENDM:
#ifdef SOFUN_ADDRESS_MAYBE_MISSING
if (pst)
{
pst = (struct partial_symtab *) 0;
includes_used = 0;
dependencies_used = 0;
}
#endif
continue;
case N_RBRAC:
if (sh.value > save_pst->texthigh)
save_pst->texthigh = sh.value;
continue;
case N_EINCL:
case N_DSLINE:
case N_BSLINE:
case N_SSYM:
case N_ENTRY:
case N_MAIN:
case N_CATCH:
case N_EHDECL:
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:
case N_DEFD:
case N_ALIAS:
case N_OBJ:
case N_OPT:
continue;
default:
complaint (&symfile_complaints, _("unknown symbol type %s"),
hex_string (type_code));
continue;
}
if (stabstring
&& stabstring != debug_info->ss + fh->issBase + sh.iss)
xfree (stabstring);
}
}
}
else
{
for (cur_sdx = 0; cur_sdx < fh->csym;)
{
char *name;
enum address_class class;
(*swap_sym_in) (cur_bfd,
((char *) debug_info->external_sym
+ ((fh->isymBase + cur_sdx)
* external_sym_size)),
&sh);
if (ECOFF_IS_STAB (&sh))
{
cur_sdx++;
continue;
}
if (SC_IS_UNDEF (sh.sc) || sh.sc == scNil
|| (sh.index == indexNil
&& (sh.st != stStatic || sh.sc == scAbs)))
{
cur_sdx++;
continue;
}
name = debug_info->ss + fh->issBase + sh.iss;
switch (sh.sc)
{
case scText:
case scRConst:
if (sh.st != stEnd)
sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
break;
case scData:
case scSData:
case scRData:
case scPData:
case scXData:
sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
break;
case scBss:
case scSBss:
sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS (objfile));
break;
}
switch (sh.st)
{
CORE_ADDR high;
CORE_ADDR procaddr;
int new_sdx;
case stStaticProc:
prim_record_minimal_symbol_and_info (name, sh.value,
mst_file_text, NULL,
SECT_OFF_TEXT (objfile), NULL,
objfile);
case stProc:
if (sh.index >= hdr->iauxMax)
{
index_complaint (name);
new_sdx = cur_sdx + 1;
}
else
new_sdx = AUX_GET_ISYM (fh->fBigendian,
(debug_info->external_aux
+ fh->iauxBase
+ sh.index));
if (new_sdx <= cur_sdx)
{
complaint (&symfile_complaints,
_("bad proc end in aux found from symbol %s"),
name);
new_sdx = cur_sdx + 1;
}
if (sh.st == stProc && sh.sc != scText)
goto skip;
if (sh.st == stProc)
add_psymbol_to_list (name, strlen (name),
VAR_DOMAIN, LOC_BLOCK,
&objfile->global_psymbols,
0, sh.value, psymtab_language, objfile);
else
add_psymbol_to_list (name, strlen (name),
VAR_DOMAIN, LOC_BLOCK,
&objfile->static_psymbols,
0, sh.value, psymtab_language, objfile);
procaddr = sh.value;
cur_sdx = new_sdx;
(*swap_sym_in) (cur_bfd,
((char *) debug_info->external_sym
+ ((fh->isymBase + cur_sdx - 1)
* external_sym_size)),
&sh);
if (sh.st != stEnd)
continue;
if (!relocatable
&& (pst->textlow == 0 || procaddr < pst->textlow))
pst->textlow = procaddr;
high = procaddr + sh.value;
if (high > pst->texthigh)
pst->texthigh = high;
continue;
case stStatic:
if (SC_IS_DATA (sh.sc))
prim_record_minimal_symbol_and_info (name, sh.value,
mst_file_data, NULL,
SECT_OFF_DATA (objfile),
NULL,
objfile);
else
prim_record_minimal_symbol_and_info (name, sh.value,
mst_file_bss, NULL,
SECT_OFF_BSS (objfile),
NULL,
objfile);
class = LOC_STATIC;
break;
case stIndirect:
goto skip;
case stTypedef:
if (sh.iss == 0 || has_opaque_xref (fh, &sh))
goto skip;
class = LOC_TYPEDEF;
break;
case stConstant:
class = LOC_CONST;
break;
case stUnion:
case stStruct:
case stEnum:
case stBlock:
if ((sh.sc == scInfo
|| SC_IS_COMMON (sh.sc))
&& sh.iss != 0
&& sh.index != cur_sdx + 2)
{
add_psymbol_to_list (name, strlen (name),
STRUCT_DOMAIN, LOC_TYPEDEF,
&objfile->static_psymbols,
0, (CORE_ADDR) 0,
psymtab_language, objfile);
}
handle_psymbol_enumerators (objfile, fh, sh.st, sh.value);
new_sdx = sh.index;
if (new_sdx <= cur_sdx)
{
complaint (&symfile_complaints,
_("bad aux index at block symbol %s"), name);
new_sdx = cur_sdx + 1;
}
cur_sdx = new_sdx;
continue;
case stFile:
case stLabel:
case stEnd:
goto skip;
case stLocal:
goto skip;
default:
complaint (&symfile_complaints, _("unknown local symbol %s"),
name);
complaint (&symfile_complaints, _("with type %d"), sh.st);
cur_sdx++;
continue;
}
add_psymbol_to_list (name, strlen (name),
VAR_DOMAIN, class,
&objfile->static_psymbols,
0, sh.value, psymtab_language, objfile);
skip:
cur_sdx++;
}
ext_ptr = &extern_tab[fdr_to_pst[f_idx].globals_offset];
cur_sdx = fdr_to_pst[f_idx].n_globals;
PST_PRIVATE (save_pst)->extern_count = cur_sdx;
PST_PRIVATE (save_pst)->extern_tab = ext_ptr;
for (; --cur_sdx >= 0; ext_ptr++)
{
enum address_class class;
SYMR *psh;
char *name;
CORE_ADDR svalue;
if (ext_ptr->ifd != f_idx)
internal_error (__FILE__, __LINE__, _("failed internal consistency check"));
psh = &ext_ptr->asym;
if (SC_IS_UNDEF (psh->sc) || psh->sc == scNil)
continue;
svalue = psh->value;
switch (psh->sc)
{
case scText:
case scRConst:
svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
break;
case scData:
case scSData:
case scRData:
case scPData:
case scXData:
svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
break;
case scBss:
case scSBss:
svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS (objfile));
break;
}
switch (psh->st)
{
case stNil:
continue;
case stProc:
case stStaticProc:
continue;
case stLabel:
class = LOC_LABEL;
break;
default:
unknown_ext_complaint (debug_info->ssext + psh->iss);
case stGlobal:
if (SC_IS_COMMON (psh->sc))
continue;
class = LOC_STATIC;
break;
}
name = debug_info->ssext + psh->iss;
add_psymbol_to_list (name, strlen (name),
VAR_DOMAIN, class,
&objfile->global_psymbols,
0, svalue,
psymtab_language, objfile);
}
}
fdr_to_pst[f_idx].pst = end_psymtab (save_pst,
psymtab_include_list, includes_used,
-1, save_pst->texthigh,
dependency_list, dependencies_used, textlow_not_set);
includes_used = 0;
dependencies_used = 0;
save_pst = fdr_to_pst[f_idx].pst;
if (save_pst != NULL
&& save_pst->textlow != 0
&& !(objfile->flags & OBJF_REORDERED))
{
ALL_OBJFILE_PSYMTABS (objfile, pst)
{
if (save_pst != pst
&& save_pst->textlow >= pst->textlow
&& save_pst->textlow < pst->texthigh
&& save_pst->texthigh > pst->texthigh)
{
objfile->flags |= OBJF_REORDERED;
break;
}
}
}
}
for (f_idx = 0; f_idx < hdr->ifdMax; f_idx++)
{
fh = f_idx + debug_info->fdr;
pst = fdr_to_pst[f_idx].pst;
if (pst == (struct partial_symtab *) NULL)
continue;
if (fh->crfd <= 1)
continue;
pst->number_of_dependencies = 0;
pst->dependencies =
((struct partial_symtab **)
obstack_alloc (&objfile->objfile_obstack,
((fh->crfd - 1)
* sizeof (struct partial_symtab *))));
for (s_idx = 1; s_idx < fh->crfd; s_idx++)
{
RFDT rh;
(*swap_rfd_in) (cur_bfd,
((char *) debug_info->external_rfd
+ (fh->rfdBase + s_idx) * external_rfd_size),
&rh);
if (rh < 0 || rh >= hdr->ifdMax)
{
complaint (&symfile_complaints, _("bad file number %ld"), rh);
continue;
}
if (rh == f_idx)
continue;
if (fdr_to_pst[rh].pst == (struct partial_symtab *) NULL)
continue;
pst->dependencies[pst->number_of_dependencies++] = fdr_to_pst[rh].pst;
}
}
PSYMTAB_OBSOLETED (pst) = 50;
if (objfile->psymtabs->next == NULL
&& objfile->psymtabs->number_of_dependencies == 0
&& objfile->psymtabs->n_global_syms == 0
&& objfile->psymtabs->n_static_syms == 0)
objfile->psymtabs = NULL;
do_cleanups (old_chain);
}
static void
handle_psymbol_enumerators (struct objfile *objfile, FDR *fh, int stype,
CORE_ADDR svalue)
{
const bfd_size_type external_sym_size = debug_swap->external_sym_size;
void (*const swap_sym_in) (bfd *, void *, SYMR *) = debug_swap->swap_sym_in;
char *ext_sym = ((char *) debug_info->external_sym
+ ((fh->isymBase + cur_sdx + 1) * external_sym_size));
SYMR sh;
TIR tir;
switch (stype)
{
case stEnum:
break;
case stBlock:
(*swap_sym_in) (cur_bfd, ext_sym, &sh);
if (sh.st != stMember)
return;
if (sh.index == indexNil
|| (sh.index == 0 && svalue == 0))
break;
(*debug_swap->swap_tir_in) (fh->fBigendian,
&(debug_info->external_aux
+ fh->iauxBase + sh.index)->a_ti,
&tir);
if ((tir.bt != btNil
&& tir.bt != btVoid
&& (tir.bt != btEnum || svalue != 0))
|| tir.tq0 != tqNil)
return;
break;
default:
return;
}
for (;;)
{
char *name;
(*swap_sym_in) (cur_bfd, ext_sym, &sh);
if (sh.st != stMember)
break;
name = debug_info->ss + cur_fdr->issBase + sh.iss;
add_psymbol_to_list (name, strlen (name),
VAR_DOMAIN, LOC_CONST,
&objfile->static_psymbols, 0,
(CORE_ADDR) 0, psymtab_language, objfile);
ext_sym += external_sym_size;
}
}
static char *
mdebug_next_symbol_text (struct objfile *objfile)
{
SYMR sh;
cur_sdx++;
(*debug_swap->swap_sym_in) (cur_bfd,
((char *) debug_info->external_sym
+ ((cur_fdr->isymBase + cur_sdx)
* debug_swap->external_sym_size)),
&sh);
return debug_info->ss + cur_fdr->issBase + sh.iss;
}
static void
psymtab_to_symtab_1 (struct partial_symtab *pst, char *filename)
{
bfd_size_type external_sym_size;
bfd_size_type external_pdr_size;
void (*swap_sym_in) (bfd *, void *, SYMR *);
void (*swap_pdr_in) (bfd *, void *, PDR *);
int i;
struct symtab *st = NULL;
FDR *fh;
struct linetable *lines;
CORE_ADDR lowest_pdr_addr = 0;
int last_symtab_ended = 0;
if (pst->readin)
return;
pst->readin = 1;
for (i = 0; i < pst->number_of_dependencies; i++)
if (!pst->dependencies[i]->readin)
{
if (info_verbose)
{
fputs_filtered (" ", gdb_stdout);
wrap_here ("");
fputs_filtered ("and ", gdb_stdout);
wrap_here ("");
printf_filtered ("%s...",
pst->dependencies[i]->filename);
wrap_here ("");
gdb_flush (gdb_stdout);
}
psymtab_to_symtab_1 (pst->dependencies[i],
pst->dependencies[i]->filename);
}
if (pst->n_global_syms == 0 && pst->n_static_syms == 0
&& pst->textlow == 0 && pst->texthigh == 0)
return;
cur_bfd = CUR_BFD (pst);
debug_swap = DEBUG_SWAP (pst);
debug_info = DEBUG_INFO (pst);
pending_list = PENDING_LIST (pst);
external_sym_size = debug_swap->external_sym_size;
external_pdr_size = debug_swap->external_pdr_size;
swap_sym_in = debug_swap->swap_sym_in;
swap_pdr_in = debug_swap->swap_pdr_in;
current_objfile = pst->objfile;
cur_fd = FDR_IDX (pst);
fh = ((cur_fd == -1)
? (FDR *) NULL
: debug_info->fdr + cur_fd);
cur_fdr = fh;
processing_gcc_compilation = 0;
if (fh != (FDR *) NULL && fh->csym >= 2)
{
SYMR sh;
(*swap_sym_in) (cur_bfd,
((char *) debug_info->external_sym
+ (fh->isymBase + 1) * external_sym_size),
&sh);
if (strcmp (debug_info->ss + fh->issBase + sh.iss,
stabs_symbol) == 0)
{
processing_gcc_compilation = 2;
}
}
if (processing_gcc_compilation != 0)
{
if (fh->csym <= 2)
{
current_objfile = NULL;
return;
}
for (cur_sdx = 2; cur_sdx < fh->csym; cur_sdx++)
{
SYMR sh;
char *name;
CORE_ADDR valu;
(*swap_sym_in) (cur_bfd,
(((char *) debug_info->external_sym)
+ (fh->isymBase + cur_sdx) * external_sym_size),
&sh);
name = debug_info->ss + fh->issBase + sh.iss;
valu = sh.value;
if (ECOFF_IS_STAB (&sh) || (name[0] == '#'))
{
int type_code = ECOFF_UNMARK_STAB (sh.index);
if (type_code & N_STAB)
{
if (type_code == N_SO
&& last_source_file
&& previous_stab_code != (unsigned char) N_SO
&& *name == '\000')
{
valu += ANOFFSET (pst->section_offsets,
SECT_OFF_TEXT (pst->objfile));
previous_stab_code = N_SO;
st = end_symtab (valu, pst->objfile,
SECT_OFF_TEXT (pst->objfile));
end_stabs ();
last_symtab_ended = 1;
}
else
{
last_symtab_ended = 0;
process_one_symbol (type_code, 0, valu, name, NULL,
pst->section_offsets, pst->objfile);
}
}
else if (name[0] == '#')
{
process_one_symbol (N_SLINE, 0, valu, name, NULL,
pst->section_offsets, pst->objfile);
}
if (type_code == N_FUN)
{
struct mdebug_extra_func_info *e =
((struct mdebug_extra_func_info *)
obstack_alloc (¤t_objfile->objfile_obstack,
sizeof (struct mdebug_extra_func_info)));
struct symbol *s = new_symbol (MDEBUG_EFI_SYMBOL_NAME);
memset (e, 0, sizeof (struct mdebug_extra_func_info));
SYMBOL_DOMAIN (s) = LABEL_DOMAIN;
SYMBOL_CLASS (s) = LOC_CONST;
SYMBOL_TYPE (s) = mdebug_type_void;
SYMBOL_VALUE (s) = (long) e;
e->pdr.framereg = -1;
add_symbol_to_list (s, &local_symbols);
}
}
else if (sh.st == stLabel)
{
if (sh.index == indexNil)
{
;
}
else
{
valu += ANOFFSET (pst->section_offsets, SECT_OFF_TEXT (pst->objfile));
record_line (current_subfile, sh.index, valu, 0,
NORMAL_LT_ENTRY);
}
}
else if (sh.st == stProc || sh.st == stStaticProc
|| sh.st == stStatic || sh.st == stEnd)
;
else
complaint (&symfile_complaints, _("unknown stabs symbol %s"), name);
}
if (! last_symtab_ended)
{
st = end_symtab (pst->texthigh, pst->objfile, SECT_OFF_TEXT (pst->objfile));
end_stabs ();
}
if (fh->cpd > 0)
{
PDR *pr_block;
struct cleanup *old_chain;
char *pdr_ptr;
char *pdr_end;
PDR *pdr_in;
PDR *pdr_in_end;
pr_block = (PDR *) xmalloc (fh->cpd * sizeof (PDR));
old_chain = make_cleanup (xfree, pr_block);
pdr_ptr = ((char *) debug_info->external_pdr
+ fh->ipdFirst * external_pdr_size);
pdr_end = pdr_ptr + fh->cpd * external_pdr_size;
pdr_in = pr_block;
for (;
pdr_ptr < pdr_end;
pdr_ptr += external_pdr_size, pdr_in++)
{
(*swap_pdr_in) (cur_bfd, pdr_ptr, pdr_in);
if (pdr_in == pr_block)
lowest_pdr_addr = pdr_in->adr;
else if (pdr_in->adr < lowest_pdr_addr)
lowest_pdr_addr = pdr_in->adr;
}
pdr_in = pr_block;
pdr_in_end = pdr_in + fh->cpd;
for (; pdr_in < pdr_in_end; pdr_in++)
parse_procedure (pdr_in, st, pst);
do_cleanups (old_chain);
}
}
else
{
int maxlines;
EXTR *ext_ptr;
if (fh == 0)
{
maxlines = 0;
st = new_symtab ("unknown", 0, pst->objfile);
}
else
{
maxlines = 2 * fh->cline;
st = new_symtab (pst->filename, maxlines, pst->objfile);
st->language = PST_PRIVATE (pst)->pst_language;
}
psymtab_language = st->language;
lines = LINETABLE (st);
push_parse_stack ();
top_stack->cur_st = st;
top_stack->cur_block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (st),
STATIC_BLOCK);
BLOCK_START (top_stack->cur_block) = pst->textlow;
BLOCK_END (top_stack->cur_block) = 0;
top_stack->blocktype = stFile;
top_stack->cur_type = 0;
top_stack->procadr = 0;
top_stack->numargs = 0;
found_ecoff_debugging_info = 0;
if (fh)
{
char *sym_ptr;
char *sym_end;
sym_ptr = ((char *) debug_info->external_sym
+ fh->isymBase * external_sym_size);
sym_end = sym_ptr + fh->csym * external_sym_size;
while (sym_ptr < sym_end)
{
SYMR sh;
int c;
(*swap_sym_in) (cur_bfd, sym_ptr, &sh);
c = parse_symbol (&sh,
debug_info->external_aux + fh->iauxBase,
sym_ptr, fh->fBigendian, pst->section_offsets, pst->objfile);
sym_ptr += c * external_sym_size;
}
if (fh->cpd > 0)
{
PDR *pr_block;
struct cleanup *old_chain;
char *pdr_ptr;
char *pdr_end;
PDR *pdr_in;
PDR *pdr_in_end;
pr_block = (PDR *) xmalloc (fh->cpd * sizeof (PDR));
old_chain = make_cleanup (xfree, pr_block);
pdr_ptr = ((char *) debug_info->external_pdr
+ fh->ipdFirst * external_pdr_size);
pdr_end = pdr_ptr + fh->cpd * external_pdr_size;
pdr_in = pr_block;
for (;
pdr_ptr < pdr_end;
pdr_ptr += external_pdr_size, pdr_in++)
{
(*swap_pdr_in) (cur_bfd, pdr_ptr, pdr_in);
if (pdr_in == pr_block)
lowest_pdr_addr = pdr_in->adr;
else if (pdr_in->adr < lowest_pdr_addr)
lowest_pdr_addr = pdr_in->adr;
}
parse_lines (fh, pr_block, lines, maxlines, pst, lowest_pdr_addr);
if (lines->nitems < fh->cline)
lines = shrink_linetable (lines);
pdr_in = pr_block;
pdr_in_end = pdr_in + fh->cpd;
for (; pdr_in < pdr_in_end; pdr_in++)
parse_procedure (pdr_in, 0, pst);
do_cleanups (old_chain);
}
}
LINETABLE (st) = lines;
top_stack->cur_st = st;
top_stack->cur_block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (top_stack->cur_st),
GLOBAL_BLOCK);
top_stack->blocktype = stFile;
ext_ptr = PST_PRIVATE (pst)->extern_tab;
for (i = PST_PRIVATE (pst)->extern_count; --i >= 0; ext_ptr++)
parse_external (ext_ptr, fh->fBigendian, pst->section_offsets, pst->objfile);
if (info_verbose && n_undef_symbols)
{
printf_filtered (_("File %s contains %d unresolved references:"),
st->filename, n_undef_symbols);
printf_filtered ("\n\t%4d variables\n\t%4d procedures\n\t%4d labels\n",
n_undef_vars, n_undef_procs, n_undef_labels);
n_undef_symbols = n_undef_labels = n_undef_vars = n_undef_procs = 0;
}
pop_parse_stack ();
st->primary = 1;
sort_blocks (st);
}
pst->symtab = st;
current_objfile = NULL;
}
static int
has_opaque_xref (FDR *fh, SYMR *sh)
{
TIR tir;
union aux_ext *ax;
RNDXR rn[1];
unsigned int rf;
if (sh->index == indexNil)
return 0;
ax = debug_info->external_aux + fh->iauxBase + sh->index;
(*debug_swap->swap_tir_in) (fh->fBigendian, &ax->a_ti, &tir);
if (tir.bt != btStruct && tir.bt != btUnion && tir.bt != btEnum)
return 0;
ax++;
(*debug_swap->swap_rndx_in) (fh->fBigendian, &ax->a_rndx, rn);
if (rn->rfd == 0xfff)
rf = AUX_GET_ISYM (fh->fBigendian, ax + 1);
else
rf = rn->rfd;
if (rf != -1)
return 0;
return 1;
}
static int
cross_ref (int fd, union aux_ext *ax, struct type **tpp, enum type_code type_code,
char **pname, int bigend, char *sym_name)
{
RNDXR rn[1];
unsigned int rf;
int result = 1;
FDR *fh;
char *esh;
SYMR sh;
int xref_fd;
struct mdebug_pending *pend;
*tpp = (struct type *) NULL;
(*debug_swap->swap_rndx_in) (bigend, &ax->a_rndx, rn);
if (rn->rfd == 0xfff)
{
result++;
rf = AUX_GET_ISYM (bigend, ax + 1);
}
else
{
rf = rn->rfd;
}
if (rf == -1)
{
*pname = "<undefined>";
*tpp = init_type (type_code, 0, TYPE_FLAG_STUB, (char *) NULL, current_objfile);
return result;
}
if (rn->rfd == 0xfff && rn->index == 0)
{
*pname = "<undefined>";
return result;
}
fh = get_rfd (fd, rf);
xref_fd = fh - debug_info->fdr;
if (rn->index >= fh->csym)
{
*pname = "<illegal>";
bad_rfd_entry_complaint (sym_name, xref_fd, rn->index);
return result;
}
esh = ((char *) debug_info->external_sym
+ ((fh->isymBase + rn->index)
* debug_swap->external_sym_size));
(*debug_swap->swap_sym_in) (cur_bfd, esh, &sh);
if ((sh.sc != scInfo
|| (sh.st != stBlock && sh.st != stTypedef && sh.st != stIndirect
&& sh.st != stStruct && sh.st != stUnion
&& sh.st != stEnum))
&& (sh.st != stBlock || !SC_IS_COMMON (sh.sc)))
{
*pname = "<illegal>";
bad_rfd_entry_complaint (sym_name, xref_fd, rn->index);
return result;
}
*pname = debug_info->ss + fh->issBase + sh.iss;
pend = is_pending_symbol (fh, esh);
if (pend)
*tpp = pend->t;
else
{
if ((sh.iss == 0 && sh.st == stTypedef) || sh.st == stIndirect)
{
TIR tir;
(*debug_swap->swap_tir_in) (bigend,
&(debug_info->external_aux
+ fh->iauxBase + sh.index)->a_ti,
&tir);
if (tir.tq0 != tqNil)
complaint (&symfile_complaints,
_("illegal tq0 in forward typedef for %s"), sym_name);
switch (tir.bt)
{
case btVoid:
*tpp = init_type (type_code, 0, 0, (char *) NULL,
current_objfile);
*pname = "<undefined>";
break;
case btStruct:
case btUnion:
case btEnum:
cross_ref (xref_fd,
(debug_info->external_aux
+ fh->iauxBase + sh.index + 1),
tpp, type_code, pname,
fh->fBigendian, sym_name);
break;
case btTypedef:
*tpp = parse_type (xref_fd,
debug_info->external_aux + fh->iauxBase,
sh.index,
(int *) NULL,
fh->fBigendian,
debug_info->ss + fh->issBase + sh.iss);
add_pending (fh, esh, *tpp);
break;
default:
complaint (&symfile_complaints,
_("illegal bt %d in forward typedef for %s"), tir.bt,
sym_name);
*tpp = init_type (type_code, 0, 0, (char *) NULL,
current_objfile);
break;
}
return result;
}
else if (sh.st == stTypedef)
{
*tpp = parse_type (xref_fd,
debug_info->external_aux + fh->iauxBase,
sh.index,
(int *) NULL,
fh->fBigendian,
debug_info->ss + fh->issBase + sh.iss);
}
else
{
*tpp = init_type (type_code, 0, 0, (char *) NULL, current_objfile);
}
add_pending (fh, esh, *tpp);
}
return result;
}
static struct symbol *
mylookup_symbol (char *name, struct block *block,
domain_enum domain, enum address_class class)
{
struct dict_iterator iter;
int inc;
struct symbol *sym;
inc = name[0];
ALL_BLOCK_SYMBOLS (block, iter, sym)
{
if (DEPRECATED_SYMBOL_NAME (sym)[0] == inc
&& SYMBOL_DOMAIN (sym) == domain
&& SYMBOL_CLASS (sym) == class
&& strcmp (DEPRECATED_SYMBOL_NAME (sym), name) == 0)
return sym;
}
block = BLOCK_SUPERBLOCK (block);
if (block)
return mylookup_symbol (name, block, domain, class);
return 0;
}
static void
add_symbol (struct symbol *s, struct block *b)
{
dict_add_symbol (BLOCK_DICT (b), s);
}
static void
add_block (struct block *b, struct symtab *s)
{
struct blockvector *bv = BLOCKVECTOR (s);
bv = (struct blockvector *) xrealloc ((void *) bv,
(sizeof (struct blockvector)
+ BLOCKVECTOR_NBLOCKS (bv)
* sizeof (bv->block)));
if (bv != BLOCKVECTOR (s))
BLOCKVECTOR (s) = bv;
BLOCKVECTOR_BLOCK (bv, BLOCKVECTOR_NBLOCKS (bv)++) = b;
}
static int
add_line (struct linetable *lt, int lineno, CORE_ADDR adr, int last)
{
if (lineno == 0)
lineno = 1;
if (last == 0)
last = -2;
if (last == lineno)
return lineno;
lt->item[lt->nitems].line = lineno;
lt->item[lt->nitems++].pc = adr << 2;
return lineno;
}
static int
compare_blocks (const void *arg1, const void *arg2)
{
LONGEST addr_diff;
struct block **b1 = (struct block **) arg1;
struct block **b2 = (struct block **) arg2;
addr_diff = (BLOCK_START ((*b1))) - (BLOCK_START ((*b2)));
if (addr_diff == 0)
return (BLOCK_END ((*b2))) - (BLOCK_END ((*b1)));
return addr_diff;
}
static void
sort_blocks (struct symtab *s)
{
struct blockvector *bv = BLOCKVECTOR (s);
if (BLOCKVECTOR_NBLOCKS (bv) <= 2)
{
if (BLOCK_END (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)) == 0)
BLOCK_START (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)) = 0;
if (BLOCK_END (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)) == 0)
BLOCK_START (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)) = 0;
return;
}
if (BLOCKVECTOR_NBLOCKS (bv) > 3)
qsort (&BLOCKVECTOR_BLOCK (bv, FIRST_LOCAL_BLOCK),
BLOCKVECTOR_NBLOCKS (bv) - FIRST_LOCAL_BLOCK,
sizeof (struct block *),
compare_blocks);
{
CORE_ADDR high = 0;
int i, j = BLOCKVECTOR_NBLOCKS (bv);
for (i = FIRST_LOCAL_BLOCK; i < j; i++)
if (high < BLOCK_END (BLOCKVECTOR_BLOCK (bv, i)))
high = BLOCK_END (BLOCKVECTOR_BLOCK (bv, i));
BLOCK_END (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)) = high;
}
BLOCK_START (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)) =
BLOCK_START (BLOCKVECTOR_BLOCK (bv, FIRST_LOCAL_BLOCK));
BLOCK_START (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)) =
BLOCK_START (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK));
BLOCK_END (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)) =
BLOCK_END (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK));
}
static struct symtab *
new_symtab (char *name, int maxlines, struct objfile *objfile)
{
struct symtab *s = allocate_symtab (name, objfile);
LINETABLE (s) = new_linetable (maxlines);
BLOCKVECTOR (s) = new_bvect (2);
BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK)
= new_block (NON_FUNCTION_BLOCK);
BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK)
= new_block (NON_FUNCTION_BLOCK);
BLOCK_SUPERBLOCK (BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK)) =
BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK);
s->free_code = free_linetable;
s->debugformat = obsavestring ("ECOFF", 5,
&objfile->objfile_obstack);
return (s);
}
static struct partial_symtab *
new_psymtab (char *name, struct objfile *objfile)
{
struct partial_symtab *psymtab;
psymtab = allocate_psymtab (name, objfile);
psymtab->section_offsets = objfile->section_offsets;
psymtab->read_symtab_private = ((char *)
obstack_alloc (&objfile->objfile_obstack,
sizeof (struct symloc)));
memset (psymtab->read_symtab_private, 0, sizeof (struct symloc));
CUR_BFD (psymtab) = cur_bfd;
DEBUG_SWAP (psymtab) = debug_swap;
DEBUG_INFO (psymtab) = debug_info;
PENDING_LIST (psymtab) = pending_list;
psymtab->read_symtab = mdebug_psymtab_to_symtab;
return (psymtab);
}
static struct linetable *
new_linetable (int size)
{
struct linetable *l;
size = (size - 1) * sizeof (l->item) + sizeof (struct linetable);
l = (struct linetable *) xmalloc (size);
l->nitems = 0;
l->lines_are_chars = 0;
return l;
}
static struct linetable *
shrink_linetable (struct linetable *lt)
{
return (struct linetable *) xrealloc ((void *) lt,
(sizeof (struct linetable)
+ ((lt->nitems - 1)
* sizeof (lt->item))));
}
static struct blockvector *
new_bvect (int nblocks)
{
struct blockvector *bv;
int size;
size = sizeof (struct blockvector) + nblocks * sizeof (struct block *);
bv = (struct blockvector *) xzalloc (size);
BLOCKVECTOR_NBLOCKS (bv) = nblocks;
return bv;
}
static struct block *
new_block (enum block_type type)
{
struct block *retval = xzalloc (sizeof (struct block));
retval->ranges = NULL;
if (type == FUNCTION_BLOCK)
BLOCK_DICT (retval) = dict_create_linear_expandable ();
else
BLOCK_DICT (retval) = dict_create_hashed_expandable ();
return retval;
}
static struct symbol *
new_symbol (char *name)
{
struct symbol *s = ((struct symbol *)
obstack_alloc (¤t_objfile->objfile_obstack,
sizeof (struct symbol)));
memset (s, 0, sizeof (*s));
SYMBOL_LANGUAGE (s) = psymtab_language;
SYMBOL_SET_NAMES (s, name, strlen (name), current_objfile);
return s;
}
static struct type *
new_type (char *name)
{
struct type *t;
t = alloc_type (current_objfile);
TYPE_NAME (t) = name;
return t;
}
void
elfmdebug_build_psymtabs (struct objfile *objfile,
const struct ecoff_debug_swap *swap, asection *sec)
{
bfd *abfd = objfile->obfd;
struct ecoff_debug_info *info;
struct cleanup *back_to;
init_minimal_symbol_collection ();
back_to = make_cleanup_discard_minimal_symbols ();
info = ((struct ecoff_debug_info *)
obstack_alloc (&objfile->objfile_obstack,
sizeof (struct ecoff_debug_info)));
if (!(*swap->read_debug_info) (abfd, sec, info))
error (_("Error reading ECOFF debugging information: %s"),
bfd_errmsg (bfd_get_error ()));
mdebug_build_psymtabs (objfile, swap, info);
install_minimal_symbols (objfile);
do_cleanups (back_to);
}
void
_initialize_mdebugread (void)
{
mdebug_type_void =
init_type (TYPE_CODE_VOID, 1,
0,
"void", (struct objfile *) NULL);
mdebug_type_char =
init_type (TYPE_CODE_INT, 1,
0,
"char", (struct objfile *) NULL);
mdebug_type_unsigned_char =
init_type (TYPE_CODE_INT, 1,
TYPE_FLAG_UNSIGNED,
"unsigned char", (struct objfile *) NULL);
mdebug_type_short =
init_type (TYPE_CODE_INT, 2,
0,
"short", (struct objfile *) NULL);
mdebug_type_unsigned_short =
init_type (TYPE_CODE_INT, 2,
TYPE_FLAG_UNSIGNED,
"unsigned short", (struct objfile *) NULL);
mdebug_type_int_32 =
init_type (TYPE_CODE_INT, 4,
0,
"int", (struct objfile *) NULL);
mdebug_type_unsigned_int_32 =
init_type (TYPE_CODE_INT, 4,
TYPE_FLAG_UNSIGNED,
"unsigned int", (struct objfile *) NULL);
mdebug_type_int_64 =
init_type (TYPE_CODE_INT, 8,
0,
"int", (struct objfile *) NULL);
mdebug_type_unsigned_int_64 =
init_type (TYPE_CODE_INT, 8,
TYPE_FLAG_UNSIGNED,
"unsigned int", (struct objfile *) NULL);
mdebug_type_long_32 =
init_type (TYPE_CODE_INT, 4,
0,
"long", (struct objfile *) NULL);
mdebug_type_unsigned_long_32 =
init_type (TYPE_CODE_INT, 4,
TYPE_FLAG_UNSIGNED,
"unsigned long", (struct objfile *) NULL);
mdebug_type_long_64 =
init_type (TYPE_CODE_INT, 8,
0,
"long", (struct objfile *) NULL);
mdebug_type_unsigned_long_64 =
init_type (TYPE_CODE_INT, 8,
TYPE_FLAG_UNSIGNED,
"unsigned long", (struct objfile *) NULL);
mdebug_type_long_long_64 =
init_type (TYPE_CODE_INT, 8,
0,
"long long", (struct objfile *) NULL);
mdebug_type_unsigned_long_long_64 =
init_type (TYPE_CODE_INT, 8,
TYPE_FLAG_UNSIGNED,
"unsigned long long", (struct objfile *) NULL);
mdebug_type_adr_32 =
init_type (TYPE_CODE_PTR, 4,
TYPE_FLAG_UNSIGNED,
"adr_32", (struct objfile *) NULL);
TYPE_TARGET_TYPE (mdebug_type_adr_32) = mdebug_type_void;
mdebug_type_adr_64 =
init_type (TYPE_CODE_PTR, 8,
TYPE_FLAG_UNSIGNED,
"adr_64", (struct objfile *) NULL);
TYPE_TARGET_TYPE (mdebug_type_adr_64) = mdebug_type_void;
mdebug_type_float =
init_type (TYPE_CODE_FLT, TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
0,
"float", (struct objfile *) NULL);
mdebug_type_double =
init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
0,
"double", (struct objfile *) NULL);
mdebug_type_complex =
init_type (TYPE_CODE_COMPLEX, 2 * TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
0,
"complex", (struct objfile *) NULL);
TYPE_TARGET_TYPE (mdebug_type_complex) = mdebug_type_float;
mdebug_type_double_complex =
init_type (TYPE_CODE_COMPLEX, 2 * TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
0,
"double complex", (struct objfile *) NULL);
TYPE_TARGET_TYPE (mdebug_type_double_complex) = mdebug_type_double;
mdebug_type_string =
init_type (TYPE_CODE_STRING,
TARGET_CHAR_BIT / TARGET_CHAR_BIT,
0, "string",
(struct objfile *) NULL);
mdebug_type_fixed_dec =
init_type (TYPE_CODE_INT,
TARGET_INT_BIT / TARGET_CHAR_BIT,
0, "fixed decimal",
(struct objfile *) NULL);
mdebug_type_float_dec =
init_type (TYPE_CODE_ERROR,
TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
0, "floating decimal",
(struct objfile *) NULL);
nodebug_func_symbol_type = init_type (TYPE_CODE_FUNC, 1, 0,
"<function, no debug info>", NULL);
TYPE_TARGET_TYPE (nodebug_func_symbol_type) = mdebug_type_int;
nodebug_var_symbol_type =
init_type (TYPE_CODE_INT, TARGET_INT_BIT / HOST_CHAR_BIT, 0,
"<variable, no debug info>", NULL);
}