This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

retry: Patch to dwarf2read.c


------- Start of forwarded message -------
Date: Mon, 27 Sep 1999 15:59:59 -0700
Message-Id: <199909272259.PAA22344@yorick.cygnus.com>
To: gdb-patches@cygnus.com, gdb-local@cygnus.com
From: Jason Merrill <jason@cygnus.com>
CC: jason@cygnus.com
Subject: Patch to dwarf2read.c
Content-Type: text

Other backends don't set main_func_*, so there seems to be no reason why
the dwarf ones should, especially since the test they use may be wrong.

It seems silly to go to the trouble of extracting the simple name for
class members when it's already there in the debugging information.

I'd also like to remove dwarf2read's other dependencies on
DW_AT_MIPS_linkage_name, since it's not part of the spec and takes up a lot
of space.  As it is, we rely on that attribute to find class members,
through the symbol table.  But that shouldn't be necessary; the definitions
of the members tell you what they're defining, so you should be able to
update the field/fn_field at that time.

1999-09-15  Jason Merrill  <jason@yorick.cygnus.com>

	* dwarfread.c (read_func_scope): Don't try to set main_func_*.
	* dwarf2read.c (read_func_scope): Likewise.
	(dwarf2_add_field, dwarf2_add_member_fn): Get member function name
	directly, not from mangled name.

Index: dwarf2read.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/dwarf2read.c,v
retrieving revision 2.30
diff -c -p -r2.30 dwarf2read.c
*** dwarf2read.c	1999/09/18 18:45:31	2.30
--- dwarf2read.c	1999/09/23 21:24:48
*************** read_func_scope (die, objfile)
*** 1597,1608 ****
        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;
--- 1597,1602 ----
*************** dwarf2_add_field (fip, die, objfile)
*** 1854,1876 ****
    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));
--- 1848,1864 ----
    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_add_member_fn (fip, die, type, ob
*** 2027,2073 ****
    char *fieldname;
    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++)
--- 2015,2030 ----
    char *fieldname;
    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)
*** 4095,4102 ****
     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)
--- 4052,4058 ----
     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/09/23 21:24:48
*************** 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 ----
------- End of forwarded message -------

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]