diff --git a/lldb/include/lldb/Core/PluginManager.h b/lldb/include/lldb/Core/PluginManager.h --- a/lldb/include/lldb/Core/PluginManager.h +++ b/lldb/include/lldb/Core/PluginManager.h @@ -449,6 +449,8 @@ static REPLCreateInstance GetREPLCreateCallbackAtIndex(uint32_t idx); + static LanguageSet GetREPLSupportedLanguagesAtIndex(uint32_t idx); + static LanguageSet GetREPLAllTypeSystemSupportedLanguages(); // Some plug-ins might register a DebuggerInitializeCallback callback when diff --git a/lldb/source/Core/PluginManager.cpp b/lldb/source/Core/PluginManager.cpp --- a/lldb/source/Core/PluginManager.cpp +++ b/lldb/source/Core/PluginManager.cpp @@ -1345,6 +1345,12 @@ return GetREPLInstances().GetCallbackAtIndex(idx); } +LanguageSet PluginManager::GetREPLSupportedLanguagesAtIndex(uint32_t idx) { + const auto &instances = GetREPLInstances().GetInstances(); + return idx < instances.size() ? instances[idx].supported_languages + : LanguageSet(); +} + LanguageSet PluginManager::GetREPLAllTypeSystemSupportedLanguages() { const auto &instances = GetREPLInstances().GetInstances(); LanguageSet all; diff --git a/lldb/source/Expression/REPL.cpp b/lldb/source/Expression/REPL.cpp --- a/lldb/source/Expression/REPL.cpp +++ b/lldb/source/Expression/REPL.cpp @@ -39,7 +39,11 @@ lldb::REPLSP ret; while (REPLCreateInstance create_instance = - PluginManager::GetREPLCreateCallbackAtIndex(idx++)) { + PluginManager::GetREPLCreateCallbackAtIndex(idx)) { + LanguageSet supported_languages = + PluginManager::GetREPLSupportedLanguagesAtIndex(idx++); + if (!supported_languages[language]) + continue; ret = (*create_instance)(err, language, debugger, target, repl_options); if (ret) { break; diff --git a/lldb/test/Shell/REPL/Basic.test b/lldb/test/Shell/REPL/Basic.test new file mode 100644 --- /dev/null +++ b/lldb/test/Shell/REPL/Basic.test @@ -0,0 +1,10 @@ +// Basic sanity checking of the REPL. + +// RUN: %lldb --repl --repl-language c++ 2>&1 | FileCheck %s --check-prefix=CPP +// CPP: error: must have a target to create a REPL + +// RUN: %lldb --repl --repl-language python 2>&1 | FileCheck %s --check-prefix=PYTHON +// PYTHON: error: couldn't find a REPL for python + +// RUN: not %lldb --repl --repl-language bogus 2>&1 | FileCheck %s --check-prefix=BOGUS +// BOGUS: error: Unrecognized language name: "bogus"