This is the mail archive of the gdb-patches@sourceware.org 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]
Other format: [Raw text]

Re: [RFA] Fix namespace aliases (c++/7539, c++/10541)


>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:

Keith> This is an attempt to fix namespace alias bugs reported in c++/7539
Keith> and c++/10541.

Thanks for working on this.

Keith> @@ -212,6 +213,13 @@ inspect_type (struct demangle_parse_info *info,
Keith>  	  /* Get the real type of the typedef.  */
Keith>  	  type = check_typedef (otype);
 
Keith> +	  /* If the symbol is a namespace and its name is no different
Keith> +	     than the name we looked up, this symbol is not a namespace
Keith> +	     alias and does not need to be substituted.  */
Keith> +	  if (TYPE_CODE (otype) == TYPE_CODE_NAMESPACE
Keith> +	      && strcmp (TYPE_NAME (type), name) == 0)
Keith> +	    return 0;
Keith> +

Ok, I think I see what is going on here.  For an alias A we have a
symbol named A, whose type is the type of the referent.

I think the comment here is a bit confusing since it says "its name",
but really it means the symbol's type's name.


I'm curious how this copes with some other situations.

For example, an import of a declaration from another namespace, where
the imported declaration is itself an import.

Or, if the program is stopped in a function inside a namespace, can the
user use the "local" (not fully qualified) alias?

I don't think either of these situations is tested.

Keith> @@ -7732,6 +7736,32 @@ process_die (struct die_info *die, struct dwarf2_cu *cu)
Keith>        read_module (die, cu);
Keith>        break;
Keith>      case DW_TAG_imported_declaration:
Keith> +      {
Keith> +	struct attribute *attr;
Keith> +
Keith> +	attr = dwarf2_attr (die, DW_AT_import, cu);
Keith> +	if (attr != NULL)
Keith> +	  {
Keith> +	    /* If the die does not have a name, this is not a namespace
Keith> +	       alias.  */
Keith> +	    attr = dwarf2_attr (die, DW_AT_name, cu);
Keith> +	    if (attr != NULL)
Keith> +	      {

It's customary not to have a body of code in process_die, but to instead
call a helper function.

Tom


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