diff options
Diffstat (limited to 'lldb/source/Expression')
-rw-r--r-- | lldb/source/Expression/ASTDumper.cpp | 9 | ||||
-rw-r--r-- | lldb/source/Expression/ClangASTSource.cpp | 90 | ||||
-rw-r--r-- | lldb/source/Expression/ClangExpressionDeclMap.cpp | 348 | ||||
-rw-r--r-- | lldb/source/Expression/ClangExpressionVariable.cpp | 19 | ||||
-rw-r--r-- | lldb/source/Expression/ClangFunction.cpp | 51 | ||||
-rw-r--r-- | lldb/source/Expression/ClangUserExpression.cpp | 32 | ||||
-rw-r--r-- | lldb/source/Expression/DWARFExpression.cpp | 623 | ||||
-rw-r--r-- | lldb/source/Expression/IRForTarget.cpp | 41 | ||||
-rw-r--r-- | lldb/source/Expression/Materializer.cpp | 184 |
9 files changed, 414 insertions, 983 deletions
diff --git a/lldb/source/Expression/ASTDumper.cpp b/lldb/source/Expression/ASTDumper.cpp index b5c7b32e4b3..5210d149e66 100644 --- a/lldb/source/Expression/ASTDumper.cpp +++ b/lldb/source/Expression/ASTDumper.cpp @@ -9,6 +9,7 @@ #include "lldb/Core/Log.h" #include "lldb/Expression/ASTDumper.h" +#include "lldb/Symbol/ClangASTType.h" #include "llvm/Support/raw_ostream.h" @@ -77,7 +78,13 @@ ASTDumper::ASTDumper (lldb::clang_type_t type) { m_dump = clang::QualType::getFromOpaquePtr(type).getAsString(); } - + +ASTDumper::ASTDumper (const ClangASTType &clang_type) +{ + m_dump = clang_type.GetQualType().getAsString(); +} + + const char * ASTDumper::GetCString() { diff --git a/lldb/source/Expression/ClangASTSource.cpp b/lldb/source/Expression/ClangASTSource.cpp index 0fc3db61b8b..49513d740f3 100644 --- a/lldb/source/Expression/ClangASTSource.cpp +++ b/lldb/source/Expression/ClangASTSource.cpp @@ -238,12 +238,12 @@ ClangASTSource::CompleteType (TagDecl *tag_decl) if (!type) continue; - lldb::clang_type_t opaque_type = type->GetClangFullType(); + ClangASTType clang_type (type->GetClangFullType()); - if (!opaque_type) + if (!clang_type) continue; - const TagType *tag_type = QualType::getFromOpaquePtr(opaque_type)->getAs<TagType>(); + const TagType *tag_type = clang_type.GetQualType()->getAs<TagType>(); if (!tag_type) continue; @@ -277,12 +277,12 @@ ClangASTSource::CompleteType (TagDecl *tag_decl) if (!type) continue; - lldb::clang_type_t opaque_type = type->GetClangFullType(); + ClangASTType clang_type (type->GetClangFullType()); - if (!opaque_type) + if (!clang_type) continue; - const TagType *tag_type = QualType::getFromOpaquePtr(opaque_type)->getAs<TagType>(); + const TagType *tag_type = clang_type.GetQualType()->getAs<TagType>(); if (!tag_type) continue; @@ -346,7 +346,7 @@ ClangASTSource::GetCompleteObjCInterface (clang::ObjCInterfaceDecl *interface_de if (!complete_type_sp) return NULL; - TypeFromUser complete_type = TypeFromUser(complete_type_sp->GetClangFullType(), complete_type_sp->GetClangAST()); + TypeFromUser complete_type = TypeFromUser(complete_type_sp->GetClangFullType()); lldb::clang_type_t complete_opaque_type = complete_type.GetOpaqueQualType(); if (!complete_opaque_type) @@ -696,12 +696,11 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context, (name_string ? name_string : "<anonymous>")); } - clang::ASTContext *type_ast = type_sp->GetClangAST(); - lldb::clang_type_t full_type = type_sp->GetClangFullType(); + ClangASTType full_type = type_sp->GetClangFullType(); - void *copied_type = GuardedCopyType(m_ast_context, type_ast, full_type); + ClangASTType copied_clang_type (GuardedCopyType(full_type)); - if (!copied_type) + if (!copied_clang_type) { if (log) log->Printf(" CAS::FEVD[%u] - Couldn't export a type", @@ -710,7 +709,7 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context, break; } - context.AddTypeDecl(copied_type); + context.AddTypeDecl(copied_clang_type); } else { @@ -750,13 +749,9 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context, name.GetCString()); } - const clang::Type *runtime_clang_type = QualType::getFromOpaquePtr(types[0].GetOpaqueQualType()).getTypePtr(); + ClangASTType copied_clang_type (GuardedCopyType(types[0])); - clang::QualType runtime_qual_type(runtime_clang_type, 0); - - void *copied_type = GuardedCopyType(m_ast_context, type_vendor->GetClangASTContext(), runtime_qual_type.getAsOpaquePtr()); - - if (!copied_type) + if (!copied_clang_type) { if (log) log->Printf(" CAS::FEVD[%u] - Couldn't export a type from the runtime", @@ -765,7 +760,7 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context, break; } - context.AddTypeDecl(copied_type); + context.AddTypeDecl(copied_clang_type); } while(0); } @@ -1688,42 +1683,43 @@ ClangASTSource::AddNamespace (NameSearchContext &context, ClangASTImporter::Name return dyn_cast<NamespaceDecl>(copied_decl); } -void * -ClangASTSource::GuardedCopyType (ASTContext *dest_context, - ASTContext *source_context, - void *clang_type) +ClangASTType +ClangASTSource::GuardedCopyType (const ClangASTType &src_type) { ClangASTMetrics::RegisterLLDBImport(); SetImportInProgress(true); - QualType ret_qual_type = m_ast_importer->CopyType (m_ast_context, source_context, QualType::getFromOpaquePtr(clang_type)); - - void *ret = ret_qual_type.getAsOpaquePtr(); + QualType copied_qual_type = m_ast_importer->CopyType (m_ast_context, src_type.GetASTContext(), src_type.GetQualType()); SetImportInProgress(false); - if (ret && ret_qual_type->getCanonicalTypeInternal().isNull()) + if (copied_qual_type.getAsOpaquePtr() && copied_qual_type->getCanonicalTypeInternal().isNull()) // this shouldn't happen, but we're hardening because the AST importer seems to be generating bad types // on occasion. - return NULL; + return ClangASTType(); - return ret; + return ClangASTType(m_ast_context, copied_qual_type); } clang::NamedDecl * -NameSearchContext::AddVarDecl(void *type) +NameSearchContext::AddVarDecl(const ClangASTType &type) { + assert (type && "Type for variable must be valid!"); + + if (!type.IsValid()) + return NULL; + IdentifierInfo *ii = m_decl_name.getAsIdentifierInfo(); - assert (type && "Type for variable must be non-NULL!"); - - clang::NamedDecl *Decl = VarDecl::Create(*m_ast_source.m_ast_context, + clang::ASTContext *ast = type.GetASTContext(); + + clang::NamedDecl *Decl = VarDecl::Create(*ast, const_cast<DeclContext*>(m_decl_context), SourceLocation(), SourceLocation(), ii, - QualType::getFromOpaquePtr(type), + type.GetQualType(), 0, SC_Static); m_decls.push_back(Decl); @@ -1732,25 +1728,32 @@ NameSearchContext::AddVarDecl(void *type) } clang::NamedDecl * -NameSearchContext::AddFunDecl (void *type) +NameSearchContext::AddFunDecl (const ClangASTType &type) { - assert (type && "Type for variable must be non-NULL!"); + assert (type && "Type for variable must be valid!"); + if (!type.IsValid()) + return NULL; + if (m_function_types.count(type)) return NULL; m_function_types.insert(type); + QualType qual_type (type.GetQualType()); + + clang::ASTContext *ast = type.GetASTContext(); + const bool isInlineSpecified = false; const bool hasWrittenPrototype = true; const bool isConstexprSpecified = false; - clang::FunctionDecl *func_decl = FunctionDecl::Create (*m_ast_source.m_ast_context, + clang::FunctionDecl *func_decl = FunctionDecl::Create (*ast, const_cast<DeclContext*>(m_decl_context), SourceLocation(), SourceLocation(), m_decl_name.getAsIdentifierInfo(), - QualType::getFromOpaquePtr(type), + qual_type, NULL, SC_Static, isInlineSpecified, @@ -1761,7 +1764,6 @@ NameSearchContext::AddFunDecl (void *type) // synthesize ParmVarDecls for all of the FunctionDecl's arguments. To do // this, we raid the function's FunctionProtoType for types. - QualType qual_type (QualType::getFromOpaquePtr(type)); const FunctionProtoType *func_proto_type = qual_type.getTypePtr()->getAs<FunctionProtoType>(); if (func_proto_type) @@ -1775,7 +1777,7 @@ NameSearchContext::AddFunDecl (void *type) { QualType arg_qual_type (func_proto_type->getArgType(ArgIndex)); - parm_var_decls.push_back(ParmVarDecl::Create (*m_ast_source.m_ast_context, + parm_var_decls.push_back(ParmVarDecl::Create (*ast, const_cast<DeclContext*>(m_decl_context), SourceLocation(), SourceLocation(), @@ -1812,15 +1814,15 @@ NameSearchContext::AddGenericFunDecl() ArrayRef<QualType>(), // argument types proto_info)); - return AddFunDecl(generic_function_type.getAsOpaquePtr()); + return AddFunDecl(ClangASTType (m_ast_source.m_ast_context, generic_function_type)); } clang::NamedDecl * -NameSearchContext::AddTypeDecl(void *type) +NameSearchContext::AddTypeDecl(const ClangASTType &clang_type) { - if (type) + if (clang_type) { - QualType qual_type = QualType::getFromOpaquePtr(type); + QualType qual_type = clang_type.GetQualType(); if (const TypedefType *typedef_type = llvm::dyn_cast<TypedefType>(qual_type)) { diff --git a/lldb/source/Expression/ClangExpressionDeclMap.cpp b/lldb/source/Expression/ClangExpressionDeclMap.cpp index 36b72ddae49..26dd5e725f4 100644 --- a/lldb/source/Expression/ClangExpressionDeclMap.cpp +++ b/lldb/source/Expression/ClangExpressionDeclMap.cpp @@ -128,14 +128,7 @@ ClangExpressionDeclMap::DidParse() { ClangExpressionVariableSP var_sp(m_found_entities.GetVariableAtIndex(entity_index)); if (var_sp) - { - ClangExpressionVariable::ParserVars *parser_vars = var_sp->GetParserVars(GetParserID()); - - if (parser_vars && parser_vars->m_lldb_value) - delete parser_vars->m_lldb_value; - var_sp->DisableParserVars(GetParserID()); - } } for (size_t pvar_index = 0, num_pvars = m_parser_vars->m_persistent_vars->GetSize(); @@ -495,7 +488,7 @@ ClangExpressionDeclMap::GetFunctionInfo ClangExpressionVariable::ParserVars *parser_vars = entity_sp->GetParserVars(GetParserID()); - ptr = parser_vars->m_lldb_value->GetScalar().ULongLong(); + ptr = parser_vars->m_lldb_value.GetScalar().ULongLong(); return true; } @@ -784,11 +777,8 @@ ClangExpressionDeclMap::FindGlobalVariable { VariableSP var_sp = vars.GetVariableAtIndex(i); - if (type->GetASTContext() == var_sp->GetType()->GetClangAST()) - { - if (ClangASTContext::AreTypesSame(type->GetASTContext(), type->GetOpaqueQualType(), var_sp->GetType()->GetClangFullType())) - return var_sp; - } + if (ClangASTContext::AreTypesSame(*type, var_sp->GetType()->GetClangFullType())) + return var_sp; } } else @@ -1009,30 +999,21 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context, if (!this_type) return; - QualType this_qual_type = QualType::getFromOpaquePtr(this_type->GetClangFullType()); - const PointerType *class_pointer_type = this_qual_type->getAs<PointerType>(); + ClangASTType pointee_type = this_type->GetClangForwardType().GetPointeeType(); - if (class_pointer_type) + if (pointee_type.IsValid()) { - QualType class_type = class_pointer_type->getPointeeType(); - - if (!class_type.getAsOpaquePtr()) - return; - if (log) { ASTDumper ast_dumper(this_type->GetClangFullType()); log->Printf(" FEVD[%u] Adding type for $__lldb_objc_class: %s", current_id, ast_dumper.GetCString()); } - TypeFromUser class_user_type (class_type.getAsOpaquePtr(), - this_type->GetClangAST()); + TypeFromUser class_user_type(pointee_type); AddOneType(context, class_user_type, current_id); - TypeFromUser this_user_type(this_type->GetClangFullType(), - this_type->GetClangAST()); - + TypeFromUser this_user_type(this_type->GetClangFullType()); m_struct_vars->m_object_pointer_type = this_user_type; return; } @@ -1135,19 +1116,17 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context, if (!self_type) return; - QualType self_qual_type = QualType::getFromOpaquePtr(self_type->GetClangFullType()); + ClangASTType self_clang_type = self_type->GetClangFullType(); - if (self_qual_type->isObjCClassType()) + if (self_clang_type.IsObjCClassType()) { return; } - else if (self_qual_type->isObjCObjectPointerType()) + else if (self_clang_type.IsObjCObjectPointerType()) { - const ObjCObjectPointerType *class_pointer_type = self_qual_type->getAs<ObjCObjectPointerType>(); - - QualType class_type = class_pointer_type->getPointeeType(); - - if (!class_type.getAsOpaquePtr()) + self_clang_type = self_clang_type.GetPointeeType(); + + if (!self_clang_type) return; if (log) @@ -1156,13 +1135,11 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context, log->Printf(" FEVD[%u] Adding type for $__lldb_objc_class: %s", current_id, ast_dumper.GetCString()); } - TypeFromUser class_user_type (class_type.getAsOpaquePtr(), - self_type->GetClangAST()); + TypeFromUser class_user_type (self_clang_type); AddOneType(context, class_user_type, current_id); - TypeFromUser self_user_type(self_type->GetClangFullType(), - self_type->GetClangAST()); + TypeFromUser self_user_type(self_type->GetClangFullType()); m_struct_vars->m_object_pointer_type = self_user_type; return; @@ -1420,14 +1397,11 @@ MaybePromoteToBlockPointerType return block_pointer_type.getAsOpaquePtr(); } -Value * -ClangExpressionDeclMap::GetVariableValue -( - VariableSP &var, - ASTContext *parser_ast_context, - TypeFromUser *user_type, - TypeFromParser *parser_type -) +bool +ClangExpressionDeclMap::GetVariableValue (VariableSP &var, + lldb_private::Value &var_location, + TypeFromUser *user_type, + TypeFromParser *parser_type) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); @@ -1437,34 +1411,31 @@ ClangExpressionDeclMap::GetVariableValue { if (log) log->PutCString("Skipped a definition because it has no type"); - return NULL; + return false; } - clang_type_t var_opaque_type = var_type->GetClangFullType(); + ClangASTType var_clang_type = var_type->GetClangFullType(); - if (!var_opaque_type) + if (!var_clang_type) { if (log) log->PutCString("Skipped a definition because it has no Clang type"); - return NULL; + return false; } + // commented out because of <rdar://problem/11024417> ASTContext *ast = var_type->GetClangASTContext().getASTContext(); - + if (!ast) { if (log) log->PutCString("There is no AST context for the current execution context"); - return NULL; + return false; } - - // commented out because of <rdar://problem/11024417> - //var_opaque_type = MaybePromoteToBlockPointerType (ast, var_opaque_type); + //var_clang_type = MaybePromoteToBlockPointerType (ast, var_clang_type); DWARFExpression &var_location_expr = var->LocationExpression(); - std::unique_ptr<Value> var_location(new Value); - lldb::addr_t loclist_base_load_addr = LLDB_INVALID_ADDRESS; Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr(); @@ -1483,41 +1454,34 @@ ClangExpressionDeclMap::GetVariableValue if (var_location_expr.GetExpressionData(const_value_extractor)) { - var_location->operator=(Value(const_value_extractor.GetDataStart(), const_value_extractor.GetByteSize())); - var_location->SetValueType(Value::eValueTypeHostAddress); + var_location = Value(const_value_extractor.GetDataStart(), const_value_extractor.GetByteSize()); + var_location.SetValueType(Value::eValueTypeHostAddress); } else { if (log) log->Printf("Error evaluating constant variable: %s", err.AsCString()); - return NULL; + return false; } } - void *type_to_use = NULL; + ClangASTType type_to_use = GuardedCopyType(var_clang_type); - if (parser_ast_context) + if (!type_to_use) { - type_to_use = GuardedCopyType(parser_ast_context, ast, var_opaque_type); - - if (!type_to_use) - { - if (log) - log->Printf("Couldn't copy a variable's type into the parser's AST context"); - - return NULL; - } + if (log) + log->Printf("Couldn't copy a variable's type into the parser's AST context"); - if (parser_type) - *parser_type = TypeFromParser(type_to_use, parser_ast_context); + return false; } - else - type_to_use = var_opaque_type; - if (var_location.get()->GetContextType() == Value::eContextTypeInvalid) - var_location.get()->SetContext(Value::eContextTypeClangType, type_to_use); + if (parser_type) + *parser_type = TypeFromParser(type_to_use); - if (var_location.get()->GetValueType() == Value::eValueTypeFileAddress) + if (var_location.GetContextType() == Value::eContextTypeInvalid) + var_location.SetClangType(type_to_use); + + if (var_location.GetValueType() == Value::eValueTypeFileAddress) { SymbolContext var_sc; var->CalculateSymbolContext(&var_sc); @@ -1525,21 +1489,21 @@ ClangExpressionDeclMap::GetVariableValue if (!var_sc.module_sp) return NULL; - Address so_addr(var_location->GetScalar().ULongLong(), var_sc.module_sp->GetSectionList()); + Address so_addr(var_location.GetScalar().ULongLong(), var_sc.module_sp->GetSectionList()); lldb::addr_t load_addr = so_addr.GetLoadAddress(target); if (load_addr != LLDB_INVALID_ADDRESS) { - var_location->GetScalar() = load_addr; - var_location->SetValueType(Value::eValueTypeLoadAddress); + var_location.GetScalar() = load_addr; + var_location.SetValueType(Value::eValueTypeLoadAddress); } } if (user_type) - *user_type = TypeFromUser(var_opaque_type, ast); + *user_type = TypeFromUser(var_clang_type); - return var_location.release(); + return true; } void @@ -1551,11 +1515,10 @@ ClangExpressionDeclMap::AddOneVariable (NameSearchContext &context, VariableSP v TypeFromUser ut; TypeFromParser pt; + Value var_location; - Value *var_location = GetVariableValue (var, - m_ast_context, - &ut, - &pt); + if (!GetVariableValue (var, var_location, &ut, &pt)) + return; clang::QualType parser_opaque_type = QualType::getFromOpaquePtr(pt.GetOpaqueQualType()); @@ -1568,17 +1531,14 @@ ClangExpressionDeclMap::AddOneVariable (NameSearchContext &context, VariableSP v CompleteType(tag_type->getDecl()); } - if (!var_location) - return; - - NamedDecl *var_decl; - bool is_reference = ClangASTContext::IsReferenceType(pt.GetOpaqueQualType()); + bool is_reference = pt.IsReferenceType(); + NamedDecl *var_decl = NULL; if (is_reference) - var_decl = context.AddVarDecl(pt.GetOpaqueQualType()); + var_decl = context.AddVarDecl(pt); else - var_decl = context.AddVarDecl(ClangASTContext::CreateLValueReferenceType(pt.GetASTContext(), pt.GetOpaqueQualType())); + var_decl = context.AddVarDecl(pt.GetLValueReferenceType()); std::string decl_name(context.m_decl_name.getAsString()); ConstString entity_name(decl_name.c_str()); @@ -1613,10 +1573,7 @@ ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context, TypeFromUser user_type (pvar_sp->GetTypeFromUser()); - TypeFromParser parser_type (GuardedCopyType(m_ast_context, - user_type.GetASTContext(), - user_type.GetOpaqueQualType()), - m_ast_context); + TypeFromParser parser_type (GuardedCopyType(user_type)); if (!parser_type.GetOpaqueQualType()) { @@ -1625,14 +1582,14 @@ ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context, return; } - NamedDecl *var_decl = context.AddVarDecl(ClangASTContext::CreateLValueReferenceType(parser_type.GetASTContext(), parser_type.GetOpaqueQualType())); + NamedDecl *var_decl = context.AddVarDecl(parser_type.GetLValueReferenceType()); pvar_sp->EnableParserVars(GetParserID()); ClangExpressionVariable::ParserVars *parser_vars = pvar_sp->GetParserVars(GetParserID()); parser_vars->m_parser_type = parser_type; - parser_vars->m_named_decl = var_decl; - parser_vars->m_llvm_value = NULL; - parser_vars->m_lldb_value = NULL; + parser_vars->m_named_decl = var_decl; + parser_vars->m_llvm_value = NULL; + parser_vars->m_lldb_value.Clear(); if (log) { @@ -1657,13 +1614,9 @@ ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext &context, ASTContext *scratch_ast_context = target->GetScratchClangASTContext()->getASTContext(); - TypeFromUser user_type (ClangASTContext::CreateLValueReferenceType(scratch_ast_context, ClangASTContext::GetVoidPtrType(scratch_ast_context, false)), - scratch_ast_context); - - TypeFromParser parser_type (ClangASTContext::CreateLValueReferenceType(m_ast_context, ClangASTContext::GetVoidPtrType(m_ast_context, false)), - m_ast_context); - - NamedDecl *var_decl = context.AddVarDecl(parser_type.GetOpaqueQualType()); + TypeFromUser user_type (ClangASTContext::GetBasicType(scratch_ast_context, eBasicTypeVoid).GetPointerType().GetLValueReferenceType()); + TypeFromParser parser_type (ClangASTContext::GetBasicType(m_ast_context, eBasicTypeVoid).GetPointerType().GetLValueReferenceType()); + NamedDecl *var_decl = context.AddVarDecl(parser_type); std::string decl_name(context.m_decl_name.getAsString()); ConstString entity_name(decl_name.c_str()); @@ -1674,21 +1627,20 @@ ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext &context, m_parser_vars->m_target_info.address_byte_size)); assert (entity.get()); - std::unique_ptr<Value> symbol_location(new Value); - + entity->EnableParserVars(GetParserID()); + ClangExpressionVariable::ParserVars *parser_vars = entity->GetParserVars(GetParserID()); + const Address &symbol_address = symbol.GetAddress(); lldb::addr_t symbol_load_addr = symbol_address.GetLoadAddress(target); - symbol_location->SetContext(Value::eContextTypeClangType, user_type.GetOpaqueQualType()); - symbol_location->GetScalar() = symbol_load_addr; - symbol_location->SetValueType(Value::eValueTypeLoadAddress); + //parser_vars->m_lldb_value.SetContext(Value::eContextTypeClangType, user_type.GetOpaqueQualType()); + parser_vars->m_lldb_value.SetClangType(user_type); + parser_vars->m_lldb_value.GetScalar() = symbol_load_addr; + parser_vars->m_lldb_value.SetValueType(Value::eValueTypeLoadAddress); - entity->EnableParserVars(GetParserID()); - ClangExpressionVariable::ParserVars *parser_vars = entity->GetParserVars(GetParserID()); parser_vars->m_parser_type = parser_type; parser_vars->m_named_decl = var_decl; parser_vars->m_llvm_value = NULL; - parser_vars->m_lldb_value = symbol_location.release(); parser_vars->m_lldb_sym = &symbol; if (log) @@ -1748,11 +1700,11 @@ ClangExpressionDeclMap::ResolveUnknownTypes() TypeFromUser user_type(copied_type, scratch_ast_context); - parser_vars->m_lldb_value->SetContext(Value::eContextTypeClangType, user_type.GetOpaqueQualType()); +// parser_vars->m_lldb_value.SetContext(Value::eContextTypeClangType, user_type.GetOpaqueQualType()); + parser_vars->m_lldb_value.SetClangType(user_type); parser_vars->m_parser_type = parser_type; - entity->SetClangAST(user_type.GetASTContext()); - entity->SetClangType(user_type.GetOpaqueQualType()); + entity->SetClangType(user_type); entity->m_flags &= ~(ClangExpressionVariable::EVUnknownType); } @@ -1768,21 +1720,20 @@ ClangExpressionDeclMap::AddOneRegister (NameSearchContext &context, { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - void *ast_type = ClangASTContext::GetBuiltinTypeForEncodingAndBitSize(m_ast_context, - reg_info->encoding, - reg_info->byte_size * 8); + ClangASTType clang_type = ClangASTContext::GetBuiltinTypeForEncodingAndBitSize (m_ast_context, + reg_info->encoding, + reg_info->byte_size * 8); - if (!ast_type) + if (!clang_type) { if (log) log->Printf(" Tried to add a type for %s, but couldn't get one", context.m_decl_name.getAsString().c_str()); return; } - TypeFromParser parser_type (ast_type, - m_ast_context); + TypeFromParser parser_clang_type (clang_type); - NamedDecl *var_decl = context.AddVarDecl(parser_type.GetOpaqueQualType()); + NamedDecl *var_decl = context.AddVarDecl(parser_clang_type); ClangExpressionVariableSP entity(m_found_entities.CreateVariable (m_parser_vars->m_exe_ctx.GetBestExecutionContextScope(), m_parser_vars->m_target_info.byte_order, @@ -1794,10 +1745,10 @@ ClangExpressionDeclMap::AddOneRegister (NameSearchContext &context, entity->SetRegisterInfo (reg_info); entity->EnableParserVars(GetParserID()); ClangExpressionVariable::ParserVars *parser_vars = entity->GetParserVars(GetParserID()); - parser_vars->m_parser_type = parser_type; - parser_vars->m_named_decl = var_decl; - parser_vars->m_llvm_value = NULL; - parser_vars->m_lldb_value = NULL; + parser_vars->m_parser_type = parser_clang_type; + parser_vars->m_named_decl = var_decl; + parser_vars->m_llvm_value = NULL; + parser_vars->m_lldb_value.Clear(); entity->m_flags |= ClangExpressionVariable::EVBareRegister; if (log) @@ -1809,7 +1760,7 @@ ClangExpressionDeclMap::AddOneRegister (NameSearchContext &context, void ClangExpressionDeclMap::AddOneFunction (NameSearchContext &context, - Function* fun, + Function* function, Symbol* symbol, unsigned int current_id) { @@ -1817,51 +1768,46 @@ ClangExpressionDeclMap::AddOneFunction (NameSearchContext &context, Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - NamedDecl *fun_decl = NULL; - std::unique_ptr<Value> fun_location(new Value); + NamedDecl *function_decl = NULL; const Address *fun_address = NULL; - - // only valid for Functions, not for Symbols - void *fun_opaque_type = NULL; - ASTContext *fun_ast_context = NULL; + ClangASTType function_clang_type; bool is_indirect_function = false; - if (fun) + if (function) { - Type *fun_type = fun->GetType(); + Type *function_type = function->GetType(); - if (!fun_type) + if (!function_type) { if (log) log->PutCString(" Skipped a function because it has no type"); return; } - fun_opaque_type = fun_type->GetClangFullType(); + function_clang_type = function_type->GetClangFullType(); - if (!fun_opaque_type) + if (!function_clang_type) { if (log) log->PutCString(" Skipped a function because it has no Clang type"); return; } - fun_address = &fun->GetAddressRange().GetBaseAddress(); + fun_address = &function->GetAddressRange().GetBaseAddress(); - fun_ast_context = fun_type->GetClangASTContext().getASTContext(); - void *copied_type = GuardedCopyType(m_ast_context, fun_ast_context, fun_opaque_type); - if (copied_type) + ClangASTType copied_function_type = GuardedCopyType(function_clang_type); + if (copied_function_type) { - fun_decl = context.AddFunDecl(copied_type); + function_decl = context.AddFunDecl(copied_function_type); - if (!fun_decl) + if (!function_decl) { if (log) { log->Printf (" Failed to create a function decl for '%s' {0x%8.8" PRIx64 "}", - fun_type->GetName().GetCString(), - fun_type->GetID()); + function_type->GetName().GetCString(), + function_type->GetID()); } return; @@ -1873,8 +1819,8 @@ ClangExpressionDeclMap::AddOneFunction (NameSearchContext &context, if (log) { log->Printf (" Failed to import the function type '%s' {0x%8.8" PRIx64 "} into the expression parser AST contenxt", - fun_type->GetName().GetCString(), - fun_type->GetID()); + function_type->GetName().GetCString(), + function_type->GetID()); } return; @@ -1883,7 +1829,7 @@ ClangExpressionDeclMap::AddOneFunction (NameSearchContext &context, else if (symbol) { fun_address = &symbol->GetAddress(); - fun_decl = context.AddGenericFunDecl(); + function_decl = context.AddGenericFunDecl(); is_indirect_function = symbol->IsIndirect(); } else @@ -1897,10 +1843,22 @@ ClangExpressionDeclMap::AddOneFunction (NameSearchContext &context, lldb::addr_t load_addr = fun_address->GetCallableLoadAddress(target, is_indirect_function); + ClangExpressionVariableSP entity(m_found_entities.CreateVariable (m_parser_vars->m_exe_ctx.GetBestExecutionContextScope (), + m_parser_vars->m_target_info.byte_order, + m_parser_vars->m_target_info.address_byte_size)); + assert (entity.get()); + + std::string decl_name(context.m_decl_name.getAsString()); + entity->SetName(ConstString(decl_name.c_str())); + entity->SetClangType (function_clang_type); + entity->EnableParserVars(GetParserID()); + + ClangExpressionVariable::ParserVars *parser_vars = entity->GetParserVars(GetParserID()); + if (load_addr != LLDB_INVALID_ADDRESS) { - fun_location->SetValueType(Value::eValueTypeLoadAddress); - fun_location->GetScalar() = load_addr; + parser_vars->m_lldb_value.SetValueType(Value::eValueTypeLoadAddress); + parser_vars->m_lldb_value.GetScalar() = load_addr; } else { @@ -1908,28 +1866,17 @@ ClangExpressionDeclMap::AddOneFunction (NameSearchContext &context, lldb::addr_t file_addr = fun_address->GetFileAddress(); - fun_location->SetValueType(Value::eValueTypeFileAddress); - fun_location->GetScalar() = file_addr; + parser_vars->m_lldb_value.SetValueType(Value::eValueTypeFileAddress); + parser_vars->m_lldb_value.GetScalar() = file_addr; } - ClangExpressionVariableSP entity(m_found_entities.CreateVariable (m_parser_vars->m_exe_ctx.GetBestExecutionContextScope (), - m_parser_vars->m_target_info.byte_order, - m_parser_vars->m_target_info.address_byte_size)); - assert (entity.get()); - std::string decl_name(context.m_decl_name.getAsString()); - entity->SetName(ConstString(decl_name.c_str())); - entity->SetClangType (fun_opaque_type); - entity->SetClangAST (fun_ast_context); - - entity->EnableParserVars(GetParserID()); - ClangExpressionVariable::ParserVars *parser_vars = entity->GetParserVars(GetParserID()); - parser_vars->m_named_decl = fun_decl; + + parser_vars->m_named_decl = function_decl; parser_vars->m_llvm_value = NULL; - parser_vars->m_lldb_value = fun_location.release(); - + if (log) { - ASTDumper ast_dumper(fun_decl); + ASTDumper ast_dumper(function_decl); StreamString ss; @@ -1937,7 +1884,7 @@ ClangExpressionDeclMap::AddOneFunction (NameSearchContext &context, log->Printf(" CEDM::FEVD[%u] Found %s function %s (description %s), returned %s", current_id, - (fun ? "specific" : "generic"), + (function ? "specific" : "generic"), decl_name.c_str(), ss.GetData(), ast_dumper.GetCString()); @@ -1948,12 +1895,9 @@ TypeFromParser ClangExpressionDeclMap::CopyClassType(TypeFromUser &ut, unsigned int current_id) { - ASTContext *parser_ast_context = m_ast_context; - ASTContext *user_ast_context = ut.GetASTContext(); - - void *copied_type = GuardedCopyType(parser_ast_context, user_ast_context, ut.GetOpaqueQualType()); + ClangASTType copied_clang_type = GuardedCopyType(ut); - if (!copied_type) + if (!copied_clang_type) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); @@ -1963,18 +1907,17 @@ ClangExpressionDeclMap::CopyClassType(TypeFromUser &ut, return TypeFromParser(); } - if (ClangASTContext::IsAggregateType(copied_type) && ClangASTContext::GetCompleteType (parser_ast_context, copied_type)) + if (copied_clang_type.IsAggregateType() && copied_clang_type.GetCompleteType ()) { - void *args[1]; + ClangASTType void_clang_type = ClangASTContext::GetBasicType(m_ast_context, eBasicTypeVoid); + ClangASTType void_ptr_clang_type = void_clang_type.GetPointerType(); - args[0] = ClangASTContext::GetVoidPtrType(parser_ast_context, false); - - clang_type_t method_type = ClangASTContext::CreateFunctionType (parser_ast_context, - ClangASTContext::GetBuiltInType_void(parser_ast_context), - args, + ClangASTType method_type = ClangASTContext::CreateFunctionType (m_ast_context, + void_clang_type, + &void_ptr_clang_type, 1, false, - ClangASTContext::GetTypeQualifiers(copied_type)); + copied_clang_type.GetTypeQualifiers()); const bool is_virtual = false; const bool is_static = false; @@ -1983,20 +1926,18 @@ ClangExpressionDeclMap::CopyClassType(TypeFromUser &ut, const bool is_attr_used = true; const bool is_artificial = false; - ClangASTContext::AddMethodToCXXRecordType (parser_ast_context, - copied_type, - "$__lldb_expr", - method_type, - lldb::eAccessPublic, - is_virtual, - is_static, - is_inline, - is_explicit, - is_attr_used, - is_artificial); + copied_clang_type.AddMethodToCXXRecordType ("$__lldb_expr", + method_type, + lldb::eAccessPublic, + is_virtual, + is_static, + is_inline, + is_explicit, + is_attr_used, + is_artificial); } - return TypeFromParser(copied_type, parser_ast_context); + return TypeFromParser(copied_clang_type); } void @@ -2004,12 +1945,9 @@ ClangExpressionDeclMap::AddOneType(NameSearchContext &context, TypeFromUser &ut, unsigned int current_id) { - ASTContext *parser_ast_context = m_ast_context; - ASTContext *user_ast_context = ut.GetASTContext(); - - void *copied_type = GuardedCopyType(parser_ast_context, user_ast_context, ut.GetOpaqueQualType()); + ClangASTType copied_clang_type = GuardedCopyType(ut); - if (!copied_type) + if (!copied_clang_type) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); @@ -2019,5 +1957,5 @@ ClangExpressionDeclMap::AddOneType(NameSearchContext &context, return; } - context.AddTypeDecl(copied_type); + context.AddTypeDecl(copied_clang_type); } diff --git a/lldb/source/Expression/ClangExpressionVariable.cpp b/lldb/source/Expression/ClangExpressionVariable.cpp index ec08a0c0af3..0d355ce341c 100644 --- a/lldb/source/Expression/ClangExpressionVariable.cpp +++ b/lldb/source/Expression/ClangExpressionVariable.cpp @@ -74,34 +74,23 @@ ClangExpressionVariable::SetRegisterInfo (const RegisterInfo *reg_info) return m_frozen_sp->GetValue().SetContext (Value::eContextTypeRegisterInfo, const_cast<RegisterInfo *>(reg_info)); } -lldb::clang_type_t +ClangASTType ClangExpressionVariable::GetClangType() { return m_frozen_sp->GetClangType(); } void -ClangExpressionVariable::SetClangType(lldb::clang_type_t clang_type) +ClangExpressionVariable::SetClangType(const ClangASTType &clang_type) { - m_frozen_sp->GetValue().SetContext(Value::eContextTypeClangType, clang_type); + m_frozen_sp->GetValue().SetClangType(clang_type); } -clang::ASTContext * -ClangExpressionVariable::GetClangAST() -{ - return m_frozen_sp->GetClangAST(); -} - -void -ClangExpressionVariable::SetClangAST (clang::ASTContext *ast) -{ - m_frozen_sp->SetClangAST (ast); -} TypeFromUser ClangExpressionVariable::GetTypeFromUser() { - TypeFromUser tfu (m_frozen_sp->GetClangType(), m_frozen_sp->GetClangAST()); + TypeFromUser tfu (m_frozen_sp->GetClangType()); return tfu; } diff --git a/lldb/source/Expression/ClangFunction.cpp b/lldb/source/Expression/ClangFunction.cpp index e37a16a4fb7..177138df801 100644 --- a/lldb/source/Expression/ClangFunction.cpp +++ b/lldb/source/Expression/ClangFunction.cpp @@ -51,15 +51,13 @@ using namespace lldb_private; ClangFunction::ClangFunction ( ExecutionContextScope &exe_scope, - ClangASTContext *ast_context, - void *return_qualtype, + const ClangASTType &return_type, const Address& functionAddress, const ValueList &arg_value_list ) : m_function_ptr (NULL), m_function_addr (functionAddress), - m_function_return_qual_type(return_qualtype), - m_clang_ast_context (ast_context), + m_function_return_type(return_type), m_wrapper_function_name ("__lldb_caller_function"), m_wrapper_struct_name ("__lldb_caller_struct"), m_wrapper_args_addrs (), @@ -81,7 +79,7 @@ ClangFunction::ClangFunction ) : m_function_ptr (&function), m_function_addr (), - m_function_return_qual_type (), + m_function_return_type (), m_clang_ast_context (ast_context), m_wrapper_function_name ("__lldb_function_caller"), m_wrapper_struct_name ("__lldb_caller_struct"), @@ -95,7 +93,7 @@ ClangFunction::ClangFunction assert (m_jit_process_wp.lock()); m_function_addr = m_function_ptr->GetAddressRange().GetBaseAddress(); - m_function_return_qual_type = m_function_ptr->GetReturnClangType(); + m_function_return_type = m_function_ptr->GetClangType().GetFunctionReturnType(); } //---------------------------------------------------------------------- @@ -114,8 +112,7 @@ ClangFunction::CompileFunction (Stream &errors) // FIXME: How does clang tell us there's no return value? We need to handle that case. unsigned num_errors = 0; - std::string return_type_str (ClangASTType::GetTypeNameForOpaqueQualType (m_clang_ast_context->getASTContext(), - m_function_return_qual_type)); + std::string return_type_str (m_function_return_type.GetTypeName()); // Cons up the function we're going to wrap our call in, then compile it... // We declare the function "extern "C"" because the compiler might be in C++ @@ -137,16 +134,22 @@ ClangFunction::CompileFunction (Stream &errors) // to pull the defined arguments out of the function, then add the types from the // arguments list for the variable arguments. - size_t num_args = UINT32_MAX; + uint32_t num_args = UINT32_MAX; bool trust_function = false; // GetArgumentCount returns -1 for an unprototyped function. + ClangASTType function_clang_type; if (m_function_ptr) { - int num_func_args = m_function_ptr->GetArgumentCount(); - if (num_func_args >= 0) - trust_function = true; - else - num_args = num_func_args; + function_clang_type = m_function_ptr->GetClangType(); + if (function_clang_type) + { + int num_func_args = function_clang_type.GetFunctionArgumentCount(); + if (num_func_args >= 0) + { + trust_function = true; + num_args = num_func_args; + } + } } if (num_args == UINT32_MAX) @@ -160,18 +163,14 @@ ClangFunction::CompileFunction (Stream &errors) if (trust_function) { - lldb::clang_type_t arg_clang_type = m_function_ptr->GetArgumentTypeAtIndex(i); - type_name = ClangASTType::GetTypeNameForOpaqueQualType (m_clang_ast_context->getASTContext(), - arg_clang_type); + type_name = function_clang_type.GetFunctionArgumentTypeAtIndex(i).GetTypeName(); } else { - Value *arg_value = m_arg_values.GetValueAtIndex(i); - lldb::clang_type_t clang_qual_type = arg_value->GetClangType (); - if (clang_qual_type != NULL) + ClangASTType clang_qual_type = m_arg_values.GetValueAtIndex(i)->GetClangType (); + if (clang_qual_type) { - type_name = ClangASTType::GetTypeNameForOpaqueQualType (m_clang_ast_context->getASTContext(), - clang_qual_type); + type_name = clang_qual_type.GetTypeName(); } else { @@ -362,11 +361,11 @@ ClangFunction::WriteFunctionArguments (ExecutionContext &exe_ctx, // Special case: if it's a pointer, don't do anything (the ABI supports passing cstrings) if (arg_value->GetValueType() == Value::eValueTypeHostAddress && - arg_value->GetContextType() == Value::eContextTypeClangType && - ClangASTContext::IsPointerType(arg_value->GetClangType())) + arg_value->GetContextType() == Value::eContextTypeInvalid && + arg_value->GetClangType().IsPointerType()) continue; - const Scalar &arg_scalar = arg_value->ResolveValue(&exe_ctx, m_clang_ast_context->getASTContext()); + const Scalar &arg_scalar = arg_value->ResolveValue(&exe_ctx); if (!process->WriteScalarToMemory(args_addr_ref + offset, arg_scalar, arg_scalar.GetByteSize(), error)) return false; @@ -464,7 +463,7 @@ ClangFunction::FetchFunctionResults (ExecutionContext &exe_ctx, lldb::addr_t arg if (error.Fail()) return false; - ret_value.SetContext (Value::eContextTypeClangType, m_function_return_qual_type); + ret_value.SetClangType(m_function_return_type); ret_value.SetValueType(Value::eValueTypeScalar); return true; } diff --git a/lldb/source/Expression/ClangUserExpression.cpp b/lldb/source/Expression/ClangUserExpression.cpp index c72c3b10d54..18f7a8daaa1 100644 --- a/lldb/source/Expression/ClangUserExpression.cpp +++ b/lldb/source/Expression/ClangUserExpression.cpp @@ -297,21 +297,19 @@ ClangUserExpression::ScanContext(ExecutionContext &exe_ctx, Error &err) return; } - lldb::clang_type_t self_opaque_type = self_type->GetClangForwardType(); + ClangASTType self_clang_type = self_type->GetClangForwardType(); - if (!self_opaque_type) + if (!self_clang_type) { err.SetErrorString(selfErrorString); return; } - - clang::QualType self_qual_type = clang::QualType::getFromOpaquePtr(self_opaque_type); - - if (self_qual_type->isObjCClassType()) + + if (self_clang_type.IsObjCClassType()) { return; } - else if (self_qual_type->isObjCObjectPointerType()) + else if (self_clang_type.IsObjCObjectPointerType()) { m_objectivec = true; m_needs_object_ptr = true; @@ -487,6 +485,26 @@ ClangUserExpression::Parse (Stream &error_stream, m_expr_decl_map.reset(new ClangExpressionDeclMap(keep_result_in_memory, exe_ctx)); + class OnExit + { + public: + typedef std::function <void (void)> Callback; + + OnExit (Callback const &callback) : + m_callback(callback) + { + } + + ~OnExit () + { + m_callback(); + } + private: + Callback m_callback; + }; + + OnExit on_exit([this]() { m_expr_decl_map.reset(); }); + if (!m_expr_decl_map->WillParse(exe_ctx, m_materializer_ap.get())) { error_stream.PutCString ("error: current process state is unsuitable for expression parsing\n"); diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp index 07cb6881efe..7797205ffb1 100644 --- a/lldb/source/Expression/DWARFExpression.cpp +++ b/lldb/source/Expression/DWARFExpression.cpp @@ -1195,7 +1195,6 @@ bool DWARFExpression::Evaluate ( ExecutionContextScope *exe_scope, - clang::ASTContext *ast_context, ClangExpressionVariableList *expr_locals, ClangExpressionDeclMap *decl_map, lldb::addr_t loclist_base_load_addr, @@ -1205,14 +1204,13 @@ DWARFExpression::Evaluate ) const { ExecutionContext exe_ctx (exe_scope); - return Evaluate(&exe_ctx, ast_context, expr_locals, decl_map, NULL, loclist_base_load_addr, initial_value_ptr, result, error_ptr); + return Evaluate(&exe_ctx, expr_locals, decl_map, NULL, loclist_base_load_addr, initial_value_ptr, result, error_ptr); } bool DWARFExpression::Evaluate ( ExecutionContext *exe_ctx, - clang::ASTContext *ast_context, ClangExpressionVariableList *expr_locals, ClangExpressionDeclMap *decl_map, RegisterContext *reg_ctx, @@ -1269,7 +1267,7 @@ DWARFExpression::Evaluate if (length > 0 && lo_pc <= pc && pc < hi_pc) { - return DWARFExpression::Evaluate (exe_ctx, ast_context, expr_locals, decl_map, reg_ctx, m_data, offset, length, m_reg_kind, initial_value_ptr, result, error_ptr); + return DWARFExpression::Evaluate (exe_ctx, expr_locals, decl_map, reg_ctx, m_data, offset, length, m_reg_kind, initial_value_ptr, result, error_ptr); } offset += length; } @@ -1281,7 +1279,7 @@ DWARFExpression::Evaluate } // Not a location list, just a single expression. - return DWARFExpression::Evaluate (exe_ctx, ast_context, expr_locals, decl_map, reg_ctx, m_data, 0, m_data.GetByteSize(), m_reg_kind, initial_value_ptr, result, error_ptr); + return DWARFExpression::Evaluate (exe_ctx, expr_locals, decl_map, reg_ctx, m_data, 0, m_data.GetByteSize(), m_reg_kind, initial_value_ptr, result, error_ptr); } @@ -1290,7 +1288,6 @@ bool DWARFExpression::Evaluate ( ExecutionContext *exe_ctx, - clang::ASTContext *ast_context, ClangExpressionVariableList *expr_locals, ClangExpressionDeclMap *decl_map, RegisterContext *reg_ctx, @@ -1769,7 +1766,7 @@ DWARFExpression::Evaluate error_ptr->SetErrorString("Expression stack needs at least 1 item for DW_OP_abs."); return false; } - else if (stack.back().ResolveValue(exe_ctx, ast_context).AbsoluteValue() == false) + else if (stack.back().ResolveValue(exe_ctx).AbsoluteValue() == false) { if (error_ptr) error_ptr->SetErrorString("Failed to take the absolute value of the first stack item."); @@ -1794,7 +1791,7 @@ DWARFExpression::Evaluate { tmp = stack.back(); stack.pop_back(); - stack.back().ResolveValue(exe_ctx, ast_context) = stack.back().ResolveValue(exe_ctx, ast_context) & tmp.ResolveValue(exe_ctx, ast_context); + stack.back().ResolveValue(exe_ctx) = stack.back().ResolveValue(exe_ctx) & tmp.ResolveValue(exe_ctx); } break; @@ -1815,7 +1812,7 @@ DWARFExpression::Evaluate else { tmp = stack.back(); - if (tmp.ResolveValue(exe_ctx, ast_context).IsZero()) + if (tmp.ResolveValue(exe_ctx).IsZero()) { if (error_ptr) error_ptr->SetErrorString("Divide by zero."); @@ -1824,8 +1821,8 @@ DWARFExpression::Evaluate else { stack.pop_back(); - stack.back() = stack.back().ResolveValue(exe_ctx, ast_context) / tmp.ResolveValue(exe_ctx, ast_context); - if (!stack.back().ResolveValue(exe_ctx, ast_context).IsValid()) + stack.back() = stack.back().ResolveValue(exe_ctx) / tmp.ResolveValue(exe_ctx); + if (!stack.back().ResolveValue(exe_ctx).IsValid()) { if (error_ptr) error_ptr->SetErrorString("Divide failed."); @@ -1852,7 +1849,7 @@ DWARFExpression::Evaluate { tmp = stack.back(); stack.pop_back(); - stack.back().ResolveValue(exe_ctx, ast_context) = stack.back().ResolveValue(exe_ctx, ast_context) - tmp.ResolveValue(exe_ctx, ast_context); + stack.back().ResolveValue(exe_ctx) = stack.back().ResolveValue(exe_ctx) - tmp.ResolveValue(exe_ctx); } break; @@ -1874,7 +1871,7 @@ DWARFExpression::Evaluate { tmp = stack.back(); stack.pop_back(); - stack.back().ResolveValue(exe_ctx, ast_context) = stack.back().ResolveValue(exe_ctx, ast_context) % tmp.ResolveValue(exe_ctx, ast_context); + stack.back().ResolveValue(exe_ctx) = stack.back().ResolveValue(exe_ctx) % tmp.ResolveValue(exe_ctx); } break; @@ -1896,7 +1893,7 @@ DWARFExpression::Evaluate { tmp = stack.back(); stack.pop_back(); - stack.back().ResolveValue(exe_ctx, ast_context) = stack.back().ResolveValue(exe_ctx, ast_context) * tmp.ResolveValue(exe_ctx, ast_context); + stack.back().ResolveValue(exe_ctx) = stack.back().ResolveValue(exe_ctx) * tmp.ResolveValue(exe_ctx); } break; @@ -1914,7 +1911,7 @@ DWARFExpression::Evaluate } else { - if (stack.back().ResolveValue(exe_ctx, ast_context).UnaryNegate() == false) + if (stack.back().ResolveValue(exe_ctx).UnaryNegate() == false) { if (error_ptr) error_ptr->SetErrorString("Unary negate failed."); @@ -1938,7 +1935,7 @@ DWARFExpression::Evaluate } else { - if (stack.back().ResolveValue(exe_ctx, ast_context).OnesComplement() == false) + if (stack.back().ResolveValue(exe_ctx).OnesComplement() == false) { if (error_ptr) error_ptr->SetErrorString("Logical NOT failed."); @@ -1964,7 +1961,7 @@ DWARFExpression::Evaluate { tmp = stack.back(); stack.pop_back(); - stack.back().ResolveValue(exe_ctx, ast_context) = stack.back().ResolveValue(exe_ctx, ast_context) | tmp.ResolveValue(exe_ctx, ast_context); + stack.back().ResolveValue(exe_ctx) = stack.back().ResolveValue(exe_ctx) | tmp.ResolveValue(exe_ctx); } break; @@ -1985,7 +1982,7 @@ DWARFExpression::Evaluate { tmp = stack.back(); stack.pop_back(); - stack.back().ResolveValue(exe_ctx, ast_context) = stack.back().ResolveValue(exe_ctx, ast_context) + tmp.ResolveValue(exe_ctx, ast_context); + stack.back().ResolveValue(exe_ctx) = stack.back().ResolveValue(exe_ctx) + tmp.ResolveValue(exe_ctx); } break; @@ -2006,8 +2003,8 @@ DWARFExpression::Evaluate { const uint64_t uconst_value = opcodes.GetULEB128(&offset); // Implicit conversion from a UINT to a Scalar... - stack.back().ResolveValue(exe_ctx, ast_context) += uconst_value; - if (!stack.back().ResolveValue(exe_ctx, ast_context).IsValid()) + stack.back().ResolveValue(exe_ctx) += uconst_value; + if (!stack.back().ResolveValue(exe_ctx).IsValid()) { if (error_ptr) error_ptr->SetErrorString("DW_OP_plus_uconst failed."); @@ -2034,7 +2031,7 @@ DWARFExpression::Evaluate { tmp = stack.back(); stack.pop_back(); - stack.back().ResolveValue(exe_ctx, ast_context) <<= tmp.ResolveValue(exe_ctx, ast_context); + stack.back().ResolveValue(exe_ctx) <<= tmp.ResolveValue(exe_ctx); } break; @@ -2056,7 +2053,7 @@ DWARFExpression::Evaluate { tmp = stack.back(); stack.pop_back(); - if (stack.back().ResolveValue(exe_ctx, ast_context).ShiftRightLogical(tmp.ResolveValue(exe_ctx, ast_context)) == false) + if (stack.back().ResolveValue(exe_ctx).ShiftRightLogical(tmp.ResolveValue(exe_ctx)) == false) { if (error_ptr) error_ptr->SetErrorString("DW_OP_shr failed."); @@ -2084,7 +2081,7 @@ DWARFExpression::Evaluate { tmp = stack.back(); stack.pop_back(); - stack.back().ResolveValue(exe_ctx, ast_context) >>= tmp.ResolveValue(exe_ctx, ast_context); + stack.back().ResolveValue(exe_ctx) >>= tmp.ResolveValue(exe_ctx); } break; @@ -2105,7 +2102,7 @@ DWARFExpression::Evaluate { tmp = stack.back(); stack.pop_back(); - stack.back().ResolveValue(exe_ctx, ast_context) = stack.back().ResolveValue(exe_ctx, ast_context) ^ tmp.ResolveValue(exe_ctx, ast_context); + stack.back().ResolveValue(exe_ctx) = stack.back().ResolveValue(exe_ctx) ^ tmp.ResolveValue(exe_ctx); } break; @@ -2149,7 +2146,7 @@ DWARFExpression::Evaluate stack.pop_back(); int16_t bra_offset = (int16_t)opcodes.GetU16(&offset); Scalar zero(0); - if (tmp.ResolveValue(exe_ctx, ast_context) != zero) + if (tmp.ResolveValue(exe_ctx) != zero) { lldb::offset_t new_offset = offset + bra_offset; if (new_offset >= opcodes_offset && new_offset < end_offset) @@ -2184,7 +2181,7 @@ DWARFExpression::Evaluate { tmp = stack.back(); stack.pop_back(); - stack.back().ResolveValue(exe_ctx, ast_context) = stack.back().ResolveValue(exe_ctx, ast_context) == tmp.ResolveValue(exe_ctx, ast_context); + stack.back().ResolveValue(exe_ctx) = stack.back().ResolveValue(exe_ctx) == tmp.ResolveValue(exe_ctx); } break; @@ -2208,7 +2205,7 @@ DWARFExpression::Evaluate { tmp = stack.back(); stack.pop_back(); - stack.back().ResolveValue(exe_ctx, ast_context) = stack.back().ResolveValue(exe_ctx, ast_context) >= tmp.ResolveValue(exe_ctx, ast_context); + stack.back().ResolveValue(exe_ctx) = stack.back().ResolveValue(exe_ctx) >= tmp.ResolveValue(exe_ctx); } break; @@ -2232,7 +2229,7 @@ DWARFExpression::Evaluate { tmp = stack.back(); stack.pop_back(); - stack.back().ResolveValue(exe_ctx, ast_context) = stack.back().ResolveValue(exe_ctx, ast_context) > tmp.ResolveValue(exe_ctx, ast_context); + stack.back().ResolveValue(exe_ctx) = stack.back().ResolveValue(exe_ctx) > tmp.ResolveValue(exe_ctx); } break; @@ -2256,7 +2253,7 @@ DWARFExpression::Evaluate { tmp = stack.back(); stack.pop_back(); - stack.back().ResolveValue(exe_ctx, ast_context) = stack.back().ResolveValue(exe_ctx, ast_context) <= tmp.ResolveValue(exe_ctx, ast_context); + stack.back().ResolveValue(exe_ctx) = stack.back().ResolveValue(exe_ctx) <= tmp.ResolveValue(exe_ctx); } break; @@ -2280,7 +2277,7 @@ DWARFExpression::Evaluate { tmp = stack.back(); stack.pop_back(); - stack.back().ResolveValue(exe_ctx, ast_context) = stack.back().ResolveValue(exe_ctx, ast_context) < tmp.ResolveValue(exe_ctx, ast_context); + stack.back().ResolveValue(exe_ctx) = stack.back().ResolveValue(exe_ctx) < tmp.ResolveValue(exe_ctx); } break; @@ -2304,7 +2301,7 @@ DWARFExpression::Evaluate { tmp = stack.back(); stack.pop_back(); - stack.back().ResolveValue(exe_ctx, ast_context) = stack.back().ResolveValue(exe_ctx, ast_context) != tmp.ResolveValue(exe_ctx, ast_context); + stack.back().ResolveValue(exe_ctx) = stack.back().ResolveValue(exe_ctx) != tmp.ResolveValue(exe_ctx); } break; @@ -2457,7 +2454,7 @@ DWARFExpression::Evaluate if (ReadRegisterValueAsScalar (reg_ctx, reg_kind, reg_num, error_ptr, tmp)) { int64_t breg_offset = opcodes.GetSLEB128(&offset); - tmp.ResolveValue(exe_ctx, ast_context) += (uint64_t)breg_offset; + tmp.ResolveValue(exe_ctx) += (uint64_t)breg_offset; tmp.ClearContext(); stack.push_back(tmp); stack.back().SetValueType (Value::eValueTypeLoadAddress); @@ -2481,7 +2478,7 @@ DWARFExpression::Evaluate if (ReadRegisterValueAsScalar (reg_ctx, reg_kind, reg_num, error_ptr, tmp)) { int64_t breg_offset = opcodes.GetSLEB128(&offset); - tmp.ResolveValue(exe_ctx, ast_context) += (uint64_t)breg_offset; + tmp.ResolveValue(exe_ctx) += (uint64_t)breg_offset; tmp.ClearContext(); stack.push_back(tmp); stack.back().SetValueType (Value::eValueTypeLoadAddress); @@ -2630,566 +2627,6 @@ DWARFExpression::Evaluate case DW_OP_stack_value: stack.back().SetValueType(Value::eValueTypeScalar); break; - -#if 0 - //---------------------------------------------------------------------- - // OPCODE: DW_OP_call_ref - // OPERANDS: - // uint32_t absolute DIE offset for 32-bit DWARF or a uint64_t - // absolute DIE offset for 64 bit DWARF. - // DESCRIPTION: Performs a subroutine call during evaluation of a DWARF - // expression. Takes a single operand. In the 32-bit DWARF format, the - // operand is a 4-byte unsigned value; in the 64-bit DWARF format, it - // is an 8-byte unsigned value. The operand is used as the offset of a - // debugging information entry in a .debug_info section which may be - // contained in a shared object for executable other than that - // containing the operator. For references from one shared object or - // executable to another, the relocation must be performed by the - // consumer. - // - // Operand interpretation of DW_OP_call_ref is exactly like that for - // DW_FORM_ref_addr. - // - // This operation transfers control of DWARF expression evaluation - // to the DW_AT_location attribute of the referenced DIE. If there is - // no such attribute, then there is no effect. Execution of the DWARF - // expression of a DW_AT_location attribute may add to and/or remove from - // values on the stack. Execution returns to the point following the call - // when the end of the attribute is reached. Values on the stack at the - // time of the call may be used as parameters by the called expression - // and values left on the stack by the called expression may be used as - // return values by prior agreement between the calling and called - // expressions. - //---------------------------------------------------------------------- - case DW_OP_call_ref: - if (error_ptr) - error_ptr->SetErrorString ("Unimplemented opcode DW_OP_call_ref."); - return false; - - //---------------------------------------------------------------------- - // OPCODE: DW_OP_APPLE_array_ref - // OPERANDS: none - // DESCRIPTION: Pops a value off the stack and uses it as the array - // index. Pops a second value off the stack and uses it as the array - // itself. Pushes a value onto the stack representing the element of - // the array specified by the index. - //---------------------------------------------------------------------- - case DW_OP_APPLE_array_ref: - { - if (stack.size() < 2) - { - if (error_ptr) - error_ptr->SetErrorString("Expression stack needs at least 2 items for DW_OP_APPLE_array_ref."); - return false; - } - - Value index_val = stack.back(); - stack.pop_back(); - Value array_val = stack.back(); - stack.pop_back(); - - Scalar &index_scalar = index_val.ResolveValue(exe_ctx, ast_context); - int64_t index = index_scalar.SLongLong(LLONG_MAX); - - if (index == LLONG_MAX) - { - if (error_ptr) - error_ptr->SetErrorString("Invalid array index."); - return false; - } - - if (array_val.GetContextType() != Value::eContextTypeClangType) - { - if (error_ptr) - error_ptr->SetErrorString("Arrays without Clang types are unhandled at this time."); - return false; - } - - if (array_val.GetValueType() != Value::eValueTypeLoadAddress && - array_val.GetValueType() != Value::eValueTypeHostAddress) - { - if (error_ptr) - error_ptr->SetErrorString("Array must be stored in memory."); - return false; - } - - void *array_type = array_val.GetClangType(); - - void *member_type; - uint64_t size = 0; - - if ((!ClangASTContext::IsPointerType(array_type, &member_type)) && - (!ClangASTContext::IsArrayType(array_type, &member_type, &size))) - { - if (error_ptr) - error_ptr->SetErrorString("Array reference from something that is neither a pointer nor an array."); - return false; - } - - if (size && (index >= size || index < 0)) - { - if (error_ptr) - error_ptr->SetErrorStringWithFormat("Out of bounds array access. %" PRId64 " is not in [0, %" PRIu64 "]", index, size); - return false; - } - - uint64_t member_bit_size = ClangASTType::GetClangTypeBitWidth(ast_context, member_type); - uint64_t member_bit_align = ClangASTType::GetTypeBitAlign(ast_context, member_type); - uint64_t member_bit_incr = ((member_bit_size + member_bit_align - 1) / member_bit_align) * member_bit_align; - if (member_bit_incr % 8) - { - if (error_ptr) - error_ptr->SetErrorStringWithFormat("Array increment is not byte aligned"); - return false; - } - int64_t member_offset = (int64_t)(member_bit_incr / 8) * index; - - Value member; - - member.SetContext(Value::eContextTypeClangType, member_type); - member.SetValueType(array_val.GetValueType()); - - addr_t array_base = (addr_t)array_val.GetScalar().ULongLong(LLDB_INVALID_ADDRESS); - addr_t member_loc = array_base + member_offset; - member.GetScalar() = (uint64_t)member_loc; - - stack.push_back(member); - } - break; - - //---------------------------------------------------------------------- - // OPCODE: DW_OP_APPLE_uninit - // OPERANDS: none - // DESCRIPTION: Lets us know that the value is currently not initialized - //---------------------------------------------------------------------- - case DW_OP_APPLE_uninit: - //return eResultTypeErrorUninitialized; - break; // Ignore this as we have seen cases where this value is incorrectly added - - //---------------------------------------------------------------------- - // OPCODE: DW_OP_APPLE_assign - // OPERANDS: none - // DESCRIPTION: Pops a value off of the stack and assigns it to the next - // item on the stack which must be something assignable (inferior - // Variable, inferior Type with address, inferior register, or - // expression local variable. - //---------------------------------------------------------------------- - case DW_OP_APPLE_assign: - if (stack.size() < 2) - { - if (error_ptr) - error_ptr->SetErrorString("Expression stack needs at least 2 items for DW_OP_APPLE_assign."); - return false; - } - else - { - tmp = stack.back(); - stack.pop_back(); - Value::ContextType context_type = stack.back().GetContextType(); - StreamString new_value(Stream::eBinary, 4, lldb::endian::InlHostByteOrder()); - switch (context_type) - { - case Value::eContextTypeClangType: - { - void *clang_type = stack.back().GetClangType(); - - if (ClangASTContext::IsAggregateType (clang_type)) - { - Value::ValueType source_value_type = tmp.GetValueType(); - Value::ValueType target_value_type = stack.back().GetValueType(); - - addr_t source_addr = (addr_t)tmp.GetScalar().ULongLong(); - addr_t target_addr = (addr_t)stack.back().GetScalar().ULongLong(); - - const uint64_t byte_size = ClangASTType::GetTypeByteSize(ast_context, clang_type); - - switch (source_value_type) - { - case Value::eValueTypeScalar: - case Value::eValueTypeFileAddress: - break; - - case Value::eValueTypeLoadAddress: - switch (target_value_type) - { - case Value::eValueTypeLoadAddress: - { - DataBufferHeap data; - data.SetByteSize(byte_size); - - Error error; - if (process->ReadMemory (source_addr, data.GetBytes(), byte_size, error) != byte_size) - { - if (error_ptr) - error_ptr->SetErrorStringWithFormat ("Couldn't read a composite type from the target: %s", error.AsCString()); - return false; - } - - if (process->WriteMemory (target_addr, data.GetBytes(), byte_size, error) != byte_size) - { - if (error_ptr) - error_ptr->SetErrorStringWithFormat ("Couldn't write a composite type to the target: %s", error.AsCString()); - return false; - } - } - break; - case Value::eValueTypeHostAddress: - if (process->GetByteOrder() != lldb::endian::InlHostByteOrder()) - { - if (error_ptr) - error_ptr->SetErrorStringWithFormat ("Copy of composite types between incompatible byte orders is unimplemented"); - return false; - } - else - { - Error error; - if (process->ReadMemory (source_addr, (uint8_t*)target_addr, byte_size, error) != byte_size) - { - if (error_ptr) - error_ptr->SetErrorStringWithFormat ("Couldn't read a composite type from the target: %s", error.AsCString()); - return false; - } - } - break; - default: - return false; - } - break; - case Value::eValueTypeHostAddress: - switch (target_value_type) - { - case Value::eValueTypeLoadAddress: - if (process->GetByteOrder() != lldb::endian::InlHostByteOrder()) - { - if (error_ptr) - error_ptr->SetErrorStringWithFormat ("Copy of composite types between incompatible byte orders is unimplemented"); - return false; - } - else - { - Error error; - if (process->WriteMemory (target_addr, (uint8_t*)source_addr, byte_size, error) != byte_size) - { - if (error_ptr) - error_ptr->SetErrorStringWithFormat ("Couldn't write a composite type to the target: %s", error.AsCString()); - return false; - } - } - case Value::eValueTypeHostAddress: - memcpy ((uint8_t*)target_addr, (uint8_t*)source_addr, byte_size); - break; - default: - return false; - } - } - } - else - { - if (!ClangASTType::SetValueFromScalar (ast_context, - clang_type, - tmp.ResolveValue(exe_ctx, ast_context), - new_value)) - { - if (error_ptr) - error_ptr->SetErrorStringWithFormat ("Couldn't extract a value from an integral type.\n"); - return false; - } - - Value::ValueType value_type = stack.back().GetValueType(); - - switch (value_type) - { - case Value::eValueTypeLoadAddress: - case Value::eValueTypeHostAddress: - { - AddressType address_type = (value_type == Value::eValueTypeLoadAddress ? eAddressTypeLoad : eAddressTypeHost); - lldb::addr_t addr = stack.back().GetScalar().ULongLong(LLDB_INVALID_ADDRESS); - if (!ClangASTType::WriteToMemory (ast_context, - clang_type, - exe_ctx, - addr, - address_type, - new_value)) - { - if (error_ptr) - error_ptr->SetErrorStringWithFormat ("Failed to write value to memory at 0x%" PRIx64 ".\n", addr); - return false; - } - } - break; - - default: - break; - } - } - } - break; - - default: - if (error_ptr) - error_ptr->SetErrorString ("Assign failed."); - return false; - } - } - break; - - //---------------------------------------------------------------------- - // OPCODE: DW_OP_APPLE_address_of - // OPERANDS: none - // DESCRIPTION: Pops a value off of the stack and pushed its address. - // The top item on the stack must be a variable, or already be a memory - // location. - //---------------------------------------------------------------------- - case DW_OP_APPLE_address_of: - if (stack.empty()) - { - if (error_ptr) - error_ptr->SetErrorString("Expression stack needs at least 1 item for DW_OP_APPLE_address_of."); - return false; - } - else - { - Value::ValueType value_type = stack.back().GetValueType(); - switch (value_type) - { - default: - case Value::eValueTypeScalar: // raw scalar value - if (error_ptr) - error_ptr->SetErrorString("Top stack item isn't a memory based object."); - return false; - - case Value::eValueTypeLoadAddress: // load address value - case Value::eValueTypeFileAddress: // file address value - case Value::eValueTypeHostAddress: // host address value (for memory in the process that is using liblldb) - // Taking the address of an object reduces it to the address - // of the value and removes any extra context it had. - //stack.back().SetValueType(Value::eValueTypeScalar); - stack.back().ClearContext(); - break; - } - } - break; - - //---------------------------------------------------------------------- - // OPCODE: DW_OP_APPLE_value_of - // OPERANDS: none - // DESCRIPTION: Pops a value off of the stack and pushed its value. - // The top item on the stack must be a variable, expression variable. - //---------------------------------------------------------------------- - case DW_OP_APPLE_value_of: - if (stack.empty()) - { - if (error_ptr) - error_ptr->SetErrorString("Expression stack needs at least 1 items for DW_OP_APPLE_value_of."); - return false; - } - else if (!stack.back().ValueOf(exe_ctx, ast_context)) - { - if (error_ptr) - error_ptr->SetErrorString ("Top stack item isn't a valid candidate for DW_OP_APPLE_value_of."); - return false; - } - break; - - //---------------------------------------------------------------------- - // OPCODE: DW_OP_APPLE_deref_type - // OPERANDS: none - // DESCRIPTION: gets the value pointed to by the top stack item - //---------------------------------------------------------------------- - case DW_OP_APPLE_deref_type: - { - if (stack.empty()) - { - if (error_ptr) - error_ptr->SetErrorString("Expression stack needs at least 1 items for DW_OP_APPLE_deref_type."); - return false; - } - - tmp = stack.back(); - stack.pop_back(); - - if (tmp.GetContextType() != Value::eContextTypeClangType) - { - if (error_ptr) - error_ptr->SetErrorString("Item at top of expression stack must have a Clang type"); - return false; - } - - void *ptr_type = tmp.GetClangType(); - void *target_type; - - if (!ClangASTContext::IsPointerType(ptr_type, &target_type)) - { - if (error_ptr) - error_ptr->SetErrorString("Dereferencing a non-pointer type"); - return false; - } - - // TODO do we want all pointers to be dereferenced as load addresses? - Value::ValueType value_type = tmp.GetValueType(); - - tmp.ResolveValue(exe_ctx, ast_context); - - tmp.SetValueType(value_type); - tmp.SetContext(Value::eContextTypeClangType, target_type); - - stack.push_back(tmp); - } - break; - - //---------------------------------------------------------------------- - // OPCODE: DW_OP_APPLE_expr_local - // OPERANDS: ULEB128 - // DESCRIPTION: pushes the expression local variable index onto the - // stack and set the appropriate context so we know the stack item is - // an expression local variable index. - //---------------------------------------------------------------------- - case DW_OP_APPLE_expr_local: - { - /* - uint32_t idx = opcodes.GetULEB128(&offset); - if (expr_locals == NULL) - { - if (error_ptr) - error_ptr->SetErrorStringWithFormat ("DW_OP_APPLE_expr_local(%u) opcode encountered with no local variable list.\n", idx); - return false; - } - Value *expr_local_variable = expr_locals->GetVariableAtIndex(idx); - if (expr_local_variable == NULL) - { - if (error_ptr) - error_ptr->SetErrorStringWithFormat ("DW_OP_APPLE_expr_local(%u) with invalid index %u.\n", idx, idx); - return false; - } - // The proxy code has been removed. If it is ever re-added, please - // use shared pointers or return by value to avoid possible memory - // leak (there is no leak here, but in general, no returning pointers - // that must be manually freed please. - Value *proxy = expr_local_variable->CreateProxy(); - stack.push_back(*proxy); - delete proxy; - //stack.back().SetContext (Value::eContextTypeClangType, expr_local_variable->GetClangType()); - */ - } - break; - - //---------------------------------------------------------------------- - // OPCODE: DW_OP_APPLE_extern - // OPERANDS: ULEB128 - // DESCRIPTION: pushes a proxy for the extern object index onto the - // stack. - //---------------------------------------------------------------------- - case DW_OP_APPLE_extern: - { - /* - uint32_t idx = opcodes.GetULEB128(&offset); - if (!decl_map) - { - if (error_ptr) - error_ptr->SetErrorStringWithFormat ("DW_OP_APPLE_extern(%u) opcode encountered with no decl map.\n", idx); - return false; - } - Value *extern_var = decl_map->GetValueForIndex(idx); - if (!extern_var) - { - if (error_ptr) - error_ptr->SetErrorStringWithFormat ("DW_OP_APPLE_extern(%u) with invalid index %u.\n", idx, idx); - return false; - } - // The proxy code has been removed. If it is ever re-added, please - // use shared pointers or return by value to avoid possible memory - // leak (there is no leak here, but in general, no returning pointers - // that must be manually freed please. - Value *proxy = extern_var->CreateProxy(); - stack.push_back(*proxy); - delete proxy; - */ - } - break; - - case DW_OP_APPLE_scalar_cast: - if (stack.empty()) - { - if (error_ptr) - error_ptr->SetErrorString("Expression stack needs at least 1 item for DW_OP_APPLE_scalar_cast."); - return false; - } - else - { - // Simple scalar cast - if (!stack.back().ResolveValue(exe_ctx, ast_context).Cast((Scalar::Type)opcodes.GetU8(&offset))) - { - if (error_ptr) - error_ptr->SetErrorString("Cast failed."); - return false; - } - } - break; - - - case DW_OP_APPLE_clang_cast: - if (stack.empty()) - { - if (error_ptr) - error_ptr->SetErrorString("Expression stack needs at least 1 item for DW_OP_APPLE_clang_cast."); - return false; - } - else - { - void *clang_type = (void *)opcodes.GetMaxU64(&offset, sizeof(void*)); - stack.back().SetContext (Value::eContextTypeClangType, clang_type); - } - break; - //---------------------------------------------------------------------- - // OPCODE: DW_OP_APPLE_constf - // OPERANDS: 1 byte float length, followed by that many bytes containing - // the constant float data. - // DESCRIPTION: Push a float value onto the expression stack. - //---------------------------------------------------------------------- - case DW_OP_APPLE_constf: // 0xF6 - 1 byte float size, followed by constant float data - { - uint8_t float_length = opcodes.GetU8(&offset); - if (sizeof(float) == float_length) - tmp.ResolveValue(exe_ctx, ast_context) = opcodes.GetFloat (&offset); - else if (sizeof(double) == float_length) - tmp.ResolveValue(exe_ctx, ast_context) = opcodes.GetDouble (&offset); - else if (sizeof(long double) == float_length) - tmp.ResolveValue(exe_ctx, ast_context) = opcodes.GetLongDouble (&offset); - else - { - StreamString new_value; - opcodes.Dump(&new_value, offset, eFormatBytes, 1, float_length, UINT32_MAX, DW_INVALID_ADDRESS, 0, 0); - - if (error_ptr) - error_ptr->SetErrorStringWithFormat ("DW_OP_APPLE_constf(<%u> %s) unsupported float size.\n", float_length, new_value.GetData()); - return false; - } - tmp.SetValueType(Value::eValueTypeScalar); - tmp.ClearContext(); - stack.push_back(tmp); - } - break; - //---------------------------------------------------------------------- - // OPCODE: DW_OP_APPLE_clear - // OPERANDS: none - // DESCRIPTION: Clears the expression stack. - //---------------------------------------------------------------------- - case DW_OP_APPLE_clear: - stack.clear(); - break; - - //---------------------------------------------------------------------- - // OPCODE: DW_OP_APPLE_error - // OPERANDS: none - // DESCRIPTION: Pops a value off of the stack and pushed its value. - // The top item on the stack must be a variable, expression variable. - //---------------------------------------------------------------------- - case DW_OP_APPLE_error: // 0xFF - Stops expression evaluation and returns an error (no args) - if (error_ptr) - error_ptr->SetErrorString ("Generic error."); - return false; -#endif // #if 0 - } } diff --git a/lldb/source/Expression/IRForTarget.cpp b/lldb/source/Expression/IRForTarget.cpp index 37b424056e5..711943401db 100644 --- a/lldb/source/Expression/IRForTarget.cpp +++ b/lldb/source/Expression/IRForTarget.cpp @@ -33,6 +33,7 @@ #include "lldb/Expression/IRInterpreter.h" #include "lldb/Host/Endian.h" #include "lldb/Symbol/ClangASTContext.h" +#include "lldb/Symbol/ClangASTType.h" #include <map> @@ -130,7 +131,7 @@ PrintValue(const Value *value, bool truncate = false) } static std::string -PrintType(const Type *type, bool truncate = false) +PrintType(const llvm::Type *type, bool truncate = false) { std::string s; raw_string_ostream rso(s); @@ -565,7 +566,7 @@ IRForTarget::CreateResultVariable (llvm::Function &llvm_function) &result_decl->getASTContext()); } - if (m_result_type.GetClangTypeBitWidth() == 0) + if (m_result_type.GetBitSize() == 0) { lldb_private::StreamString type_desc_stream; m_result_type.DumpTypeDescription(&type_desc_stream); @@ -592,7 +593,7 @@ IRForTarget::CreateResultVariable (llvm::Function &llvm_function) if (log) log->Printf("Creating a new result global: \"%s\" with size 0x%" PRIx64, m_result_name.GetCString(), - m_result_type.GetClangTypeBitWidth() / 8); + m_result_type.GetByteSize()); // Construct a new result global and set up its metadata @@ -1496,22 +1497,14 @@ IRForTarget::MaybeHandleVariable (Value *llvm_value_ptr) std::string name (named_decl->getName().str()); - void *opaque_type = NULL; - clang::ASTContext *ast_context = NULL; - - if (clang::ValueDecl *value_decl = dyn_cast<clang::ValueDecl>(named_decl)) - { - opaque_type = value_decl->getType().getAsOpaquePtr(); - ast_context = &value_decl->getASTContext(); - } - else - { + clang::ValueDecl *value_decl = dyn_cast<clang::ValueDecl>(named_decl); + if (value_decl == NULL) return false; - } + + lldb_private::ClangASTType clang_type(&value_decl->getASTContext(), value_decl->getType()); - clang::QualType qual_type; const Type *value_type = NULL; - + if (name[0] == '$') { // The $__lldb_expr_result name indicates the the return value has allocated as @@ -1523,26 +1516,26 @@ IRForTarget::MaybeHandleVariable (Value *llvm_value_ptr) // to the type of $__lldb_expr_result, not the type itself. // // We also do this for any user-declared persistent variables. - - qual_type = ast_context->getPointerType(clang::QualType::getFromOpaquePtr(opaque_type)); + clang_type = clang_type.GetPointerType(); value_type = PointerType::get(global_variable->getType(), 0); } else { - qual_type = clang::QualType::getFromOpaquePtr(opaque_type); value_type = global_variable->getType(); } - - uint64_t value_size = (ast_context->getTypeSize(qual_type) + 7ull) / 8ull; - off_t value_alignment = (ast_context->getTypeAlign(qual_type) + 7ull) / 8ull; + + const uint64_t value_size = clang_type.GetByteSize(); + off_t value_alignment = (clang_type.GetTypeBitAlign() + 7ull) / 8ull; if (log) + { log->Printf("Type of \"%s\" is [clang \"%s\", llvm \"%s\"] [size %" PRIu64 ", align %" PRId64 "]", name.c_str(), - qual_type.getAsString().c_str(), - PrintType(value_type).c_str(), + clang_type.GetQualType().getAsString().c_str(), + PrintType(value_type).c_str(), value_size, value_alignment); + } if (named_decl && !m_decl_map->AddValueToStruct(named_decl, diff --git a/lldb/source/Expression/Materializer.cpp b/lldb/source/Expression/Materializer.cpp index 52dfefd6c99..6236eda1a86 100644 --- a/lldb/source/Expression/Materializer.cpp +++ b/lldb/source/Expression/Materializer.cpp @@ -49,7 +49,7 @@ Materializer::AddStructMember (Entity &entity) void Materializer::Entity::SetSizeAndAlignmentFromType (ClangASTType &type) { - m_size = type.GetTypeByteSize(); + m_size = type.GetByteSize(); uint32_t bit_alignment = type.GetTypeBitAlign(); @@ -100,8 +100,7 @@ public: // Put the location of the spare memory into the live data of the ValueObject. m_persistent_variable_sp->m_live_sp = ValueObjectConstResult::Create (map.GetBestExecutionContextScope(), - m_persistent_variable_sp->GetTypeFromUser().GetASTContext(), - m_persistent_variable_sp->GetTypeFromUser().GetOpaqueQualType(), + m_persistent_variable_sp->GetTypeFromUser(), m_persistent_variable_sp->GetName(), mem, eAddressTypeLoad, @@ -151,10 +150,12 @@ public: { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + const lldb::addr_t load_addr = process_address + m_offset; + if (log) { - log->Printf("EntityPersistentVariable::Materialize [process_address = 0x%" PRIx64 ", m_name = %s, m_flags = 0x%hx]", - (uint64_t)process_address, + log->Printf("EntityPersistentVariable::Materialize [address = 0x%" PRIx64 ", m_name = %s, m_flags = 0x%hx]", + (uint64_t)load_addr, m_persistent_variable_sp->GetName().AsCString(), m_persistent_variable_sp->m_flags); } @@ -173,7 +174,7 @@ public: { Error write_error; - map.WriteScalarToMemory(process_address + m_offset, + map.WriteScalarToMemory(load_addr, m_persistent_variable_sp->m_live_sp->GetValue().GetScalar(), map.GetAddressByteSize(), write_error); @@ -190,15 +191,21 @@ public: } } - void Dematerialize (lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address, - lldb::addr_t frame_top, lldb::addr_t frame_bottom, Error &err) + void Dematerialize (lldb::StackFrameSP &frame_sp, + IRMemoryMap &map, + lldb::addr_t process_address, + lldb::addr_t frame_top, + lldb::addr_t frame_bottom, + Error &err) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + const lldb::addr_t load_addr = process_address + m_offset; + if (log) { - log->Printf("EntityPersistentVariable::Dematerialize [process_address = 0x%" PRIx64 ", m_name = %s, m_flags = 0x%hx]", - (uint64_t)process_address, + log->Printf("EntityPersistentVariable::Dematerialize [address = 0x%" PRIx64 ", m_name = %s, m_flags = 0x%hx]", + (uint64_t)process_address + m_offset, m_persistent_variable_sp->GetName().AsCString(), m_persistent_variable_sp->m_flags); } @@ -215,7 +222,7 @@ public: lldb::addr_t location; Error read_error; - map.ReadPointerFromMemory(&location, process_address + m_offset, read_error); + map.ReadPointerFromMemory(&location, load_addr, read_error); if (!read_error.Success()) { @@ -224,8 +231,7 @@ public: } m_persistent_variable_sp->m_live_sp = ValueObjectConstResult::Create (map.GetBestExecutionContextScope (), - m_persistent_variable_sp->GetTypeFromUser().GetASTContext(), - m_persistent_variable_sp->GetTypeFromUser().GetOpaqueQualType(), + m_persistent_variable_sp->GetTypeFromUser(), m_persistent_variable_sp->GetName(), location, eAddressTypeLoad, @@ -319,14 +325,16 @@ public: Error err; - dump_stream.Printf("0x%" PRIx64 ": EntityPersistentVariable (%s)\n", process_address + m_offset, m_persistent_variable_sp->GetName().AsCString()); + const lldb::addr_t load_addr = process_address + m_offset; + + dump_stream.Printf("0x%" PRIx64 ": EntityPersistentVariable (%s)\n", load_addr, m_persistent_variable_sp->GetName().AsCString()); { dump_stream.Printf("Pointer:\n"); DataBufferHeap data (m_size, 0); - map.ReadMemory(data.GetBytes(), process_address + m_offset, m_size, err); + map.ReadMemory(data.GetBytes(), load_addr, m_size, err); if (!err.Success()) { @@ -336,7 +344,7 @@ public: { DataExtractor extractor (data.GetBytes(), data.GetByteSize(), map.GetByteOrder(), map.GetAddressByteSize()); - extractor.DumpHexBytes(&dump_stream, data.GetBytes(), data.GetByteSize(), 16, process_address + m_offset); + extractor.DumpHexBytes(&dump_stream, data.GetBytes(), data.GetByteSize(), 16, load_addr); dump_stream.PutChar('\n'); } @@ -347,7 +355,7 @@ public: lldb::addr_t target_address; - map.ReadPointerFromMemory (&target_address, process_address + m_offset, err); + map.ReadPointerFromMemory (&target_address, load_addr, err); if (!err.Success()) { @@ -407,17 +415,18 @@ public: // Hard-coding to maximum size of a pointer since all variables are materialized by reference m_size = 8; m_alignment = 8; - m_is_reference = ClangASTContext::IsReferenceType(m_variable_sp->GetType()->GetClangForwardType()); + m_is_reference = m_variable_sp->GetType()->GetClangForwardType().IsReferenceType(); } void Materialize (lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address, Error &err) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + const lldb::addr_t load_addr = process_address + m_offset; if (log) { - log->Printf("EntityVariable::Materialize [process_address = 0x%" PRIx64 ", m_variable_sp = %s]", - (uint64_t)process_address, + log->Printf("EntityVariable::Materialize [address = 0x%" PRIx64 ", m_variable_sp = %s]", + (uint64_t)load_addr, m_variable_sp->GetName().AsCString()); } @@ -442,7 +451,7 @@ public: lldb::addr_t reference_addr = valobj_extractor.GetAddress(&offset); Error write_error; - map.WritePointerToMemory(process_address + m_offset, reference_addr, write_error); + map.WritePointerToMemory(load_addr, reference_addr, write_error); if (!write_error.Success()) { @@ -462,7 +471,7 @@ public: lldb::addr_t addr_of_valobj_addr = valobj_extractor.GetAddress(&offset); Error write_error; - map.WritePointerToMemory(process_address + m_offset, addr_of_valobj_addr, write_error); + map.WritePointerToMemory(load_addr, addr_of_valobj_addr, write_error); if (!write_error.Success()) { @@ -494,7 +503,7 @@ public: return; } - size_t bit_align = ClangASTType::GetTypeBitAlign(m_variable_sp->GetType()->GetClangAST(), m_variable_sp->GetType()->GetClangLayoutType()); + size_t bit_align = m_variable_sp->GetType()->GetClangLayoutType().GetTypeBitAlign(); size_t byte_align = (bit_align + 7) / 8; Error alloc_error; @@ -520,7 +529,7 @@ public: Error pointer_write_error; - map.WritePointerToMemory(process_address + m_offset, m_temporary_allocation, pointer_write_error); + map.WritePointerToMemory(load_addr, m_temporary_allocation, pointer_write_error); if (!pointer_write_error.Success()) { @@ -530,15 +539,20 @@ public: } } - void Dematerialize (lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address, - lldb::addr_t frame_top, lldb::addr_t frame_bottom, Error &err) + void Dematerialize (lldb::StackFrameSP &frame_sp, + IRMemoryMap &map, + lldb::addr_t process_address, + lldb::addr_t frame_top, + lldb::addr_t frame_bottom, + Error &err) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + const lldb::addr_t load_addr = process_address + m_offset; if (log) { - log->Printf("EntityVariable::Dematerialize [process_address = 0x%" PRIx64 ", m_variable_sp = %s]", - (uint64_t)process_address, + log->Printf("EntityVariable::Dematerialize [address = 0x%" PRIx64 ", m_variable_sp = %s]", + (uint64_t)load_addr, m_variable_sp->GetName().AsCString()); } @@ -597,8 +611,9 @@ public: void DumpToLog (IRMemoryMap &map, lldb::addr_t process_address, Log *log) { StreamString dump_stream; - - dump_stream.Printf("0x%" PRIx64 ": EntityVariable\n", process_address + m_offset); + + const lldb::addr_t load_addr = process_address + m_offset; + dump_stream.Printf("0x%" PRIx64 ": EntityVariable\n", load_addr); Error err; @@ -609,7 +624,7 @@ public: DataBufferHeap data (m_size, 0); - map.ReadMemory(data.GetBytes(), process_address + m_offset, m_size, err); + map.ReadMemory(data.GetBytes(), load_addr, m_size, err); if (!err.Success()) { @@ -619,7 +634,7 @@ public: { DataExtractor extractor (data.GetBytes(), data.GetByteSize(), map.GetByteOrder(), map.GetAddressByteSize()); - extractor.DumpHexBytes(&dump_stream, data.GetBytes(), data.GetByteSize(), 16, process_address + m_offset); + extractor.DumpHexBytes(&dump_stream, data.GetBytes(), data.GetByteSize(), 16, load_addr); lldb::offset_t offset; @@ -656,7 +671,7 @@ public: { DataExtractor extractor (data.GetBytes(), data.GetByteSize(), map.GetByteOrder(), map.GetAddressByteSize()); - extractor.DumpHexBytes(&dump_stream, data.GetBytes(), data.GetByteSize(), 16, process_address + m_offset); + extractor.DumpHexBytes(&dump_stream, data.GetBytes(), data.GetByteSize(), 16, load_addr); dump_stream.PutChar('\n'); } @@ -721,7 +736,9 @@ public: return; } - size_t byte_size = m_type.GetTypeByteSize(); + const lldb::addr_t load_addr = process_address + m_offset; + + size_t byte_size = m_type.GetByteSize(); size_t bit_align = m_type.GetTypeBitAlign(); size_t byte_align = (bit_align + 7) / 8; @@ -738,7 +755,7 @@ public: Error pointer_write_error; - map.WritePointerToMemory(process_address + m_offset, m_temporary_allocation, pointer_write_error); + map.WritePointerToMemory(load_addr, m_temporary_allocation, pointer_write_error); if (!pointer_write_error.Success()) { @@ -747,15 +764,23 @@ public: } } - void Dematerialize (lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address, - lldb::addr_t frame_top, lldb::addr_t frame_bottom, Error &err) + void Dematerialize (lldb::StackFrameSP &frame_sp, + IRMemoryMap &map, + lldb::addr_t process_address, + lldb::addr_t frame_top, + lldb::addr_t frame_bottom, + Error &err) { err.SetErrorString("Tried to detmaterialize a result variable with the normal Dematerialize method"); } void Dematerialize (lldb::ClangExpressionVariableSP &result_variable_sp, - lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address, - lldb::addr_t frame_top, lldb::addr_t frame_bottom, Error &err) + lldb::StackFrameSP &frame_sp, + IRMemoryMap &map, + lldb::addr_t process_address, + lldb::addr_t frame_top, + lldb::addr_t frame_bottom, + Error &err) { err.Clear(); @@ -769,8 +794,9 @@ public: lldb::addr_t address; Error read_error; + const lldb::addr_t load_addr = process_address + m_offset; - map.ReadPointerFromMemory (&address, process_address + m_offset, read_error); + map.ReadPointerFromMemory (&address, load_addr, read_error); if (!read_error.Success()) { @@ -809,8 +835,7 @@ public: if (can_persist && m_keep_in_memory) { ret->m_live_sp = ValueObjectConstResult::Create(exe_scope, - m_type.GetASTContext(), - m_type.GetOpaqueQualType(), + m_type, name, address, eAddressTypeLoad, @@ -854,8 +879,10 @@ public: void DumpToLog (IRMemoryMap &map, lldb::addr_t process_address, Log *log) { StreamString dump_stream; - - dump_stream.Printf("0x%" PRIx64 ": EntityResultVariable\n", process_address + m_offset); + + const lldb::addr_t load_addr = process_address + m_offset; + + dump_stream.Printf("0x%" PRIx64 ": EntityResultVariable\n", load_addr); Error err; @@ -866,7 +893,7 @@ public: DataBufferHeap data (m_size, 0); - map.ReadMemory(data.GetBytes(), process_address + m_offset, m_size, err); + map.ReadMemory(data.GetBytes(), load_addr, m_size, err); if (!err.Success()) { @@ -876,7 +903,7 @@ public: { DataExtractor extractor (data.GetBytes(), data.GetByteSize(), map.GetByteOrder(), map.GetAddressByteSize()); - extractor.DumpHexBytes(&dump_stream, data.GetBytes(), data.GetByteSize(), 16, process_address + m_offset); + extractor.DumpHexBytes(&dump_stream, data.GetBytes(), data.GetByteSize(), 16, load_addr); lldb::offset_t offset; @@ -913,7 +940,7 @@ public: { DataExtractor extractor (data.GetBytes(), data.GetByteSize(), map.GetByteOrder(), map.GetAddressByteSize()); - extractor.DumpHexBytes(&dump_stream, data.GetBytes(), data.GetByteSize(), 16, process_address + m_offset); + extractor.DumpHexBytes(&dump_stream, data.GetBytes(), data.GetByteSize(), 16, load_addr); dump_stream.PutChar('\n'); } @@ -970,10 +997,12 @@ public: { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + const lldb::addr_t load_addr = process_address + m_offset; + if (log) { - log->Printf("EntitySymbol::Materialize [process_address = 0x%" PRIx64 ", m_symbol = %s]", - (uint64_t)process_address, + log->Printf("EntitySymbol::Materialize [address = 0x%" PRIx64 ", m_symbol = %s]", + (uint64_t)load_addr, m_symbol.GetName().AsCString()); } @@ -999,7 +1028,7 @@ public: Error pointer_write_error; - map.WritePointerToMemory(process_address + m_offset, resolved_address, pointer_write_error); + map.WritePointerToMemory(load_addr, resolved_address, pointer_write_error); if (!pointer_write_error.Success()) { @@ -1008,15 +1037,21 @@ public: } } - void Dematerialize (lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address, - lldb::addr_t frame_top, lldb::addr_t frame_bottom, Error &err) + void Dematerialize (lldb::StackFrameSP &frame_sp, + IRMemoryMap &map, + lldb::addr_t process_address, + lldb::addr_t frame_top, + lldb::addr_t frame_bottom, + Error &err) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + const lldb::addr_t load_addr = process_address + m_offset; + if (log) { - log->Printf("EntitySymbol::Dematerialize [process_address = 0x%" PRIx64 ", m_symbol = %s]", - (uint64_t)process_address, + log->Printf("EntitySymbol::Dematerialize [address = 0x%" PRIx64 ", m_symbol = %s]", + (uint64_t)load_addr, m_symbol.GetName().AsCString()); } @@ -1029,14 +1064,16 @@ public: Error err; - dump_stream.Printf("0x%" PRIx64 ": EntitySymbol (%s)\n", process_address + m_offset, m_symbol.GetName().AsCString()); + const lldb::addr_t load_addr = process_address + m_offset; + + dump_stream.Printf("0x%" PRIx64 ": EntitySymbol (%s)\n", load_addr, m_symbol.GetName().AsCString()); { dump_stream.Printf("Pointer:\n"); DataBufferHeap data (m_size, 0); - map.ReadMemory(data.GetBytes(), process_address + m_offset, m_size, err); + map.ReadMemory(data.GetBytes(), load_addr, m_size, err); if (!err.Success()) { @@ -1046,7 +1083,7 @@ public: { DataExtractor extractor (data.GetBytes(), data.GetByteSize(), map.GetByteOrder(), map.GetAddressByteSize()); - extractor.DumpHexBytes(&dump_stream, data.GetBytes(), data.GetByteSize(), 16, process_address + m_offset); + extractor.DumpHexBytes(&dump_stream, data.GetBytes(), data.GetByteSize(), 16, load_addr); dump_stream.PutChar('\n'); } @@ -1088,10 +1125,12 @@ public: { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + const lldb::addr_t load_addr = process_address + m_offset; + if (log) { - log->Printf("EntityRegister::Materialize [process_address = 0x%" PRIx64 ", m_register_info = %s]", - (uint64_t)process_address, + log->Printf("EntityRegister::Materialize [address = 0x%" PRIx64 ", m_register_info = %s]", + (uint64_t)load_addr, m_register_info.name); } @@ -1127,7 +1166,7 @@ public: Error write_error; - map.WriteMemory(process_address + m_offset, register_data.GetDataStart(), register_data.GetByteSize(), write_error); + map.WriteMemory(load_addr, register_data.GetDataStart(), register_data.GetByteSize(), write_error); if (!write_error.Success()) { @@ -1136,15 +1175,21 @@ public: } } - void Dematerialize (lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address, - lldb::addr_t frame_top, lldb::addr_t frame_bottom, Error &err) + void Dematerialize (lldb::StackFrameSP &frame_sp, + IRMemoryMap &map, + lldb::addr_t process_address, + lldb::addr_t frame_top, + lldb::addr_t frame_bottom, + Error &err) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + const lldb::addr_t load_addr = process_address + m_offset; + if (log) { - log->Printf("EntityRegister::Dematerialize [process_address = 0x%" PRIx64 ", m_register_info = %s]", - (uint64_t)process_address, + log->Printf("EntityRegister::Dematerialize [address = 0x%" PRIx64 ", m_register_info = %s]", + (uint64_t)load_addr, m_register_info.name); } @@ -1160,7 +1205,7 @@ public: lldb::RegisterContextSP reg_context_sp = frame_sp->GetRegisterContext(); - map.GetMemoryData(register_data, process_address + m_offset, m_register_info.byte_size, extract_error); + map.GetMemoryData(register_data, load_addr, m_register_info.byte_size, extract_error); if (!extract_error.Success()) { @@ -1183,14 +1228,17 @@ public: Error err; - dump_stream.Printf("0x%" PRIx64 ": EntityRegister (%s)\n", process_address + m_offset, m_register_info.name); + const lldb::addr_t load_addr = process_address + m_offset; + + + dump_stream.Printf("0x%" PRIx64 ": EntityRegister (%s)\n", load_addr, m_register_info.name); { dump_stream.Printf("Value:\n"); DataBufferHeap data (m_size, 0); - map.ReadMemory(data.GetBytes(), process_address + m_offset, m_size, err); + map.ReadMemory(data.GetBytes(), load_addr, m_size, err); if (!err.Success()) { @@ -1200,7 +1248,7 @@ public: { DataExtractor extractor (data.GetBytes(), data.GetByteSize(), map.GetByteOrder(), map.GetAddressByteSize()); - extractor.DumpHexBytes(&dump_stream, data.GetBytes(), data.GetByteSize(), 16, process_address + m_offset); + extractor.DumpHexBytes(&dump_stream, data.GetBytes(), data.GetByteSize(), 16, load_addr); dump_stream.PutChar('\n'); } |