[Lldb-commits] [lldb] r141917 - in /lldb/trunk/source/Plugins/SymbolFile/DWARF: SymbolFileDWARF.cpp SymbolFileDWARF.h
Greg Clayton
gclayton at apple.com
Thu Oct 13 16:49:28 PDT 2011
Author: gclayton
Date: Thu Oct 13 18:49:28 2011
New Revision: 141917
URL: http://llvm.org/viewvc/llvm-project?rev=141917&view=rev
Log:
Modified the DWARF parser to take care of a 1 clang::DeclContext to many
DIEs. Prior to this fix, there was a 1 to 1 mapping.
Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
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=141917&r1=141916&r2=141917&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Thu Oct 13 18:49:28 2011
@@ -1376,7 +1376,7 @@
DWARFCompileUnitSP cu_sp;
const DWARFDebugInfoEntry* die = debug_info->GetDIEPtr(type_uid, &cu_sp);
if (die)
- return GetClangDeclContextContainingDIE (cu_sp.get(), die);
+ return GetClangDeclContextContainingDIE (cu_sp.get(), die, NULL);
}
return NULL;
}
@@ -2011,7 +2011,7 @@
return false;
}
- return decl_ctx_die == pos->second;
+ return pos->second.count (decl_ctx_die);
}
else
{
@@ -3288,7 +3288,7 @@
{
DWARFCompileUnitSP cu_sp;
const DWARFDebugInfoEntry* die = DebugInfo()->GetDIEPtr(die_offset, &cu_sp);
- return GetClangDeclContextContainingDIE (cu_sp.get(), die);
+ return GetClangDeclContextContainingDIE (cu_sp.get(), die, NULL);
}
return NULL;
}
@@ -3319,7 +3319,7 @@
if (namespace_name)
{
Declaration decl; // TODO: fill in the decl object
- clang::NamespaceDecl *namespace_decl = GetClangASTContext().GetUniqueNamespaceDeclaration (namespace_name, decl, GetClangDeclContextContainingDIE (curr_cu, die->GetParent()));
+ clang::NamespaceDecl *namespace_decl = GetClangASTContext().GetUniqueNamespaceDeclaration (namespace_name, decl, GetClangDeclContextContainingDIE (curr_cu, die->GetParent(), NULL));
if (namespace_decl)
LinkDeclContextToDIE((clang::DeclContext*)namespace_decl, die);
return namespace_decl;
@@ -3354,15 +3354,19 @@
}
clang::DeclContext *
-SymbolFileDWARF::GetClangDeclContextContainingDIE (DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die)
+SymbolFileDWARF::GetClangDeclContextContainingDIE (DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die, const DWARFDebugInfoEntry **decl_ctx_die_copy)
{
if (m_clang_tu_decl == NULL)
m_clang_tu_decl = GetClangASTContext().getASTContext()->getTranslationUnitDecl();
const DWARFDebugInfoEntry *decl_ctx_die = GetDeclContextDIEContainingDIE (cu, die);
+
+ if (decl_ctx_die_copy)
+ *decl_ctx_die_copy = decl_ctx_die;
if (decl_ctx_die)
{
+
DIEToDeclContextMap::iterator pos = m_die_to_decl_ctx.find (decl_ctx_die);
if (pos != m_die_to_decl_ctx.end())
return pos->second;
@@ -3378,7 +3382,7 @@
if (namespace_name)
{
Declaration decl; // TODO: fill in the decl object
- clang::NamespaceDecl *namespace_decl = GetClangASTContext().GetUniqueNamespaceDeclaration (namespace_name, decl, GetClangDeclContextContainingDIE (cu, decl_ctx_die));
+ clang::NamespaceDecl *namespace_decl = GetClangASTContext().GetUniqueNamespaceDeclaration (namespace_name, decl, GetClangDeclContextContainingDIE (cu, decl_ctx_die, NULL));
if (namespace_decl)
LinkDeclContextToDIE((clang::DeclContext*)namespace_decl, decl_ctx_die);
return namespace_decl;
@@ -3864,7 +3868,7 @@
clang_type_was_created = true;
clang_type = ast.CreateRecordType (type_name_cstr,
tag_decl_kind,
- GetClangDeclContextContainingDIE (dwarf_cu, die),
+ GetClangDeclContextContainingDIE (dwarf_cu, die, NULL),
class_language);
}
@@ -3972,7 +3976,7 @@
DW_ATE_signed,
byte_size * 8);
clang_type = ast.CreateEnumerationType (type_name_cstr,
- GetClangDeclContextContainingDIE (dwarf_cu, die),
+ GetClangDeclContextContainingDIE (dwarf_cu, die, NULL),
decl,
enumerator_clang_type);
}
@@ -4135,7 +4139,8 @@
// Parse the function children for the parameters
- clang::DeclContext *containing_decl_ctx = GetClangDeclContextContainingDIE (dwarf_cu, die);
+ const DWARFDebugInfoEntry *decl_ctx_die = NULL;
+ clang::DeclContext *containing_decl_ctx = GetClangDeclContextContainingDIE (dwarf_cu, die, &decl_ctx_die);
const clang::Decl::Kind containing_decl_kind = containing_decl_ctx->getDeclKind();
const bool is_cxx_method = containing_decl_kind == clang::Decl::CXXRecord;
@@ -4222,7 +4227,7 @@
// Look at the parent of this DIE and see if is is
// a class or struct and see if this is actually a
// C++ method
- Type *class_type = ResolveType (dwarf_cu, m_decl_ctx_to_die[containing_decl_ctx]);
+ Type *class_type = ResolveType (dwarf_cu, decl_ctx_die);
if (class_type)
{
if (specification_die_offset != DW_INVALID_OFFSET)
@@ -5174,43 +5179,46 @@
if (iter == m_decl_ctx_to_die.end())
return;
- const DWARFDebugInfoEntry *context_die = iter->second;
-
- if (!results)
- return;
-
- DWARFDebugInfo* info = DebugInfo();
-
- DIEArray die_offsets;
-
- DWARFCompileUnit* dwarf_cu = NULL;
- const DWARFDebugInfoEntry* die = NULL;
- size_t num_matches = m_type_index.Find (ConstString(name), die_offsets);
-
- if (num_matches)
+ for (DIEPointerSet::iterator pos = iter->second.begin(), end = iter->second.end(); pos != end; ++pos)
{
- for (size_t i = 0; i < num_matches; ++i)
+ const DWARFDebugInfoEntry *context_die = *pos;
+
+ if (!results)
+ return;
+
+ DWARFDebugInfo* info = DebugInfo();
+
+ DIEArray die_offsets;
+
+ DWARFCompileUnit* dwarf_cu = NULL;
+ const DWARFDebugInfoEntry* die = NULL;
+ size_t num_matches = m_type_index.Find (ConstString(name), die_offsets);
+
+ if (num_matches)
{
- const dw_offset_t die_offset = die_offsets[i];
- die = info->GetDIEPtrWithCompileUnitHint (die_offset, &dwarf_cu);
-
- if (die->GetParent() != context_die)
- continue;
-
- Type *matching_type = ResolveType (dwarf_cu, die);
-
- lldb::clang_type_t type = matching_type->GetClangFullType();
- clang::QualType qual_type = clang::QualType::getFromOpaquePtr(type);
-
- if (const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr()))
- {
- clang::TagDecl *tag_decl = tag_type->getDecl();
- results->push_back(tag_decl);
- }
- else if (const clang::TypedefType *typedef_type = llvm::dyn_cast<clang::TypedefType>(qual_type.getTypePtr()))
+ for (size_t i = 0; i < num_matches; ++i)
{
- clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
- results->push_back(typedef_decl);
+ const dw_offset_t die_offset = die_offsets[i];
+ die = info->GetDIEPtrWithCompileUnitHint (die_offset, &dwarf_cu);
+
+ if (die->GetParent() != context_die)
+ continue;
+
+ Type *matching_type = ResolveType (dwarf_cu, die);
+
+ lldb::clang_type_t type = matching_type->GetClangFullType();
+ clang::QualType qual_type = clang::QualType::getFromOpaquePtr(type);
+
+ if (const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr()))
+ {
+ clang::TagDecl *tag_decl = tag_type->getDecl();
+ results->push_back(tag_decl);
+ }
+ else if (const clang::TypedefType *typedef_type = llvm::dyn_cast<clang::TypedefType>(qual_type.getTypePtr()))
+ {
+ clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
+ results->push_back(typedef_decl);
+ }
}
}
}
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h?rev=141917&r1=141916&r2=141917&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Thu Oct 13 18:49:28 2011
@@ -20,6 +20,7 @@
// Other libraries and framework includes
#include "clang/AST/ExternalASTSource.h"
#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SmallPtrSet.h"
#include "lldb/Core/ClangForward.h"
#include "lldb/Core/ConstString.h"
@@ -204,7 +205,9 @@
GetClangDeclContextForDIEOffset (const lldb_private::SymbolContext &sc, dw_offset_t die_offset);
clang::DeclContext *
- GetClangDeclContextContainingDIE (DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die);
+ GetClangDeclContextContainingDIE (DWARFCompileUnit *cu,
+ const DWARFDebugInfoEntry *die,
+ const DWARFDebugInfoEntry **decl_ctx_die);
clang::DeclContext *
GetClangDeclContextContainingDIEOffset (dw_offset_t die_offset);
@@ -403,7 +406,8 @@
const DWARFDebugInfoEntry *die)
{
m_die_to_decl_ctx[die] = decl_ctx;
- m_decl_ctx_to_die[decl_ctx] = die;
+ // There can be many DIEs for a single decl context
+ m_decl_ctx_to_die[decl_ctx].insert(die);
}
void
@@ -448,8 +452,9 @@
std::auto_ptr<DWARFDebugRanges> m_ranges;
UniqueDWARFASTTypeMap m_unique_ast_type_map;
+ typedef llvm::SmallPtrSet<const DWARFDebugInfoEntry *, 4> DIEPointerSet;
typedef llvm::DenseMap<const DWARFDebugInfoEntry *, clang::DeclContext *> DIEToDeclContextMap;
- typedef llvm::DenseMap<const clang::DeclContext *, const DWARFDebugInfoEntry *> DeclContextToDIEMap;
+ typedef llvm::DenseMap<const clang::DeclContext *, DIEPointerSet> DeclContextToDIEMap;
typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb_private::Type *> DIEToTypePtr;
typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb::VariableSP> DIEToVariableSP;
typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb::clang_type_t> DIEToClangType;
More information about the lldb-commits
mailing list