Skip to content

Commit 1562511

Browse files
committed
[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.
1 parent b449d19 commit 1562511

File tree

7 files changed

+12
-26
lines changed

7 files changed

+12
-26
lines changed

lldb/include/lldb/Interpreter/ScriptInterpreter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ class ScriptInterpreter : public PluginInterface {
457457
virtual bool CheckObjectExists(const char *name) { return false; }
458458

459459
virtual bool
460-
LoadScriptingModule(const char *filename, bool can_reload, bool init_session,
460+
LoadScriptingModule(const char *filename, bool init_session,
461461
lldb_private::Status &error,
462462
StructuredData::ObjectSP *module_sp = nullptr);
463463

lldb/source/Commands/CommandObjectCommands.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,7 +1403,7 @@ class CommandObjectCommandsScriptImport : public CommandObjectParsed {
14031403

14041404
switch (short_option) {
14051405
case 'r':
1406-
m_allow_reload = true;
1406+
// NO-OP
14071407
break;
14081408
default:
14091409
llvm_unreachable("Unimplemented option");
@@ -1413,16 +1413,11 @@ class CommandObjectCommandsScriptImport : public CommandObjectParsed {
14131413
}
14141414

14151415
void OptionParsingStarting(ExecutionContext *execution_context) override {
1416-
m_allow_reload = true;
14171416
}
14181417

14191418
llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
14201419
return llvm::makeArrayRef(g_script_import_options);
14211420
}
1422-
1423-
// Instance variables to hold the values for command options.
1424-
1425-
bool m_allow_reload;
14261421
};
14271422

14281423
bool DoExecute(Args &command, CommandReturnObject &result) override {
@@ -1446,7 +1441,7 @@ class CommandObjectCommandsScriptImport : public CommandObjectParsed {
14461441
// more)
14471442
m_exe_ctx.Clear();
14481443
if (GetDebugger().GetScriptInterpreter()->LoadScriptingModule(
1449-
entry.c_str(), m_options.m_allow_reload, init_session, error)) {
1444+
entry.c_str(), init_session, error)) {
14501445
result.SetStatus(eReturnStatusSuccessFinishNoResult);
14511446
} else {
14521447
result.AppendErrorWithFormat("module importing failed: %s",

lldb/source/Core/Module.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,11 +1512,9 @@ bool Module::LoadScriptingResourceInTarget(Target *target, Status &error,
15121512
}
15131513
StreamString scripting_stream;
15141514
scripting_fspec.Dump(scripting_stream.AsRawOstream());
1515-
const bool can_reload = true;
15161515
const bool init_lldb_globals = false;
15171516
bool did_load = script_interpreter->LoadScriptingModule(
1518-
scripting_stream.GetData(), can_reload, init_lldb_globals,
1519-
error);
1517+
scripting_stream.GetData(), init_lldb_globals, error);
15201518
if (!did_load)
15211519
return false;
15221520
}

lldb/source/Interpreter/ScriptInterpreter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ void ScriptInterpreter::CollectDataForWatchpointCommandCallback(
4343
}
4444

4545
bool ScriptInterpreter::LoadScriptingModule(
46-
const char *filename, bool can_reload, bool init_session,
47-
lldb_private::Status &error, StructuredData::ObjectSP *module_sp) {
46+
const char *filename, bool init_session, lldb_private::Status &error,
47+
StructuredData::ObjectSP *module_sp) {
4848
error.SetErrorString(
4949
"This script interpreter does not support importing modules.");
5050
return false;

lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,12 @@ OperatingSystemPython::OperatingSystemPython(lldb_private::Process *process,
9090
python_module_path.GetFilename().AsCString(""));
9191
if (!os_plugin_class_name.empty()) {
9292
const bool init_session = false;
93-
const bool allow_reload = true;
9493
char python_module_path_cstr[PATH_MAX];
9594
python_module_path.GetPath(python_module_path_cstr,
9695
sizeof(python_module_path_cstr));
9796
Status error;
98-
if (m_interpreter->LoadScriptingModule(
99-
python_module_path_cstr, allow_reload, init_session, error)) {
97+
if (m_interpreter->LoadScriptingModule(python_module_path_cstr,
98+
init_session, error)) {
10099
// Strip the ".py" extension if there is one
101100
size_t py_extension_pos = os_plugin_class_name.rfind(".py");
102101
if (py_extension_pos != std::string::npos)

lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2057,8 +2057,7 @@ ScriptInterpreterPythonImpl::LoadPluginModule(const FileSpec &file_spec,
20572057

20582058
StructuredData::ObjectSP module_sp;
20592059

2060-
if (LoadScriptingModule(file_spec.GetPath().c_str(), true, true, error,
2061-
&module_sp))
2060+
if (LoadScriptingModule(file_spec.GetPath().c_str(), true, error, &module_sp))
20622061
return module_sp;
20632062

20642063
return StructuredData::ObjectSP();
@@ -2737,8 +2736,8 @@ uint64_t replace_all(std::string &str, const std::string &oldStr,
27372736
}
27382737

27392738
bool ScriptInterpreterPythonImpl::LoadScriptingModule(
2740-
const char *pathname, bool can_reload, bool init_session,
2741-
lldb_private::Status &error, StructuredData::ObjectSP *module_sp) {
2739+
const char *pathname, bool init_session, lldb_private::Status &error,
2740+
StructuredData::ObjectSP *module_sp) {
27422741
if (!pathname || !pathname[0]) {
27432742
error.SetErrorString("invalid pathname");
27442743
return false;
@@ -2838,11 +2837,6 @@ bool ScriptInterpreterPythonImpl::LoadScriptingModule(
28382837

28392838
bool was_imported = (was_imported_globally || was_imported_locally);
28402839

2841-
if (was_imported && !can_reload) {
2842-
error.SetErrorString("module already imported");
2843-
return false;
2844-
}
2845-
28462840
// now actually do the import
28472841
command_stream.Clear();
28482842

lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ class ScriptInterpreterPythonImpl : public ScriptInterpreterPython {
224224
std::string &output, Status &error) override;
225225

226226
bool
227-
LoadScriptingModule(const char *filename, bool can_reload, bool init_session,
227+
LoadScriptingModule(const char *filename, bool init_session,
228228
lldb_private::Status &error,
229229
StructuredData::ObjectSP *module_sp = nullptr) override;
230230

0 commit comments

Comments
 (0)