* dwarf2read.c (dwarf2_linkage_name): New function to get

the linkage name of a die from DW_AT_MIPS_linkage_name or
	DW_AT_name.
	(read_func_scope, dwarf2_add_field, dwarf2_add_member_fn,
	new_symbol):  Use it instead of accessing DW_AT_name.
	(read_partial_die):  Use DW_AT_MIPS_linkage name as name of the
	partial die if present.
	(dwarf2_add_member_fn):  Make a copy of physname on the type obstack.
This commit is contained in:
Peter Schauer 1997-02-08 09:16:26 +00:00
parent dfe6379731
commit e7e98487ba
2 changed files with 59 additions and 31 deletions

View File

@ -1,3 +1,14 @@
Sat Feb 8 01:14:43 1997 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
* dwarf2read.c (dwarf2_linkage_name): New function to get
the linkage name of a die from DW_AT_MIPS_linkage_name or
DW_AT_name.
(read_func_scope, dwarf2_add_field, dwarf2_add_member_fn,
new_symbol): Use it instead of accessing DW_AT_name.
(read_partial_die): Use DW_AT_MIPS_linkage name as name of the
partial die if present.
(dwarf2_add_member_fn): Make a copy of physname on the type obstack.
Fri Feb 7 10:06:22 1997 Jeffrey A Law (law@cygnus.com) Fri Feb 7 10:06:22 1997 Jeffrey A Law (law@cygnus.com)
* blockframe.c (generic_frame_chain_valid): If the new frame * blockframe.c (generic_frame_chain_valid): If the new frame

View File

@ -687,6 +687,8 @@ static void free_die_list PARAMS ((struct die_info *));
static void process_die PARAMS ((struct die_info *, struct objfile *)); static void process_die PARAMS ((struct die_info *, struct objfile *));
static char *dwarf2_linkage_name PARAMS ((struct die_info *));
static char *dwarf_tag_name PARAMS ((unsigned int)); static char *dwarf_tag_name PARAMS ((unsigned int));
static char *dwarf_attr_name PARAMS ((unsigned int)); static char *dwarf_attr_name PARAMS ((unsigned int));
@ -1511,13 +1513,9 @@ read_func_scope (die, objfile)
CORE_ADDR highpc; CORE_ADDR highpc;
struct die_info *child_die; struct die_info *child_die;
struct attribute *attr; struct attribute *attr;
char *name = NULL; char *name;
attr = dwarf_attr (die, DW_AT_name); name = dwarf2_linkage_name (die);
if (attr)
{
name = DW_STRING (attr);
}
/* Ignore functions with missing or empty names and functions with /* Ignore functions with missing or empty names and functions with
missing or invalid low and high pc attributes. */ missing or invalid low and high pc attributes. */
@ -1788,24 +1786,21 @@ dwarf2_add_field (fip, die, objfile)
} }
else if (die->tag == DW_TAG_variable) else if (die->tag == DW_TAG_variable)
{ {
char *physname = ""; char *physname;
char *cp;
/* C++ static member. /* C++ static member.
Get physical name, extract field name from physical name. */ Get physical name, extract field name from physical name. */
attr = dwarf_attr (die, DW_AT_name); physname = dwarf2_linkage_name (die);
if (attr && DW_STRING (attr)) if (physname == NULL)
{ return;
char *cp;
physname = DW_STRING (attr); cp = physname;
while (*cp && !is_cplus_marker (*cp))
cp = physname; cp++;
while (*cp && !is_cplus_marker (*cp)) if (*cp)
cp++; fieldname = cp + 1;
if (*cp) if (*fieldname == '\0')
fieldname = cp + 1;
}
if (*physname == '\0' || *fieldname == '\0')
{ {
complain (&dwarf2_bad_static_member_name, physname); complain (&dwarf2_bad_static_member_name, physname);
} }
@ -1964,15 +1959,13 @@ dwarf2_add_member_fn (fip, die, type, objfile)
int i; int i;
struct fn_field *fnp; struct fn_field *fnp;
char *fieldname; char *fieldname;
char *physname = ""; char *physname;
struct nextfnfield *new_fnfield; struct nextfnfield *new_fnfield;
/* Extract member function name from mangled name. */ /* Extract member function name from mangled name. */
attr = dwarf_attr (die, DW_AT_name); physname = dwarf2_linkage_name (die);
if (attr && DW_STRING (attr)) if (physname == NULL)
{ return;
physname = DW_STRING (attr);
}
if ((physname[0] == '_' && physname[1] == '_' if ((physname[0] == '_' && physname[1] == '_'
&& strchr ("0123456789Qt", physname[2])) && strchr ("0123456789Qt", physname[2]))
|| DESTRUCTOR_PREFIX_P (physname)) || DESTRUCTOR_PREFIX_P (physname))
@ -2049,7 +2042,8 @@ dwarf2_add_member_fn (fip, die, type, objfile)
/* Fill in the member function field info. */ /* Fill in the member function field info. */
fnp = &new_fnfield->fnfield; fnp = &new_fnfield->fnfield;
fnp->physname = physname; fnp->physname = obsavestring (physname, strlen (physname),
&objfile->type_obstack);
fnp->type = alloc_type (objfile); fnp->type = alloc_type (objfile);
if (die->type && TYPE_CODE (die->type) == TYPE_CODE_FUNC) if (die->type && TYPE_CODE (die->type) == TYPE_CODE_FUNC)
{ {
@ -3176,6 +3170,12 @@ read_partial_die (part_die, abfd, info_ptr, has_pc_info)
switch (attr.name) switch (attr.name)
{ {
case DW_AT_name: case DW_AT_name:
/* Prefer DW_AT_MIPS_linkage_name over DW_AT_name. */
if (part_die->name == NULL)
part_die->name = DW_STRING (&attr);
break;
case DW_AT_MIPS_linkage_name:
part_die->name = DW_STRING (&attr); part_die->name = DW_STRING (&attr);
break; break;
case DW_AT_low_pc: case DW_AT_low_pc:
@ -4005,19 +4005,19 @@ new_symbol (die, type, objfile)
struct objfile *objfile; struct objfile *objfile;
{ {
struct symbol *sym = NULL; struct symbol *sym = NULL;
char *name;
struct attribute *attr = NULL; struct attribute *attr = NULL;
struct attribute *attr2 = NULL; struct attribute *attr2 = NULL;
CORE_ADDR addr; CORE_ADDR addr;
attr = dwarf_attr (die, DW_AT_name); name = dwarf2_linkage_name (die);
if (attr && DW_STRING (attr)) if (name)
{ {
sym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack, sym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack,
sizeof (struct symbol)); sizeof (struct symbol));
OBJSTAT (objfile, n_syms++); OBJSTAT (objfile, n_syms++);
memset (sym, 0, sizeof (struct symbol)); memset (sym, 0, sizeof (struct symbol));
SYMBOL_NAME (sym) = obsavestring (DW_STRING (attr), SYMBOL_NAME (sym) = obsavestring (name, strlen (name),
strlen (DW_STRING (attr)),
&objfile->symbol_obstack); &objfile->symbol_obstack);
/* Default assumptions. /* Default assumptions.
@ -4614,6 +4614,23 @@ sibling_die (die)
} }
} }
/* Get linkage name of a die, return NULL if not found. */
static char *
dwarf2_linkage_name (die)
struct die_info *die;
{
struct attribute *attr;
attr = dwarf_attr (die, DW_AT_MIPS_linkage_name);
if (attr && DW_STRING (attr))
return DW_STRING (attr);
attr = dwarf_attr (die, DW_AT_name);
if (attr && DW_STRING (attr))
return DW_STRING (attr);
return NULL;
}
/* Convert a DIE tag into its string name. */ /* Convert a DIE tag into its string name. */
static char * static char *