Skip to content

Commit 8ffdb19

Browse files
authored
Support running multiple init LLDB commands (#840)
1 parent 2c62eb7 commit 8ffdb19

1 file changed

Lines changed: 32 additions & 10 deletions

File tree

core/adapters/lldbadapter.cpp

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,11 @@ Ref<Settings> LldbAdapterType::RegisterAdapterSettings()
298298
})");
299299
settings->RegisterSetting("common.initialLLDBCommand",
300300
R"({
301-
"title": "Initial LLDB Command",
302-
"type": "string",
303-
"default": "",
304-
"description": "Specifies an LLDB command to execute immediately after launching/attaching/connecting to the target",
301+
"title": "Initial LLDB Commands",
302+
"type": "array",
303+
"sorted": false,
304+
"default": [],
305+
"description": "Specifies LLDB commands to execute immediately after launching/attaching/connecting to the target",
305306
"readOnly": false
306307
})");
307308

@@ -392,7 +393,7 @@ bool LldbAdapter::ExecuteWithArgs(const std::string& path, const std::string& ar
392393
scope = SettingsResourceScope;
393394
auto followForkMode = adapterSettings->Get<std::string>("common.followForkMode", data, &scope);
394395
scope = SettingsResourceScope;
395-
auto initialLLDBCommand = adapterSettings->Get<std::string>("common.initialLLDBCommand", data, &scope);
396+
auto initialLLDBCommand = adapterSettings->Get<vector<string>>("common.initialLLDBCommand", data, &scope);
396397

397398
CreateTarget(inputFile);
398399

@@ -431,7 +432,14 @@ bool LldbAdapter::ExecuteWithArgs(const std::string& path, const std::string& ar
431432
InvokeBackendCommand(fmt::format("settings set target.process.follow-fork-mode \"{}\"", followForkMode));
432433

433434
if (!initialLLDBCommand.empty())
434-
InvokeBackendCommand(initialLLDBCommand);
435+
{
436+
for (const auto& command : initialLLDBCommand)
437+
{
438+
if (command.empty())
439+
continue;
440+
InvokeBackendCommand(command);
441+
}
442+
}
435443

436444
std::string launchCommand = "process launch";
437445
if (Settings::Instance()->Get<bool>("debugger.stopAtSystemEntryPoint") ||
@@ -511,7 +519,7 @@ bool LldbAdapter::Attach(std::uint32_t pid)
511519
scope = SettingsResourceScope;
512520
auto followForkMode = adapterSettings->Get<std::string>("common.followForkMode", data, &scope);
513521
scope = SettingsResourceScope;
514-
auto initialLLDBCommand = adapterSettings->Get<std::string>("common.initialLLDBCommand", data, &scope);
522+
auto initialLLDBCommand = adapterSettings->Get<vector<string>>("common.initialLLDBCommand", data, &scope);
515523

516524
CreateTarget(inputFile);
517525

@@ -533,7 +541,14 @@ bool LldbAdapter::Attach(std::uint32_t pid)
533541
InvokeBackendCommand(fmt::format("settings set target.process.follow-fork-mode \"{}\"", followForkMode));
534542

535543
if (!initialLLDBCommand.empty())
536-
InvokeBackendCommand(initialLLDBCommand);
544+
{
545+
for (const auto& command : initialLLDBCommand)
546+
{
547+
if (command.empty())
548+
continue;
549+
InvokeBackendCommand(command);
550+
}
551+
}
537552

538553
SBAttachInfo info(attachPID);
539554
m_process = m_target.Attach(info, err);
@@ -614,7 +629,7 @@ bool LldbAdapter::Connect(const std::string& server, std::uint32_t port)
614629
scope = SettingsResourceScope;
615630
auto followForkMode = adapterSettings->Get<std::string>("common.followForkMode", data, &scope);
616631
scope = SettingsResourceScope;
617-
auto initialLLDBCommand = adapterSettings->Get<std::string>("common.initialLLDBCommand", data, &scope);
632+
auto initialLLDBCommand = adapterSettings->Get<vector<string>>("common.initialLLDBCommand", data, &scope);
618633

619634
CreateTarget(inputFile);
620635

@@ -636,7 +651,14 @@ bool LldbAdapter::Connect(const std::string& server, std::uint32_t port)
636651
InvokeBackendCommand(fmt::format("settings set target.process.follow-fork-mode \"{}\"", followForkMode));
637652

638653
if (!initialLLDBCommand.empty())
639-
InvokeBackendCommand(initialLLDBCommand);
654+
{
655+
for (const auto& command : initialLLDBCommand)
656+
{
657+
if (command.empty())
658+
continue;
659+
InvokeBackendCommand(command);
660+
}
661+
}
640662

641663
if (Settings::Instance()->Get<bool>("debugger.stopAtEntryPoint") && m_hasEntryFunction)
642664
AddBreakpoint(ModuleNameAndOffset(inputFile, m_entryPoint - m_start));

0 commit comments

Comments
 (0)