diff options
| author | Sean Callanan <scallanan@apple.com> | 2012-09-24 22:25:51 +0000 |
|---|---|---|
| committer | Sean Callanan <scallanan@apple.com> | 2012-09-24 22:25:51 +0000 |
| commit | 3d654b30449e2dedd6e5d3f4961a724cf93860bf (patch) | |
| tree | 4634b19442525870a967bd217330e64da44f884b /lldb/source | |
| parent | 9f4729d3317f8f04b2e7a1e7ac36418722dc492e (diff) | |
| download | bcm5719-llvm-3d654b30449e2dedd6e5d3f4961a724cf93860bf.tar.gz bcm5719-llvm-3d654b30449e2dedd6e5d3f4961a724cf93860bf.zip | |
Brought LLDB top-of-tree into sync with LLVM/Clang
top-of-tree. Removed all local patches and llvm.zip.
The intent is that fron now on top-of-tree will
always build against LLVM/Clang top-of-tree, and
that problems building will be resolved as they
occur. Stable release branches of LLDB can be
constructed as needed and linked to specific release
branches of LLVM/Clang.
llvm-svn: 164563
Diffstat (limited to 'lldb/source')
| -rw-r--r-- | lldb/source/Commands/CommandObjectMemory.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Expression/ASTStructExtractor.cpp | 39 | ||||
| -rw-r--r-- | lldb/source/Expression/ClangASTSource.cpp | 4 | ||||
| -rw-r--r-- | lldb/source/Expression/ClangExpressionDeclMap.cpp | 1 | ||||
| -rw-r--r-- | lldb/source/Expression/ClangExpressionParser.cpp | 131 | ||||
| -rw-r--r-- | lldb/source/Expression/IRForTarget.cpp | 61 | ||||
| -rw-r--r-- | lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | 6 | ||||
| -rw-r--r-- | lldb/source/Symbol/ClangASTContext.cpp | 26 | ||||
| -rw-r--r-- | lldb/source/Symbol/ClangASTImporter.cpp | 3 | ||||
| -rw-r--r-- | lldb/source/Symbol/ClangASTType.cpp | 3 | ||||
| -rw-r--r-- | lldb/source/Symbol/TypeHierarchyNavigator.cpp | 1 |
11 files changed, 195 insertions, 82 deletions
diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp index 7c14dceee86..6a008956b65 100644 --- a/lldb/source/Commands/CommandObjectMemory.cpp +++ b/lldb/source/Commands/CommandObjectMemory.cpp @@ -39,7 +39,7 @@ g_option_table[] = { { LLDB_OPT_SET_1, false, "num-per-line" ,'l', required_argument, NULL, 0, eArgTypeNumberPerLine ,"The number of items per line to display."}, { LLDB_OPT_SET_2, false, "binary" ,'b', no_argument , NULL, 0, eArgTypeNone ,"If true, memory will be saved as binary. If false, the memory is saved save as an ASCII dump that uses the format, size, count and number per line settings."}, - { LLDB_OPT_SET_3, true , "view-as" ,'t', required_argument, NULL, 0, eArgTypeNone ,"The name of a type to view memory as."}, + { LLDB_OPT_SET_3, true , "type" ,'t', required_argument, NULL, 0, eArgTypeNone ,"The name of a type to view memory as."}, { LLDB_OPT_SET_4, false, "force" ,'r', no_argument, NULL, 0, eArgTypeNone ,"Necessary if reading over 1024 bytes of memory."}, }; diff --git a/lldb/source/Expression/ASTStructExtractor.cpp b/lldb/source/Expression/ASTStructExtractor.cpp index 7bc31a5d815..d1f21923deb 100644 --- a/lldb/source/Expression/ASTStructExtractor.cpp +++ b/lldb/source/Expression/ASTStructExtractor.cpp @@ -59,13 +59,42 @@ ASTStructExtractor::Initialize(ASTContext &Context) void ASTStructExtractor::ExtractFromFunctionDecl(FunctionDecl *F) { - DeclarationName struct_name(&m_ast_context->Idents.get(m_struct_name.c_str())); - RecordDecl::lookup_result struct_lookup = F->lookup(struct_name); - - if (struct_lookup.first == struct_lookup.second) + if (!F->hasBody()) return; - RecordDecl *struct_decl = dyn_cast<RecordDecl>(*(struct_lookup.first)); + Stmt *body_stmt = F->getBody(); + CompoundStmt *body_compound_stmt = dyn_cast<CompoundStmt>(body_stmt); + + if (!body_compound_stmt) + return; // do we have to handle this? + + RecordDecl *struct_decl = NULL; + + StringRef desired_name(m_struct_name.c_str()); + + for (CompoundStmt::const_body_iterator bi = body_compound_stmt->body_begin(), be = body_compound_stmt->body_end(); + bi != be; + ++bi) + { + Stmt *curr_stmt = *bi; + DeclStmt *curr_decl_stmt = dyn_cast<DeclStmt>(curr_stmt); + if (!curr_decl_stmt) + continue; + DeclGroupRef decl_group = curr_decl_stmt->getDeclGroup(); + for (Decl *candidate_decl : decl_group) + { + RecordDecl *candidate_record_decl = dyn_cast<RecordDecl>(candidate_decl); + if (!candidate_record_decl) + continue; + if (candidate_record_decl->getName() == desired_name) + { + struct_decl = candidate_record_decl; + break; + } + } + if (struct_decl) + break; + } if (!struct_decl) return; diff --git a/lldb/source/Expression/ClangASTSource.cpp b/lldb/source/Expression/ClangASTSource.cpp index 3d3a6f61ca7..ef84b5033f4 100644 --- a/lldb/source/Expression/ClangASTSource.cpp +++ b/lldb/source/Expression/ClangASTSource.cpp @@ -439,9 +439,9 @@ ClangASTSource::FindExternalLexicalDecls (const DeclContext *decl_context, { ASTDumper ast_dumper(decl); if (const NamedDecl *context_named_decl = dyn_cast<NamedDecl>(context_decl)) - log->Printf(" FELD[%d] Adding [to %s] lexical decl %s", current_id, context_named_decl->getNameAsString().c_str(), ast_dumper.GetCString()); + log->Printf(" FELD[%d] Adding [to %sDecl %s] lexical %sDecl %s", current_id, context_named_decl->getDeclKindName(), context_named_decl->getNameAsString().c_str(), decl->getDeclKindName(), ast_dumper.GetCString()); else - log->Printf(" FELD[%d] Adding lexical decl %s", current_id, ast_dumper.GetCString()); + log->Printf(" FELD[%d] Adding lexical %sDecl %s", current_id, decl->getDeclKindName(), ast_dumper.GetCString()); } Decl *copied_decl = m_ast_importer->CopyDecl(m_ast_context, original_ctx, decl); diff --git a/lldb/source/Expression/ClangExpressionDeclMap.cpp b/lldb/source/Expression/ClangExpressionDeclMap.cpp index 33910279bc7..f4bdfc04549 100644 --- a/lldb/source/Expression/ClangExpressionDeclMap.cpp +++ b/lldb/source/Expression/ClangExpressionDeclMap.cpp @@ -13,6 +13,7 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "clang/AST/ASTContext.h" #include "clang/AST/DeclarationName.h" #include "clang/AST/Decl.h" #include "lldb/lldb-private.h" diff --git a/lldb/source/Expression/ClangExpressionParser.cpp b/lldb/source/Expression/ClangExpressionParser.cpp index 5dd2ce2eb51..ea03defbc5e 100644 --- a/lldb/source/Expression/ClangExpressionParser.cpp +++ b/lldb/source/Expression/ClangExpressionParser.cpp @@ -43,12 +43,13 @@ #include "clang/Frontend/TextDiagnosticPrinter.h" #include "clang/Lex/Preprocessor.h" #include "clang/Parse/ParseAST.h" -#include "clang/Rewrite/FrontendActions.h" +#include "clang/Rewrite/Frontend/FrontendActions.h" #include "clang/Sema/SemaConsumer.h" #include "clang/StaticAnalyzer/Frontend/FrontendActions.h" #include "llvm/ADT/StringRef.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" +#include "llvm/Support/Debug.h" #include "llvm/Support/TargetSelect.h" #if !defined(__APPLE__) @@ -199,11 +200,59 @@ ClangExpressionParser::ClangExpressionParser (ExecutionContextScope *exe_scope, llvm::DisablePrettyStackTrace = true; } } InitializeLLVM; - + + llvm::setCurrentDebugType("internalize"); + llvm::DebugFlag = true; + // 1. Create a new compiler instance. m_compiler.reset(new CompilerInstance()); - // 2. Set options. + // 2. Install the target. + + lldb::TargetSP target_sp; + if (exe_scope) + target_sp = exe_scope->CalculateTarget(); + + // TODO: figure out what to really do when we don't have a valid target. + // Sometimes this will be ok to just use the host target triple (when we + // evaluate say "2+3", but other expressions like breakpoint conditions + // and other things that _are_ target specific really shouldn't just be + // using the host triple. This needs to be fixed in a better way. + if (target_sp && target_sp->GetArchitecture().IsValid()) + { + std::string triple = target_sp->GetArchitecture().GetTriple().str(); + + int dash_count = 0; + for (size_t i = 0; i < triple.size(); ++i) + { + if (triple[i] == '-') + dash_count++; + if (dash_count == 3) + { + triple.resize(i); + break; + } + } + + m_compiler->getTargetOpts().Triple = triple; + } + else + { + m_compiler->getTargetOpts().Triple = llvm::sys::getDefaultTargetTriple(); + } + + if (m_compiler->getTargetOpts().Triple.find("ios") != std::string::npos) + m_compiler->getTargetOpts().ABI = "apcs-gnu"; + + m_compiler->createDiagnostics(0, 0); + + // Create the target instance. + m_compiler->setTarget(TargetInfo::CreateTargetInfo(m_compiler->getDiagnostics(), + m_compiler->getTargetOpts())); + + assert (m_compiler->hasTarget()); + + // 3. Set options. lldb::LanguageType language = expr.Language(); @@ -247,15 +296,12 @@ ClangExpressionParser::ClangExpressionParser (ExecutionContextScope *exe_scope, if (process_sp->GetObjCLanguageRuntime()) { if (process_sp->GetObjCLanguageRuntime()->GetRuntimeVersion() == eAppleObjC_V2) - { - m_compiler->getLangOpts().ObjCNonFragileABI = true; // NOT i386 - m_compiler->getLangOpts().ObjCNonFragileABI2 = true; // NOT i386 - } + m_compiler->getLangOpts().ObjCRuntime.set(ObjCRuntime::MacOSX, VersionTuple(10, 7)); + else + m_compiler->getLangOpts().ObjCRuntime.set(ObjCRuntime::FragileMacOSX, VersionTuple(10, 7)); if (process_sp->GetObjCLanguageRuntime()->HasNewLiteralsAndIndexing()) - { m_compiler->getLangOpts().DebuggerObjCLiteral = true; - } } } @@ -270,51 +316,6 @@ ClangExpressionParser::ClangExpressionParser (ExecutionContextScope *exe_scope, // Disable some warnings. m_compiler->getDiagnosticOpts().Warnings.push_back("no-unused-value"); - // Set the target triple. - lldb::TargetSP target_sp; - if (exe_scope) - target_sp = exe_scope->CalculateTarget(); - - // TODO: figure out what to really do when we don't have a valid target. - // Sometimes this will be ok to just use the host target triple (when we - // evaluate say "2+3", but other expressions like breakpoint conditions - // and other things that _are_ target specific really shouldn't just be - // using the host triple. This needs to be fixed in a better way. - if (target_sp && target_sp->GetArchitecture().IsValid()) - { - std::string triple = target_sp->GetArchitecture().GetTriple().str(); - - int dash_count = 0; - for (size_t i = 0; i < triple.size(); ++i) - { - if (triple[i] == '-') - dash_count++; - if (dash_count == 3) - { - triple.resize(i); - break; - } - } - - m_compiler->getTargetOpts().Triple = triple; - } - else - { - m_compiler->getTargetOpts().Triple = llvm::sys::getDefaultTargetTriple(); - } - - if (m_compiler->getTargetOpts().Triple.find("ios") != std::string::npos) - m_compiler->getTargetOpts().ABI = "apcs-gnu"; - - // 3. Set up various important bits of infrastructure. - m_compiler->createDiagnostics(0, 0); - - // Create the target instance. - m_compiler->setTarget(TargetInfo::CreateTargetInfo(m_compiler->getDiagnostics(), - m_compiler->getTargetOpts())); - - assert (m_compiler->hasTarget()); - // Inform the target of the language options // // FIXME: We shouldn't need to do this, the target should be immutable once @@ -509,7 +510,7 @@ ClangExpressionParser::PrepareForExecution (lldb::addr_t &func_allocation_addr, error_stream, function_name.c_str()); - ir_for_target.runOnModule(*module); + bool ir_can_run = ir_for_target.runOnModule(*module); Error &interpreter_error(ir_for_target.getInterpreterError()); @@ -534,6 +535,13 @@ ClangExpressionParser::PrepareForExecution (lldb::addr_t &func_allocation_addr, return err; } + else if (!ir_can_run) + { + err.SetErrorToGenericError(); + err.SetErrorString("The expression could not be prepared to run in the target"); + + return err; + } if (execution_policy != eExecutionPolicyNever && m_expr.NeedsValidation() && @@ -599,7 +607,18 @@ ClangExpressionParser::PrepareForExecution (lldb::addr_t &func_allocation_addr, .setAllocateGVsWithCode(true) .setCodeModel(CodeModel::Small) .setUseMCJIT(true); - execution_engine.reset(builder.create()); + + llvm::Triple triple(module->getTargetTriple()); + StringRef mArch; + StringRef mCPU; + SmallVector<std::string, 0> mAttrs; + + TargetMachine *target_machine = builder.selectTarget(triple, + mArch, + mCPU, + mAttrs); + + execution_engine.reset(builder.create(target_machine)); if (!execution_engine.get()) { diff --git a/lldb/source/Expression/IRForTarget.cpp b/lldb/source/Expression/IRForTarget.cpp index 544c4bcaf19..b74e9f97aa7 100644 --- a/lldb/source/Expression/IRForTarget.cpp +++ b/lldb/source/Expression/IRForTarget.cpp @@ -15,7 +15,9 @@ #include "llvm/Instructions.h" #include "llvm/Intrinsics.h" #include "llvm/Module.h" +#include "llvm/PassManager.h" #include "llvm/Target/TargetData.h" +#include "llvm/Transforms/IPO.h" #include "llvm/ValueSymbolTable.h" #include "clang/AST/ASTContext.h" @@ -2630,6 +2632,55 @@ IRForTarget::CompleteDataAllocation () } bool +IRForTarget::StripAllGVs (Module &llvm_module) +{ + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + std::vector<GlobalVariable *> global_vars; + std::set<GlobalVariable *>erased_vars; + + bool erased = true; + + while (erased) + { + erased = false; + + for (Module::global_iterator gi = llvm_module.global_begin(), ge = llvm_module.global_end(); + gi != ge; + ++gi) + { + GlobalVariable *global_var = dyn_cast<GlobalVariable>(gi); + + global_var->removeDeadConstantUsers(); + + if (global_var->use_empty()) + { + if (log) + log->Printf("Did remove %s", + PrintValue(global_var).c_str()); + global_var->eraseFromParent(); + erased = true; + break; + } + } + } + + for (Module::global_iterator gi = llvm_module.global_begin(), ge = llvm_module.global_end(); + gi != ge; + ++gi) + { + GlobalVariable *global_var = dyn_cast<GlobalVariable>(gi); + + GlobalValue::use_iterator ui = global_var->use_begin(); + + log->Printf("Couldn't remove %s because of %s", + PrintValue(global_var).c_str(), + PrintValue(*ui).c_str()); + } + + return true; +} + +bool IRForTarget::runOnModule (Module &llvm_module) { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); @@ -2674,12 +2725,12 @@ IRForTarget::runOnModule (Module &llvm_module) m_reloc_placeholder = new llvm::GlobalVariable((*m_module), intptr_ty, - false /* isConstant */, + false /* IsConstant */, GlobalVariable::InternalLinkage, Constant::getNullValue(intptr_ty), "reloc_placeholder", NULL /* InsertBefore */, - false /* ThreadLocal */, + GlobalVariable::NotThreadLocal /* ThreadLocal */, 0 /* AddressSpace */); Function::iterator bbi; @@ -2876,6 +2927,12 @@ IRForTarget::runOnModule (Module &llvm_module) return false; } + if (!StripAllGVs(llvm_module)) + { + if (log) + log->Printf("StripAllGVs() failed"); + } + if (log && log->GetVerbose()) { std::string s; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 52e262e3c14..144b8f97272 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -1388,7 +1388,9 @@ SymbolFileDWARF::ParseTemplateDIE (DWARFCompileUnit* dwarf_cu, if (tag == DW_TAG_template_value_parameter && ClangASTContext::IsIntegerType (clang_type, is_signed) && uval64_valid) { llvm::APInt apint (lldb_type->GetByteSize() * 8, uval64, is_signed); - template_param_infos.args.push_back (clang::TemplateArgument (llvm::APSInt(apint), clang_qual_type)); + template_param_infos.args.push_back (clang::TemplateArgument (*GetClangASTContext().getASTContext(), + llvm::APSInt(apint), + clang_qual_type)); } else { @@ -1547,7 +1549,7 @@ SymbolFileDWARF::ParseChildMembers switch (tag) { case DW_TAG_member: - case DW_TAG_APPLE_Property: + case DW_TAG_APPLE_property: { DWARFDebugInfoEntry::Attributes attributes; const size_t num_attributes = die->GetAttributes (this, diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp index 9c8e24e404a..5929ebb45c8 100644 --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -358,7 +358,7 @@ ParseLangArgs // inlining enabled. // // FIXME: This is affected by other options (-fno-inline). - Opts.NoInline = !Opt; + Opts.NoInlineDefine = !Opt; // unsigned SSP = getLastArgIntValue(Args, OPT_stack_protector, 0, Diags); // switch (SSP) { @@ -1167,7 +1167,7 @@ ClangASTContext::CreateRecordType (DeclContext *decl_ctx, AccessType access_type static TemplateParameterList * CreateTemplateParameterList (ASTContext *ast, - const ClangASTContext::TemplateParameterInfos &template_param_infos, + const ClangASTContext::TemplateParameterInfos &template_param_infos, llvm::SmallVector<NamedDecl *, 8> &template_param_decls) { const bool parameter_pack = false; @@ -1177,7 +1177,7 @@ CreateTemplateParameterList (ASTContext *ast, for (size_t i=0; i<num_template_params; ++i) { const char *name = template_param_infos.names[i]; - if (template_param_infos.args[i].getAsIntegral()) + if (template_param_infos.args[i].getKind() == TemplateArgument::Integral) { template_param_decls.push_back (NonTypeTemplateParmDecl::Create (*ast, ast->getTranslationUnitDecl(), // Is this the right decl context?, SourceLocation StartLoc, @@ -1948,15 +1948,15 @@ ClangASTContext::AddFieldToRecordType bit_width = new (*ast)IntegerLiteral (*ast, bitfield_bit_size_apint, ast->IntTy, SourceLocation()); } field = FieldDecl::Create (*ast, - record_decl, - SourceLocation(), - SourceLocation(), - name ? &identifier_table->get(name) : NULL, // Identifier - QualType::getFromOpaquePtr(field_type), // Field type - NULL, // TInfo * - bit_width, // BitWidth - false, // Mutable - false); // HasInit + record_decl, + SourceLocation(), + SourceLocation(), + name ? &identifier_table->get(name) : NULL, // Identifier + QualType::getFromOpaquePtr(field_type), // Field type + NULL, // TInfo * + bit_width, // BitWidth + false, // Mutable + ICIS_NoInit); // HasInit if (!name) { // Determine whether this field corresponds to an anonymous @@ -3698,6 +3698,7 @@ ClangASTContext::GetNumPointeeChildren (clang_type_t clang_type) case clang::BuiltinType::Half: case clang::BuiltinType::ARCUnbridgedCast: case clang::BuiltinType::PseudoObject: + case clang::BuiltinType::BuiltinFn: return 1; } break; @@ -5586,6 +5587,7 @@ ClangASTContext::IsPossibleDynamicType (clang::ASTContext *ast, case clang::BuiltinType::Half: case clang::BuiltinType::ARCUnbridgedCast: case clang::BuiltinType::PseudoObject: + case clang::BuiltinType::BuiltinFn: break; } break; diff --git a/lldb/source/Symbol/ClangASTImporter.cpp b/lldb/source/Symbol/ClangASTImporter.cpp index 40434384cc6..b1328aa5771 100644 --- a/lldb/source/Symbol/ClangASTImporter.cpp +++ b/lldb/source/Symbol/ClangASTImporter.cpp @@ -535,7 +535,8 @@ clang::Decl TagDecl *to_tag_decl = dyn_cast<TagDecl>(to); to_tag_decl->setHasExternalLexicalStorage(); - + to_tag_decl->setMustBuildLookupTable(); + if (log) log->Printf(" [ClangASTImporter] To is a TagDecl - attributes %s%s [%s->%s]", (to_tag_decl->hasExternalLexicalStorage() ? " Lexical" : ""), diff --git a/lldb/source/Symbol/ClangASTType.cpp b/lldb/source/Symbol/ClangASTType.cpp index 8e5f3b86177..2d76d528c18 100644 --- a/lldb/source/Symbol/ClangASTType.cpp +++ b/lldb/source/Symbol/ClangASTType.cpp @@ -555,6 +555,7 @@ ClangASTType::GetFormat (clang_type_t clang_type) case clang::BuiltinType::Half: case clang::BuiltinType::ARCUnbridgedCast: case clang::BuiltinType::PseudoObject: + case clang::BuiltinType::BuiltinFn: return lldb::eFormatHex; } break; @@ -1271,7 +1272,7 @@ ClangASTType::DumpTypeDescription (clang::ASTContext *ast_context, clang_type_t if (class_interface_decl) { clang::PrintingPolicy policy = ast_context->getPrintingPolicy(); - policy.Dump = 1; + policy.DumpSourceManager = &ast_context->getSourceManager(); class_interface_decl->print(llvm_ostrm, policy, s->GetIndentLevel()); } } diff --git a/lldb/source/Symbol/TypeHierarchyNavigator.cpp b/lldb/source/Symbol/TypeHierarchyNavigator.cpp index 6bf43385358..e046204fd7d 100644 --- a/lldb/source/Symbol/TypeHierarchyNavigator.cpp +++ b/lldb/source/Symbol/TypeHierarchyNavigator.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +#include "clang/AST/ASTContext.h" #include "lldb/Core/Error.h" #include "lldb/Core/ValueObject.h" #include "lldb/Symbol/ClangASTContext.h" |

