[Lldb-commits] [lldb] r274809 - Fix it so that we only grab the typedef from the module DWARF file if the type that is typedef'ed is a declaration. This fixes the following bugs:

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Thu Jul 7 16:57:39 PDT 2016


Author: gclayton
Date: Thu Jul  7 18:57:39 2016
New Revision: 274809

URL: http://llvm.org/viewvc/llvm-project?rev=274809&view=rev
Log:
Fix it so that we only grab the typedef from the module DWARF file if the type that is typedef'ed is a declaration. This fixes the following bugs:

<rdar://problem/26870890> [PR28156] TestWithModuleDebugging.py: failing on macOS
https://llvm.org/bugs/show_bug.cgi?id=27412
https://llvm.org/bugs/show_bug.cgi?id=28156


Modified:
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp?rev=274809&r1=274808&r2=274809&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Thu Jul  7 18:57:39 2016
@@ -275,30 +275,6 @@ DWARFASTParserClang::ParseTypeFromDWARF
             switch (tag)
             {
                 case DW_TAG_typedef:
-                    // Try to parse a typedef from the DWO file first as modules
-                    // can contain typedef'ed structures that have no names like:
-                    //
-                    //  typedef struct { int a; } Foo;
-                    //
-                    // In this case we will have a structure with no name and a
-                    // typedef named "Foo" that points to this unnamed structure.
-                    // The name in the typedef is the only identifier for the struct,
-                    // so always try to get typedefs from DWO files if possible.
-                    //
-                    // The type_sp returned will be empty if the typedef doesn't exist
-                    // in a DWO file, so it is cheap to call this function just to check.
-                    //
-                    // If we don't do this we end up creating a TypeSP that says this
-                    // is a typedef to type 0x123 (the DW_AT_type value would be 0x123
-                    // in the DW_TAG_typedef), and this is the unnamed structure type.
-                    // We will have a hard time tracking down an unnammed structure
-                    // type in the module DWO file, so we make sure we don't get into
-                    // this situation by always resolving typedefs from the DWO file.
-                    type_sp = ParseTypeFromDWO(die, log);
-                    if (type_sp)
-                        return type_sp;
-
-                LLVM_FALLTHROUGH;
                 case DW_TAG_base_type:
                 case DW_TAG_pointer_type:
                 case DW_TAG_reference_type:
@@ -352,6 +328,42 @@ DWARFASTParserClang::ParseTypeFromDWARF
                         }
                     }
 
+                    if (tag == DW_TAG_typedef)
+                    {
+                        // Try to parse a typedef from the DWO file first as modules
+                        // can contain typedef'ed structures that have no names like:
+                        //
+                        //  typedef struct { int a; } Foo;
+                        //
+                        // In this case we will have a structure with no name and a
+                        // typedef named "Foo" that points to this unnamed structure.
+                        // The name in the typedef is the only identifier for the struct,
+                        // so always try to get typedefs from DWO files if possible.
+                        //
+                        // The type_sp returned will be empty if the typedef doesn't exist
+                        // in a DWO file, so it is cheap to call this function just to check.
+                        //
+                        // If we don't do this we end up creating a TypeSP that says this
+                        // is a typedef to type 0x123 (the DW_AT_type value would be 0x123
+                        // in the DW_TAG_typedef), and this is the unnamed structure type.
+                        // We will have a hard time tracking down an unnammed structure
+                        // type in the module DWO file, so we make sure we don't get into
+                        // this situation by always resolving typedefs from the DWO file.
+                        const DWARFDIE encoding_die = dwarf->GetDIE(DIERef(encoding_uid));
+
+                        // First make sure that the die that this is typedef'ed to _is_
+                        // just a declaration (DW_AT_declaration == 1), not a full definition
+                        // since template types can't be represented in modules since only
+                        // concrete instances of templates are ever emitted and modules
+                        // won't contain those
+                        if (encoding_die && encoding_die.GetAttributeValueAsUnsigned(DW_AT_declaration, 0) == 1)
+                        {
+                            type_sp = ParseTypeFromDWO(die, log);
+                            if (type_sp)
+                                return type_sp;
+                        }
+                    }
+
                     DEBUG_PRINTF ("0x%8.8" PRIx64 ": %s (\"%s\") type => 0x%8.8lx\n", die.GetID(), DW_TAG_value_to_name(tag), type_name_cstr, encoding_uid.Reference());
 
                     switch (tag)




More information about the lldb-commits mailing list