summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/source/Target/Process.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index c88ef0dcf81..66204da2c59 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -1574,17 +1574,28 @@ LanguageRuntime *Process::GetLanguageRuntime(lldb::LanguageType language,
if (m_finalizing)
return nullptr;
+ LanguageRuntime *runtime = nullptr;
+
std::lock_guard<std::recursive_mutex> guard(m_language_runtimes_mutex);
LanguageRuntimeCollection::iterator pos;
pos = m_language_runtimes.find(language);
- if (pos == m_language_runtimes.end() || (retry_if_null && !(*pos).second)) {
+ if (pos == m_language_runtimes.end() || (retry_if_null && !pos->second)) {
lldb::LanguageRuntimeSP runtime_sp(
LanguageRuntime::FindPlugin(this, language));
m_language_runtimes[language] = runtime_sp;
- return runtime_sp.get();
+ runtime = runtime_sp.get();
} else
- return (*pos).second.get();
+ runtime = pos->second.get();
+
+ if (runtime)
+ // It's possible that a language runtime can support multiple LanguageTypes,
+ // for example, CPPLanguageRuntime will support eLanguageTypeC_plus_plus,
+ // eLanguageTypeC_plus_plus_03, etc. Because of this, we should get the
+ // primary language type and make sure that our runtime supports it.
+ assert(runtime->GetLanguageType() == Language::GetPrimaryLanguage(language));
+
+ return runtime;
}
CPPLanguageRuntime *Process::GetCPPLanguageRuntime(bool retry_if_null) {
@@ -1594,7 +1605,6 @@ CPPLanguageRuntime *Process::GetCPPLanguageRuntime(bool retry_if_null) {
if (!runtime)
return nullptr;
- assert(runtime->GetLanguageType() == eLanguageTypeC_plus_plus);
return static_cast<CPPLanguageRuntime *>(runtime);
}
@@ -1605,7 +1615,6 @@ ObjCLanguageRuntime *Process::GetObjCLanguageRuntime(bool retry_if_null) {
if (!runtime)
return nullptr;
- assert(runtime->GetLanguageType() == eLanguageTypeObjC);
return static_cast<ObjCLanguageRuntime *>(runtime);
}
OpenPOWER on IntegriCloud