[Lldb-commits] [lldb] r258443 - Always try to read DW_TAG_typedef types from DWO files first if we can.
Greg Clayton via lldb-commits
lldb-commits at lists.llvm.org
Thu Jan 21 14:26:13 PST 2016
Author: gclayton
Date: Thu Jan 21 16:26:13 2016
New Revision: 258443
URL: http://llvm.org/viewvc/llvm-project?rev=258443&view=rev
Log:
Always try to read DW_TAG_typedef types from DWO files first if we can.
A lot of C code uses code like:
typedef struct
{
int a;
} FooType;
This creates debug info with an anonymous struct (a DW_TAG_structure_type with no DW_AT_name) and then a DW_TAG_typedef that points to the anonymous structure type. When a typedef is from a module and clang uses -gmodules and -fmodules, then we can end up trying to resolve an anonymous structure type in a DWO symbol file. This doesn't work very well when the structuture has no name, so we now check if a typedef comes from a module, and we directly resolve the typedef type in the module and copy it over. The version we copy from the module of course is correctly able to find the structure in the DWO symbol file, so this fixes the issues we run into.
<rdar://problem/24092915>
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=258443&r1=258442&r2=258443&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Thu Jan 21 16:26:13 2016
@@ -252,11 +252,34 @@ 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;
+
case DW_TAG_base_type:
case DW_TAG_pointer_type:
case DW_TAG_reference_type:
case DW_TAG_rvalue_reference_type:
- case DW_TAG_typedef:
case DW_TAG_const_type:
case DW_TAG_restrict_type:
case DW_TAG_volatile_type:
More information about the lldb-commits
mailing list