[Dwarf-Discuss] How to interpret DW_AT_artificial tag?

Michael Eager eager@eagercon.com
Mon Feb 28 22:58:20 GMT 2022


On 2/28/22 13:11, David Blaikie via Dwarf-Discuss wrote:
> On Mon, Feb 28, 2022 at 12:55 PM Greg Clayton via Dwarf-Discuss 
>     You could choose to not show this, but I find it is often easier to
>     show this information in case some compiler change in the future
>     marks something that you might want to see as artificial. For
>     example the "this" parameter to C++ methods is marked as artificial,
>     and people do want to see the "this" in the variables view. Granted
>     that is a variable vs a member variable.
> 
> 
> Probably the important distinction there is that "this", while 
> artificial, is named/usable in the source whereas the vtable isn't.
> 
> Either having some DWARF attribute to communicate that distinction, or a 
> workaround might be to detect that the vtable name uses a reserved 
> identifier could be good - I guess the reality is that DWARF consumers 
> probably hardcode some sort of "this is the vtable pointer" -o so maybe 
> we should have some DWARF attribute that communicates that, instead of 
> relying on the string name of the member? Not sure.

This is a peculiarity of C++ where an artificial variable has a user-
accessible name.  Rather than have a special attribute to distinguish
this oddity, and since "this" is a reserved word in C++, it seems
easiest to simply check for this special case if the language is C++.
You can reasonably hard-code "this" knowing it can't be used for any
other purpose.  You cannot say the same about vtable pointers which can
have any (or no) name.

-- 
Michael Eager



More information about the Dwarf-discuss mailing list