[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
This commit is contained in:
Alex Langford 2019-06-10 20:53:23 +00:00
parent 4bf1c23990
commit e823bbe8d1
25 changed files with 61 additions and 68 deletions

View File

@ -199,6 +199,11 @@ public:
return runtime->isA(&ID);
}
static ObjCLanguageRuntime *Get(Process &process) {
return llvm::cast_or_null<ObjCLanguageRuntime>(
process.GetLanguageRuntime(lldb::eLanguageTypeObjC));
}
virtual TaggedPointerVendor *GetTaggedPointerVendor() { return nullptr; }
typedef std::shared_ptr<EncodingToType> EncodingToTypeSP;

View File

@ -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;

View File

@ -130,7 +130,6 @@ class ModuleList;
class ModuleSpec;
class ModuleSpecList;
struct NameSearchContext;
class ObjCLanguageRuntime;
class ObjectContainer;
class OptionGroup;
class OptionGroupOptions;

View File

@ -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();

View File

@ -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();
}

View File

@ -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(

View File

@ -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);
}

View File

@ -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;

View File

@ -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);

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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<AppleObjCRuntime>(
process_sp->GetObjCLanguageRuntime());
AppleObjCRuntime *runtime = llvm::dyn_cast_or_null<AppleObjCRuntime>(
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<AppleObjCRuntime>(
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<AppleObjCRuntime>(
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);

View File

@ -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<AppleObjCRuntime>(
process_sp->GetObjCLanguageRuntime());
ObjCLanguageRuntime::Get(*process_sp));
if (!runtime)
return nullptr;

View File

@ -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<AppleObjCRuntime>(process_sp->GetObjCLanguageRuntime());
AppleObjCRuntime *runtime = llvm::dyn_cast_or_null<AppleObjCRuntime>(
ObjCLanguageRuntime::Get(*process_sp));
if (!runtime)
return nullptr;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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<Language::TypeScavenger> 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) {

View File

@ -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();

View File

@ -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);

View File

@ -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)

View File

@ -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);

View File

@ -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<std::recursive_mutex> guard(m_language_runtimes_mutex);
LanguageRuntime *runtime =
GetLanguageRuntime(eLanguageTypeObjC, retry_if_null);
return llvm::cast_or_null<ObjCLanguageRuntime>(runtime);
}
bool Process::IsPossibleDynamicValue(ValueObject &in_value) {
if (m_finalizing)
return false;