This is an archive of the discontinued LLVM Phabricator instance.

DWARFDeclContext: Don't add '::' in front of symbol names
AbandonedPublic

Authored by labath on Jul 14 2016, 10:03 AM.

Details

Reviewers
clayborg
Summary

I believe the symbol names more consistent.

In case a symbol has DW_AT_linkage_name (e.g. clang puts it everywhere), we print the demangled
linkage name, which does not contain the '::'. If it does not have the attribute (gcc does not
put it for symbols with internal linkage) then we used to prefix it with '::'. Now we don't.

Also, we used to put the '::' only in front of names which are not in a namespace ('::foo' vs 'A::foo'). Now we are consistent and don't put the leading :: anywhere.

Diff Detail

Event Timeline

labath updated this revision to Diff 63999.Jul 14 2016, 10:03 AM
labath retitled this revision from to DWARFDeclContext: Don't add '::' in front of symbol names.
labath updated this object.
labath added a reviewer: clayborg.
labath added a subscriber: lldb-commits.
labath added a comment.Aug 8 2016, 9:24 AM

Greg, what do you think about this?

clayborg requested changes to this revision.Aug 8 2016, 11:29 AM
clayborg edited edge metadata.

We can't currently do this because we have a dependency on having this be there for existing customers. The problem is that the debug info always has the base names of types in the tables: "pointer_type", "reference_type", etc. The problem arises when we say 'I want only matches to the full qualified name of "size_type"'. We will pick up many many matches if we don't look up "::size_type" because every STL class has things like:

template <class _Tp, class _Allocator = allocator<_Tp> >
class vector : private __vector_base<_Tp, _Allocator>
{
private:
    typedef __vector_base<_Tp, _Allocator>           __base;
    typedef allocator<_Tp>                           __default_allocator_type;
public:
    typedef vector                                   __self;
    typedef _Tp                                      value_type;
    typedef _Allocator                               allocator_type;
    typedef typename __base::__alloc_traits          __alloc_traits;
    typedef typename __base::reference               reference;
    typedef typename __base::const_reference         const_reference;
    typedef typename __base::size_type               size_type;
    typedef typename __base::difference_type         difference_type;

So having the extra "::" on the name for things that are top level helps us avoid pulling in many mega bytes of DWARF every time do this. So we can't make these changes without affecting type lookups. The DWARFDDeclContext class is used to get fully qualified names during SymbolFileDWARF::FindTypes(...) to avoid pulling in all DWARF for any type whose basename matches, but this only happens when using the Apple accelerator tables. For a type like like:

typedef unsigned long size_type;

The Apple accelerator tables will have an entry for "size_type", and this table entry includes a fully qualified name hash. So we will hash up "::size_type" and include that in the type accelerator table entry so we can omit any non matching entries (all "size_type" values in all STL classes will have "std::vector::size_type" hashed up in their "size_type" accelerator table entry and we can avoid parsing all of the DWARF for std::vector and all other STL classes when).

So I can't condone this patch without further modifications.

This revision now requires changes to proceed.Aug 8 2016, 11:29 AM
labath abandoned this revision.Aug 9 2016, 7:24 AM

Ok, thanks for the explanation. It'll take some time for me to parse all the information there, but this is not a priority for us now. Maybe I'll come back to this later, but I'm fine with leaving it like this for now.