public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: Mark Kettenis <kettenis@science.uva.nl>
To: nobody@gcc.gnu.org
Cc: gcc-prs@gcc.gnu.org
Subject: Re: debug/2971: Type of variable is wrong in dwarf2 debugging info
Date: Sun, 27 May 2001 03:56:00 -0000	[thread overview]
Message-ID: <20010527105601.31343.qmail@sourceware.cygnus.com> (raw)

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),
 


             reply	other threads:[~2001-05-27  3:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-27  3:56 Mark Kettenis [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-06-08 15:35 mmitchel
2001-06-08  9:52 mmitchel
2001-05-27  3:26 kettenis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010527105601.31343.qmail@sourceware.cygnus.com \
    --to=kettenis@science.uva.nl \
    --cc=gcc-prs@gcc.gnu.org \
    --cc=nobody@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).