Index: lldb/include/lldb/Core/PluginManager.h =================================================================== --- lldb/include/lldb/Core/PluginManager.h +++ 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 Index: lldb/source/Core/PluginManager.cpp =================================================================== --- lldb/source/Core/PluginManager.cpp +++ 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; Index: lldb/source/Expression/REPL.cpp =================================================================== --- lldb/source/Expression/REPL.cpp +++ 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; Index: lldb/test/Shell/REPL/Basic.test =================================================================== --- /dev/null +++ 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"