Skip to content

Commit 465f969

Browse files
authored
[lldb][Module][NFC] Extract script loading logic into helper (#188712)
Planning on re-using this within the same function. Extracting into helper makes that slightly more readable.
1 parent 948a914 commit 465f969

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

lldb/source/Core/Module.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,6 +1420,19 @@ bool Module::IsLoadedInTarget(Target *target) {
14201420
return false;
14211421
}
14221422

1423+
static bool LoadScriptingModule(const FileSpec &scripting_fspec,
1424+
ScriptInterpreter &script_interpreter,
1425+
Target &target, Status &error) {
1426+
assert(scripting_fspec);
1427+
1428+
StreamString scripting_stream;
1429+
scripting_fspec.Dump(scripting_stream.AsRawOstream());
1430+
LoadScriptOptions options;
1431+
return script_interpreter.LoadScriptingModule(
1432+
scripting_stream.GetData(), options, error,
1433+
/*module_sp*/ nullptr, /*extra_path*/ {}, target.shared_from_this());
1434+
}
1435+
14231436
bool Module::LoadScriptingResourceInTarget(Target *target, Status &error) {
14241437
if (!target) {
14251438
error = Status::FromErrorString("invalid destination Target");
@@ -1489,13 +1502,8 @@ To run all discovered debug scripts in this session:
14891502
LLDB_LOG(GetLog(LLDBLog::Modules), "Auto-loading {0}",
14901503
scripting_fspec.GetPath());
14911504

1492-
StreamString scripting_stream;
1493-
scripting_fspec.Dump(scripting_stream.AsRawOstream());
1494-
LoadScriptOptions options;
1495-
bool did_load = script_interpreter->LoadScriptingModule(
1496-
scripting_stream.GetData(), options, error,
1497-
/*module_sp*/ nullptr, /*extra_path*/ {}, target->shared_from_this());
1498-
if (!did_load)
1505+
if (!LoadScriptingModule(scripting_fspec, *script_interpreter, *target,
1506+
error))
14991507
return false;
15001508
}
15011509

0 commit comments

Comments
 (0)