This is the first phase of supporting the DW_AT_object_pointer tag. I expanded the decl metadata
so it could hold this information, and then used it to look up unfound names in the object pointer
if it exists. This gets "frame var" to work for unqualified references to ivars captured in blocks.
But the expression parser is ignoring this information still.
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@166860 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Expression/ClangExpressionDeclMap.cpp b/source/Expression/ClangExpressionDeclMap.cpp
index 5a575bd..940be04 100644
--- a/source/Expression/ClangExpressionDeclMap.cpp
+++ b/source/Expression/ClangExpressionDeclMap.cpp
@@ -2661,7 +2661,8 @@
{
valobj = frame->GetValueForVariableExpressionPath(name_unique_cstr,
eNoDynamicValues,
- StackFrame::eExpressionPathOptionCheckPtrVsMember,
+ StackFrame::eExpressionPathOptionCheckPtrVsMember
+ | StackFrame::eExpressionPathOptionsAllowDirectIVarAccess,
var,
err);
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.cpp
index da6dc2b..8aaa9e4 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.cpp
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.cpp
@@ -192,7 +192,9 @@
&identifier_info,
NULL);
- m_external_source->SetMetadata((uintptr_t)new_iface_decl, (uint64_t)isa);
+ ClangASTMetadata meta_data;
+ meta_data.SetISAPtr((uint64_t) isa);
+ m_external_source->SetMetadata((uintptr_t)new_iface_decl, meta_data);
new_iface_decl->setHasExternalVisibleStorage();
@@ -488,7 +490,10 @@
{
lldb::LogSP log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); // FIXME - a more appropriate log channel?
- ObjCLanguageRuntime::ObjCISA objc_isa = (ObjCLanguageRuntime::ObjCISA)m_external_source->GetMetadata((uintptr_t)interface_decl);
+ ClangASTMetadata *metadata = m_external_source->GetMetadata((uintptr_t)interface_decl);
+ ObjCLanguageRuntime::ObjCISA objc_isa = 0;
+ if (metadata)
+ objc_isa = metadata->GetISAPtr();
if (!objc_isa)
return false;
@@ -591,10 +596,16 @@
if (log)
{
ASTDumper dumper(result_iface_type);
+
+ uint64_t isa_value = LLDB_INVALID_ADDRESS;
+ ClangASTMetadata *metadata = m_external_source->GetMetadata((uintptr_t)result_iface_decl);
+ if (metadata)
+ isa_value = metadata->GetISAPtr();
+
log->Printf("AOCTV::FT [%u] Found %s (isa 0x%llx) in the ASTContext",
current_id,
dumper.GetCString(),
- m_external_source->GetMetadata((uintptr_t)result_iface_decl));
+ isa_value);
}
types.push_back(ClangASTType(ast_ctx, result_iface_type.getAsOpaquePtr()));
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index c58dd10..9837a12 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1482,7 +1482,7 @@
const char *property_setter_name,
const char *property_getter_name,
uint32_t property_attributes,
- uint64_t metadata = 0
+ const ClangASTMetadata *metadata
) :
m_ast (ast),
m_class_opaque_type (class_opaque_type),
@@ -1491,9 +1491,32 @@
m_ivar_decl (ivar_decl),
m_property_setter_name (property_setter_name),
m_property_getter_name (property_getter_name),
- m_property_attributes (property_attributes),
- m_metadata (metadata)
+ m_property_attributes (property_attributes)
{
+ if (metadata != NULL)
+ {
+ m_metadata_ap.reset(new ClangASTMetadata());
+ *(m_metadata_ap.get()) = *metadata;
+ }
+ }
+
+ DelayedAddObjCClassProperty (const DelayedAddObjCClassProperty &rhs)
+ {
+ m_ast = rhs.m_ast;
+ m_class_opaque_type = rhs.m_class_opaque_type;
+ m_property_name = rhs.m_property_name;
+ m_property_opaque_type = rhs.m_property_opaque_type;
+ m_ivar_decl = rhs.m_ivar_decl;
+ m_property_setter_name = rhs.m_property_setter_name;
+ m_property_getter_name = rhs.m_property_getter_name;
+ m_property_attributes = rhs.m_property_attributes;
+
+ if (rhs.m_metadata_ap.get())
+ {
+ m_metadata_ap.reset (new ClangASTMetadata());
+ *(m_metadata_ap.get()) = *(rhs.m_metadata_ap.get());
+ }
+
}
bool Finalize() const
@@ -1506,7 +1529,7 @@
m_property_setter_name,
m_property_getter_name,
m_property_attributes,
- m_metadata);
+ m_metadata_ap.get());
}
private:
clang::ASTContext *m_ast;
@@ -1517,7 +1540,7 @@
const char *m_property_setter_name;
const char *m_property_getter_name;
uint32_t m_property_attributes;
- uint64_t m_metadata;
+ std::auto_ptr<ClangASTMetadata> m_metadata_ap;
};
size_t
@@ -1740,7 +1763,7 @@
accessibility,
bit_size);
- GetClangASTContext().SetMetadata((uintptr_t)field_decl, MakeUserID(die->GetOffset()));
+ GetClangASTContext().SetMetadataAsUserID ((uintptr_t)field_decl, MakeUserID(die->GetOffset()));
}
else
{
@@ -1803,6 +1826,8 @@
assert (ivar_decl != NULL);
}
+ ClangASTMetadata metadata;
+ metadata.SetUserID (MakeUserID(die->GetOffset()));
delayed_properties.push_back(DelayedAddObjCClassProperty(GetClangASTContext().getASTContext(),
class_clang_type,
prop_name,
@@ -1811,10 +1836,10 @@
prop_setter_name,
prop_getter_name,
prop_attributes,
- MakeUserID(die->GetOffset())));
+ &metadata));
if (ivar_decl)
- GetClangASTContext().SetMetadata((uintptr_t)ivar_decl, MakeUserID(die->GetOffset()));
+ GetClangASTContext().SetMetadataAsUserID ((uintptr_t)ivar_decl, MakeUserID(die->GetOffset()));
}
}
}
@@ -3906,7 +3931,7 @@
assert(param_var_decl);
function_param_decls.push_back(param_var_decl);
- GetClangASTContext().SetMetadata((uintptr_t)param_var_decl, MakeUserID(die->GetOffset()));
+ GetClangASTContext().SetMetadataAsUserID ((uintptr_t)param_var_decl, MakeUserID(die->GetOffset()));
}
}
}
@@ -5552,20 +5577,22 @@
clang_type = ast.CreateClassTemplateSpecializationType (class_specialization_decl);
clang_type_was_created = true;
- GetClangASTContext().SetMetadata((uintptr_t)class_template_decl, MakeUserID(die->GetOffset()));
- GetClangASTContext().SetMetadata((uintptr_t)class_specialization_decl, MakeUserID(die->GetOffset()));
+ GetClangASTContext().SetMetadataAsUserID ((uintptr_t)class_template_decl, MakeUserID(die->GetOffset()));
+ GetClangASTContext().SetMetadataAsUserID ((uintptr_t)class_specialization_decl, MakeUserID(die->GetOffset()));
}
}
if (!clang_type_was_created)
{
clang_type_was_created = true;
+ ClangASTMetadata metadata;
+ metadata.SetUserID(MakeUserID(die->GetOffset()));
clang_type = ast.CreateRecordType (decl_ctx,
accessibility,
type_name_cstr,
tag_decl_kind,
class_language,
- MakeUserID(die->GetOffset()));
+ &metadata);
}
}
@@ -5768,6 +5795,7 @@
bool is_artificial = false;
dw_offset_t specification_die_offset = DW_INVALID_OFFSET;
dw_offset_t abstract_origin_die_offset = DW_INVALID_OFFSET;
+ dw_offset_t object_pointer_die_offset = DW_INVALID_OFFSET;
unsigned type_quals = 0;
clang::StorageClass storage = clang::SC_None;//, Extern, Static, PrivateExtern
@@ -5821,6 +5849,10 @@
abstract_origin_die_offset = form_value.Reference(dwarf_cu);
break;
+ case DW_AT_object_pointer:
+ object_pointer_die_offset = form_value.Reference(dwarf_cu);
+ break;
+
case DW_AT_allocated:
case DW_AT_associated:
case DW_AT_address_class:
@@ -5831,7 +5863,6 @@
case DW_AT_frame_base:
case DW_AT_high_pc:
case DW_AT_low_pc:
- case DW_AT_object_pointer:
case DW_AT_prototyped:
case DW_AT_pure:
case DW_AT_ranges:
@@ -5851,6 +5882,17 @@
}
}
+ std::string object_pointer_name;
+ if (object_pointer_die_offset != DW_INVALID_OFFSET)
+ {
+ // Get the name from the object pointer die
+ StreamString s;
+ if (DWARFDebugInfoEntry::GetName (this, dwarf_cu, object_pointer_die_offset, s))
+ {
+ object_pointer_name.assign(s.GetData());
+ }
+ }
+
DEBUG_PRINTF ("0x%8.8llx: %s (\"%s\")\n", MakeUserID(die->GetOffset()), DW_TAG_value_to_name(tag), type_name_cstr);
clang_type_t return_clang_type = NULL;
@@ -5884,14 +5926,14 @@
if (die->HasChildren())
{
bool skip_artificial = true;
- ParseChildParameters (sc,
+ ParseChildParameters (sc,
containing_decl_ctx,
- dwarf_cu,
- die,
+ dwarf_cu,
+ die,
skip_artificial,
is_static,
- type_list,
- function_param_types,
+ type_list,
+ function_param_types,
function_param_decls,
type_quals,
template_param_infos);
@@ -5947,7 +5989,7 @@
if (type_handled)
{
LinkDeclContextToDIE(ClangASTContext::GetAsDeclContext(objc_method_decl), die);
- GetClangASTContext().SetMetadata((uintptr_t)objc_method_decl, MakeUserID(die->GetOffset()));
+ GetClangASTContext().SetMetadataAsUserID ((uintptr_t)objc_method_decl, MakeUserID(die->GetOffset()));
}
}
}
@@ -6079,7 +6121,15 @@
type_handled = cxx_method_decl != NULL;
- GetClangASTContext().SetMetadata((uintptr_t)cxx_method_decl, MakeUserID(die->GetOffset()));
+ ClangASTMetadata metadata;
+ metadata.SetUserID(MakeUserID(die->GetOffset()));
+
+ if (!object_pointer_name.empty())
+ {
+ metadata.SetObjectPtrName(object_pointer_name.c_str());
+ printf ("Setting object pointer name: %s on method object 0x%ld.\n", object_pointer_name.c_str(), (uintptr_t) cxx_method_decl);
+ }
+ GetClangASTContext().SetMetadata ((uintptr_t)cxx_method_decl, metadata);
}
}
else
@@ -6145,7 +6195,15 @@
&function_param_decls.front(),
function_param_decls.size());
- GetClangASTContext().SetMetadata((uintptr_t)function_decl, MakeUserID(die->GetOffset()));
+ ClangASTMetadata metadata;
+ metadata.SetUserID(MakeUserID(die->GetOffset()));
+
+ if (!object_pointer_name.empty())
+ {
+ metadata.SetObjectPtrName(object_pointer_name.c_str());
+ printf ("Setting object pointer name: %s on function object 0x%ld.\n", object_pointer_name.c_str(), (uintptr_t) function_decl);
+ }
+ GetClangASTContext().SetMetadata ((uintptr_t)function_decl, metadata);
}
}
type_sp.reset( new Type (MakeUserID(die->GetOffset()),
diff --git a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
index 1e1a0f2..5c74dd7 100644
--- a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
+++ b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
@@ -12,6 +12,7 @@
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/Timer.h"
+#include "lldb/Symbol/ClangExternalASTSourceCommon.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/ObjectFile.h"
@@ -403,11 +404,13 @@
ClangASTContext &ast = GetClangASTContext();
+ ClangASTMetadata metadata;
+ metadata.SetUserID(0xffaaffaaffaaffaall);
lldb::clang_type_t objc_object_type = ast.CreateObjCClass (name.AsCString(),
ast.GetTranslationUnitDecl(),
isForwardDecl,
isInternal,
- 0xffaaffaaffaaffaall);
+ &metadata);
Declaration decl;
diff --git a/source/Symbol/ClangASTContext.cpp b/source/Symbol/ClangASTContext.cpp
index 4ce9aa4..76ec6bc 100644
--- a/source/Symbol/ClangASTContext.cpp
+++ b/source/Symbol/ClangASTContext.cpp
@@ -1126,7 +1126,7 @@
#pragma mark Structure, Unions, Classes
clang_type_t
-ClangASTContext::CreateRecordType (DeclContext *decl_ctx, AccessType access_type, const char *name, int kind, LanguageType language, uint64_t metadata)
+ClangASTContext::CreateRecordType (DeclContext *decl_ctx, AccessType access_type, const char *name, int kind, LanguageType language, ClangASTMetadata *metadata)
{
ASTContext *ast = getASTContext();
assert (ast != NULL);
@@ -1154,8 +1154,8 @@
SourceLocation(),
name && name[0] ? &ast->Idents.get(name) : NULL);
- if (decl)
- SetMetadata(ast, (uintptr_t)decl, metadata);
+ if (decl && metadata)
+ SetMetadata(ast, (uintptr_t)decl, *metadata);
if (decl_ctx)
{
@@ -2262,7 +2262,7 @@
DeclContext *decl_ctx,
bool isForwardDecl,
bool isInternal,
- uint64_t metadata
+ ClangASTMetadata *metadata
)
{
ASTContext *ast = getASTContext();
@@ -2285,8 +2285,8 @@
/*isForwardDecl,*/
isInternal);
- if (decl)
- SetMetadata(ast, (uintptr_t)decl, metadata);
+ if (decl && metadata)
+ SetMetadata(ast, (uintptr_t)decl, *metadata);
return ast->getObjCInterfaceType(decl).getAsOpaquePtr();
}
@@ -2400,7 +2400,7 @@
const char *property_setter_name,
const char *property_getter_name,
uint32_t property_attributes,
- uint64_t metadata
+ ClangASTMetadata *metadata
)
{
if (class_opaque_type == NULL || property_name == NULL || property_name[0] == '\0')
@@ -2447,7 +2447,8 @@
if (property_decl)
{
- SetMetadata(ast, (uintptr_t)property_decl, metadata);
+ if (metadata)
+ SetMetadata(ast, (uintptr_t)property_decl, *metadata);
class_interface_decl->addDecl (property_decl);
@@ -2526,8 +2527,8 @@
impControl,
HasRelatedResultType);
- if (getter)
- SetMetadata(ast, (uintptr_t)getter, metadata);
+ if (getter && metadata)
+ SetMetadata(ast, (uintptr_t)getter, *metadata);
getter->setMethodParams(*ast, ArrayRef<ParmVarDecl*>(), ArrayRef<SourceLocation>());
@@ -2561,8 +2562,8 @@
impControl,
HasRelatedResultType);
- if (setter)
- SetMetadata(ast, (uintptr_t)setter, metadata);
+ if (setter && metadata)
+ SetMetadata(ast, (uintptr_t)setter, *metadata);
llvm::SmallVector<ParmVarDecl *, 1> params;
@@ -6400,9 +6401,18 @@
}
void
+ClangASTContext::SetMetadataAsUserID (uintptr_t object,
+ user_id_t user_id)
+{
+ ClangASTMetadata meta_data;
+ meta_data.SetUserID (user_id);
+ SetMetadata (object, meta_data);
+}
+
+void
ClangASTContext::SetMetadata (clang::ASTContext *ast,
uintptr_t object,
- uint64_t metadata)
+ ClangASTMetadata &metadata)
{
ClangExternalASTSourceCommon *external_source =
static_cast<ClangExternalASTSourceCommon*>(ast->getExternalSource());
@@ -6411,7 +6421,7 @@
external_source->SetMetadata(object, metadata);
}
-uint64_t
+ClangASTMetadata *
ClangASTContext::GetMetadata (clang::ASTContext *ast,
uintptr_t object)
{
@@ -6421,7 +6431,7 @@
if (external_source && external_source->HasMetadata(object))
return external_source->GetMetadata(object);
else
- return 0;
+ return NULL;
}
clang::DeclContext *
@@ -6478,6 +6488,17 @@
language = eLanguageTypeObjC;
return true;
}
+ else if (clang::FunctionDecl *function_decl = llvm::dyn_cast<clang::FunctionDecl>(decl_ctx))
+ {
+ ClangASTMetadata *metadata = GetMetadata (&decl_ctx->getParentASTContext(), (uintptr_t) function_decl);
+ if (metadata && metadata->HasObjectPtr())
+ {
+ language_object_name.SetCString (metadata->GetObjectPtrName());
+ language = eLanguageTypeObjC;
+ is_instance_method = true;
+ }
+ return true;
+ }
}
return false;
}
diff --git a/source/Symbol/ClangASTImporter.cpp b/source/Symbol/ClangASTImporter.cpp
index b121284..bd669fc 100644
--- a/source/Symbol/ClangASTImporter.cpp
+++ b/source/Symbol/ClangASTImporter.cpp
@@ -60,15 +60,20 @@
if (log)
{
+ lldb::user_id_t user_id;
+ ClangASTMetadata *metadata = GetDeclMetadata(decl);
+ if (metadata)
+ user_id = metadata->GetUserID();
+
if (NamedDecl *named_decl = dyn_cast<NamedDecl>(decl))
log->Printf(" [ClangASTImporter] WARNING: Failed to import a %s '%s', metadata 0x%llx",
decl->getDeclKindName(),
named_decl->getNameAsString().c_str(),
- GetDeclMetadata(decl));
+ user_id);
else
log->Printf(" [ClangASTImporter] WARNING: Failed to import a %s, metadata 0x%llx",
decl->getDeclKindName(),
- GetDeclMetadata(decl));
+ user_id);
}
}
@@ -243,7 +248,7 @@
return true;
}
-uint64_t
+ClangASTMetadata *
ClangASTImporter::GetDeclMetadata (const clang::Decl *decl)
{
DeclOrigin decl_origin = GetDeclOrigin(decl);
@@ -450,6 +455,11 @@
if (log)
{
+ lldb::user_id_t user_id;
+ ClangASTMetadata *metadata = m_master.GetDeclMetadata(from);
+ if (metadata)
+ user_id = metadata->GetUserID();
+
if (NamedDecl *from_named_decl = dyn_cast<clang::NamedDecl>(from))
{
std::string name_string;
@@ -462,7 +472,7 @@
to,
name_string.c_str(),
from,
- m_master.GetDeclMetadata(from));
+ user_id);
}
else
{
@@ -470,7 +480,7 @@
from->getDeclKindName(),
to,
from,
- m_master.GetDeclMetadata(from));
+ user_id);
}
}
diff --git a/source/Symbol/ClangExternalASTSourceCommon.cpp b/source/Symbol/ClangExternalASTSourceCommon.cpp
index 85e1dc8..0e00e40 100644
--- a/source/Symbol/ClangExternalASTSourceCommon.cpp
+++ b/source/Symbol/ClangExternalASTSourceCommon.cpp
@@ -27,14 +27,19 @@
g_TotalSizeOfMetadata -= m_metadata.size();
}
-uint64_t ClangExternalASTSourceCommon::GetMetadata (uintptr_t object)
+ClangASTMetadata *
+ClangExternalASTSourceCommon::GetMetadata (uintptr_t object)
{
assert (m_magic == ClangExternalASTSourceCommon_MAGIC);
- return m_metadata[object];
+ if (HasMetadata (object))
+ return &m_metadata[object];
+ else
+ return NULL;
}
-void ClangExternalASTSourceCommon::SetMetadata (uintptr_t object, uint64_t metadata)
+void
+ClangExternalASTSourceCommon::SetMetadata (uintptr_t object, ClangASTMetadata &metadata)
{
assert (m_magic == ClangExternalASTSourceCommon_MAGIC);
@@ -44,7 +49,8 @@
g_TotalSizeOfMetadata += (new_size - orig_size);
}
-bool ClangExternalASTSourceCommon::HasMetadata (uintptr_t object)
+bool
+ClangExternalASTSourceCommon::HasMetadata (uintptr_t object)
{
assert (m_magic == ClangExternalASTSourceCommon_MAGIC);