#include "defs.h"
#include "symtab.h"
#include "gdbtypes.h"
#include "hpread.h"
#include "demangle.h"
#include "complaints.h"
static struct complaint hpread_unhandled_end_common_complaint =
{
"unhandled symbol in hp-symtab-read.c: DNTT_TYPE_COMMON/DNTT_TYPE_END.\n", 0, 0
};
static struct complaint hpread_unhandled_type_complaint =
{
"hpread_type_translate: unhandled type code.", 0, 0
};
static struct complaint hpread_struct_complaint =
{
"hpread_read_struct_type: expected SVAR type...", 0, 0
};
static struct complaint hpread_array_complaint =
{
"error in hpread_array_type.", 0, 0
};
static struct complaint hpread_type_lookup_complaint =
{
"error in hpread_type_lookup().", 0, 0
};
static struct complaint hpread_unexpected_end_complaint =
{
"internal error in hp-symtab-read.c: Unexpected DNTT_TYPE_END kind.", 0, 0
};
static struct complaint hpread_tagdef_complaint =
{
"error processing class tagdef", 0, 0
};
static struct complaint hpread_unhandled_common_complaint =
{
"unhandled symbol in hp-symtab-read.c: DNTT_TYPE_COMMON.", 0, 0
};
static struct complaint hpread_unhandled_blockdata_complaint =
{
"unhandled symbol in hp-symtab-read.c: DNTT_TYPE_BLOCKDATA.", 0, 0
};
static unsigned long hpread_get_scope_start (sltpointer, struct objfile *);
static unsigned long hpread_get_line (sltpointer, struct objfile *);
static CORE_ADDR hpread_get_location (sltpointer, struct objfile *);
static void hpread_psymtab_to_symtab_1 (struct partial_symtab *);
void hpread_psymtab_to_symtab (struct partial_symtab *);
static struct symtab *hpread_expand_symtab
(struct objfile *, int, int, CORE_ADDR, int,
struct section_offsets *, char *);
static int hpread_type_translate (dnttpointer);
static struct type **hpread_lookup_type (dnttpointer, struct objfile *);
static struct type *hpread_alloc_type (dnttpointer, struct objfile *);
static struct type *hpread_read_enum_type
(dnttpointer, union dnttentry *, struct objfile *);
static struct type *hpread_read_function_type
(dnttpointer, union dnttentry *, struct objfile *, int);
static struct type *hpread_read_doc_function_type
(dnttpointer, union dnttentry *, struct objfile *, int);
static struct type *hpread_read_struct_type
(dnttpointer, union dnttentry *, struct objfile *);
static struct type *hpread_get_nth_template_arg (struct objfile *, int);
static struct type *hpread_read_templ_arg_type
(dnttpointer, union dnttentry *, struct objfile *, char *);
static struct type *hpread_read_set_type
(dnttpointer, union dnttentry *, struct objfile *);
static struct type *hpread_read_array_type
(dnttpointer, union dnttentry *dn_bufp, struct objfile *objfile);
static struct type *hpread_read_subrange_type
(dnttpointer, union dnttentry *, struct objfile *);
static struct type *hpread_type_lookup (dnttpointer, struct objfile *);
static sltpointer hpread_record_lines
(struct subfile *, sltpointer, sltpointer, struct objfile *, CORE_ADDR);
static void hpread_process_one_debug_symbol
(union dnttentry *, char *, struct section_offsets *,
struct objfile *, CORE_ADDR, int, char *, int, int *);
static int hpread_get_scope_depth (union dnttentry *, struct objfile *, int);
static void fix_static_member_physnames
(struct type *, char *, struct objfile *);
static void fixup_class_method_type
(struct type *, struct type *, struct objfile *);
static void hpread_adjust_bitoffsets (struct type *, int);
static dnttpointer hpread_get_next_skip_over_anon_unions
(int, dnttpointer, union dnttentry **, struct objfile *);
extern int hp_som_som_object_present;
static struct type *fixup_class = NULL;
static struct type *fixup_method = NULL;
static unsigned long
hpread_get_scope_start (sltpointer index, struct objfile *objfile)
{
union sltentry *sl_bufp;
sl_bufp = hpread_get_slt (index, objfile);
return sl_bufp->sspec.backptr.dnttp.index;
}
static unsigned long
hpread_get_line (sltpointer index, struct objfile *objfile)
{
union sltentry *sl_bufp;
sl_bufp = hpread_get_slt (index, objfile);
return sl_bufp->snorm.line;
}
static CORE_ADDR
hpread_get_location (sltpointer index, struct objfile *objfile)
{
union sltentry *sl_bufp;
int i;
sl_bufp = hpread_get_slt (index, objfile);
if (sl_bufp->snorm.sltdesc == SLT_END)
{
for (i = 0; ((sl_bufp->snorm.sltdesc != SLT_NORMAL) &&
(sl_bufp->snorm.sltdesc != SLT_NORMAL_OFFSET) &&
(sl_bufp->snorm.sltdesc != SLT_EXIT)); i++)
sl_bufp = hpread_get_slt (index - i, objfile);
if (sl_bufp->snorm.sltdesc == SLT_NORMAL_OFFSET)
return sl_bufp->snormoff.address;
else
return sl_bufp->snorm.address;
}
for (i = 0; ((sl_bufp->snorm.sltdesc != SLT_NORMAL) &&
(sl_bufp->snorm.sltdesc != SLT_NORMAL_OFFSET) &&
(sl_bufp->snorm.sltdesc != SLT_EXIT)); i++)
sl_bufp = hpread_get_slt (index + i, objfile);
if (sl_bufp->snorm.sltdesc == SLT_NORMAL_OFFSET)
return sl_bufp->snormoff.address;
else
return sl_bufp->snorm.address;
}
int
hpread_has_name (enum dntt_entry_type kind)
{
switch (kind)
{
case DNTT_TYPE_SRCFILE:
case DNTT_TYPE_MODULE:
case DNTT_TYPE_FUNCTION:
case DNTT_TYPE_DOC_FUNCTION:
case DNTT_TYPE_ENTRY:
case DNTT_TYPE_IMPORT:
case DNTT_TYPE_LABEL:
case DNTT_TYPE_FPARAM:
case DNTT_TYPE_SVAR:
case DNTT_TYPE_DVAR:
case DNTT_TYPE_CONST:
case DNTT_TYPE_TYPEDEF:
case DNTT_TYPE_TAGDEF:
case DNTT_TYPE_MEMENUM:
case DNTT_TYPE_FIELD:
case DNTT_TYPE_SA:
case DNTT_TYPE_BLOCKDATA:
case DNTT_TYPE_MEMFUNC:
case DNTT_TYPE_DOC_MEMFUNC:
return 1;
case DNTT_TYPE_BEGIN:
case DNTT_TYPE_END:
case DNTT_TYPE_POINTER:
case DNTT_TYPE_ENUM:
case DNTT_TYPE_SET:
case DNTT_TYPE_ARRAY:
case DNTT_TYPE_STRUCT:
case DNTT_TYPE_UNION:
case DNTT_TYPE_VARIANT:
case DNTT_TYPE_FILE:
case DNTT_TYPE_FUNCTYPE:
case DNTT_TYPE_SUBRANGE:
case DNTT_TYPE_WITH:
case DNTT_TYPE_COMMON:
case DNTT_TYPE_COBSTRUCT:
case DNTT_TYPE_XREF:
case DNTT_TYPE_MACRO:
case DNTT_TYPE_CLASS_SCOPE:
case DNTT_TYPE_REFERENCE:
case DNTT_TYPE_PTRMEM:
case DNTT_TYPE_PTRMEMFUNC:
case DNTT_TYPE_CLASS:
case DNTT_TYPE_GENFIELD:
case DNTT_TYPE_VFUNC:
case DNTT_TYPE_MEMACCESS:
case DNTT_TYPE_INHERITANCE:
case DNTT_TYPE_FRIEND_CLASS:
case DNTT_TYPE_FRIEND_FUNC:
case DNTT_TYPE_MODIFIER:
case DNTT_TYPE_OBJECT_ID:
case DNTT_TYPE_TEMPLATE:
case DNTT_TYPE_TEMPLATE_ARG:
case DNTT_TYPE_FUNC_TEMPLATE:
case DNTT_TYPE_LINK:
default:
return 0;
}
}
static void
hpread_psymtab_to_symtab_1 (struct partial_symtab *pst)
{
struct cleanup *old_chain;
int i;
if (!pst)
return;
if (pst->readin)
{
fprintf (stderr, "Psymtab for %s already read in. Shouldn't happen.\n",
pst->filename);
return;
}
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);
}
hpread_psymtab_to_symtab_1 (pst->dependencies[i]);
}
if (LDSYMLEN (pst))
{
buildsym_init ();
old_chain = make_cleanup (really_free_pendings, 0);
pst->symtab =
hpread_expand_symtab (pst->objfile, LDSYMOFF (pst), LDSYMLEN (pst),
pst->textlow, pst->texthigh - pst->textlow,
pst->section_offsets, pst->filename);
sort_symtab_syms (pst->symtab);
do_cleanups (old_chain);
}
pst->readin = 1;
}
void
hpread_psymtab_to_symtab (struct partial_symtab *pst)
{
if (!pst)
return;
if (pst->readin)
{
fprintf (stderr, "Psymtab for %s already read in. Shouldn't happen.\n",
pst->filename);
return;
}
processing_gcc_compilation = 0;
if (LDSYMLEN (pst) || pst->number_of_dependencies)
{
if (info_verbose)
{
printf_filtered ("Reading in symbols for %s...", pst->filename);
gdb_flush (gdb_stdout);
}
hpread_psymtab_to_symtab_1 (pst);
scan_file_globals (pst->objfile);
if (info_verbose)
printf_filtered ("done.\n");
}
}
static struct symtab *
hpread_expand_symtab (struct objfile *objfile, int sym_offset, int sym_size,
CORE_ADDR text_offset, int text_size,
struct section_offsets *section_offsets, char *filename)
{
char *namestring;
union dnttentry *dn_bufp;
unsigned max_symnum;
int at_module_boundary = 0;
int sym_index = sym_offset / sizeof (struct dntt_type_block);
current_objfile = objfile;
subfile_stack = 0;
last_source_file = 0;
if (current_demangling_style != edg_demangling)
{
set_demangling_style (HP_DEMANGLING_STYLE_STRING);
}
dn_bufp = hpread_get_lntt (sym_index, objfile);
if (!((dn_bufp->dblock.kind == (unsigned char) DNTT_TYPE_SRCFILE) ||
(dn_bufp->dblock.kind == (unsigned char) DNTT_TYPE_MODULE)))
{
start_symtab ("globals", NULL, 0);
record_debugformat ("HP");
}
max_symnum = sym_size / sizeof (struct dntt_type_block);
for (symnum = 0;
symnum < max_symnum;
symnum++)
{
QUIT;
dn_bufp = hpread_get_lntt (sym_index + symnum, objfile);
if (dn_bufp->dblock.extension)
continue;
SET_NAMESTRING (dn_bufp, &namestring, objfile);
hpread_process_one_debug_symbol (dn_bufp, namestring, section_offsets,
objfile, text_offset, text_size,
filename, symnum + sym_index,
&at_module_boundary
);
if (at_module_boundary == -1)
break;
}
current_objfile = NULL;
hp_som_som_object_present = 1;
return end_symtab (text_offset + text_size, objfile, SECT_OFF_TEXT (objfile));
}
static int
hpread_type_translate (dnttpointer typep)
{
if (!typep.dntti.immediate)
{
error ("error in hpread_type_translate\n.");
return FT_VOID;
}
switch (typep.dntti.type)
{
case HP_TYPE_BOOLEAN:
case HP_TYPE_BOOLEAN_S300_COMPAT:
case HP_TYPE_BOOLEAN_VAX_COMPAT:
return FT_BOOLEAN;
case HP_TYPE_CHAR:
case HP_TYPE_WIDE_CHAR:
return FT_CHAR;
case HP_TYPE_INT:
if (typep.dntti.bitlength <= 8)
return FT_SIGNED_CHAR;
if (typep.dntti.bitlength <= 16)
return FT_SHORT;
if (typep.dntti.bitlength <= 32)
return FT_INTEGER;
return FT_LONG_LONG;
case HP_TYPE_LONG:
if (typep.dntti.bitlength <= 8)
return FT_SIGNED_CHAR;
return FT_LONG;
case HP_TYPE_UNSIGNED_LONG:
if (typep.dntti.bitlength <= 8)
return FT_UNSIGNED_CHAR;
if (typep.dntti.bitlength <= 16)
return FT_UNSIGNED_SHORT;
if (typep.dntti.bitlength <= 32)
return FT_UNSIGNED_LONG;
return FT_UNSIGNED_LONG_LONG;
case HP_TYPE_UNSIGNED_INT:
if (typep.dntti.bitlength <= 8)
return FT_UNSIGNED_CHAR;
if (typep.dntti.bitlength <= 16)
return FT_UNSIGNED_SHORT;
if (typep.dntti.bitlength <= 32)
return FT_UNSIGNED_INTEGER;
return FT_UNSIGNED_LONG_LONG;
case HP_TYPE_REAL:
case HP_TYPE_REAL_3000:
case HP_TYPE_DOUBLE:
if (typep.dntti.bitlength == 64)
return FT_DBL_PREC_FLOAT;
if (typep.dntti.bitlength == 128)
return FT_EXT_PREC_FLOAT;
return FT_FLOAT;
case HP_TYPE_COMPLEX:
case HP_TYPE_COMPLEXS3000:
if (typep.dntti.bitlength == 128)
return FT_DBL_PREC_COMPLEX;
if (typep.dntti.bitlength == 192)
return FT_EXT_PREC_COMPLEX;
return FT_COMPLEX;
case HP_TYPE_VOID:
return FT_VOID;
case HP_TYPE_STRING200:
case HP_TYPE_LONGSTRING200:
case HP_TYPE_FTN_STRING_SPEC:
case HP_TYPE_MOD_STRING_SPEC:
case HP_TYPE_MOD_STRING_3000:
case HP_TYPE_FTN_STRING_S300_COMPAT:
case HP_TYPE_FTN_STRING_VAX_COMPAT:
return FT_STRING;
case HP_TYPE_TEMPLATE_ARG:
return FT_TEMPLATE_ARG;
case HP_TYPE_TEXT:
case HP_TYPE_FLABEL:
case HP_TYPE_PACKED_DECIMAL:
case HP_TYPE_ANYPOINTER:
case HP_TYPE_GLOBAL_ANYPOINTER:
case HP_TYPE_LOCAL_ANYPOINTER:
default:
warning ("hpread_type_translate: unhandled type code.\n");
return FT_VOID;
}
}
static struct type **
hpread_lookup_type (dnttpointer hp_type, struct objfile *objfile)
{
unsigned old_len;
int index = hp_type.dnttp.index;
int size_changed = 0;
if (hp_type.dntti.immediate)
return NULL;
if (index < LNTT_SYMCOUNT (objfile))
{
if (index >= TYPE_VECTOR_LENGTH (objfile))
{
old_len = TYPE_VECTOR_LENGTH (objfile);
if (old_len == 0)
{
TYPE_VECTOR_LENGTH (objfile) = LNTT_SYMCOUNT (objfile) + GNTT_SYMCOUNT (objfile);
TYPE_VECTOR (objfile) = (struct type **)
xmmalloc (objfile->md, TYPE_VECTOR_LENGTH (objfile) * sizeof (struct type *));
memset (&TYPE_VECTOR (objfile)[old_len], 0,
(TYPE_VECTOR_LENGTH (objfile) - old_len) *
sizeof (struct type *));
}
while (index >= TYPE_VECTOR_LENGTH (objfile))
{
TYPE_VECTOR_LENGTH (objfile) *= 2;
size_changed = 1;
}
if (size_changed)
{
TYPE_VECTOR (objfile) = (struct type **)
xmrealloc (objfile->md,
(char *) TYPE_VECTOR (objfile),
(TYPE_VECTOR_LENGTH (objfile) * sizeof (struct type *)));
memset (&TYPE_VECTOR (objfile)[old_len], 0,
(TYPE_VECTOR_LENGTH (objfile) - old_len) *
sizeof (struct type *));
}
}
return &TYPE_VECTOR (objfile)[index];
}
else
return NULL;
}
static struct type *
hpread_alloc_type (dnttpointer hp_type, struct objfile *objfile)
{
struct type **type_addr;
type_addr = hpread_lookup_type (hp_type, objfile);
if (*type_addr == 0)
{
*type_addr = alloc_type (objfile);
TYPE_CPLUS_SPECIFIC (*type_addr)
= (struct cplus_struct_type *) &cplus_struct_default;
}
return *type_addr;
}
static struct type *
hpread_read_enum_type (dnttpointer hp_type, union dnttentry *dn_bufp,
struct objfile *objfile)
{
struct type *type;
struct pending **symlist, *osyms, *syms;
struct pending *local_list = NULL;
int o_nsyms, nsyms = 0;
dnttpointer mem;
union dnttentry *memp;
char *name;
long n;
struct symbol *sym;
type = hpread_alloc_type (hp_type, objfile);
if (TYPE_CODE (type) == TYPE_CODE_ENUM)
return type;
TYPE_LENGTH (type) = dn_bufp->denum.bitlength / 8;
symlist = &file_symbols;
osyms = *symlist;
o_nsyms = osyms ? osyms->nsyms : 0;
mem = dn_bufp->denum.firstmem;
while (mem.word && mem.word != DNTTNIL)
{
memp = hpread_get_lntt (mem.dnttp.index, objfile);
name = VT (objfile) + memp->dmember.name;
sym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack,
sizeof (struct symbol));
memset (sym, 0, sizeof (struct symbol));
SYMBOL_NAME (sym) = obsavestring (name, strlen (name),
&objfile->symbol_obstack);
SYMBOL_CLASS (sym) = LOC_CONST;
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
SYMBOL_VALUE (sym) = memp->dmember.value;
add_symbol_to_list (sym, symlist);
nsyms++;
mem = memp->dmember.nextmem;
}
TYPE_CODE (type) = TYPE_CODE_ENUM;
TYPE_FLAGS (type) &= ~TYPE_FLAG_STUB;
TYPE_NFIELDS (type) = nsyms;
TYPE_FIELDS (type) = (struct field *)
obstack_alloc (&objfile->type_obstack, sizeof (struct field) * nsyms);
for (syms = *symlist, n = 0; syms; syms = syms->next)
{
int j = 0;
if (syms == osyms)
j = o_nsyms;
for (; j < syms->nsyms; j++, n++)
{
struct symbol *xsym = syms->symbol[j];
SYMBOL_TYPE (xsym) = type;
TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (xsym);
TYPE_FIELD_BITPOS (type, n) = SYMBOL_VALUE (xsym);
TYPE_FIELD_BITSIZE (type, n) = 0;
}
if (syms == osyms)
break;
}
return type;
}
static struct type *
hpread_read_function_type (dnttpointer hp_type, union dnttentry *dn_bufp,
struct objfile *objfile, int newblock)
{
struct type *type, *type1;
struct pending *syms;
struct pending *local_list = NULL;
int nsyms = 0;
dnttpointer param;
union dnttentry *paramp;
char *name;
long n;
struct symbol *sym;
int record_args = 1;
type = hpread_alloc_type (hp_type, objfile);
if (TYPE_CODE (type) == TYPE_CODE_FUNC)
{
record_args = 0;
}
else
{
if (dn_bufp->dblock.kind == DNTT_TYPE_FUNCTION ||
dn_bufp->dblock.kind == DNTT_TYPE_MEMFUNC)
type1 = lookup_function_type (hpread_type_lookup (dn_bufp->dfunc.retval,
objfile));
else if (dn_bufp->dblock.kind == DNTT_TYPE_FUNCTYPE)
type1 = lookup_function_type (hpread_type_lookup (dn_bufp->dfunctype.retval,
objfile));
else
type1 = lookup_function_type (hpread_type_lookup (dn_bufp->dfunc_template.retval,
objfile));
memcpy ((char *) type, (char *) type1, sizeof (struct type));
TYPE_FLAGS (type) |= TYPE_FLAG_INCOMPLETE;
}
if (dn_bufp->dblock.kind == DNTT_TYPE_FUNCTION ||
dn_bufp->dblock.kind == DNTT_TYPE_MEMFUNC)
param = dn_bufp->dfunc.firstparam;
else if (dn_bufp->dblock.kind == DNTT_TYPE_FUNCTYPE)
param = dn_bufp->dfunctype.firstparam;
else
param = dn_bufp->dfunc_template.firstparam;
while (param.word && param.word != DNTTNIL)
{
paramp = hpread_get_lntt (param.dnttp.index, objfile);
nsyms++;
param = paramp->dfparam.nextparam;
name = VT (objfile) + paramp->dfparam.name;
sym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack,
sizeof (struct symbol));
(void) memset (sym, 0, sizeof (struct symbol));
SYMBOL_NAME (sym) = obsavestring (name, strlen (name),
&objfile->symbol_obstack);
if (paramp->dfparam.regparam)
SYMBOL_CLASS (sym) = LOC_REGPARM;
else if (paramp->dfparam.indirect)
SYMBOL_CLASS (sym) = LOC_REF_ARG;
else
SYMBOL_CLASS (sym) = LOC_ARG;
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
if (paramp->dfparam.copyparam)
{
SYMBOL_VALUE (sym) = paramp->dfparam.location;
#ifdef HPREAD_ADJUST_STACK_ADDRESS
SYMBOL_VALUE (sym)
+= HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile));
#endif
#if 0
SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR;
#endif
}
else
SYMBOL_VALUE (sym) = paramp->dfparam.location;
SYMBOL_TYPE (sym) = hpread_type_lookup (paramp->dfparam.type, objfile);
add_symbol_to_list (sym, &local_list);
}
if (!record_args)
goto finish;
TYPE_NFIELDS (type) = nsyms;
TYPE_FIELDS (type) = (struct field *)
obstack_alloc (&objfile->type_obstack,
sizeof (struct field) * nsyms);
for (syms = local_list, n = 0; syms; syms = syms->next)
{
int j = 0;
for (j = 0; j < syms->nsyms; j++, n++)
{
struct symbol *xsym = syms->symbol[j];
TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (xsym);
TYPE_FIELD_TYPE (type, n) = SYMBOL_TYPE (xsym);
TYPE_FIELD_ARTIFICIAL (type, n) = 0;
TYPE_FIELD_BITSIZE (type, n) = 0;
}
}
TYPE_FLAGS (type) &= ~(TYPE_FLAG_INCOMPLETE);
if (fixup_class && (fixup_method == type))
{
fixup_class_method_type (fixup_class, fixup_method, objfile);
fixup_class = NULL;
fixup_method = NULL;
}
finish:
if (newblock)
param_symbols = local_list;
return type;
}
static struct type *
hpread_read_doc_function_type (dnttpointer hp_type, union dnttentry *dn_bufp,
struct objfile *objfile, int newblock)
{
struct type *type, *type1;
struct pending *syms;
struct pending *local_list = NULL;
int nsyms = 0;
dnttpointer param;
union dnttentry *paramp;
char *name;
long n;
struct symbol *sym;
int record_args = 1;
type = hpread_alloc_type (hp_type, objfile);
if (TYPE_CODE (type) == TYPE_CODE_FUNC)
{
record_args = 0;
}
else
{
if (dn_bufp->dblock.kind == DNTT_TYPE_DOC_FUNCTION ||
dn_bufp->dblock.kind == DNTT_TYPE_DOC_MEMFUNC)
type1 = lookup_function_type (hpread_type_lookup (dn_bufp->ddocfunc.retval,
objfile));
memcpy ((char *) type, (char *) type1, sizeof (struct type));
TYPE_FLAGS (type) |= TYPE_FLAG_INCOMPLETE;
}
if (dn_bufp->dblock.kind == DNTT_TYPE_DOC_FUNCTION ||
dn_bufp->dblock.kind == DNTT_TYPE_DOC_MEMFUNC)
param = dn_bufp->ddocfunc.firstparam;
while (param.word && param.word != DNTTNIL)
{
paramp = hpread_get_lntt (param.dnttp.index, objfile);
nsyms++;
param = paramp->dfparam.nextparam;
name = VT (objfile) + paramp->dfparam.name;
sym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack,
sizeof (struct symbol));
(void) memset (sym, 0, sizeof (struct symbol));
SYMBOL_NAME (sym) = name;
if (paramp->dfparam.regparam)
SYMBOL_CLASS (sym) = LOC_REGPARM;
else if (paramp->dfparam.indirect)
SYMBOL_CLASS (sym) = LOC_REF_ARG;
else
SYMBOL_CLASS (sym) = LOC_ARG;
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
if (paramp->dfparam.copyparam)
{
SYMBOL_VALUE (sym) = paramp->dfparam.location;
#ifdef HPREAD_ADJUST_STACK_ADDRESS
SYMBOL_VALUE (sym)
+= HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile));
#endif
#if 0
SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR;
#endif
}
else
SYMBOL_VALUE (sym) = paramp->dfparam.location;
SYMBOL_TYPE (sym) = hpread_type_lookup (paramp->dfparam.type, objfile);
add_symbol_to_list (sym, &local_list);
}
if (!record_args)
goto finish;
TYPE_NFIELDS (type) = nsyms;
TYPE_FIELDS (type) = (struct field *)
obstack_alloc (&objfile->type_obstack,
sizeof (struct field) * nsyms);
for (syms = local_list, n = 0; syms; syms = syms->next)
{
int j = 0;
for (j = 0; j < syms->nsyms; j++, n++)
{
struct symbol *xsym = syms->symbol[j];
TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (xsym);
TYPE_FIELD_TYPE (type, n) = SYMBOL_TYPE (xsym);
TYPE_FIELD_ARTIFICIAL (type, n) = 0;
TYPE_FIELD_BITSIZE (type, n) = 0;
}
}
TYPE_FLAGS (type) &= ~(TYPE_FLAG_INCOMPLETE);
if (fixup_class && (fixup_method == type))
{
fixup_class_method_type (fixup_class, fixup_method, objfile);
fixup_class = NULL;
fixup_method = NULL;
}
finish:
if (newblock)
param_symbols = local_list;
return type;
}
static struct type *current_template = NULL;
static struct type *
hpread_read_struct_type (dnttpointer hp_type, union dnttentry *dn_bufp,
struct objfile *objfile)
{
struct nextfield
{
struct nextfield *next;
struct field field;
unsigned char attributes;
#define ATTR_VIRTUAL 1
#define ATTR_PRIVATE 2
#define ATTR_PROTECT 3
};
struct next_fn_field
{
struct next_fn_field *next;
struct fn_fieldlist field;
struct fn_field fn_field;
int num_fn_fields;
};
struct next_template
{
struct next_template *next;
struct template_arg arg;
};
struct next_instantiation
{
struct next_instantiation *next;
struct type *t;
};
struct type *type;
struct type *baseclass;
struct type *memtype;
struct nextfield *list = 0, *tmp_list = 0;
struct next_fn_field *fn_list = 0;
struct next_fn_field *fn_p;
struct next_template *t_new, *t_list = 0;
struct nextfield *new;
struct next_fn_field *fn_new;
struct next_instantiation *i_new, *i_list = 0;
int n, nfields = 0, n_fn_fields = 0, n_fn_fields_total = 0;
int n_base_classes = 0, n_templ_args = 0;
int ninstantiations = 0;
dnttpointer field, fn_field, parent;
union dnttentry *fieldp, *fn_fieldp, *parentp;
int i;
int static_member = 0;
int const_member = 0;
int volatile_member = 0;
unsigned long vtbl_offset;
int need_bitvectors = 0;
char *method_name = NULL;
char *method_alias = NULL;
type = hpread_alloc_type (hp_type, objfile);
if ((TYPE_CODE (type) == TYPE_CODE_STRUCT) ||
(TYPE_CODE (type) == TYPE_CODE_UNION) ||
(TYPE_CODE (type) == TYPE_CODE_CLASS) ||
(TYPE_CODE (type) == TYPE_CODE_TEMPLATE))
return type;
if (dn_bufp->dblock.kind == DNTT_TYPE_STRUCT)
{
TYPE_CODE (type) = TYPE_CODE_STRUCT;
TYPE_LENGTH (type) = dn_bufp->dstruct.bitlength / 8;
}
else if (dn_bufp->dblock.kind == DNTT_TYPE_UNION)
{
TYPE_CODE (type) = TYPE_CODE_UNION;
TYPE_LENGTH (type) = dn_bufp->dunion.bitlength / 8;
}
else if (dn_bufp->dblock.kind == DNTT_TYPE_CLASS)
{
TYPE_CODE (type) = TYPE_CODE_CLASS;
TYPE_LENGTH (type) = dn_bufp->dclass.bitlength / 8;
allocate_cplus_struct_type (type);
TYPE_DECLARED_TYPE (type) = dn_bufp->dclass.class_decl;
}
else if (dn_bufp->dblock.kind == DNTT_TYPE_TEMPLATE)
{
TYPE_CODE (type) = TYPE_CODE_TEMPLATE;
allocate_cplus_struct_type (type);
TYPE_DECLARED_TYPE (type) = DECLARED_TYPE_TEMPLATE;
}
else
return type;
TYPE_FLAGS (type) &= ~TYPE_FLAG_STUB;
if (dn_bufp->dblock.kind == DNTT_TYPE_CLASS)
{
parent = dn_bufp->dclass.parentlist;
while (parent.word && parent.word != DNTTNIL)
{
parentp = hpread_get_lntt (parent.dnttp.index, objfile);
new = (struct nextfield *) alloca (sizeof (struct nextfield));
new->next = list;
list = new;
FIELD_BITSIZE (list->field) = 0;
baseclass = hpread_type_lookup (parentp->dinheritance.classname,
objfile);
FIELD_TYPE (list->field) = baseclass;
list->field.name = type_name_no_tag (FIELD_TYPE (list->field));
list->attributes = 0;
if (parentp->dinheritance.Virtual)
{
B_SET (&(list->attributes), ATTR_VIRTUAL);
parentp->dinheritance.offset = -1;
}
else
FIELD_BITPOS (list->field) = parentp->dinheritance.offset;
switch (parentp->dinheritance.visibility)
{
case 1:
B_SET (&(list->attributes), ATTR_PROTECT);
break;
case 2:
B_SET (&(list->attributes), ATTR_PRIVATE);
break;
}
n_base_classes++;
nfields++;
parent = parentp->dinheritance.next;
}
}
if (dn_bufp->dblock.kind == DNTT_TYPE_TEMPLATE)
{
current_template = type;
field = dn_bufp->dtemplate.arglist;
while (field.word && field.word != DNTTNIL)
{
fieldp = hpread_get_lntt (field.dnttp.index, objfile);
if (fieldp->dblock.kind != DNTT_TYPE_TEMPLATE_ARG)
{
warning ("Invalid debug info: Template argument entry is of wrong kind");
break;
}
n_templ_args++;
t_new = (struct next_template *) alloca (sizeof (struct next_template));
t_new->next = t_list;
t_list = t_new;
t_list->arg.name = VT (objfile) + fieldp->dtempl_arg.name;
t_list->arg.type = hpread_read_templ_arg_type (field, fieldp,
objfile, t_list->arg.name);
field = fieldp->dtempl_arg.nextarg;
}
}
TYPE_NTEMPLATE_ARGS (type) = n_templ_args;
if (n_templ_args > 0)
TYPE_TEMPLATE_ARGS (type) = (struct template_arg *)
obstack_alloc (&objfile->type_obstack, sizeof (struct template_arg) * n_templ_args);
for (n = n_templ_args; t_list; t_list = t_list->next)
{
n -= 1;
TYPE_TEMPLATE_ARG (type, n) = t_list->arg;
}
if (dn_bufp->dblock.kind == DNTT_TYPE_STRUCT)
field = dn_bufp->dstruct.firstfield;
else if (dn_bufp->dblock.kind == DNTT_TYPE_UNION)
field = dn_bufp->dunion.firstfield;
else if (dn_bufp->dblock.kind == DNTT_TYPE_CLASS)
field = dn_bufp->dclass.memberlist;
else if (dn_bufp->dblock.kind == DNTT_TYPE_TEMPLATE)
field = dn_bufp->dtemplate.memberlist;
else
field.word = DNTTNIL;
while (field.word && field.word != DNTTNIL)
{
fieldp = hpread_get_lntt (field.dnttp.index, objfile);
vtbl_offset = 0;
static_member = 0;
const_member = 0;
volatile_member = 0;
if (fieldp->dblock.kind == DNTT_TYPE_GENFIELD)
{
fn_field = fieldp->dgenfield.field;
fn_fieldp = hpread_get_lntt (fn_field.dnttp.index, objfile);
if (fn_fieldp->dblock.kind == DNTT_TYPE_VFUNC)
{
vtbl_offset = fn_fieldp->dvfunc.vtbl_offset;
fn_field = fn_fieldp->dvfunc.funcptr;
fn_fieldp = hpread_get_lntt (fn_field.dnttp.index, objfile);
}
if (fn_fieldp->dblock.kind == DNTT_TYPE_MODIFIER)
{
static_member = fn_fieldp->dmodifier.m_static;
const_member = fn_fieldp->dmodifier.m_const;
volatile_member = fn_fieldp->dmodifier.m_volatile;
fn_field = fn_fieldp->dmodifier.type;
fn_fieldp = hpread_get_lntt (fn_field.dnttp.index, objfile);
}
if ((fn_fieldp->dblock.kind == DNTT_TYPE_MEMFUNC) ||
(fn_fieldp->dblock.kind == DNTT_TYPE_FUNCTION) ||
(fn_fieldp->dblock.kind == DNTT_TYPE_DOC_MEMFUNC) ||
(fn_fieldp->dblock.kind == DNTT_TYPE_DOC_FUNCTION))
{
short ix = 0;
memtype = hpread_type_lookup (fn_field, objfile);
if (TYPE_INCOMPLETE (memtype))
{
TYPE_FLAGS (type) |= TYPE_FLAG_INCOMPLETE;
if (fixup_class)
warning ("Two classes to fix up for method?? Type information may be incorrect for some classes.");
if (fixup_method)
warning ("Two methods to be fixed up at once?? Type information may be incorrect for some classes.");
fixup_class = type;
fixup_method = memtype;
}
method_name = (char *) (VT (objfile) + fn_fieldp->dfunc.name);
method_alias = (char *) (VT (objfile) + fn_fieldp->dfunc.alias);
if (!method_name ||
!*method_name ||
cplus_mangle_opname (method_name, DMGL_ANSI))
{
char *tmp_name = cplus_demangle (method_alias, DMGL_ANSI);
char *op_string = strstr (tmp_name, "operator");
method_name = xmalloc (strlen (op_string) + 1);
strcpy (method_name, op_string);
}
fn_p = fn_list;
while (fn_p)
{
if (STREQ (fn_p->field.name, method_name))
break;
fn_p = fn_p->next;
}
if (!fn_p)
{
fn_new = (struct next_fn_field *) alloca (sizeof (struct next_fn_field));
fn_new->next = fn_list;
fn_list = fn_new;
fn_list->field.name = method_name;
fn_list->field.fn_fields = (struct fn_field *) xmalloc (5 * (sizeof (struct fn_field)));
fn_list->field.length = 1;
fn_list->num_fn_fields = 5;
fn_p = fn_list;
ix = 0;
n_fn_fields++;
}
else
{
if (++(fn_p->field.length) > fn_p->num_fn_fields)
{
fn_p->field.fn_fields
= (struct fn_field *) xrealloc (fn_p->field.fn_fields,
(fn_p->num_fn_fields + 5) * sizeof (struct fn_field));
fn_p->num_fn_fields += 5;
}
ix = fn_p->field.length - 1;
}
if ((fn_fieldp->dfunc.language == HP_LANGUAGE_CPLUSPLUS) &&
method_alias &&
*method_alias)
fn_p->field.fn_fields[ix].physname = method_alias;
else
fn_p->field.fn_fields[ix].physname = method_name;
if (TYPE_INCOMPLETE (memtype))
{
fn_p->field.fn_fields[ix].type = NULL;
fn_p->field.fn_fields[ix].args = NULL;
}
else
{
fn_p->field.fn_fields[ix].type = memtype;
fn_p->field.fn_fields[ix].type->type_specific.arg_types =
(struct type **) obstack_alloc (&objfile->type_obstack,
sizeof (struct type *) * (memtype->nfields + 1));
for (i = 0; i < memtype->nfields; i++)
fn_p->field.fn_fields[ix].type->type_specific.arg_types[i] = memtype->fields[i].type;
fn_p->field.fn_fields[ix].type->type_specific.arg_types[memtype->nfields] = builtin_type_void;
fn_p->field.fn_fields[ix].args =
(struct type **) obstack_alloc (&objfile->type_obstack,
sizeof (struct type *) * (memtype->nfields + 1));
for (i = 0; i < memtype->nfields; i++)
fn_p->field.fn_fields[ix].args[i] = memtype->fields[i].type;
fn_p->field.fn_fields[ix].args[memtype->nfields] = NULL;
}
if (static_member)
fn_p->field.fn_fields[ix].voffset = VOFFSET_STATIC;
else
fn_p->field.fn_fields[ix].voffset = vtbl_offset ? vtbl_offset + 1 : 0;
if (vtbl_offset != 0)
fn_p->field.fn_fields[ix].fcontext = type;
else
fn_p->field.fn_fields[ix].fcontext = NULL;
fn_p->field.fn_fields[ix].is_const = const_member;
fn_p->field.fn_fields[ix].is_volatile = volatile_member;
switch (fieldp->dgenfield.visibility)
{
case 1:
fn_p->field.fn_fields[ix].is_protected = 1;
fn_p->field.fn_fields[ix].is_private = 0;
break;
case 2:
fn_p->field.fn_fields[ix].is_protected = 0;
fn_p->field.fn_fields[ix].is_private = 1;
break;
default:
fn_p->field.fn_fields[ix].is_protected = 0;
fn_p->field.fn_fields[ix].is_private = 0;
}
fn_p->field.fn_fields[ix].is_stub = 0;
if ((fn_fieldp->dblock.kind == DNTT_TYPE_MEMFUNC) ||
(fn_fieldp->dblock.kind == DNTT_TYPE_DOC_MEMFUNC))
fn_p->field.fn_fields[ix].is_inlined = 1;
else
fn_p->field.fn_fields[ix].is_inlined = 0;
fn_p->field.fn_fields[ix].dummy = 0;
n_fn_fields_total++;
}
else if (fn_fieldp->dblock.kind == DNTT_TYPE_SVAR)
{
new = (struct nextfield *) alloca (sizeof (struct nextfield));
new->next = list;
list = new;
list->field.name = VT (objfile) + fn_fieldp->dsvar.name;
FIELD_BITSIZE (list->field) = -1;
SET_FIELD_PHYSNAME (list->field, 0);
memtype = hpread_type_lookup (fn_fieldp->dsvar.type, objfile);
FIELD_TYPE (list->field) = memtype;
list->attributes = 0;
switch (fieldp->dgenfield.visibility)
{
case 1:
B_SET (&(list->attributes), ATTR_PROTECT);
break;
case 2:
B_SET (&(list->attributes), ATTR_PRIVATE);
break;
}
nfields++;
}
else if (fn_fieldp->dblock.kind == DNTT_TYPE_FIELD)
{
if (!fn_fieldp->dfield.a_union)
warning ("Debug info inconsistent: FIELD of anonymous union doesn't have a_union bit set");
new = (struct nextfield *) alloca (sizeof (struct nextfield));
new->next = list;
list = new;
list->field.name = VT (objfile) + fn_fieldp->dfield.name;
FIELD_BITPOS (list->field) = fn_fieldp->dfield.bitoffset;
if (fn_fieldp->dfield.bitlength % 8)
list->field.bitsize = fn_fieldp->dfield.bitlength;
else
list->field.bitsize = 0;
memtype = hpread_type_lookup (fn_fieldp->dfield.type, objfile);
list->field.type = memtype;
list->attributes = 0;
switch (fn_fieldp->dfield.visibility)
{
case 1:
B_SET (&(list->attributes), ATTR_PROTECT);
break;
case 2:
B_SET (&(list->attributes), ATTR_PRIVATE);
break;
}
nfields++;
}
else if (fn_fieldp->dblock.kind == DNTT_TYPE_SVAR)
{
if (!fn_fieldp->dsvar.a_union)
warning ("Debug info inconsistent: SVAR field in anonymous union doesn't have a_union bit set");
new = (struct nextfield *) alloca (sizeof (struct nextfield));
new->next = list;
list = new;
list->field.name = VT (objfile) + fn_fieldp->dsvar.name;
FIELD_BITPOS (list->field) = 0;
FIELD_BITSIZE (list->field) = 0;
memtype = hpread_type_lookup (fn_fieldp->dsvar.type, objfile);
list->field.type = memtype;
list->attributes = 0;
nfields++;
}
else if (fn_fieldp->dblock.kind == DNTT_TYPE_DVAR)
{
if (!fn_fieldp->ddvar.a_union)
warning ("Debug info inconsistent: DVAR field in anonymous union doesn't have a_union bit set");
new = (struct nextfield *) alloca (sizeof (struct nextfield));
new->next = list;
list = new;
list->field.name = VT (objfile) + fn_fieldp->ddvar.name;
FIELD_BITPOS (list->field) = 0;
FIELD_BITSIZE (list->field) = 0;
memtype = hpread_type_lookup (fn_fieldp->ddvar.type, objfile);
list->field.type = memtype;
list->attributes = 0;
nfields++;
}
else
{
if ((fn_fieldp->dblock.kind != DNTT_TYPE_MEMACCESS) &&
(fn_fieldp->dblock.kind != DNTT_TYPE_MEMENUM) &&
(fn_fieldp->dblock.kind != DNTT_TYPE_FUNC_TEMPLATE))
warning ("Internal error: Unexpected debug record kind %d found following DNTT_GENFIELD",
fn_fieldp->dblock.kind);
}
field = fieldp->dgenfield.nextfield;
}
else if (fieldp->dblock.kind == DNTT_TYPE_FIELD)
{
struct type *anon_union_type;
new = (struct nextfield *) alloca (sizeof (struct nextfield));
new->next = list;
list = new;
list->field.name = VT (objfile) + fieldp->dfield.name;
if (fieldp->dfield.staticmem)
{
FIELD_BITPOS (list->field) = -1;
FIELD_BITSIZE (list->field) = 0;
}
else
{
FIELD_BITPOS (list->field) = fieldp->dfield.bitoffset;
if (fieldp->dfield.bitlength % 8)
FIELD_BITSIZE (list->field) = fieldp->dfield.bitlength;
else
FIELD_BITSIZE (list->field) = 0;
}
memtype = hpread_type_lookup (fieldp->dfield.type, objfile);
FIELD_TYPE (list->field) = memtype;
list->attributes = 0;
switch (fieldp->dfield.visibility)
{
case 1:
B_SET (&(list->attributes), ATTR_PROTECT);
break;
case 2:
B_SET (&(list->attributes), ATTR_PRIVATE);
break;
}
nfields++;
field = hpread_get_next_skip_over_anon_unions (1, field, &fieldp, objfile);
}
else
{
warning ("Internal error: unexpected DNTT kind %d encountered as field of struct",
fieldp->dblock.kind);
warning ("Skipping remaining fields of struct");
break;
}
}
if (dn_bufp->dblock.kind == DNTT_TYPE_TEMPLATE)
{
ninstantiations = 0;
field = dn_bufp->dtemplate.expansions;
while (field.word && field.word != DNTTNIL)
{
fieldp = hpread_get_lntt (field.dnttp.index, objfile);
if (fieldp->dblock.kind != DNTT_TYPE_TAGDEF)
break;
i_new = (struct next_instantiation *) alloca (sizeof (struct next_instantiation));
i_new->next = i_list;
i_list = i_new;
i_list->t = hpread_type_lookup (field, objfile);
ninstantiations++;
field = fieldp->dtag.type;
fieldp = hpread_get_lntt (field.dnttp.index, objfile);
if (fieldp->dblock.kind != DNTT_TYPE_CLASS)
break;
field = fieldp->dclass.nextexp;
}
}
TYPE_NINSTANTIATIONS (type) = ninstantiations;
if (ninstantiations > 0)
TYPE_INSTANTIATIONS (type) = (struct type **)
obstack_alloc (&objfile->type_obstack, sizeof (struct type *) * ninstantiations);
for (n = ninstantiations; i_list; i_list = i_list->next)
{
n -= 1;
TYPE_INSTANTIATION (type, n) = i_list->t;
}
TYPE_NFIELDS (type) = nfields;
TYPE_N_BASECLASSES (type) = n_base_classes;
TYPE_FIELDS (type) = (struct field *)
obstack_alloc (&objfile->type_obstack, sizeof (struct field) * nfields);
for (n = nfields, tmp_list = list; tmp_list; tmp_list = tmp_list->next)
{
n -= 1;
TYPE_FIELD (type, n) = tmp_list->field;
}
TYPE_NFN_FIELDS (type) = n_fn_fields;
TYPE_NFN_FIELDS_TOTAL (type) = n_fn_fields_total;
TYPE_FN_FIELDLISTS (type) = (struct fn_fieldlist *)
obstack_alloc (&objfile->type_obstack, sizeof (struct fn_fieldlist) * n_fn_fields);
for (n = n_fn_fields; fn_list; fn_list = fn_list->next)
{
n -= 1;
TYPE_FN_FIELDLIST (type, n) = fn_list->field;
}
for (n = nfields, tmp_list = list; tmp_list; tmp_list = tmp_list->next)
{
n -= 1;
if (tmp_list->attributes)
{
need_bitvectors = 1;
break;
}
}
if (need_bitvectors)
{
ALLOCATE_CPLUS_STRUCT_TYPE (type);
TYPE_FIELD_VIRTUAL_BITS (type) =
(B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
B_CLRALL (TYPE_FIELD_VIRTUAL_BITS (type), nfields);
TYPE_FIELD_PRIVATE_BITS (type) =
(B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
B_CLRALL (TYPE_FIELD_PRIVATE_BITS (type), nfields);
TYPE_FIELD_PROTECTED_BITS (type) =
(B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
B_CLRALL (TYPE_FIELD_PROTECTED_BITS (type), nfields);
TYPE_FIELD_IGNORE_BITS (type) =
(B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
B_CLRALL (TYPE_FIELD_IGNORE_BITS (type), nfields);
while (nfields-- > 0)
{
if (B_TST (&(list->attributes), ATTR_VIRTUAL))
SET_TYPE_FIELD_VIRTUAL (type, nfields);
if (B_TST (&(list->attributes), ATTR_PRIVATE))
SET_TYPE_FIELD_PRIVATE (type, nfields);
if (B_TST (&(list->attributes), ATTR_PROTECT))
SET_TYPE_FIELD_PROTECTED (type, nfields);
list = list->next;
}
}
else
{
TYPE_FIELD_VIRTUAL_BITS (type) = NULL;
TYPE_FIELD_PROTECTED_BITS (type) = NULL;
TYPE_FIELD_PRIVATE_BITS (type) = NULL;
}
if (has_vtable (type))
{
TYPE_RUNTIME_PTR (type) = (struct runtime_info *) xmalloc (sizeof (struct runtime_info));
TYPE_VTABLE (type) = 1;
TYPE_PRIMARY_BASE (type) = primary_base_class (type);
TYPE_VIRTUAL_BASE_LIST (type) = virtual_base_list (type);
}
else
TYPE_RUNTIME_PTR (type) = NULL;
if (hpread_get_scope_depth (dn_bufp, objfile, 1 ))
{
TYPE_LOCALTYPE_PTR (type) = (struct local_type_info *) xmalloc (sizeof (struct local_type_info));
TYPE_LOCALTYPE_FILE (type) = (char *) xmalloc (strlen (current_subfile->name) + 1);
strcpy (TYPE_LOCALTYPE_FILE (type), current_subfile->name);
if (current_subfile->line_vector && (current_subfile->line_vector->nitems > 0))
TYPE_LOCALTYPE_LINE (type) = current_subfile->line_vector->item[current_subfile->line_vector->nitems - 1].line;
else
TYPE_LOCALTYPE_LINE (type) = 0;
}
else
TYPE_LOCALTYPE_PTR (type) = NULL;
current_template = NULL;
finish_cv_type (type);
return type;
}
static void
fix_static_member_physnames (struct type *type, char *class_name,
struct objfile *objfile)
{
int i;
if (TYPE_CODE (type) != TYPE_CODE_STRUCT)
return;
for (i = 0; i < TYPE_NFIELDS (type); i++)
if (TYPE_FIELD_STATIC (type, i))
{
if (TYPE_FIELD_STATIC_PHYSNAME (type, i))
return;
SET_FIELD_PHYSNAME (type->fields[i],
obstack_alloc (&objfile->type_obstack,
strlen (class_name) + strlen (TYPE_FIELD_NAME (type, i)) + 3));
strcpy (TYPE_FIELD_STATIC_PHYSNAME (type, i), class_name);
strcat (TYPE_FIELD_STATIC_PHYSNAME (type, i), "::");
strcat (TYPE_FIELD_STATIC_PHYSNAME (type, i), TYPE_FIELD_NAME (type, i));
}
}
static void
fixup_class_method_type (struct type *class, struct type *method,
struct objfile *objfile)
{
int i, j, k;
if (!class || !method || !objfile)
return;
if ((TYPE_CODE (class) != TYPE_CODE_CLASS) &&
(TYPE_CODE (class) != TYPE_CODE_UNION))
return;
for (i = 0; i < TYPE_NFN_FIELDS (class); i++)
for (j = 0; j < TYPE_FN_FIELDLIST_LENGTH (class, i); j++)
if (TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i), j) == NULL)
{
TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i), j) = method;
(TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i), j))->type_specific.arg_types
= (struct type **) obstack_alloc (&objfile->type_obstack,
sizeof (struct type *) * (method->nfields + 1));
for (k = 0; k < method->nfields; k++)
(TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i), j))->type_specific.arg_types[k] = method->fields[k].type;
(TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i), j))->type_specific.arg_types[method->nfields] = builtin_type_void;
(TYPE_FN_FIELD (TYPE_FN_FIELDLIST1 (class, i), j)).args
= (struct type **) obstack_alloc (&objfile->type_obstack,
sizeof (struct type *) * (method->nfields + 1));
for (k = 0; k < method->nfields; k++)
(TYPE_FN_FIELD (TYPE_FN_FIELDLIST1 (class, i), j)).args[k] = method->fields[k].type;
(TYPE_FN_FIELD (TYPE_FN_FIELDLIST1 (class, i), j)).args[method->nfields] = NULL;
goto finish;
}
finish:
TYPE_FLAGS (class) &= ~TYPE_FLAG_INCOMPLETE;
}
static struct type *
hpread_get_nth_template_arg (struct objfile *objfile, int n)
{
if (current_template != NULL)
return TYPE_TEMPLATE_ARG (current_template, n).type;
else
return lookup_fundamental_type (objfile, FT_TEMPLATE_ARG);
}
static struct type *
hpread_read_templ_arg_type (dnttpointer hp_type, union dnttentry *dn_bufp,
struct objfile *objfile, char *name)
{
struct type *type;
type = hpread_alloc_type (hp_type, objfile);
if (TYPE_CODE (type) == TYPE_CODE_TEMPLATE_ARG)
return type;
TYPE_CODE (type) = TYPE_CODE_TEMPLATE_ARG;
TYPE_LENGTH (type) = 0;
TYPE_NFIELDS (type) = 0;
TYPE_NAME (type) = name;
return type;
}
static struct type *
hpread_read_set_type (dnttpointer hp_type, union dnttentry *dn_bufp,
struct objfile *objfile)
{
struct type *type;
type = hpread_alloc_type (hp_type, objfile);
if (TYPE_CODE (type) == TYPE_CODE_SET)
return type;
TYPE_CODE (type) = TYPE_CODE_SET;
TYPE_LENGTH (type) = dn_bufp->dset.bitlength / 8;
TYPE_NFIELDS (type) = 0;
TYPE_TARGET_TYPE (type) = hpread_type_lookup (dn_bufp->dset.subtype,
objfile);
return type;
}
static struct type *
hpread_read_array_type (dnttpointer hp_type, union dnttentry *dn_bufp,
struct objfile *objfile)
{
struct type *type;
type = hpread_alloc_type (hp_type, objfile);
TYPE_CODE (type) = TYPE_CODE_ARRAY;
if (!((dn_bufp->darray.arrayisbytes && dn_bufp->darray.elemisbytes) ||
(!dn_bufp->darray.arrayisbytes && !dn_bufp->darray.elemisbytes)))
{
warning ("error in hpread_array_type.\n");
return NULL;
}
else if (dn_bufp->darray.arraylength == 0x7fffffff)
{
TYPE_LENGTH (type) = 0;
}
else if (dn_bufp->darray.arrayisbytes)
TYPE_LENGTH (type) = dn_bufp->darray.arraylength;
else
TYPE_LENGTH (type) = dn_bufp->darray.arraylength / 8;
TYPE_TARGET_TYPE (type) = hpread_type_lookup (dn_bufp->darray.elemtype,
objfile);
TYPE_NFIELDS (type) = 1;
TYPE_FIELDS (type) = (struct field *)
obstack_alloc (&objfile->type_obstack, sizeof (struct field));
TYPE_FIELD_TYPE (type, 0) = hpread_type_lookup (dn_bufp->darray.indextype,
objfile);
return type;
}
static struct type *
hpread_read_subrange_type (dnttpointer hp_type, union dnttentry *dn_bufp,
struct objfile *objfile)
{
struct type *type;
type = hpread_alloc_type (hp_type, objfile);
if (TYPE_CODE (type) == TYPE_CODE_RANGE)
return type;
TYPE_CODE (type) = TYPE_CODE_RANGE;
TYPE_LENGTH (type) = dn_bufp->dsubr.bitlength / 8;
TYPE_NFIELDS (type) = 2;
TYPE_FIELDS (type)
= (struct field *) obstack_alloc (&objfile->type_obstack,
2 * sizeof (struct field));
if (dn_bufp->dsubr.dyn_low)
TYPE_FIELD_BITPOS (type, 0) = 0;
else
TYPE_FIELD_BITPOS (type, 0) = dn_bufp->dsubr.lowbound;
if (dn_bufp->dsubr.dyn_high)
TYPE_FIELD_BITPOS (type, 1) = -1;
else
TYPE_FIELD_BITPOS (type, 1) = dn_bufp->dsubr.highbound;
TYPE_TARGET_TYPE (type) = hpread_type_lookup (dn_bufp->dsubr.subtype,
objfile);
return type;
}
static struct type *
hpread_type_lookup (dnttpointer hp_type, struct objfile *objfile)
{
union dnttentry *dn_bufp;
struct type *tmp_type;
if (hp_type.dntti.immediate)
{
if (hp_type.dntti.type == HP_TYPE_TEMPLATE_ARG)
return hpread_get_nth_template_arg (objfile, hp_type.dntti.bitlength);
else
return lookup_fundamental_type (objfile,
hpread_type_translate (hp_type));
}
if (hp_type.dnttp.index < LNTT_SYMCOUNT (objfile))
dn_bufp = hpread_get_lntt (hp_type.dnttp.index, objfile);
else
return lookup_fundamental_type (objfile, FT_VOID);
switch (dn_bufp->dblock.kind)
{
case DNTT_TYPE_SRCFILE:
case DNTT_TYPE_MODULE:
case DNTT_TYPE_ENTRY:
case DNTT_TYPE_BEGIN:
case DNTT_TYPE_END:
case DNTT_TYPE_IMPORT:
case DNTT_TYPE_LABEL:
case DNTT_TYPE_FPARAM:
case DNTT_TYPE_SVAR:
case DNTT_TYPE_DVAR:
case DNTT_TYPE_CONST:
case DNTT_TYPE_MEMENUM:
case DNTT_TYPE_VARIANT:
case DNTT_TYPE_FILE:
case DNTT_TYPE_WITH:
case DNTT_TYPE_COMMON:
case DNTT_TYPE_COBSTRUCT:
case DNTT_TYPE_XREF:
case DNTT_TYPE_SA:
case DNTT_TYPE_MACRO:
case DNTT_TYPE_BLOCKDATA:
case DNTT_TYPE_CLASS_SCOPE:
case DNTT_TYPE_MEMACCESS:
case DNTT_TYPE_INHERITANCE:
case DNTT_TYPE_OBJECT_ID:
case DNTT_TYPE_FRIEND_CLASS:
case DNTT_TYPE_FRIEND_FUNC:
return lookup_fundamental_type (objfile, FT_VOID);
case DNTT_TYPE_FUNCTION:
return hpread_read_function_type (hp_type, dn_bufp, objfile, 0);
case DNTT_TYPE_DOC_FUNCTION:
return hpread_read_doc_function_type (hp_type, dn_bufp, objfile, 0);
case DNTT_TYPE_TYPEDEF:
{
struct type *structtype = hpread_type_lookup (dn_bufp->dtype.type,
objfile);
return structtype;
}
case DNTT_TYPE_TAGDEF:
{
struct type *structtype = hpread_type_lookup (dn_bufp->dtype.type,
objfile);
char *prefix, *suffix;
suffix = VT (objfile) + dn_bufp->dtype.name;
if (dn_bufp->dtype.type.dnttp.index < LNTT_SYMCOUNT (objfile))
dn_bufp = hpread_get_lntt (dn_bufp->dtype.type.dnttp.index, objfile);
else
{
complain (&hpread_type_lookup_complaint);
return NULL;
}
if (dn_bufp->dblock.kind == DNTT_TYPE_STRUCT)
{
prefix = "struct ";
}
else if (dn_bufp->dblock.kind == DNTT_TYPE_UNION)
{
prefix = "union ";
}
else if (dn_bufp->dblock.kind == DNTT_TYPE_CLASS)
{
if (dn_bufp->dclass.class_decl == 0)
prefix = "class ";
else if (dn_bufp->dclass.class_decl == 1)
prefix = "union ";
else if (dn_bufp->dclass.class_decl == 2)
prefix = "struct ";
else
prefix = "";
}
else if (dn_bufp->dblock.kind == DNTT_TYPE_ENUM)
{
prefix = "enum ";
}
else if (dn_bufp->dblock.kind == DNTT_TYPE_TEMPLATE)
{
prefix = "template ";
}
else
{
prefix = "";
}
structtype->name
= (char *) obstack_alloc (&objfile->type_obstack,
strlen (prefix) + strlen (suffix) + 1);
TYPE_NAME (structtype) = strcpy (TYPE_NAME (structtype), prefix);
TYPE_NAME (structtype) = strcat (TYPE_NAME (structtype), suffix);
TYPE_TAG_NAME (structtype) = suffix;
if (TYPE_CODE (structtype) == TYPE_CODE_STRUCT)
fix_static_member_physnames (structtype, suffix, objfile);
return structtype;
}
case DNTT_TYPE_POINTER:
return make_pointer_type (
hpread_type_lookup (dn_bufp->dptr.pointsto,
objfile),
NULL);
case DNTT_TYPE_REFERENCE:
return make_reference_type (
hpread_type_lookup (dn_bufp->dreference.pointsto,
objfile),
NULL);
case DNTT_TYPE_ENUM:
return hpread_read_enum_type (hp_type, dn_bufp, objfile);
case DNTT_TYPE_SET:
return hpread_read_set_type (hp_type, dn_bufp, objfile);
case DNTT_TYPE_SUBRANGE:
return hpread_read_subrange_type (hp_type, dn_bufp, objfile);
case DNTT_TYPE_ARRAY:
return hpread_read_array_type (hp_type, dn_bufp, objfile);
case DNTT_TYPE_STRUCT:
case DNTT_TYPE_UNION:
return hpread_read_struct_type (hp_type, dn_bufp, objfile);
case DNTT_TYPE_FIELD:
return hpread_type_lookup (dn_bufp->dfield.type, objfile);
case DNTT_TYPE_FUNCTYPE:
return hpread_read_function_type (hp_type, dn_bufp, objfile, 0);
case DNTT_TYPE_PTRMEM:
{
struct type *ptrmemtype;
struct type *class_type;
struct type *memtype;
memtype = hpread_type_lookup (dn_bufp->dptrmem.memtype,
objfile),
class_type = hpread_type_lookup (dn_bufp->dptrmem.pointsto,
objfile),
ptrmemtype = alloc_type (objfile);
smash_to_member_type (ptrmemtype, class_type, memtype);
return make_pointer_type (ptrmemtype, NULL);
}
break;
case DNTT_TYPE_PTRMEMFUNC:
{
struct type *ptrmemtype;
struct type *class_type;
struct type *functype;
struct type *retvaltype;
int nargs;
int i;
struct type **args_type;
class_type = hpread_type_lookup (dn_bufp->dptrmem.pointsto,
objfile);
functype = hpread_type_lookup (dn_bufp->dptrmem.memtype,
objfile);
retvaltype = TYPE_TARGET_TYPE (functype);
nargs = TYPE_NFIELDS (functype);
args_type = (struct type **) xmalloc ((nargs + 1) * sizeof (struct type *));
for (i = 0; i < nargs; i++)
{
args_type[i] = TYPE_FIELD_TYPE (functype, i);
}
args_type[nargs] = NULL;
ptrmemtype = alloc_type (objfile);
smash_to_method_type (ptrmemtype, class_type, retvaltype, args_type);
return make_pointer_type (ptrmemtype, NULL);
}
break;
case DNTT_TYPE_CLASS:
return hpread_read_struct_type (hp_type, dn_bufp, objfile);
case DNTT_TYPE_GENFIELD:
return hpread_type_lookup (dn_bufp->dgenfield.field, objfile);
case DNTT_TYPE_VFUNC:
return hpread_type_lookup (dn_bufp->dvfunc.funcptr, objfile);
case DNTT_TYPE_MODIFIER:
tmp_type = make_cv_type (dn_bufp->dmodifier.m_const,
dn_bufp->dmodifier.m_volatile,
hpread_type_lookup (dn_bufp->dmodifier.type, objfile),
0);
return tmp_type;
case DNTT_TYPE_MEMFUNC:
return hpread_read_function_type (hp_type, dn_bufp, objfile, 0);
case DNTT_TYPE_DOC_MEMFUNC:
return hpread_read_doc_function_type (hp_type, dn_bufp, objfile, 0);
case DNTT_TYPE_TEMPLATE:
return hpread_read_struct_type (hp_type, dn_bufp, objfile);
case DNTT_TYPE_TEMPLATE_ARG:
{
char *name;
name = VT (objfile) + dn_bufp->dtempl_arg.name;
return hpread_read_templ_arg_type (hp_type, dn_bufp, objfile, name);
}
case DNTT_TYPE_FUNC_TEMPLATE:
return hpread_read_function_type (hp_type, dn_bufp, objfile, 0);
case DNTT_TYPE_LINK:
return lookup_fundamental_type (objfile, FT_VOID);
default:
return lookup_fundamental_type (objfile, FT_VOID);
}
}
static sltpointer
hpread_record_lines (struct subfile *subfile, sltpointer s_idx,
sltpointer e_idx, struct objfile *objfile,
CORE_ADDR offset)
{
union sltentry *sl_bufp;
while (s_idx <= e_idx)
{
sl_bufp = hpread_get_slt (s_idx, objfile);
if (sl_bufp->snorm.sltdesc == SLT_NORMAL
|| sl_bufp->snorm.sltdesc == SLT_EXIT)
record_line (subfile, sl_bufp->snorm.line,
sl_bufp->snorm.address + offset);
else if (sl_bufp->snorm.sltdesc == SLT_NORMAL_OFFSET)
record_line (subfile, sl_bufp->snormoff.line,
sl_bufp->snormoff.address + offset);
s_idx++;
}
return e_idx;
}
char *
class_of (struct type *functype)
{
struct type *first_param_type;
char *first_param_name;
struct type *pointed_to_type;
char *class_name;
if (TYPE_NFIELDS (functype) == 0)
return NULL;
first_param_name = TYPE_FIELD_NAME (functype, 0);
if (first_param_name == NULL)
return NULL;
if (strcmp (first_param_name, "this"))
return NULL;
first_param_type = TYPE_FIELD_TYPE (functype, 0);
if (first_param_type == NULL)
return NULL;
if (TYPE_CODE (first_param_type) != TYPE_CODE_PTR)
return NULL;
pointed_to_type = TYPE_TARGET_TYPE (first_param_type);
if (pointed_to_type == NULL)
return NULL;
if (TYPE_CODE (pointed_to_type) != TYPE_CODE_CLASS)
return NULL;
class_name = TYPE_NAME (pointed_to_type);
if (class_name == NULL)
return NULL;
if (strncmp (class_name, "class ", 6) == 0)
class_name += 6;
return class_name;
}
static void
hpread_process_one_debug_symbol (union dnttentry *dn_bufp, char *name,
struct section_offsets *section_offsets,
struct objfile *objfile, CORE_ADDR text_offset,
int text_size, char *filename, int index,
int *at_module_boundary_p)
{
unsigned long desc;
int type;
CORE_ADDR valu;
int offset = ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
int data_offset = ANOFFSET (section_offsets, SECT_OFF_DATA (objfile));
union dnttentry *dn_temp;
dnttpointer hp_type;
struct symbol *sym;
struct context_stack *new;
char *class_scope_name;
sym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack,
sizeof (struct symbol));
memset (sym, 0, sizeof (struct symbol));
SYMBOL_NAME (sym) = obsavestring (name, strlen (name), &objfile->symbol_obstack);
SYMBOL_LANGUAGE (sym) = language_auto;
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
SYMBOL_LINE (sym) = 0;
SYMBOL_VALUE (sym) = 0;
SYMBOL_CLASS (sym) = LOC_TYPEDEF;
hp_type.dnttp.extension = 1;
hp_type.dnttp.immediate = 0;
hp_type.dnttp.global = 0;
hp_type.dnttp.index = index;
type = dn_bufp->dblock.kind;
switch (type)
{
case DNTT_TYPE_SRCFILE:
valu = text_offset;
if (!last_source_file)
{
start_symtab (name, NULL, valu);
record_debugformat ("HP");
SL_INDEX (objfile) = dn_bufp->dsfile.address;
}
else
{
SL_INDEX (objfile) = hpread_record_lines (current_subfile,
SL_INDEX (objfile),
dn_bufp->dsfile.address,
objfile, offset);
}
start_subfile (name, NULL);
break;
case DNTT_TYPE_MODULE:
valu = text_offset;
if (!last_source_file)
{
start_symtab (name, NULL, valu);
SL_INDEX (objfile) = dn_bufp->dmodule.address;
}
else
{
*at_module_boundary_p = -1;
}
start_subfile (name, NULL);
break;
case DNTT_TYPE_FUNCTION:
case DNTT_TYPE_ENTRY:
valu = dn_bufp->dfunc.lowaddr + offset;
SL_INDEX (objfile) = hpread_record_lines (current_subfile,
SL_INDEX (objfile),
dn_bufp->dfunc.address,
objfile, offset);
WITHIN_FUNCTION (objfile) = 1;
CURRENT_FUNCTION_VALUE (objfile) = valu;
if (context_stack_depth != 0)
complain (&lbrac_unmatched_complaint, (char *) symnum);
new = push_context (0, valu);
SYMBOL_CLASS (sym) = LOC_BLOCK;
SYMBOL_TYPE (sym) = hpread_read_function_type (hp_type, dn_bufp, objfile, 1);
if ((dn_bufp->dfunc.language == HP_LANGUAGE_CPLUSPLUS) &&
dn_bufp->dfunc.alias &&
*(char *) (VT (objfile) + dn_bufp->dfunc.alias))
SYMBOL_NAME (sym) = VT (objfile) + dn_bufp->dfunc.alias;
else
SYMBOL_NAME (sym) = VT (objfile) + dn_bufp->dfunc.name;
if ((strcmp (SYMBOL_NAME (sym), "_MAIN_") == 0) &&
(strcmp (VT (objfile) + dn_bufp->dfunc.name, "main") == 0))
SYMBOL_NAME (sym) = VT (objfile) + dn_bufp->dfunc.name;
if (dn_bufp->dfunc.language == HP_LANGUAGE_CPLUSPLUS)
{
SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->symbol_obstack);
if ((SYMBOL_NAME (sym) == VT (objfile) + dn_bufp->dfunc.alias) &&
(!SYMBOL_CPLUS_DEMANGLED_NAME (sym)))
{
char *basename;
char *classname;
char *dem_name;
basename = VT (objfile) + dn_bufp->dfunc.name;
classname = class_of (SYMBOL_TYPE (sym));
if (classname)
{
dem_name = xmalloc (strlen (basename) + strlen (classname) + 3);
strcpy (dem_name, classname);
strcat (dem_name, "::");
strcat (dem_name, basename);
SYMBOL_CPLUS_DEMANGLED_NAME (sym) = dem_name;
SYMBOL_LANGUAGE (sym) = language_cplus;
}
}
}
if (dn_bufp->dfunc.global)
add_symbol_to_list (sym, &global_symbols);
else
add_symbol_to_list (sym, &file_symbols);
new->name = sym;
if (dn_bufp->dfunc.language == HP_LANGUAGE_C ||
dn_bufp->dfunc.language == HP_LANGUAGE_CPLUSPLUS)
{
while (dn_bufp->dblock.kind != DNTT_TYPE_BEGIN)
{
dn_bufp = hpread_get_lntt (++index, objfile);
if (dn_bufp->dblock.extension)
continue;
}
SL_INDEX (objfile) = hpread_record_lines (current_subfile,
SL_INDEX (objfile),
dn_bufp->dbegin.address,
objfile, offset);
SYMBOL_LINE (sym) = hpread_get_line (dn_bufp->dbegin.address, objfile);
}
record_line (current_subfile, SYMBOL_LINE (sym), valu);
break;
case DNTT_TYPE_DOC_FUNCTION:
valu = dn_bufp->ddocfunc.lowaddr + offset;
SL_INDEX (objfile) = hpread_record_lines (current_subfile,
SL_INDEX (objfile),
dn_bufp->ddocfunc.address,
objfile, offset);
WITHIN_FUNCTION (objfile) = 1;
CURRENT_FUNCTION_VALUE (objfile) = valu;
if (context_stack_depth != 0)
complain (&lbrac_unmatched_complaint, (char *) symnum);
new = push_context (0, valu);
SYMBOL_CLASS (sym) = LOC_BLOCK;
SYMBOL_TYPE (sym) = hpread_read_doc_function_type (hp_type, dn_bufp, objfile, 1);
if ((dn_bufp->ddocfunc.language == HP_LANGUAGE_CPLUSPLUS) &&
dn_bufp->ddocfunc.alias &&
*(char *) (VT (objfile) + dn_bufp->ddocfunc.alias))
SYMBOL_NAME (sym) = VT (objfile) + dn_bufp->ddocfunc.alias;
else
SYMBOL_NAME (sym) = VT (objfile) + dn_bufp->ddocfunc.name;
if ((strcmp (SYMBOL_NAME (sym), "_MAIN_") == 0) &&
(strcmp (VT (objfile) + dn_bufp->ddocfunc.name, "main") == 0))
SYMBOL_NAME (sym) = VT (objfile) + dn_bufp->ddocfunc.name;
if (dn_bufp->ddocfunc.language == HP_LANGUAGE_CPLUSPLUS)
{
SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->symbol_obstack);
if ((SYMBOL_NAME (sym) == VT (objfile) + dn_bufp->ddocfunc.alias) &&
(!SYMBOL_CPLUS_DEMANGLED_NAME (sym)))
{
char *basename;
char *classname;
char *dem_name;
basename = VT (objfile) + dn_bufp->ddocfunc.name;
classname = class_of (SYMBOL_TYPE (sym));
if (classname)
{
dem_name = xmalloc (strlen (basename) + strlen (classname) + 3);
strcpy (dem_name, classname);
strcat (dem_name, "::");
strcat (dem_name, basename);
SYMBOL_CPLUS_DEMANGLED_NAME (sym) = dem_name;
SYMBOL_LANGUAGE (sym) = language_cplus;
}
}
}
if (dn_bufp->ddocfunc.global)
add_symbol_to_list (sym, &global_symbols);
else
add_symbol_to_list (sym, &file_symbols);
new->name = sym;
if (dn_bufp->ddocfunc.language == HP_LANGUAGE_C ||
dn_bufp->ddocfunc.language == HP_LANGUAGE_CPLUSPLUS)
{
while (dn_bufp->dblock.kind != DNTT_TYPE_BEGIN)
{
dn_bufp = hpread_get_lntt (++index, objfile);
if (dn_bufp->dblock.extension)
continue;
}
SL_INDEX (objfile) = hpread_record_lines (current_subfile,
SL_INDEX (objfile),
dn_bufp->dbegin.address,
objfile, offset);
SYMBOL_LINE (sym) = hpread_get_line (dn_bufp->dbegin.address, objfile);
}
record_line (current_subfile, SYMBOL_LINE (sym), valu);
break;
case DNTT_TYPE_BEGIN:
if (context_stack_depth == 1 &&
context_stack[0].name != NULL &&
context_stack[0].depth == 0
)
{
context_stack[0].depth++;
}
else
{
SL_INDEX (objfile) = hpread_record_lines (current_subfile,
SL_INDEX (objfile),
dn_bufp->dbegin.address,
objfile, offset);
valu = hpread_get_location (dn_bufp->dbegin.address, objfile);
valu += offset;
desc = hpread_get_scope_start (dn_bufp->dbegin.address, objfile);
new = push_context (desc, valu);
}
break;
case DNTT_TYPE_END:
SL_INDEX (objfile) = hpread_record_lines (current_subfile,
SL_INDEX (objfile),
dn_bufp->dend.address,
objfile, offset);
switch (dn_bufp->dend.endkind)
{
case DNTT_TYPE_MODULE:
valu = text_offset + text_size + offset;
*at_module_boundary_p = 1;
break;
case DNTT_TYPE_FUNCTION:
dn_temp = hpread_get_lntt (dn_bufp->dend.beginscope.dnttp.index,
objfile);
valu = dn_temp->dfunc.hiaddr + offset;
merge_symbol_lists (¶m_symbols, &local_symbols);
new = pop_context ();
finish_block (new->name, &local_symbols, new->old_blocks,
new->start_addr, valu, objfile);
WITHIN_FUNCTION (objfile) = 0;
local_symbols = new->locals;
param_symbols = new->params;
break;
case DNTT_TYPE_BEGIN:
if (context_stack_depth == 1 &&
context_stack[0].name != NULL &&
context_stack[0].depth == 1)
{
context_stack[0].depth--;
}
else
{
valu = hpread_get_location (dn_bufp->dend.address, objfile);
valu += offset + 9;
new = pop_context ();
desc = dn_bufp->dend.beginscope.dnttp.index;
if (desc != new->depth)
complain (&lbrac_mismatch_complaint, (char *) symnum);
finish_block (new->name, &local_symbols, new->old_blocks,
new->start_addr, valu, objfile);
local_symbols = new->locals;
param_symbols = new->params;
}
break;
case DNTT_TYPE_WITH:
break;
case DNTT_TYPE_COMMON:
complain (&hpread_unhandled_end_common_complaint);
break;
case DNTT_TYPE_CLASS_SCOPE:
class_scope_name = NULL;
#if 0
valu = hpread_get_location (dn_bufp->dend.address, objfile);
valu += offset + 9;
new = pop_context ();
desc = dn_bufp->dend.beginscope.dnttp.index;
if (desc != new->depth)
complain (&lbrac_mismatch_complaint, (char *) symnum);
finish_block (new->name, &local_symbols, new->old_blocks,
new->start_addr, valu, objfile);
local_symbols = new->locals;
param_symbols = new->params;
#endif
break;
default:
complain (&hpread_unexpected_end_complaint);
break;
}
break;
case DNTT_TYPE_LABEL:
SYMBOL_NAMESPACE (sym) = LABEL_NAMESPACE;
break;
case DNTT_TYPE_FPARAM:
break;
#if 0
if (dn_bufp->dfparam.regparam)
SYMBOL_CLASS (sym) = LOC_REGISTER;
else if (dn_bufp->dfparam.indirect)
SYMBOL_CLASS (sym) = LOC_REF_ARG;
else
SYMBOL_CLASS (sym) = LOC_ARG;
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
if (dn_bufp->dfparam.copyparam)
{
SYMBOL_VALUE (sym) = dn_bufp->dfparam.location;
#ifdef HPREAD_ADJUST_STACK_ADDRESS
SYMBOL_VALUE (sym)
+= HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile));
#endif
}
else
SYMBOL_VALUE (sym) = dn_bufp->dfparam.location;
SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->dfparam.type, objfile);
add_symbol_to_list (sym, &fparam_symbols);
break;
#endif
case DNTT_TYPE_SVAR:
SYMBOL_CLASS (sym) = LOC_STATIC;
if (is_in_import_list (SYMBOL_NAME (sym), objfile))
SYMBOL_CLASS (sym) = LOC_INDIRECT;
SYMBOL_VALUE_ADDRESS (sym) = dn_bufp->dsvar.location + data_offset;
SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->dsvar.type, objfile);
if (dn_bufp->dsvar.global)
add_symbol_to_list (sym, &global_symbols);
else if (WITHIN_FUNCTION (objfile))
add_symbol_to_list (sym, &local_symbols);
else
add_symbol_to_list (sym, &file_symbols);
if (dn_bufp->dsvar.thread_specific)
{
SYMBOL_CLASS (sym) = LOC_THREAD_LOCAL_STATIC;
SYMBOL_BASEREG (sym) = CR27_REGNUM;
if (objfile->flags & OBJF_SHARED)
{
struct so_list *so;
if (objfile->obj_private == NULL)
error ("Internal error in reading shared library information.");
so = ((obj_private_data_t *) (objfile->obj_private))->so_info;
if (so == NULL)
error ("Internal error in reading shared library information.");
SYMBOL_VALUE_ADDRESS (sym) = dn_bufp->dsvar.location +
so_lib_thread_start_addr (so);
}
}
break;
case DNTT_TYPE_DVAR:
if (dn_bufp->ddvar.regvar)
SYMBOL_CLASS (sym) = LOC_REGISTER;
else
SYMBOL_CLASS (sym) = LOC_LOCAL;
SYMBOL_VALUE (sym) = dn_bufp->ddvar.location;
#ifdef HPREAD_ADJUST_STACK_ADDRESS
SYMBOL_VALUE (sym)
+= HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile));
#endif
SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->ddvar.type, objfile);
if (dn_bufp->ddvar.global)
add_symbol_to_list (sym, &global_symbols);
else if (WITHIN_FUNCTION (objfile))
add_symbol_to_list (sym, &local_symbols);
else
add_symbol_to_list (sym, &file_symbols);
break;
case DNTT_TYPE_CONST:
SYMBOL_CLASS (sym) = LOC_CONST;
SYMBOL_VALUE (sym) = dn_bufp->dconst.location;
SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->dconst.type, objfile);
if (dn_bufp->dconst.global)
add_symbol_to_list (sym, &global_symbols);
else if (WITHIN_FUNCTION (objfile))
add_symbol_to_list (sym, &local_symbols);
else
add_symbol_to_list (sym, &file_symbols);
break;
case DNTT_TYPE_TYPEDEF:
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->dtype.type, objfile);
if (dn_bufp->dtype.global)
add_symbol_to_list (sym, &global_symbols);
else if (WITHIN_FUNCTION (objfile))
add_symbol_to_list (sym, &local_symbols);
else
add_symbol_to_list (sym, &file_symbols);
break;
case DNTT_TYPE_TAGDEF:
{
int global = dn_bufp->dtag.global;
SYMBOL_NAMESPACE (sym) = STRUCT_NAMESPACE;
SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->dtype.type, objfile);
TYPE_NAME (sym->type) = SYMBOL_NAME (sym);
TYPE_TAG_NAME (sym->type) = SYMBOL_NAME (sym);
if (dn_bufp->dtag.global)
add_symbol_to_list (sym, &global_symbols);
else if (WITHIN_FUNCTION (objfile))
add_symbol_to_list (sym, &local_symbols);
else
add_symbol_to_list (sym, &file_symbols);
if (dn_bufp->dtype.type.dnttp.index < LNTT_SYMCOUNT (objfile))
dn_bufp = hpread_get_lntt (dn_bufp->dtag.type.dnttp.index, objfile);
else
{
complain (&hpread_tagdef_complaint);
return;
}
if (dn_bufp->dblock.kind == DNTT_TYPE_CLASS ||
dn_bufp->dblock.kind == DNTT_TYPE_ENUM ||
dn_bufp->dblock.kind == DNTT_TYPE_TEMPLATE)
{
struct symbol *newsym;
newsym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack,
sizeof (struct symbol));
memset (newsym, 0, sizeof (struct symbol));
SYMBOL_NAME (newsym) = name;
SYMBOL_LANGUAGE (newsym) = language_auto;
SYMBOL_NAMESPACE (newsym) = VAR_NAMESPACE;
SYMBOL_LINE (newsym) = 0;
SYMBOL_VALUE (newsym) = 0;
SYMBOL_CLASS (newsym) = LOC_TYPEDEF;
SYMBOL_TYPE (newsym) = sym->type;
if (global)
add_symbol_to_list (newsym, &global_symbols);
else if (WITHIN_FUNCTION (objfile))
add_symbol_to_list (newsym, &local_symbols);
else
add_symbol_to_list (newsym, &file_symbols);
}
}
break;
case DNTT_TYPE_POINTER:
break;
case DNTT_TYPE_ENUM:
break;
case DNTT_TYPE_MEMENUM:
break;
case DNTT_TYPE_SET:
break;
case DNTT_TYPE_SUBRANGE:
break;
case DNTT_TYPE_ARRAY:
break;
case DNTT_TYPE_STRUCT:
case DNTT_TYPE_UNION:
break;
case DNTT_TYPE_FIELD:
break;
case DNTT_TYPE_FUNCTYPE:
break;
case DNTT_TYPE_WITH:
break;
case DNTT_TYPE_COMMON:
complain (&hpread_unhandled_common_complaint);
break;
case DNTT_TYPE_BLOCKDATA:
complain (&hpread_unhandled_blockdata_complaint);
break;
case DNTT_TYPE_CLASS_SCOPE:
dn_temp = hpread_get_lntt (dn_bufp->dclass_scope.type.dnttp.index, objfile);
if (dn_temp->dblock.kind == DNTT_TYPE_TAGDEF)
class_scope_name = VT (objfile) + dn_temp->dtag.name;
else
class_scope_name = NULL;
#if 0
SL_INDEX (objfile) = hpread_record_lines (current_subfile,
SL_INDEX (objfile),
dn_bufp->dclass_scope.address,
objfile, offset);
valu = hpread_get_location (dn_bufp->dclass_scope.address, objfile);
valu += offset;
desc = hpread_get_scope_start (dn_bufp->dclass_scope.address, objfile);
new = push_context (desc, valu);
#endif
break;
case DNTT_TYPE_REFERENCE:
break;
case DNTT_TYPE_PTRMEM:
break;
case DNTT_TYPE_PTRMEMFUNC:
break;
case DNTT_TYPE_CLASS:
break;
case DNTT_TYPE_GENFIELD:
break;
case DNTT_TYPE_VFUNC:
break;
case DNTT_TYPE_MEMACCESS:
break;
case DNTT_TYPE_INHERITANCE:
break;
case DNTT_TYPE_FRIEND_CLASS:
case DNTT_TYPE_FRIEND_FUNC:
break;
case DNTT_TYPE_MODIFIER:
break;
case DNTT_TYPE_OBJECT_ID:
break;
case DNTT_TYPE_MEMFUNC:
break;
case DNTT_TYPE_DOC_MEMFUNC:
break;
case DNTT_TYPE_TEMPLATE:
break;
case DNTT_TYPE_TEMPLATE_ARG:
break;
case DNTT_TYPE_FUNC_TEMPLATE:
break;
case DNTT_TYPE_LINK:
break;
default:
break;
}
}
static int
hpread_get_scope_depth (union dnttentry *dn_bufp, struct objfile *objfile,
int report_nested)
{
register int index;
register union dnttentry *dn_tmp;
register short depth = 0;
return 0;
index = (((char *) dn_bufp) - LNTT (objfile)) / (sizeof (struct dntt_type_block));
while (--index >= 0)
{
dn_tmp = hpread_get_lntt (index, objfile);
switch (dn_tmp->dblock.kind)
{
case DNTT_TYPE_MODULE:
return depth;
case DNTT_TYPE_END:
index = (int) dn_tmp->dend.beginscope.dnttp.index;
break;
case DNTT_TYPE_BEGIN:
case DNTT_TYPE_FUNCTION:
case DNTT_TYPE_DOC_FUNCTION:
case DNTT_TYPE_WITH:
case DNTT_TYPE_COMMON:
case DNTT_TYPE_CLASS_SCOPE:
depth++;
if (report_nested)
return 1;
break;
default:
break;
}
}
return depth;
}
static void
hpread_adjust_bitoffsets (struct type *type, int bits)
{
register int i;
if (TYPE_CODE (type) != TYPE_CODE_UNION)
return;
for (i = 0; i < TYPE_NFIELDS (type); i++)
TYPE_FIELD_BITPOS (type, i) -= bits;
}
static dnttpointer
hpread_get_next_skip_over_anon_unions (int skip_fields, dnttpointer field,
union dnttentry **fieldp,
struct objfile *objfile)
{
struct type *anon_type;
register int i;
int bitoffset;
char *name;
for (i = 0; i < skip_fields; i++)
{
anon_type = hpread_type_lookup ((*fieldp)->dfield.type, objfile);
anon_type = CHECK_TYPEDEF (anon_type);
bitoffset = (*fieldp)->dfield.bitoffset;
name = VT (objfile) + (*fieldp)->dfield.name;
field = (*fieldp)->dfield.nextfield;
*fieldp = hpread_get_lntt (field.dnttp.index, objfile);
if ((TYPE_CODE (anon_type) == TYPE_CODE_UNION) &&
(!name || STREQ (name, "")))
{
hpread_adjust_bitoffsets (anon_type, bitoffset);
field = hpread_get_next_skip_over_anon_unions (TYPE_NFIELDS (anon_type), field, fieldp, objfile);
}
}
return field;
}