[Lldb-commits] [lldb] r129942 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp

Greg Clayton gclayton at apple.com
Thu Apr 21 14:41:14 PDT 2011


Author: gclayton
Date: Thu Apr 21 16:41:13 2011
New Revision: 129942

URL: http://llvm.org/viewvc/llvm-project?rev=129942&view=rev
Log:
Fixed a case where if a function, inlined function, or global with a mangled
name had a DW_AT_name that was the same string as the DW_AT_MIPS_linkage_name,
then it would get added twice to the DWARF index.


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

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=129942&r1=129941&r2=129942&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Thu Apr 21 16:41:13 2011
@@ -624,7 +624,7 @@
 
         DWARFDebugInfoEntry::Attributes attributes;
         const char *name = NULL;
-        Mangled mangled;
+        const char *mangled_cstr = NULL;
         bool is_variable = false;
         bool is_declaration = false;
         bool is_artificial = false;
@@ -664,7 +664,7 @@
 
                 case DW_AT_MIPS_linkage_name:
                     if (attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value))
-                        mangled.GetMangledName().SetCString(form_value.AsCString(debug_str));
+                        mangled_cstr = form_value.AsCString(debug_str);                        
                     break;
 
                 case DW_AT_low_pc:
@@ -825,7 +825,7 @@
                         }
                         else
                         {
-                            if (mangled && specification_die_offset != DW_INVALID_OFFSET)
+                            if (mangled_cstr && specification_die_offset != DW_INVALID_OFFSET)
                             {
                                 const DWARFDebugInfoEntry *specification_die = m_dwarf2Data->DebugInfo()->GetDIEPtr (specification_die_offset, NULL);
                                 if (specification_die)
@@ -849,10 +849,20 @@
                     else
                         func_basenames.Insert (ConstString(name), die_info);
                 }
-                if (mangled.GetMangledName())
-                    func_fullnames.Insert (mangled.GetMangledName(), die_info);
-                if (mangled.GetDemangledName())
-                    func_fullnames.Insert (mangled.GetDemangledName(), die_info);
+                if (mangled_cstr)
+                {
+                    // Make sure our mangled name isn't the same string table entry
+                    // as our name. If it starts with '_', then it is ok, else compare
+                    // the string to make sure it isn't the same and we don't end up
+                    // with duplicate entries
+                    if (name != mangled_cstr && ((mangled_cstr[0] == '_') || (::strcmp(name, mangled_cstr) != 0)))
+                    {
+                        Mangled mangled (mangled_cstr, true);
+                        func_fullnames.Insert (mangled.GetMangledName(), die_info);
+                        if (mangled.GetDemangledName())
+                            func_fullnames.Insert (mangled.GetDemangledName(), die_info);
+                    }
+                }
             }
             break;
 
@@ -861,10 +871,20 @@
             {
                 if (name)
                     func_basenames.Insert (ConstString(name), die_info);
-                if (mangled.GetMangledName())
-                    func_fullnames.Insert (mangled.GetMangledName(), die_info);
-                if (mangled.GetDemangledName())
-                    func_fullnames.Insert (mangled.GetDemangledName(), die_info);
+                if (mangled_cstr)
+                {
+                    // Make sure our mangled name isn't the same string table entry
+                    // as our name. If it starts with '_', then it is ok, else compare
+                    // the string to make sure it isn't the same and we don't end up
+                    // with duplicate entries
+                    if (name != mangled_cstr && ((mangled_cstr[0] == '_') || (::strcmp(name, mangled_cstr) != 0)))
+                    {
+                        Mangled mangled (mangled_cstr, true);
+                        func_fullnames.Insert (mangled.GetMangledName(), die_info);
+                        if (mangled.GetDemangledName())
+                            func_fullnames.Insert (mangled.GetDemangledName(), die_info);
+                    }
+                }
             }
             break;
         
@@ -896,10 +916,18 @@
                 // names if they have any since a variable can have a basename
                 // "i", a mangled named "_ZN12_GLOBAL__N_11iE" and a demangled 
                 // mangled name "(anonymous namespace)::i"...
-                if (mangled.GetMangledName())
+                
+                // Make sure our mangled name isn't the same string table entry
+                // as our name. If it starts with '_', then it is ok, else compare
+                // the string to make sure it isn't the same and we don't end up
+                // with duplicate entries
+                if (mangled_cstr && name != mangled_cstr && ((mangled_cstr[0] == '_') || (::strcmp(name, mangled_cstr) != 0)))
+                {
+                    Mangled mangled (mangled_cstr, true);
                     globals.Insert (mangled.GetMangledName(), die_info);
-                if (mangled.GetDemangledName())
-                    globals.Insert (mangled.GetDemangledName(), die_info);
+                    if (mangled.GetDemangledName())
+                        globals.Insert (mangled.GetDemangledName(), die_info);
+                }
             }
             break;
             





More information about the lldb-commits mailing list