Ah, right...  Too many patches (a good problem!)

The standard as I read it says that the name entry points into the general 
string table, but doesn't specify which entry it points to.  However, the 
current DWARF debug_info doesn't ever emit a string for the fully qualified 
name, so you would have to construct it specially to have an exact name to 
refer to.  I also couldn't see anything that said specifically whether the 
DW_AT_name for a type has to be the full name or a base name, it just says:

If a name has been given to the structure, union, or class in the source 
program, then the corresponding structure type, union type, or class type entry 
has a DW_AT_name attribute whose value is a null-terminated string containing 
the type name.

But it would bloat the name tables to use the full name, and since you can 
reconstruct it from the context it's not needed...  So I've only seen base 
names in the name entry for types in the debug_info.

Anyway, current clang for -gdwarf-5 produces:

  Bucket 1 [
    Name 2 {
      Hash: 0xB887389
      String: 0x000000c3 "Foo"
      Entry @ 0x92 {
        Abbrev: 0x39
        Tag: DW_TAG_namespace
        DW_IDX_die_offset: 0x0000004c
      }
    }
  ]
  Bucket 2 [
    Name 3 {
      Hash: 0xB8860BA
      String: 0x000000c7 "Bar"
      Entry @ 0x9b {
        Abbrev: 0x13
        Tag: DW_TAG_structure_type
        DW_IDX_die_offset: 0x0000004e
      }
    }
    Name 4 {
      Hash: 0x7C9A7F6A
      String: 0x000000b5 "main"
      Entry @ 0xa4 {
        Abbrev: 0x2E
        Tag: DW_TAG_subprogram
        DW_IDX_die_offset: 0x00000026
      }
    }

For:

namespace Foo
{
  struct Bar
  {
    int First;
  };
}

int
main() 
{
  Foo::Bar mine = {10};
  return mine.First;
}

Jim


> On Oct 25, 2018, at 11:12 AM, Zachary Turner via Phabricator 
> <revi...@reviews.llvm.org> wrote:
> 
> zturner added a comment.
> 
> In https://reviews.llvm.org/D53597#1276145, @jingham wrote:
> 
>> So far as I can tell, this patch will make lookup of exact types faster for 
>> PDB, but because of the way DWARF debug_names tables are constructed, I 
>> don't think there's any way we can do the same thing for DWARF.
>> 
>> But unless I'm misunderstanding the patch, this doesn't change correctness 
>> of the lookup (except for fixing "type lookup 'struct Foo'").  Did I miss 
>> something?
>> 
>> Jim
> 
> 
> That's the other patch.  This patch is NFC and just makes debugging nicer 
> because you can see enum values in your debugger as rich enumerators.  But 
> for the other patch, if what you said is correct, then I suppose that's 
> correct.  I asked Eric Christopher and he said he thought (but wasn't 100% 
> sure) that types were hashed in the accelerator tables by their full name and 
> not their base name.  If that is true then it could make exact matches 
> faster.  But if it's incorrect then yes, it wouldn't be able to make exact 
> matches faster in DWARF.
> 
> 
> https://reviews.llvm.org/D53597
> 
> 
> 

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to