From e823bbe8d1d47f60e23a45d1ea98324e57296c36 Mon Sep 17 00:00:00 2001 From: Alex Langford Date: Mon, 10 Jun 2019 20:53:23 +0000 Subject: [PATCH] [Target] Remove Process::GetObjCLanguageRuntime Summary: In an effort to make Process more language agnostic, I removed GetCPPLanguageRuntime from Process. I'm following up now with an equivalent change for ObjC. Differential Revision: https://reviews.llvm.org/D63052 llvm-svn: 362981 --- .../include/lldb/Target/ObjCLanguageRuntime.h | 5 +++ lldb/include/lldb/Target/Process.h | 2 -- lldb/include/lldb/lldb-forward.h | 1 - lldb/source/API/SBTarget.cpp | 4 +-- lldb/source/Core/ValueObject.cpp | 5 ++- lldb/source/Expression/IRDynamicChecks.cpp | 2 +- .../MacOSX-DYLD/DynamicLoaderDarwin.cpp | 2 +- .../ExpressionParser/Clang/ClangASTSource.cpp | 10 +++--- .../Clang/ClangExpressionDeclMap.cpp | 2 +- .../Clang/ClangExpressionParser.cpp | 6 ++-- lldb/source/Plugins/Language/ObjC/CF.cpp | 6 ++-- lldb/source/Plugins/Language/ObjC/Cocoa.cpp | 31 +++++++++---------- lldb/source/Plugins/Language/ObjC/NSArray.cpp | 4 +-- .../Plugins/Language/ObjC/NSDictionary.cpp | 6 ++-- lldb/source/Plugins/Language/ObjC/NSError.cpp | 2 +- .../Plugins/Language/ObjC/NSException.cpp | 2 +- .../Plugins/Language/ObjC/NSIndexPath.cpp | 2 +- lldb/source/Plugins/Language/ObjC/NSSet.cpp | 4 +-- .../source/Plugins/Language/ObjC/NSString.cpp | 2 +- .../Plugins/Language/ObjC/ObjCLanguage.cpp | 5 ++- .../AppleObjCRuntime/AppleObjCRuntimeV2.cpp | 5 +-- .../AppleObjCTrampolineHandler.cpp | 7 +++-- ...pleThreadPlanStepThroughObjCTrampoline.cpp | 2 +- lldb/source/Symbol/ClangASTContext.cpp | 4 +-- lldb/source/Target/Process.cpp | 8 ----- 25 files changed, 61 insertions(+), 68 deletions(-) diff --git a/lldb/include/lldb/Target/ObjCLanguageRuntime.h b/lldb/include/lldb/Target/ObjCLanguageRuntime.h index 8dc7b92bdec7..5b5a6cd2be8d 100644 --- a/lldb/include/lldb/Target/ObjCLanguageRuntime.h +++ b/lldb/include/lldb/Target/ObjCLanguageRuntime.h @@ -199,6 +199,11 @@ public: return runtime->isA(&ID); } + static ObjCLanguageRuntime *Get(Process &process) { + return llvm::cast_or_null( + process.GetLanguageRuntime(lldb::eLanguageTypeObjC)); + } + virtual TaggedPointerVendor *GetTaggedPointerVendor() { return nullptr; } typedef std::shared_ptr EncodingToTypeSP; diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index c3ffa99a73c6..8cda789aa7aa 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -2184,8 +2184,6 @@ public: LanguageRuntime *GetLanguageRuntime(lldb::LanguageType language, bool retry_if_null = true); - ObjCLanguageRuntime *GetObjCLanguageRuntime(bool retry_if_null = true); - bool IsPossibleDynamicValue(ValueObject &in_value); bool IsRunning() const; diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h index fd2d272c8915..ccb5f13e1d7c 100644 --- a/lldb/include/lldb/lldb-forward.h +++ b/lldb/include/lldb/lldb-forward.h @@ -130,7 +130,6 @@ class ModuleList; class ModuleSpec; class ModuleSpecList; struct NameSearchContext; -class ObjCLanguageRuntime; class ObjectContainer; class OptionGroup; class OptionGroupOptions; diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index 56d258187ea0..0a408e7037b2 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -1854,7 +1854,7 @@ lldb::SBType SBTarget::FindFirstType(const char *typename_cstr) { if (process_sp) { ObjCLanguageRuntime *objc_language_runtime = - process_sp->GetObjCLanguageRuntime(); + ObjCLanguageRuntime::Get(*process_sp); if (objc_language_runtime) { DeclVendor *objc_decl_vendor = objc_language_runtime->GetDeclVendor(); @@ -1924,7 +1924,7 @@ lldb::SBTypeList SBTarget::FindTypes(const char *typename_cstr) { if (process_sp) { ObjCLanguageRuntime *objc_language_runtime = - process_sp->GetObjCLanguageRuntime(); + ObjCLanguageRuntime::Get(*process_sp); if (objc_language_runtime) { DeclVendor *objc_decl_vendor = objc_language_runtime->GetDeclVendor(); diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index e083b8dc086c..409f3d6b13fd 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -302,7 +302,7 @@ CompilerType ValueObject::MaybeCalculateCompleteType() { if (process_sp) { ObjCLanguageRuntime *objc_language_runtime( - process_sp->GetObjCLanguageRuntime()); + ObjCLanguageRuntime::Get(*process_sp)); if (objc_language_runtime) { TypeSP complete_objc_class_type_sp = @@ -1699,7 +1699,7 @@ bool ValueObject::IsRuntimeSupportValue() { LanguageRuntime *runtime = process->GetLanguageRuntime(GetObjectRuntimeLanguage()); if (!runtime) - runtime = process->GetObjCLanguageRuntime(); + runtime = ObjCLanguageRuntime::Get(*process); if (runtime) return runtime->IsRuntimeSupportValue(*this); // If there is no language runtime, trust the compiler to mark all @@ -3399,4 +3399,3 @@ lldb::StackFrameSP ValueObjectManager::GetFrameSP() const { return m_root_valobj_sp->GetFrameSP(); return lldb::StackFrameSP(); } - diff --git a/lldb/source/Expression/IRDynamicChecks.cpp b/lldb/source/Expression/IRDynamicChecks.cpp index 0f10ff4bb569..f66dec2e7884 100644 --- a/lldb/source/Expression/IRDynamicChecks.cpp +++ b/lldb/source/Expression/IRDynamicChecks.cpp @@ -61,7 +61,7 @@ bool DynamicCheckerFunctions::Install(DiagnosticManager &diagnostic_manager, if (process) { ObjCLanguageRuntime *objc_language_runtime = - process->GetObjCLanguageRuntime(); + ObjCLanguageRuntime::Get(*process); if (objc_language_runtime) { m_objc_object_check.reset(objc_language_runtime->CreateObjectChecker( diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp index 339aeaec50f7..ce1215768836 100644 --- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp +++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp @@ -693,7 +693,7 @@ bool DynamicLoaderDarwin::AlwaysRelyOnEHUnwindInfo(SymbolContext &sym_ctx) { if (module_sp.get() == nullptr) return false; - ObjCLanguageRuntime *objc_runtime = m_process->GetObjCLanguageRuntime(); + ObjCLanguageRuntime *objc_runtime = ObjCLanguageRuntime::Get(*m_process); return objc_runtime != nullptr && objc_runtime->IsModuleObjCLibrary(module_sp); } diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp index e9dd73c5fa64..97a853feeb14 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp @@ -90,7 +90,7 @@ void ClangASTSource::InstallASTContext(clang::ASTContext &ast_context, if (!process) break; - ObjCLanguageRuntime *language_runtime(process->GetObjCLanguageRuntime()); + ObjCLanguageRuntime *language_runtime(ObjCLanguageRuntime::Get(*process)); if (!language_runtime) break; @@ -479,7 +479,7 @@ clang::ObjCInterfaceDecl *ClangASTSource::GetCompleteObjCInterface( if (!process) return nullptr; - ObjCLanguageRuntime *language_runtime(process->GetObjCLanguageRuntime()); + ObjCLanguageRuntime *language_runtime(ObjCLanguageRuntime::Get(*process)); if (!language_runtime) return nullptr; @@ -950,7 +950,7 @@ void ClangASTSource::FindExternalVisibleDecls( break; ObjCLanguageRuntime *language_runtime( - process->GetObjCLanguageRuntime()); + ObjCLanguageRuntime::Get(*process)); if (!language_runtime) break; @@ -1401,7 +1401,7 @@ void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) { if (!process) break; - ObjCLanguageRuntime *language_runtime(process->GetObjCLanguageRuntime()); + ObjCLanguageRuntime *language_runtime(ObjCLanguageRuntime::Get(*process)); if (!language_runtime) break; @@ -1593,7 +1593,7 @@ void ClangASTSource::FindObjCPropertyAndIvarDecls(NameSearchContext &context) { if (!process) return; - ObjCLanguageRuntime *language_runtime(process->GetObjCLanguageRuntime()); + ObjCLanguageRuntime *language_runtime(ObjCLanguageRuntime::Get(*process)); if (!language_runtime) return; diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index c2ebfe9ce4e2..06425602f486 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -698,7 +698,7 @@ addr_t ClangExpressionDeclMap::GetSymbolAddress(Target &target, } if (symbol_load_addr == LLDB_INVALID_ADDRESS && process) { - ObjCLanguageRuntime *runtime = process->GetObjCLanguageRuntime(); + ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process); if (runtime) { symbol_load_addr = runtime->LookupRuntimeSymbol(name); diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp index 9fd9fe9a59f6..ec757501c237 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -512,15 +512,15 @@ ClangExpressionParser::ClangExpressionParser( } if (process_sp && lang_opts.ObjC) { - if (process_sp->GetObjCLanguageRuntime()) { - if (process_sp->GetObjCLanguageRuntime()->GetRuntimeVersion() == + if (auto *runtime = ObjCLanguageRuntime::Get(*process_sp)) { + if (runtime->GetRuntimeVersion() == ObjCLanguageRuntime::ObjCRuntimeVersions::eAppleObjC_V2) lang_opts.ObjCRuntime.set(ObjCRuntime::MacOSX, VersionTuple(10, 7)); else lang_opts.ObjCRuntime.set(ObjCRuntime::FragileMacOSX, VersionTuple(10, 7)); - if (process_sp->GetObjCLanguageRuntime()->HasNewLiteralsAndIndexing()) + if (runtime->HasNewLiteralsAndIndexing()) lang_opts.DebuggerObjCLiteral = true; } } diff --git a/lldb/source/Plugins/Language/ObjC/CF.cpp b/lldb/source/Plugins/Language/ObjC/CF.cpp index e1816a2d2c4d..d9b688156537 100644 --- a/lldb/source/Plugins/Language/ObjC/CF.cpp +++ b/lldb/source/Plugins/Language/ObjC/CF.cpp @@ -50,7 +50,7 @@ bool lldb_private::formatters::CFBagSummaryProvider( if (!process_sp) return false; - ObjCLanguageRuntime *runtime = process_sp->GetObjCLanguageRuntime(); + ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp); if (!runtime) return false; @@ -112,7 +112,7 @@ bool lldb_private::formatters::CFBitVectorSummaryProvider( if (!process_sp) return false; - ObjCLanguageRuntime *runtime = process_sp->GetObjCLanguageRuntime(); + ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp); if (!runtime) return false; @@ -232,7 +232,7 @@ bool lldb_private::formatters::CFBinaryHeapSummaryProvider( if (!process_sp) return false; - ObjCLanguageRuntime *runtime = process_sp->GetObjCLanguageRuntime(); + ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp); if (!runtime) return false; diff --git a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp index ec77787f9512..6c9d024a1321 100644 --- a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp +++ b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp @@ -43,7 +43,7 @@ bool lldb_private::formatters::NSBundleSummaryProvider( if (!process_sp) return false; - ObjCLanguageRuntime *runtime = process_sp->GetObjCLanguageRuntime(); + ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp); if (!runtime) return false; @@ -91,7 +91,7 @@ bool lldb_private::formatters::NSTimeZoneSummaryProvider( if (!process_sp) return false; - ObjCLanguageRuntime *runtime = process_sp->GetObjCLanguageRuntime(); + ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp); if (!runtime) return false; @@ -136,7 +136,7 @@ bool lldb_private::formatters::NSNotificationSummaryProvider( if (!process_sp) return false; - ObjCLanguageRuntime *runtime = process_sp->GetObjCLanguageRuntime(); + ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp); if (!runtime) return false; @@ -181,7 +181,7 @@ bool lldb_private::formatters::NSMachPortSummaryProvider( if (!process_sp) return false; - ObjCLanguageRuntime *runtime = process_sp->GetObjCLanguageRuntime(); + ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp); if (!runtime) return false; @@ -227,7 +227,7 @@ bool lldb_private::formatters::NSIndexSetSummaryProvider( if (!process_sp) return false; - ObjCLanguageRuntime *runtime = process_sp->GetObjCLanguageRuntime(); + ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp); if (!runtime) return false; @@ -416,7 +416,7 @@ bool lldb_private::formatters::NSNumberSummaryProvider( if (!process_sp) return false; - ObjCLanguageRuntime *runtime = process_sp->GetObjCLanguageRuntime(); + ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp); if (!runtime) return false; @@ -472,10 +472,9 @@ bool lldb_private::formatters::NSNumberSummaryProvider( return true; } else { Status error; - - AppleObjCRuntime *runtime = - llvm::dyn_cast_or_null( - process_sp->GetObjCLanguageRuntime()); + + AppleObjCRuntime *runtime = llvm::dyn_cast_or_null( + ObjCLanguageRuntime::Get(*process_sp)); const bool new_format = (runtime && runtime->GetFoundationVersion() >= 1400); @@ -667,7 +666,7 @@ bool lldb_private::formatters::NSURLSummaryProvider( if (!process_sp) return false; - ObjCLanguageRuntime *runtime = process_sp->GetObjCLanguageRuntime(); + ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp); if (!runtime) return false; @@ -781,7 +780,7 @@ bool lldb_private::formatters::NSDateSummaryProvider( if (!process_sp) return false; - ObjCLanguageRuntime *runtime = process_sp->GetObjCLanguageRuntime(); + ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp); if (!runtime) return false; @@ -848,7 +847,7 @@ bool lldb_private::formatters::NSDateSummaryProvider( // Accomodate for the __NSTaggedDate format introduced in Foundation 1600. if (class_name == g___NSTaggedDate) { auto *runtime = llvm::dyn_cast_or_null( - process_sp->GetObjCLanguageRuntime()); + ObjCLanguageRuntime::Get(*process_sp)); if (runtime && runtime->GetFoundationVersion() >= 1600) date_value = decodeTaggedTimeInterval(value_bits << 4); } @@ -876,7 +875,7 @@ bool lldb_private::formatters::ObjCClassSummaryProvider( if (!process_sp) return false; - ObjCLanguageRuntime *runtime = process_sp->GetObjCLanguageRuntime(); + ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp); if (!runtime) return false; @@ -935,7 +934,7 @@ bool lldb_private::formatters::NSDataSummaryProvider( if (!process_sp) return false; - ObjCLanguageRuntime *runtime = process_sp->GetObjCLanguageRuntime(); + ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp); if (!runtime) return false; @@ -1035,7 +1034,7 @@ bool lldb_private::formatters::ObjCBooleanSummaryProvider( return false; if (AppleObjCRuntime *objc_runtime = llvm::dyn_cast_or_null( - process_sp->GetObjCLanguageRuntime())) { + ObjCLanguageRuntime::Get(*process_sp))) { lldb::addr_t cf_true = LLDB_INVALID_ADDRESS, cf_false = LLDB_INVALID_ADDRESS; objc_runtime->GetValuesForGlobalCFBooleans(cf_true, cf_false); diff --git a/lldb/source/Plugins/Language/ObjC/NSArray.cpp b/lldb/source/Plugins/Language/ObjC/NSArray.cpp index 154e2d7a2815..b981b373cf27 100644 --- a/lldb/source/Plugins/Language/ObjC/NSArray.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSArray.cpp @@ -344,7 +344,7 @@ bool lldb_private::formatters::NSArraySummaryProvider( if (!process_sp) return false; - ObjCLanguageRuntime *runtime = process_sp->GetObjCLanguageRuntime(); + ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp); if (!runtime) return false; @@ -797,7 +797,7 @@ lldb_private::formatters::NSArraySyntheticFrontEndCreator( if (!process_sp) return nullptr; AppleObjCRuntime *runtime = llvm::dyn_cast_or_null( - process_sp->GetObjCLanguageRuntime()); + ObjCLanguageRuntime::Get(*process_sp)); if (!runtime) return nullptr; diff --git a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp index 462adf4bf855..601d777b1371 100644 --- a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp @@ -347,7 +347,7 @@ bool lldb_private::formatters::NSDictionarySummaryProvider( if (!process_sp) return false; - ObjCLanguageRuntime *runtime = process_sp->GetObjCLanguageRuntime(); + ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp); if (!runtime) return false; @@ -437,8 +437,8 @@ lldb_private::formatters::NSDictionarySyntheticFrontEndCreator( lldb::ProcessSP process_sp(valobj_sp->GetProcessSP()); if (!process_sp) return nullptr; - AppleObjCRuntime *runtime = - llvm::dyn_cast_or_null(process_sp->GetObjCLanguageRuntime()); + AppleObjCRuntime *runtime = llvm::dyn_cast_or_null( + ObjCLanguageRuntime::Get(*process_sp)); if (!runtime) return nullptr; diff --git a/lldb/source/Plugins/Language/ObjC/NSError.cpp b/lldb/source/Plugins/Language/ObjC/NSError.cpp index 96e31a8ebcc3..3804a71e40dc 100644 --- a/lldb/source/Plugins/Language/ObjC/NSError.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSError.cpp @@ -187,7 +187,7 @@ lldb_private::formatters::NSErrorSyntheticFrontEndCreator( lldb::ProcessSP process_sp(valobj_sp->GetProcessSP()); if (!process_sp) return nullptr; - ObjCLanguageRuntime *runtime = process_sp->GetObjCLanguageRuntime(); + ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp); if (!runtime) return nullptr; diff --git a/lldb/source/Plugins/Language/ObjC/NSException.cpp b/lldb/source/Plugins/Language/ObjC/NSException.cpp index 32df575f7408..eea34e61d47b 100644 --- a/lldb/source/Plugins/Language/ObjC/NSException.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSException.cpp @@ -179,7 +179,7 @@ lldb_private::formatters::NSExceptionSyntheticFrontEndCreator( lldb::ProcessSP process_sp(valobj_sp->GetProcessSP()); if (!process_sp) return nullptr; - ObjCLanguageRuntime *runtime = process_sp->GetObjCLanguageRuntime(); + ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp); if (!runtime) return nullptr; diff --git a/lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp b/lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp index 8fe3bc2c55ba..a15650fdb08b 100644 --- a/lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp @@ -68,7 +68,7 @@ public: if (!process_sp) return false; - ObjCLanguageRuntime *runtime = process_sp->GetObjCLanguageRuntime(); + ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp); if (!runtime) return false; diff --git a/lldb/source/Plugins/Language/ObjC/NSSet.cpp b/lldb/source/Plugins/Language/ObjC/NSSet.cpp index cb6f59acb6cb..f201526deef1 100644 --- a/lldb/source/Plugins/Language/ObjC/NSSet.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSSet.cpp @@ -225,7 +225,7 @@ bool lldb_private::formatters::NSSetSummaryProvider( if (!process_sp) return false; - ObjCLanguageRuntime *runtime = process_sp->GetObjCLanguageRuntime(); + ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp); if (!runtime) return false; @@ -302,7 +302,7 @@ lldb_private::formatters::NSSetSyntheticFrontEndCreator( lldb::ProcessSP process_sp(valobj_sp->GetProcessSP()); if (!process_sp) return nullptr; - ObjCLanguageRuntime *runtime = process_sp->GetObjCLanguageRuntime(); + ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp); if (!runtime) return nullptr; diff --git a/lldb/source/Plugins/Language/ObjC/NSString.cpp b/lldb/source/Plugins/Language/ObjC/NSString.cpp index 1d77f8f3fcb7..4800c955e5f5 100644 --- a/lldb/source/Plugins/Language/ObjC/NSString.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSString.cpp @@ -59,7 +59,7 @@ bool lldb_private::formatters::NSStringSummaryProvider( if (!process_sp) return false; - ObjCLanguageRuntime *runtime = process_sp->GetObjCLanguageRuntime(); + ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp); if (!runtime) return false; diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp index 1e12a66af305..bce7e93ad3a1 100644 --- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp +++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp @@ -890,7 +890,7 @@ ObjCLanguage::GetPossibleFormattersMatches(ValueObject &valobj, lldb::ProcessSP process_sp = valobj.GetProcessSP(); if (!process_sp) break; - ObjCLanguageRuntime *runtime = process_sp->GetObjCLanguageRuntime(); + ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp); if (runtime == nullptr) break; ObjCLanguageRuntime::ClassDescriptorSP objc_class_sp( @@ -934,8 +934,7 @@ std::unique_ptr ObjCLanguage::GetTypeScavenger() { Process *process = exe_scope->CalculateProcess().get(); if (process) { - const bool create_on_demand = false; - auto objc_runtime = process->GetObjCLanguageRuntime(create_on_demand); + auto objc_runtime = ObjCLanguageRuntime::Get(*process); if (objc_runtime) { auto decl_vendor = objc_runtime->GetDeclVendor(); if (decl_vendor) { diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp index 04629f7d8e7e..26fd593029af 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -42,6 +42,7 @@ #include "lldb/Symbol/VariableList.h" #include "lldb/Target/ABI.h" #include "lldb/Target/ExecutionContext.h" +#include "lldb/Target/ObjCLanguageRuntime.h" #include "lldb/Target/Platform.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" @@ -591,7 +592,7 @@ protected: } Process *process = m_exe_ctx.GetProcessPtr(); - ObjCLanguageRuntime *objc_runtime = process->GetObjCLanguageRuntime(); + ObjCLanguageRuntime *objc_runtime = ObjCLanguageRuntime::Get(*process); if (objc_runtime) { auto iterators_pair = objc_runtime->GetDescriptorIteratorPair(); auto iterator = iterators_pair.first; @@ -693,7 +694,7 @@ protected: Process *process = m_exe_ctx.GetProcessPtr(); ExecutionContext exe_ctx(process); - ObjCLanguageRuntime *objc_runtime = process->GetObjCLanguageRuntime(); + ObjCLanguageRuntime *objc_runtime = ObjCLanguageRuntime::Get(*process); if (objc_runtime) { ObjCLanguageRuntime::TaggedPointerVendor *tagged_ptr_vendor = objc_runtime->GetTaggedPointerVendor(); diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp index 4589b1f5d5e3..654dbf0e2409 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp @@ -457,8 +457,9 @@ bool AppleObjCTrampolineHandler::AppleObjCVTables::InitializeVTableSymbols() { size_t num_modules = target_modules.GetSize(); if (!m_objc_module_sp) { for (size_t i = 0; i < num_modules; i++) { - if (process_sp->GetObjCLanguageRuntime()->IsModuleObjCLibrary( - target_modules.GetModuleAtIndexUnlocked(i))) { + if (ObjCLanguageRuntime::Get(*process_sp) + ->IsModuleObjCLibrary( + target_modules.GetModuleAtIndexUnlocked(i))) { m_objc_module_sp = target_modules.GetModuleAtIndexUnlocked(i); break; } @@ -1036,7 +1037,7 @@ AppleObjCTrampolineHandler::GetStepThroughDispatchPlan(Thread &thread, isa_addr, sel_addr); } ObjCLanguageRuntime *objc_runtime = - thread.GetProcess()->GetObjCLanguageRuntime(); + ObjCLanguageRuntime::Get(*thread.GetProcess()); assert(objc_runtime != nullptr); impl_addr = objc_runtime->LookupInMethodCache(isa_addr, sel_addr); diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp index f3f38d3f9de6..12b637bd9d0c 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp @@ -171,7 +171,7 @@ bool AppleThreadPlanStepThroughObjCTrampoline::ShouldStop(Event *event_ptr) { target_addr); ObjCLanguageRuntime *objc_runtime = - GetThread().GetProcess()->GetObjCLanguageRuntime(); + ObjCLanguageRuntime::Get(*GetThread().GetProcess()); assert(objc_runtime != nullptr); objc_runtime->AddToMethodCache(m_isa_addr, m_sel_addr, target_addr); if (log) diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp index c554d989b17e..de1512eb3aef 100644 --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -5035,7 +5035,7 @@ ClangASTContext::GetBitSize(lldb::opaque_compiler_type_t type, ExecutionContext exe_ctx(exe_scope); Process *process = exe_ctx.GetProcessPtr(); if (process) { - ObjCLanguageRuntime *objc_runtime = process->GetObjCLanguageRuntime(); + ObjCLanguageRuntime *objc_runtime = ObjCLanguageRuntime::Get(*process); if (objc_runtime) { uint64_t bit_size = 0; if (objc_runtime->GetTypeBitSize( @@ -6842,7 +6842,7 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex( process = exe_ctx->GetProcessPtr(); if (process) { ObjCLanguageRuntime *objc_runtime = - process->GetObjCLanguageRuntime(); + ObjCLanguageRuntime::Get(*process); if (objc_runtime != nullptr) { CompilerType parent_ast_type(getASTContext(), parent_qual_type); diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index f6bb5cdd2d77..1f2305ac832f 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -47,7 +47,6 @@ #include "lldb/Target/LanguageRuntime.h" #include "lldb/Target/MemoryHistory.h" #include "lldb/Target/MemoryRegionInfo.h" -#include "lldb/Target/ObjCLanguageRuntime.h" #include "lldb/Target/OperatingSystem.h" #include "lldb/Target/Platform.h" #include "lldb/Target/Process.h" @@ -1597,13 +1596,6 @@ LanguageRuntime *Process::GetLanguageRuntime(lldb::LanguageType language, return runtime; } -ObjCLanguageRuntime *Process::GetObjCLanguageRuntime(bool retry_if_null) { - std::lock_guard guard(m_language_runtimes_mutex); - LanguageRuntime *runtime = - GetLanguageRuntime(eLanguageTypeObjC, retry_if_null); - return llvm::cast_or_null(runtime); -} - bool Process::IsPossibleDynamicValue(ValueObject &in_value) { if (m_finalizing) return false;