forked from OSchip/llvm-project
[lldb/ScriptInterpreter] Remove can_reload which is always true (NFC)
The `-r` option for `command script import` is there for legacy compatibility, however the can_reload flag is always set to true. This patch removes the flag and any code that relies on it being false.
This commit is contained in:
parent
b449d19e55
commit
1562511275
|
@ -457,7 +457,7 @@ public:
|
|||
virtual bool CheckObjectExists(const char *name) { return false; }
|
||||
|
||||
virtual bool
|
||||
LoadScriptingModule(const char *filename, bool can_reload, bool init_session,
|
||||
LoadScriptingModule(const char *filename, bool init_session,
|
||||
lldb_private::Status &error,
|
||||
StructuredData::ObjectSP *module_sp = nullptr);
|
||||
|
||||
|
|
|
@ -1403,7 +1403,7 @@ protected:
|
|||
|
||||
switch (short_option) {
|
||||
case 'r':
|
||||
m_allow_reload = true;
|
||||
// NO-OP
|
||||
break;
|
||||
default:
|
||||
llvm_unreachable("Unimplemented option");
|
||||
|
@ -1413,16 +1413,11 @@ protected:
|
|||
}
|
||||
|
||||
void OptionParsingStarting(ExecutionContext *execution_context) override {
|
||||
m_allow_reload = true;
|
||||
}
|
||||
|
||||
llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
|
||||
return llvm::makeArrayRef(g_script_import_options);
|
||||
}
|
||||
|
||||
// Instance variables to hold the values for command options.
|
||||
|
||||
bool m_allow_reload;
|
||||
};
|
||||
|
||||
bool DoExecute(Args &command, CommandReturnObject &result) override {
|
||||
|
@ -1446,7 +1441,7 @@ protected:
|
|||
// more)
|
||||
m_exe_ctx.Clear();
|
||||
if (GetDebugger().GetScriptInterpreter()->LoadScriptingModule(
|
||||
entry.c_str(), m_options.m_allow_reload, init_session, error)) {
|
||||
entry.c_str(), init_session, error)) {
|
||||
result.SetStatus(eReturnStatusSuccessFinishNoResult);
|
||||
} else {
|
||||
result.AppendErrorWithFormat("module importing failed: %s",
|
||||
|
|
|
@ -1512,11 +1512,9 @@ bool Module::LoadScriptingResourceInTarget(Target *target, Status &error,
|
|||
}
|
||||
StreamString scripting_stream;
|
||||
scripting_fspec.Dump(scripting_stream.AsRawOstream());
|
||||
const bool can_reload = true;
|
||||
const bool init_lldb_globals = false;
|
||||
bool did_load = script_interpreter->LoadScriptingModule(
|
||||
scripting_stream.GetData(), can_reload, init_lldb_globals,
|
||||
error);
|
||||
scripting_stream.GetData(), init_lldb_globals, error);
|
||||
if (!did_load)
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -43,8 +43,8 @@ void ScriptInterpreter::CollectDataForWatchpointCommandCallback(
|
|||
}
|
||||
|
||||
bool ScriptInterpreter::LoadScriptingModule(
|
||||
const char *filename, bool can_reload, bool init_session,
|
||||
lldb_private::Status &error, StructuredData::ObjectSP *module_sp) {
|
||||
const char *filename, bool init_session, lldb_private::Status &error,
|
||||
StructuredData::ObjectSP *module_sp) {
|
||||
error.SetErrorString(
|
||||
"This script interpreter does not support importing modules.");
|
||||
return false;
|
||||
|
|
|
@ -90,13 +90,12 @@ OperatingSystemPython::OperatingSystemPython(lldb_private::Process *process,
|
|||
python_module_path.GetFilename().AsCString(""));
|
||||
if (!os_plugin_class_name.empty()) {
|
||||
const bool init_session = false;
|
||||
const bool allow_reload = true;
|
||||
char python_module_path_cstr[PATH_MAX];
|
||||
python_module_path.GetPath(python_module_path_cstr,
|
||||
sizeof(python_module_path_cstr));
|
||||
Status error;
|
||||
if (m_interpreter->LoadScriptingModule(
|
||||
python_module_path_cstr, allow_reload, init_session, error)) {
|
||||
if (m_interpreter->LoadScriptingModule(python_module_path_cstr,
|
||||
init_session, error)) {
|
||||
// Strip the ".py" extension if there is one
|
||||
size_t py_extension_pos = os_plugin_class_name.rfind(".py");
|
||||
if (py_extension_pos != std::string::npos)
|
||||
|
|
|
@ -2057,8 +2057,7 @@ ScriptInterpreterPythonImpl::LoadPluginModule(const FileSpec &file_spec,
|
|||
|
||||
StructuredData::ObjectSP module_sp;
|
||||
|
||||
if (LoadScriptingModule(file_spec.GetPath().c_str(), true, true, error,
|
||||
&module_sp))
|
||||
if (LoadScriptingModule(file_spec.GetPath().c_str(), true, error, &module_sp))
|
||||
return module_sp;
|
||||
|
||||
return StructuredData::ObjectSP();
|
||||
|
@ -2737,8 +2736,8 @@ uint64_t replace_all(std::string &str, const std::string &oldStr,
|
|||
}
|
||||
|
||||
bool ScriptInterpreterPythonImpl::LoadScriptingModule(
|
||||
const char *pathname, bool can_reload, bool init_session,
|
||||
lldb_private::Status &error, StructuredData::ObjectSP *module_sp) {
|
||||
const char *pathname, bool init_session, lldb_private::Status &error,
|
||||
StructuredData::ObjectSP *module_sp) {
|
||||
if (!pathname || !pathname[0]) {
|
||||
error.SetErrorString("invalid pathname");
|
||||
return false;
|
||||
|
@ -2838,11 +2837,6 @@ bool ScriptInterpreterPythonImpl::LoadScriptingModule(
|
|||
|
||||
bool was_imported = (was_imported_globally || was_imported_locally);
|
||||
|
||||
if (was_imported && !can_reload) {
|
||||
error.SetErrorString("module already imported");
|
||||
return false;
|
||||
}
|
||||
|
||||
// now actually do the import
|
||||
command_stream.Clear();
|
||||
|
||||
|
|
|
@ -224,7 +224,7 @@ public:
|
|||
std::string &output, Status &error) override;
|
||||
|
||||
bool
|
||||
LoadScriptingModule(const char *filename, bool can_reload, bool init_session,
|
||||
LoadScriptingModule(const char *filename, bool init_session,
|
||||
lldb_private::Status &error,
|
||||
StructuredData::ObjectSP *module_sp = nullptr) override;
|
||||
|
||||
|
|
Loading…
Reference in New Issue