public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: debug/2971: Type of variable is wrong in dwarf2 debugging info
@ 2001-06-08 15:35 mmitchel
  0 siblings, 0 replies; 4+ messages in thread
From: mmitchel @ 2001-06-08 15:35 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, kettenis, mmitchel

Synopsis: Type of variable is wrong in dwarf2 debugging info

State-Changed-From-To: analyzed->closed
State-Changed-By: mmitchel
State-Changed-When: Fri Jun  8 15:35:30 2001
State-Changed-Why:
    Fixed.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=2971&database=gcc


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: debug/2971: Type of variable is wrong in dwarf2 debugging info
@ 2001-06-08  9:52 mmitchel
  0 siblings, 0 replies; 4+ messages in thread
From: mmitchel @ 2001-06-08  9:52 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, kettenis, mmitchel, nobody

Synopsis: Type of variable is wrong in dwarf2 debugging info

Responsible-Changed-From-To: unassigned->mmitchel
Responsible-Changed-By: mmitchel
Responsible-Changed-When: Fri Jun  8 09:52:18 2001
Responsible-Changed-Why:
    Working on a fix.
State-Changed-From-To: open->analyzed
State-Changed-By: mmitchel
State-Changed-When: Fri Jun  8 09:52:18 2001
State-Changed-Why:
    Working on a fix.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=2971&database=gcc


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: debug/2971: Type of variable is wrong in dwarf2 debugging info
@ 2001-05-27  3:56 Mark Kettenis
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Kettenis @ 2001-05-27  3:56 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR debug/2971; it has been noted by GNATS.

From: Mark Kettenis <kettenis@science.uva.nl>
To: gcc-gnats@gcc.gnu.org, gcc-patches@gcc.gnu.org
Cc:  
Subject: Re: debug/2971: Type of variable is wrong in dwarf2 debugging info
Date: Sun, 27 May 2001 12:37:34 +0200

 Here's the patch promised in the PR.  I don't think I completely
 understand the comment about recursive types.  It suggests that this
 patch might break those, but if so, I'm pretty sure they were broken
 anyway.
 
 I've made qualified_type a register variable, since I guess it
 deserves it if item_type deserves it.
 
 Mark
 
 
 Index: ChangeLog
 from  Mark Kettenis  <kettenis@gnu.org>
 
 	* dwarf2out.c (modified_type_die): Reorganize somewhat.  Return
 	NULL if type is ERROR_MARK.  Only call equate_type_number_to_die
 	if an appropriately qualified variant of TYPE already exists.
 
 Index: dwarf2out.c
 ===================================================================
 RCS file: /cvs/gcc/egcs/gcc/dwarf2out.c,v
 retrieving revision 1.242.2.18
 diff -u -p -r1.242.2.18 dwarf2out.c
 --- dwarf2out.c 2001/05/21 23:29:41 1.242.2.18
 +++ dwarf2out.c 2001/05/27 10:20:36
 @@ -6890,113 +6890,107 @@ modified_type_die (type, is_const_type, 
       register dw_die_ref context_die;
  {
    register enum tree_code code = TREE_CODE (type);
 +  register tree qualified_type;
    register dw_die_ref mod_type_die = NULL;
    register dw_die_ref sub_die = NULL;
    register tree item_type = NULL;
  
 -  if (code != ERROR_MARK)
 +  if (code == ERROR_MARK)
 +    return NULL;
 +
 +  /* See if we already have the appropriately qualified variant of
 +     this type.  */
 +  qualified_type = get_qualified_type (type,
 +				       ((is_const_type ? TYPE_QUAL_CONST : 0)
 +					| (is_volatile_type 
 +					   ? TYPE_QUAL_VOLATILE : 0)));
 +  /* If we do, then we can just use its DIE, if it exists.  */
 +  if (qualified_type)
      {
 -      tree qualified_type;
 +      mod_type_die = lookup_type_die (qualified_type);
 +      if (mod_type_die)
 +	return mod_type_die;
 +    }
  
 -      /* See if we already have the appropriately qualified variant of
 -	 this type.  */
 -      qualified_type 
 -	= get_qualified_type (type,
 -			      ((is_const_type ? TYPE_QUAL_CONST : 0)
 -			       | (is_volatile_type 
 -				  ? TYPE_QUAL_VOLATILE : 0)));
 -      /* If we do, then we can just use its DIE, if it exists.  */
 -      if (qualified_type)
 +  /* Handle C typedef types.  */
 +  if (qualified_type && TYPE_NAME (qualified_type) 
 +      && TREE_CODE (TYPE_NAME (qualified_type)) == TYPE_DECL
 +      && DECL_ORIGINAL_TYPE (TYPE_NAME (qualified_type)))
 +    {
 +      tree type_name = TYPE_NAME (qualified_type);
 +      tree dtype = TREE_TYPE (type_name);
 +      if (qualified_type == dtype)
  	{
 +	  /* For a named type, use the typedef.  */
 +	  gen_type_die (qualified_type, context_die);
  	  mod_type_die = lookup_type_die (qualified_type);
 -	  if (mod_type_die)
 -	    return mod_type_die;
  	}
  
 -      /* Handle C typedef types.  */
 -      if (qualified_type && TYPE_NAME (qualified_type) 
 -	  && TREE_CODE (TYPE_NAME (qualified_type)) == TYPE_DECL
 -	  && DECL_ORIGINAL_TYPE (TYPE_NAME (qualified_type)))
 -	{
 -	  tree type_name = TYPE_NAME (qualified_type);
 -	  tree dtype = TREE_TYPE (type_name);
 -	  if (qualified_type == dtype)
 -	    {
 -	      /* For a named type, use the typedef.  */
 -	      gen_type_die (qualified_type, context_die);
 -	      mod_type_die = lookup_type_die (qualified_type);
 -	    }
 -
 -	  else if (is_const_type < TYPE_READONLY (dtype)
 -		   || is_volatile_type < TYPE_VOLATILE (dtype))
 -	    /* cv-unqualified version of named type.  Just use the unnamed
 -	       type to which it refers.  */
 -	    mod_type_die
 -	      = modified_type_die (DECL_ORIGINAL_TYPE (type_name),
 -				   is_const_type, is_volatile_type,
 -				   context_die);
 -	  /* Else cv-qualified version of named type; fall through.  */
 -	}
 +      else if (is_const_type < TYPE_READONLY (dtype)
 +	       || is_volatile_type < TYPE_VOLATILE (dtype))
 +	/* cv-unqualified version of named type.  Just use the unnamed
 +	   type to which it refers.  */
 +	mod_type_die = modified_type_die (DECL_ORIGINAL_TYPE (type_name),
 +					  is_const_type, is_volatile_type,
 +					  context_die);
 +      /* Else cv-qualified version of named type; fall through.  */
 +    }
  
 -      if (mod_type_die)
 -	/* OK.  */
 -	;
 -      else if (is_const_type)
 -	{
 -	  mod_type_die = new_die (DW_TAG_const_type, comp_unit_die);
 -	  sub_die = modified_type_die (type, 0, is_volatile_type, context_die);
 -	}
 -      else if (is_volatile_type)
 -	{
 -	  mod_type_die = new_die (DW_TAG_volatile_type, comp_unit_die);
 -	  sub_die = modified_type_die (type, 0, 0, context_die);
 -	}
 -      else if (code == POINTER_TYPE)
 -	{
 -	  mod_type_die = new_die (DW_TAG_pointer_type, comp_unit_die);
 -	  add_AT_unsigned (mod_type_die, DW_AT_byte_size, PTR_SIZE);
 +  if (mod_type_die)
 +    /* OK.  */
 +    ;
 +  else if (is_const_type)
 +    {
 +      mod_type_die = new_die (DW_TAG_const_type, comp_unit_die);
 +      sub_die = modified_type_die (type, 0, is_volatile_type, context_die);
 +    }
 +  else if (is_volatile_type)
 +    {
 +      mod_type_die = new_die (DW_TAG_volatile_type, comp_unit_die);
 +      sub_die = modified_type_die (type, 0, 0, context_die);
 +    }
 +  else if (code == POINTER_TYPE)
 +    {
 +      mod_type_die = new_die (DW_TAG_pointer_type, comp_unit_die);
 +      add_AT_unsigned (mod_type_die, DW_AT_byte_size, PTR_SIZE);
  #if 0
 -	  add_AT_unsigned (mod_type_die, DW_AT_address_class, 0);
 +      add_AT_unsigned (mod_type_die, DW_AT_address_class, 0);
  #endif
 -	  item_type = TREE_TYPE (type);
 -	}
 -      else if (code == REFERENCE_TYPE)
 -	{
 -	  mod_type_die = new_die (DW_TAG_reference_type, comp_unit_die);
 -	  add_AT_unsigned (mod_type_die, DW_AT_byte_size, PTR_SIZE);
 +      item_type = TREE_TYPE (type);
 +    }
 +  else if (code == REFERENCE_TYPE)
 +    {
 +      mod_type_die = new_die (DW_TAG_reference_type, comp_unit_die);
 +      add_AT_unsigned (mod_type_die, DW_AT_byte_size, PTR_SIZE);
  #if 0
 -	  add_AT_unsigned (mod_type_die, DW_AT_address_class, 0);
 +      add_AT_unsigned (mod_type_die, DW_AT_address_class, 0);
  #endif
 -	  item_type = TREE_TYPE (type);
 -	}
 -      else if (is_base_type (type))
 -	mod_type_die = base_type_die (type);
 -      else
 -	{
 -	  gen_type_die (type, context_die);
 -
 -	  /* We have to get the type_main_variant here (and pass that to the
 -	     `lookup_type_die' routine) because the ..._TYPE node we have
 -	     might simply be a *copy* of some original type node (where the
 -	     copy was created to help us keep track of typedef names) and
 -	     that copy might have a different TYPE_UID from the original
 -	     ..._TYPE node.  */
 -	  mod_type_die = lookup_type_die (type_main_variant (type));
 -	  if (mod_type_die == NULL)
 -	    abort ();
 -	}
 +      item_type = TREE_TYPE (type);
 +    }
 +  else if (is_base_type (type))
 +    mod_type_die = base_type_die (type);
 +  else
 +    {
 +      gen_type_die (type, context_die);
  
 -      /* We want to equate the qualified type to the die below.  */
 -      if (qualified_type)
 -	type = qualified_type;
 +      /* We have to get the type_main_variant here (and pass that to
 +	 the `lookup_type_die' routine) because the ..._TYPE node we
 +	 have might simply be a *copy* of some original type node
 +	 (where the copy was created to help us keep track of typedef
 +	 names) and that copy might have a different TYPE_UID from the
 +	 original ..._TYPE node.  */
 +      mod_type_die = lookup_type_die (type_main_variant (type));
 +      if (mod_type_die == NULL)
 +	abort ();
      }
  
 -  equate_type_number_to_die (type, mod_type_die);
 +  if (qualified_type)
 +    equate_type_number_to_die (qualified_type, mod_type_die);
    if (item_type)
 -    /* We must do this after the equate_type_number_to_die call, in case
 -       this is a recursive type.  This ensures that the modified_type_die
 -       recursion will terminate even if the type is recursive.  Recursive
 -       types are possible in Ada.  */
 +    /* We must do this after the equate_type_number_to_die call, in
 +       case this is a recursive type.  This ensures that the
 +       modified_type_die recursion will terminate even if the type is
 +       recursive.  Recursive types are possible in Ada.  */
      sub_die = modified_type_die (item_type,
  				 TYPE_READONLY (item_type),
  				 TYPE_VOLATILE (item_type),
 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* debug/2971: Type of variable is wrong in dwarf2 debugging info
@ 2001-05-27  3:26 kettenis
  0 siblings, 0 replies; 4+ messages in thread
From: kettenis @ 2001-05-27  3:26 UTC (permalink / raw)
  To: gcc-gnats

>Number:         2971
>Category:       debug
>Synopsis:       Type of variable is wrong in dwarf2 debugging info
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun May 27 03:26:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     kettenis@gnu.org
>Release:        GCC 3.0 20010525
>Organization:
>Environment:
alpha-unknown-freebsd5.0 and i586-pc-linux-gnu
>Description:
Compiling the attached test with -gdwarf-2 -dA, we find DW_AT_type of variable lave points
at the DW_TAG_const_type die constructed for the argument cc, instead of pointing directly
to the DW_TAG_base_type that represents type unsigned char.

This is a regression from GCC 2.95.2.

This is a similar problem as the one described in PR 2813 (and I shamelessly copied parts
of that report).  Apparently the fix for that problem wasn't complete.
The problem that when modified_type_die is called, a tree node for "const unsigned char"
isn't available, so qualified_type will be NULL.  As a result the newly created DIE for
"const unsigned char" is equated to the tree node for its base type.
>How-To-Repeat:

>Fix:
I'll send a patch later :-).
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="t.c"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="t.c"

aW50CnF1eDEgKGNvbnN0IHVuc2lnbmVkIGNoYXIgY2MpCnsKICB1bnNpZ25lZCBjaGFyIGxhdmUg
PSAnQic7Cn0K


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2001-06-08 15:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-08 15:35 debug/2971: Type of variable is wrong in dwarf2 debugging info mmitchel
  -- strict thread matches above, loose matches on Subject: below --
2001-06-08  9:52 mmitchel
2001-05-27  3:56 Mark Kettenis
2001-05-27  3:26 kettenis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).