[PATCH] D66352: Debug Info: Support for DW_AT_export_symbols for anonymous structs

Shafik Yaghmour via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 19 16:09:34 PDT 2019


shafik added a comment.

In D66352#1636241 <https://reviews.llvm.org/D66352#1636241>, @aprantl wrote:

> In D66352#1636225 <https://reviews.llvm.org/D66352#1636225>, @dblaikie wrote:
>
> > Eh, I think it's still pretty unnecessary (& the DWARF spec is only suggestive, doesn't tend to have requirements in this regard) and so I'd probably suggest waiting until some consumer really wants this (& I'd still want to have a discussion with the consumer about why they find this to be needed). But it's really cheap (especially in DWARFv5 where it can use a const_value form & cost no bytes in debug_info (if/when that sort of thing is implemented in LLVM, if it isn't already).
>
>
> @shafik, Can you outline the problem Clang has differentiating anonymous structs and lambdas that made this patch necessary?


The issue in on the LLDB side where we want to reconstruct the clang AST for something like this:

  struct A { 
    // anonymous struct
     struct {
         int x;
     };  
    // unnamed struct
     struct {
         int y;
     } C;
  };

We have both an anonymous struct and an unnamed struct and the DWARF we currently generated w/o `DW_AT_export_symbols` would look something like this for the anonymous struct:

  0x0000008a:     DW_TAG_structure_type
                    DW_AT_calling_convention      (DW_CC_pass_by_value)
                    DW_AT_byte_size       (0x04)
                    DW_AT_decl_file       ("/Users/shafik/code/anon_class.cpp")
                    DW_AT_decl_line       (2)
  
  0x0000008f:       DW_TAG_member
                      DW_AT_name  ("x")
                      DW_AT_type  (0x0000000000000072 "int")
                      DW_AT_decl_file     ("/Users/shafik/code/anon_class.cpp")
                      DW_AT_decl_line     (3)
                      DW_AT_data_member_location  (0x00)

and like this for the unnamed struct:

  0x000000a8:     DW_TAG_structure_type
                    DW_AT_calling_convention      (DW_CC_pass_by_value)
                    DW_AT_byte_size       (0x04)
                    DW_AT_decl_file       ("/Users/shafik/code/anon_class.cpp")
                    DW_AT_decl_line       (5)
  
  0x000000ad:       DW_TAG_member
                      DW_AT_name  ("y")
                      DW_AT_type  (0x0000000000000072 "int")
                      DW_AT_decl_file     ("/Users/shafik/code/anon_class.cpp")
                      DW_AT_decl_line     (6)
                      DW_AT_data_member_location  (0x00)

and we are left not being able to tell the difference between the two cases.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66352/new/

https://reviews.llvm.org/D66352





More information about the llvm-commits mailing list