[Lldb-commits] r176140 (static members)

Greg Clayton gclayton at apple.com
Wed Feb 27 11:31:25 PST 2013


On Feb 27, 2013, at 10:32 AM, "Thirumurthi, Ashok" <ashok.thirumurthi at intel.com> wrote:

> Hi Greg,
> 
> Thanks for your fix.  I see that the loop break for static members prevents lldb from calling ASTContext::AddFieldToRecordType in the first place, which neatly allows the many lldb tests which asserted because of PR-15256 to go their merry way.
> 
> I was wondering if there was a more complete solution, however, because the omission of static members in the RecordDecl prevents lldb from being able to complete expressions on static members.  Consider for instance, the following code snippet:
> 
> struct A
> {
>    short m_a;
>    static long s_b;
>    char m_c;
>    static int s_d;
> };
> 
> A my_a;
> 
> An attempt to "print my_a.s_b" or "print A::s_b" results in:
>   "no member named 's_b' in 'A'" 
> 
> With your fix, expression evaluation of my_a reports on a struct with two members.  In comparison, gdb reports static and non-static members, qualifies s_a and s_b as static, and works with the expression mentioned above.  I wrote a handler for static members in ParseChildMembers that extracts the DW_OP_addr of the defining variable.  However, clang/lib/AST/RecordBuilder and clang/lib/CodeGen/CGRecordLayoutBuilder expect sequential offsets for all members of a record.

I guess we just need to figure out how to correctly add static class variables and "do the right thing" when we build the RecordDecl.

> 
> Interestingly, "print s_b" works even outside of the scope of A.  

Yes, there has always been a DW_TAG_variable that contains the mangled name ("_Z...") and the base name "s_b" of the class global variables. So expression lookup will work for both:

(lldb) expr A::s_b
(lldb) expr s_b


> So, I expect that lldb needs a little extra work to couple the globals with the right scope, and to couple static members with structs and classes.  If you agree, I can open tickets for these and commit a unit test.  Cheers,

Yes, that would be great.

> 
> -	Ashok
> 
> 
> -----Original Message-----
> From: lldb-commits-bounces at cs.uiuc.edu [mailto:lldb-commits-bounces at cs.uiuc.edu] On Behalf Of Greg Clayton
> Sent: Tuesday, February 26, 2013 6:45 PM
> To: lldb-commits at cs.uiuc.edu
> Subject: [Lldb-commits] [lldb] r176140 - <rdar://problem/13287629>
> 
> Author: gclayton
> Date: Tue Feb 26 17:45:18 2013
> New Revision: 176140
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=176140&view=rev
> Log:
> <rdar://problem/13287629>
> 
> Fixed an issue with clang 500's new way to represent static class variables where it emits a DW_TAG_member with a DW_AT_external(0x01) attribute and no DW_AT_data_member_location.
> 
> 
> Modified:
>    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
> 
> Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=176140&r1=176139&r2=176140&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
> +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Tue 
> +++ Feb 26 17:45:18 2013
> @@ -1634,7 +1634,7 @@ SymbolFileDWARF::ParseChildMembers
>                     const char *prop_name = NULL;
>                     const char *prop_getter_name = NULL;
>                     const char *prop_setter_name = NULL;
> -                    uint32_t        prop_attributes = 0;
> +                    uint32_t prop_attributes = 0;
> 
> 
>                     bool is_artificial = false; @@ -1644,6 +1644,7 @@ SymbolFileDWARF::ParseChildMembers
>                     size_t byte_size = 0;
>                     size_t bit_offset = 0;
>                     size_t bit_size = 0;
> +                    bool is_external = false; // On DW_TAG_members, 
> + this means the member is static
>                     uint32_t i;
>                     for (i=0; i<num_attributes && !is_artificial; ++i)
>                     {
> @@ -1688,11 +1689,12 @@ SymbolFileDWARF::ParseChildMembers
>                                 break;
> 
>                             case DW_AT_accessibility: accessibility = DW_ACCESS_to_AccessType (form_value.Unsigned()); break;
> -                            case DW_AT_artificial: is_artificial = form_value.Unsigned() != 0; break;                            
> +                            case DW_AT_artificial: is_artificial = 
> + form_value.Unsigned() != 0; break;
>                             case DW_AT_APPLE_property_name:      prop_name = form_value.AsCString(&get_debug_str_data()); break;
>                             case DW_AT_APPLE_property_getter:    prop_getter_name = form_value.AsCString(&get_debug_str_data()); break;
>                             case DW_AT_APPLE_property_setter:    prop_setter_name = form_value.AsCString(&get_debug_str_data()); break;
>                             case DW_AT_APPLE_property_attribute: prop_attributes = form_value.Unsigned(); break;
> +                            case DW_AT_external:                 is_external = form_value.Unsigned() != 0; break;
> 
>                             default:
>                             case DW_AT_declaration:
> @@ -1781,6 +1783,10 @@ SymbolFileDWARF::ParseChildMembers
>                         is_artificial = true;
>                     }
> 
> +                    // Skip static members
> +                    if (is_external && member_byte_offset == UINT32_MAX)
> +                        break;
> +
>                     if (is_artificial == false)
>                     {
>                         Type *member_type = ResolveTypeUID(encoding_uid);
> 
> 
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits




More information about the lldb-commits mailing list