Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
mikem8361 committed Jul 18, 2022
1 parent 071234d commit bbd7192
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 17 deletions.
39 changes: 39 additions & 0 deletions src/SOS/lldbplugin/services.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2784,6 +2784,45 @@ LLDBServices::AddCommand(
return command;
}

bool
LLDBServices::ExecuteCommand(
const char* commandName,
char** arguments,
lldb::SBCommandReturnObject &result)
{
std::string commandLine;
commandLine.append(commandName);
commandLine.append(" ");
for (const char* arg = *arguments; arg != nullptr; arg = *(++arguments))
{
commandLine.append(arg);
commandLine.append(" ");
}
if (m_commands.find(commandName) == m_commands.end())
{
lldb::ReturnStatus status = m_interpreter.HandleCommand(commandLine.c_str(), result);
result.SetStatus(status);
return true;
}
IHostServices* hostservices = GetHostServices();
if (hostservices != nullptr)
{
g_services->FlushCheck();
HRESULT hr = hostservices->DispatchCommand(commandLine.c_str());
if (hr != S_OK)
{
result.SetStatus(lldb::eReturnStatusFailed);
}
else
{
result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
}
return true;
}
// This means command not found
return false;
}

HRESULT
LLDBServices::InternalOutputVaList(
ULONG mask,
Expand Down
2 changes: 2 additions & 0 deletions src/SOS/lldbplugin/services.h
Original file line number Diff line number Diff line change
Expand Up @@ -414,5 +414,7 @@ class LLDBServices : public ILLDBServices, public ILLDBServices2, public IDebugg

lldb::SBCommand AddCommand(const char *name, lldb::SBCommandPluginInterface *impl, const char *help);

bool ExecuteCommand( const char* commandName, char** arguments, lldb::SBCommandReturnObject &result);

HRESULT InternalOutputVaList(ULONG mask, PCSTR format, va_list args);
};
19 changes: 2 additions & 17 deletions src/SOS/lldbplugin/soscommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,9 @@ class sosCommand : public lldb::SBCommandPluginInterface
else
{
sosCommand = *arguments++;

IHostServices* hostservices = GetHostServices();
if (hostservices != nullptr)
if (g_services->ExecuteCommand(sosCommand, arguments, result))
{
std::string commandLine;
commandLine.append(sosCommand);
commandLine.append(" ");
for (const char* arg = *arguments; arg != nullptr; arg = *(++arguments))
{
commandLine.append(arg);
commandLine.append(" ");
}
g_services->FlushCheck();
HRESULT hr = hostservices->DispatchCommand(commandLine.c_str());
if (hr == S_OK)
{
return result.Succeeded();
}
return result.Succeeded();
}
}
}
Expand Down

0 comments on commit bbd7192

Please sign in to comment.