This revision was automatically updated to reflect the committed changes. Closed by commit rG100863ccd8d4: [lldb] Check if language is supported before creating a REPL instance (authored by JDevlieghere). Herald added a project: LLDB.
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D115698/new/ https://reviews.llvm.org/D115698 Files: lldb/include/lldb/Core/PluginManager.h lldb/source/Core/PluginManager.cpp lldb/source/Expression/REPL.cpp lldb/test/Shell/REPL/Basic.test 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" 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/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/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/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" 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/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/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
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits