defines a typedef for "foo". Synthesize a typedef symbol so that "ptype foo" works as expected.  */ if (cu->language == language_cplus)
defines a typedef for "foo".  A Java class declaration also defines a typedef for the class.  Synthesize a typedef symbol so that "ptype foo" works as expected.  */ if (cu->language == language_cplus || cu->language == language_java)
new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu){  struct objfile *objfile = cu->objfile;  struct symbol *sym = NULL;  char *name;  struct attribute *attr = NULL;  struct attribute *attr2 = NULL;  CORE_ADDR baseaddr;  baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));  if (die->tag != DW_TAG_namespace)    name = dwarf2_linkage_name (die, cu);  else    name = TYPE_NAME (type);  if (name)    {      sym = (struct symbol *) obstack_alloc (&objfile->objfile_obstack,					     sizeof (struct symbol));      OBJSTAT (objfile, n_syms++);      memset (sym, 0, sizeof (struct symbol));      /* Cache this symbol's name and the name's demangled form (if any).  */      SYMBOL_LANGUAGE (sym) = cu->language;      SYMBOL_SET_NAMES (sym, name, strlen (name), objfile);      /* Default assumptions.         Use the passed type or decode it from the die.  */      SYMBOL_DOMAIN (sym) = VAR_DOMAIN;      SYMBOL_CLASS (sym) = LOC_STATIC;      if (type != NULL)	SYMBOL_TYPE (sym) = type;      else	SYMBOL_TYPE (sym) = die_type (die, cu);      attr = dwarf2_attr (die, DW_AT_decl_line, cu);      if (attr)	{	  SYMBOL_LINE (sym) = DW_UNSND (attr);	}      switch (die->tag)	{	case DW_TAG_label:	  attr = dwarf2_attr (die, DW_AT_low_pc, cu);	  if (attr)	    {	      SYMBOL_VALUE_ADDRESS (sym) = DW_ADDR (attr) + baseaddr;	    }	  SYMBOL_CLASS (sym) = LOC_LABEL;	  break;	case DW_TAG_subprogram:	  /* SYMBOL_BLOCK_VALUE (sym) will be filled in later by	     finish_block.  */	  SYMBOL_CLASS (sym) = LOC_BLOCK;	  attr2 = dwarf2_attr (die, DW_AT_external, cu);	  if (attr2 && (DW_UNSND (attr2) != 0))	    {	      add_symbol_to_list (sym, &global_symbols);	    }	  else	    {	      add_symbol_to_list (sym, cu->list_in_scope);	    }	  break;	case DW_TAG_variable:	  /* Compilation with minimal debug info may result in variables	     with missing type entries. Change the misleading `void' type	     to something sensible.  */	  if (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_VOID)	    SYMBOL_TYPE (sym) = init_type (TYPE_CODE_INT,					   TARGET_INT_BIT / HOST_CHAR_BIT, 0,					   "<variable, no debug info>",					   objfile);	  attr = dwarf2_attr (die, DW_AT_const_value, cu);	  if (attr)	    {	      dwarf2_const_value (attr, sym, cu);	      attr2 = dwarf2_attr (die, DW_AT_external, cu);	      if (attr2 && (DW_UNSND (attr2) != 0))		add_symbol_to_list (sym, &global_symbols);	      else		add_symbol_to_list (sym, cu->list_in_scope);	      break;	    }	  attr = dwarf2_attr (die, DW_AT_location, cu);	  if (attr)	    {	      var_decode_location (attr, sym, cu);	      attr2 = dwarf2_attr (die, DW_AT_external, cu);	      if (attr2 && (DW_UNSND (attr2) != 0))		add_symbol_to_list (sym, &global_symbols);	      else		add_symbol_to_list (sym, cu->list_in_scope);	    }	  else	    {	      /* We do not know the address of this symbol.	         If it is an external symbol and we have type information	         for it, enter the symbol as a LOC_UNRESOLVED symbol.	         The address of the variable will then be determined from	         the minimal symbol table whenever the variable is	         referenced.  */	      attr2 = dwarf2_attr (die, DW_AT_external, cu);	      if (attr2 && (DW_UNSND (attr2) != 0)		  && dwarf2_attr (die, DW_AT_type, cu) != NULL)		{		  SYMBOL_CLASS (sym) = LOC_UNRESOLVED;		  add_symbol_to_list (sym, &global_symbols);		}	    }	  break;	case DW_TAG_formal_parameter:	  attr = dwarf2_attr (die, DW_AT_location, cu);	  if (attr)	    {	      var_decode_location (attr, sym, cu);	      /* FIXME drow/2003-07-31: Is LOC_COMPUTED_ARG necessary?  */	      if (SYMBOL_CLASS (sym) == LOC_COMPUTED)		SYMBOL_CLASS (sym) = LOC_COMPUTED_ARG;	    }	  attr = dwarf2_attr (die, DW_AT_const_value, cu);	  if (attr)	    {	      dwarf2_const_value (attr, sym, cu);	    }	  add_symbol_to_list (sym, cu->list_in_scope);	  break;	case DW_TAG_unspecified_parameters:	  /* From varargs functions; gdb doesn't seem to have any	     interest in this information, so just ignore it for now.	     (FIXME?) */	  break;	case DW_TAG_class_type:	case DW_TAG_structure_type:	case DW_TAG_union_type:	case DW_TAG_enumeration_type:	  SYMBOL_CLASS (sym) = LOC_TYPEDEF;	  SYMBOL_DOMAIN (sym) = STRUCT_DOMAIN;	  /* Make sure that the symbol includes appropriate enclosing	     classes/namespaces in its name.  These are calculated in	     read_structure_type, and the correct name is saved in	     the type.  */	  if (cu->language == language_cplus)	    {	      struct type *type = SYMBOL_TYPE (sym);	      	      if (TYPE_TAG_NAME (type) != NULL)		{		  /* FIXME: carlton/2003-11-10: Should this use		     SYMBOL_SET_NAMES instead?  (The same problem also		     arises a further down in the function.)  */		  SYMBOL_LINKAGE_NAME (sym)		    = obsavestring (TYPE_TAG_NAME (type),				    strlen (TYPE_TAG_NAME (type)),				    &objfile->objfile_obstack);		}	    }	  {	    /* NOTE: carlton/2003-11-10: C++ class symbols shouldn't	       really ever be static objects: otherwise, if you try	       to, say, break of a class's method and you're in a file	       which doesn't mention that class, it won't work unless	       the check for all static symbols in lookup_symbol_aux	       saves you.  See the OtherFileClass tests in	       gdb.c++/namespace.exp.  */	    struct pending **list_to_add;	    list_to_add = (cu->list_in_scope == &file_symbols			   && cu->language == language_cplus			   ? &global_symbols : cu->list_in_scope);	  	    add_symbol_to_list (sym, list_to_add);	    /* The semantics of C++ state that "struct foo { ... }" also	       defines a typedef for "foo". Synthesize a typedef symbol so	       that "ptype foo" works as expected.  */	    if (cu->language == language_cplus)	      {		struct symbol *typedef_sym = (struct symbol *)		  obstack_alloc (&objfile->objfile_obstack,				 sizeof (struct symbol));		*typedef_sym = *sym;		SYMBOL_DOMAIN (typedef_sym) = VAR_DOMAIN;		if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0)		  TYPE_NAME (SYMBOL_TYPE (sym)) =		    obsavestring (SYMBOL_NATURAL_NAME (sym),				  strlen (SYMBOL_NATURAL_NAME (sym)),				  &objfile->objfile_obstack);		add_symbol_to_list (typedef_sym, list_to_add);	      }	  }	  break;	case DW_TAG_typedef:	  if (processing_has_namespace_info	      && processing_current_prefix[0] != '\0')	    {	      SYMBOL_LINKAGE_NAME (sym) = obconcat (&objfile->objfile_obstack,						    processing_current_prefix,						    "::",						    name);	    }	  SYMBOL_CLASS (sym) = LOC_TYPEDEF;	  SYMBOL_DOMAIN (sym) = VAR_DOMAIN;	  add_symbol_to_list (sym, cu->list_in_scope);	  break;	case DW_TAG_base_type:        case DW_TAG_subrange_type:	  SYMBOL_CLASS (sym) = LOC_TYPEDEF;	  SYMBOL_DOMAIN (sym) = VAR_DOMAIN;	  add_symbol_to_list (sym, cu->list_in_scope);	  break;	case DW_TAG_enumerator:	  if (processing_has_namespace_info	      && processing_current_prefix[0] != '\0')	    {	      SYMBOL_LINKAGE_NAME (sym) = obconcat (&objfile->objfile_obstack,						    processing_current_prefix,						    "::",						    name);	    }	  attr = dwarf2_attr (die, DW_AT_const_value, cu);	  if (attr)	    {	      dwarf2_const_value (attr, sym, cu);	    }	  {	    /* NOTE: carlton/2003-11-10: See comment above in the	       DW_TAG_class_type, etc. block.  */	    struct pending **list_to_add;	    list_to_add = (cu->list_in_scope == &file_symbols			   && cu->language == language_cplus			   ? &global_symbols : cu->list_in_scope);	  	    add_symbol_to_list (sym, list_to_add);	  }	  break;	case DW_TAG_namespace:	  SYMBOL_CLASS (sym) = LOC_TYPEDEF;	  add_symbol_to_list (sym, &global_symbols);	  break;	default:	  /* Not a tag we recognize.  Hopefully we aren't processing	     trash data, but since we must specifically ignore things	     we don't recognize, there is nothing else we should do at	     this point. */	  complaint (&symfile_complaints, "unsupported tag: '%s'",		     dwarf_tag_name (die->tag));	  break;	}    }  return (sym);}