Patch to dwarf2read.c

Jason Merrill jason@cygnus.com
Mon Oct 11 12:54:00 GMT 1999


>>>>> Jim Blandy <jimb@cygnus.com> writes:

 > This looks great.  Please commit it.

I don't think I can; I'm not in the gdb group on sourceware.  I can check
it into devo, if that would be appropriate.

 > - Please also delete skip_member_fn_name, since you've deleted its only use.

OK.

 > - You might want to note in your ChangeLog entry that inside_main_func
 >   in blockframe.c takes care of setting main_func_{low,high}pc.

OK.

1999-10-11  Jason Merrill  <jason@yorick.cygnus.com>

	* dwarfread.c (read_func_scope): Don't try to set main_func_*;
	we handle that in blockframe.c:inside_main_func.
	* dwarf2read.c (read_func_scope): Likewise.
	(dwarf2_add_field, dwarf2_add_member_fn): Get member function name
	directly, not from mangled name.
	(skip_member_fn_name): Lose.

Index: dwarf2read.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/dwarf2read.c,v
retrieving revision 2.32
diff -c -p -r2.32 dwarf2read.c
*** dwarf2read.c	1999/10/07 16:11:39	2.32
--- dwarf2read.c	1999/10/11 17:45:37
*************** static void dwarf2_attach_fields_to_type
*** 671,678 ****
  						  struct type *,
  						  struct objfile *));
  
- static char *skip_member_fn_name PARAMS ((char *));
- 
  static void dwarf2_add_member_fn PARAMS ((struct field_info *,
  					  struct die_info *, struct type *,
  					  struct objfile * objfile));
--- 671,676 ----
*************** read_func_scope (die, objfile)
*** 1601,1612 ****
        objfile->ei.entry_func_highpc = highpc;
      }
  
-   if (STREQ (name, "main"))	/* FIXME: hardwired name */
-     {
-       objfile->ei.main_func_lowpc = lowpc;
-       objfile->ei.main_func_highpc = highpc;
-     }
- 
    /* Decode DW_AT_frame_base location descriptor if present, keep result
       for DW_OP_fbreg operands in decode_locdesc.  */
    frame_base_reg = -1;
--- 1599,1604 ----
*************** dwarf2_add_field (fip, die, objfile)
*** 1858,1880 ****
    else if (die->tag == DW_TAG_variable)
      {
        char *physname;
-       char *cp;
  
        /* C++ static member.
!          Get physical name, extract field name from physical name.  */
!       physname = dwarf2_linkage_name (die);
!       if (physname == NULL)
  	return;
  
!       cp = physname;
!       while (*cp && !is_cplus_marker (*cp))
! 	cp++;
!       if (*cp)
! 	fieldname = cp + 1;
!       if (*fieldname == '\0')
! 	{
! 	  complain (&dwarf2_bad_static_member_name, physname);
! 	}
  
        SET_FIELD_PHYSNAME (*fp, obsavestring (physname, strlen (physname),
  					     &objfile->type_obstack));
--- 1850,1866 ----
    else if (die->tag == DW_TAG_variable)
      {
        char *physname;
  
        /* C++ static member.
! 	 Get name of field.  */
!       attr = dwarf_attr (die, DW_AT_name);
!       if (attr && DW_STRING (attr))
! 	fieldname = DW_STRING (attr);
!       else
  	return;
  
!       /* Get physical name.  */
!       physname = dwarf2_linkage_name (die);
  
        SET_FIELD_PHYSNAME (*fp, obsavestring (physname, strlen (physname),
  					     &objfile->type_obstack));
*************** dwarf2_attach_fields_to_type (fip, type,
*** 1984,2020 ****
      }
  }
  
- /* Skip to the end of a member function name in a mangled name.  */
- 
- static char *
- skip_member_fn_name (physname)
-      char *physname;
- {
-   char *endname = physname;
- 
-   /* Skip over leading underscores.  */
-   while (*endname == '_')
-     endname++;
- 
-   /* Find two succesive underscores.  */
-   do
-     endname = strchr (endname, '_');
-   while (endname != NULL && *++endname != '_');
- 
-   if (endname == NULL)
-     {
-       complain (&dwarf2_bad_member_name_complaint, physname);
-       endname = physname;
-     }
-   else
-     {
-       /* Take care of trailing underscores.  */
-       if (endname[1] != '_')
- 	endname--;
-     }
-   return endname;
- }
- 
  /* Add a member function to the proper fieldlist.  */
  
  static void
--- 1970,1975 ----
*************** dwarf2_add_member_fn (fip, die, type, ob
*** 2032,2077 ****
    char *physname;
    struct nextfnfield *new_fnfield;
  
!   /* Extract member function name from mangled name.  */
!   physname = dwarf2_linkage_name (die);
!   if (physname == NULL)
!     return;
!   if ((physname[0] == '_' && physname[1] == '_'
!        && strchr ("0123456789Qt", physname[2]))
!       || DESTRUCTOR_PREFIX_P (physname))
!     {
!       /* Constructor and destructor field names are set to the name
!          of the class, but without template parameter lists.
!          The name might be missing for anonymous aggregates.  */
!       if (TYPE_TAG_NAME (type))
! 	{
! 	  char *p = strchr (TYPE_TAG_NAME (type), '<');
! 
! 	  if (p == NULL)
! 	    fieldname = TYPE_TAG_NAME (type);
! 	  else
! 	    fieldname = obsavestring (TYPE_TAG_NAME (type),
! 				      p - TYPE_TAG_NAME (type),
! 				      &objfile->type_obstack);
! 	}
!       else
! 	{
! 	  char *anon_name = "";
! 	  fieldname = obsavestring (anon_name, strlen (anon_name),
! 				    &objfile->type_obstack);
! 	}
!     }
    else
!     {
!       char *endname = skip_member_fn_name (physname);
  
!       /* Ignore member function if we were unable not extract the member
!          function name.  */
!       if (endname == physname)
! 	return;
!       fieldname = obsavestring (physname, endname - physname,
! 				&objfile->type_obstack);
!     }
  
    /* Look up member function name in fieldlist.  */
    for (i = 0; i < fip->nfnfields; i++)
--- 1987,2001 ----
    char *physname;
    struct nextfnfield *new_fnfield;
  
!   /* Get name of member function.  */
!   attr = dwarf_attr (die, DW_AT_name);
!   if (attr && DW_STRING (attr))
!     fieldname = DW_STRING (attr);
    else
!     return;
  
!   /* Get the mangled name.  */
!   physname = dwarf2_linkage_name (die);
  
    /* Look up member function name in fieldlist.  */
    for (i = 0; i < fip->nfnfields; i++)
*************** dwarf2_start_subfile (filename, dirname)
*** 4099,4106 ****
     to make a symbol table entry for it, and if so, create a new entry
     and return a pointer to it.
     If TYPE is NULL, determine symbol type from the die, otherwise
!    used the passed type.
!  */
  
  static struct symbol *
  new_symbol (die, type, objfile)
--- 4023,4029 ----
     to make a symbol table entry for it, and if so, create a new entry
     and return a pointer to it.
     If TYPE is NULL, determine symbol type from the die, otherwise
!    used the passed type.  */
  
  static struct symbol *
  new_symbol (die, type, objfile)
Index: dwarfread.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/dwarfread.c,v
retrieving revision 2.129
diff -c -p -r2.129 dwarfread.c
*** dwarfread.c	1999/09/01 00:16:01	2.129
--- dwarfread.c	1999/10/11 17:45:37
*************** read_func_scope (dip, thisdie, enddie, o
*** 1866,1876 ****
        objfile->ei.entry_func_lowpc = dip->at_low_pc;
        objfile->ei.entry_func_highpc = dip->at_high_pc;
      }
-   if (STREQ (dip->at_name, "main"))	/* FIXME: hardwired name */
-     {
-       objfile->ei.main_func_lowpc = dip->at_low_pc;
-       objfile->ei.main_func_highpc = dip->at_high_pc;
-     }
    new = push_context (0, dip->at_low_pc);
    new->name = new_symbol (dip, objfile);
    list_in_scope = &local_symbols;
--- 1866,1871 ----


More information about the Gdb-patches mailing list