template <>
-HRESULT CLIProtocol::doCommand<CommandTag::Backtrace>(const std::vector<std::string> &args_orig, std::string &output)
+HRESULT CLIProtocol::doCommand<CommandTag::Backtrace>(const std::string &, const std::vector<std::string> &args_orig, std::string &output)
{
lock_guard lock(m_mutex);
}
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::Break>(const std::vector<std::string> &unmutable_args, std::string &output)
+HRESULT CLIProtocol::doCommand<CommandTag::Break>(const std::string &, const std::vector<std::string> &unmutable_args, std::string &output)
{
HRESULT Status = E_FAIL;
Breakpoint breakpoint;
}
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::Catch>(const std::vector<std::string> &args, std::string &outStr)
+HRESULT CLIProtocol::doCommand<CommandTag::Catch>(const std::string &, const std::vector<std::string> &args, std::string &outStr)
{
if (args.size() < 2)
{
}
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::Continue>(const std::vector<std::string> &, std::string &output)
+HRESULT CLIProtocol::doCommand<CommandTag::Continue>(const std::string &, const std::vector<std::string> &, std::string &output)
{
{
lock_guard lock(m_mutex);
}
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::Delete>(const std::vector<std::string> &args, std::string &)
+HRESULT CLIProtocol::doCommand<CommandTag::Delete>(const std::string &, const std::vector<std::string> &args, std::string &)
{
std::unordered_set<uint32_t> ids;
for (const std::string &idStr : args)
}
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::Detach>(const std::vector<std::string> &args, std::string &output)
+HRESULT CLIProtocol::doCommand<CommandTag::Detach>(const std::string &, const std::vector<std::string> &args, std::string &output)
{
{
lock_guard lock(m_mutex);
}
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::Disable>(const std::vector<std::string> &args, std::string &)
+HRESULT CLIProtocol::doCommand<CommandTag::Disable>(const std::string &, const std::vector<std::string> &args, std::string &)
{
int count = 0, sub = 0;
}
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::Enable>(const std::vector<std::string> &args, std::string &)
+HRESULT CLIProtocol::doCommand<CommandTag::Enable>(const std::string &, const std::vector<std::string> &args, std::string &)
{
int count = 0, sub = 0;
}
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::File>(const std::vector<std::string> &args, std::string &output)
+HRESULT CLIProtocol::doCommand<CommandTag::File>(const std::string &, const std::vector<std::string> &args, std::string &output)
{
if (args.empty())
{
}
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::Finish>(const std::vector<std::string> &args, std::string &output)
+HRESULT CLIProtocol::doCommand<CommandTag::Finish>(const std::string &, const std::vector<std::string> &args, std::string &output)
{
return StepCommand(args, output, IDebugger::StepType::STEP_OUT);
}
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::Frame>(const std::vector<std::string> &args, std::string &output)
+HRESULT CLIProtocol::doCommand<CommandTag::Frame>(const std::string &, const std::vector<std::string> &args, std::string &output)
{
lock_guard lock(m_mutex);
}
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::Help>(const std::vector<std::string> &args, std::string &output)
+HRESULT CLIProtocol::doCommand<CommandTag::Help>(const std::string &, const std::vector<std::string> &args, std::string &output)
{
printHelp(CommandsList::commands_list, args.empty() ? string_view{} : string_view{args[0]});
return S_OK;
}
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::InfoThreads>(const std::vector<std::string> &args, std::string &output)
+HRESULT CLIProtocol::doCommand<CommandTag::InfoThreads>(const std::string &, const std::vector<std::string> &args, std::string &output)
{
{
lock_guard lock(m_mutex);
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::InfoBreakpoints>(const std::vector<std::string>& args, std::string& output)
+HRESULT CLIProtocol::doCommand<CommandTag::InfoBreakpoints>(const std::string &, const std::vector<std::string>& args, std::string& output)
{
const static string_view header[] {"#", "Enb", "Rslvd", "Hits", "Source/Function"};
const static string_view data[] { "99999", "Y", "N", "999999999", "" };
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::Interrupt>(const std::vector<std::string> &, std::string &output)
+HRESULT CLIProtocol::doCommand<CommandTag::Interrupt>(const std::string &, const std::vector<std::string> &, std::string &output)
{
{
lock_guard lock(m_mutex);
}
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::List>(const std::vector<std::string> &args, std::string &output)
+HRESULT CLIProtocol::doCommand<CommandTag::List>(const std::string &, const std::vector<std::string> &args, std::string &output)
{
HRESULT status = S_OK;
int line = m_sourceLine;
}
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::Next>(const std::vector<std::string> &args, std::string &output)
+HRESULT CLIProtocol::doCommand<CommandTag::Next>(const std::string &, const std::vector<std::string> &args, std::string &output)
{
return StepCommand(args, output, IDebugger::StepType::STEP_OVER);
}
}
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::Print>(const std::vector<std::string> &args, std::string &output)
+HRESULT CLIProtocol::doCommand<CommandTag::Print>(const std::string &input, const std::vector<std::string> &args, std::string &output)
{
ThreadId threadId;
FrameId frameId;
if (!args.empty())
{
- m_lastPrintArg = args[0];
+ // In order to get expression from input string that contain command and spaces (for example, ` p "test"`):
+ // 1) find first 'p' (could be "p" or "print" only here);
+ // 2) find first ' ' (after command we have at least one space for sure);
+ // 3) find first not ' ' (skip all spaces before expression);
+ // Note, we don't check errors here, since at this point `input` string have "p "/"print " substrings for sure.
+ m_lastPrintArg = input.substr(input.find_first_not_of(' ', input.find_first_of(' ', input.find_first_of('p'))));
}
else if (m_lastPrintArg.empty())
{
}
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::Quit>(const std::vector<std::string> &, std::string &)
+HRESULT CLIProtocol::doCommand<CommandTag::Quit>(const std::string &, const std::vector<std::string> &, std::string &)
{
// no mutex locking needed here
m_exit = true;
}
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::Run>(const std::vector<std::string> &args, std::string &output)
+HRESULT CLIProtocol::doCommand<CommandTag::Run>(const std::string &, const std::vector<std::string> &args, std::string &output)
{
unique_lock lock(m_mutex);
}
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::Attach>(const std::vector<std::string>& args, std::string& output)
+HRESULT CLIProtocol::doCommand<CommandTag::Attach>(const std::string &, const std::vector<std::string>& args, std::string& output)
{
unique_lock lock(m_mutex);
}
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::Step>(const std::vector<std::string> &args, std::string &output)
+HRESULT CLIProtocol::doCommand<CommandTag::Step>(const std::string &, const std::vector<std::string> &args, std::string &output)
{
return StepCommand(args, output, IDebugger::StepType::STEP_IN);
}
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::Source>(const std::vector<std::string> &args, std::string &output)
+HRESULT CLIProtocol::doCommand<CommandTag::Source>(const std::string &, const std::vector<std::string> &args, std::string &output)
{
// check arguments
if (args.empty())
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::Wait>(const std::vector<std::string> &, std::string &)
+HRESULT CLIProtocol::doCommand<CommandTag::Wait>(const std::string &, const std::vector<std::string> &, std::string &)
{
lock_guard lock(m_mutex);
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::Set>(const std::vector<std::string> &args, std::string &output)
+HRESULT CLIProtocol::doCommand<CommandTag::Set>(const std::string &, const std::vector<std::string> &args, std::string &output)
{
printf("Argument(s) required: see 'help set' for details.\n");
return S_FALSE;
}
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::Info>(const std::vector<std::string> &args, std::string &output)
+HRESULT CLIProtocol::doCommand<CommandTag::Info>(const std::string &, const std::vector<std::string> &args, std::string &output)
{
printHelp(CommandsList::info_commands, args.empty() ? string_view{} : string_view{args[0]});
return S_OK;
}
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::InfoHelp>(const std::vector<std::string> &args, std::string &output)
+HRESULT CLIProtocol::doCommand<CommandTag::InfoHelp>(const std::string &, const std::vector<std::string> &args, std::string &output)
{
printHelp(CommandsList::info_commands, args.empty() ? string_view{} : string_view{args[0]});
return S_OK;
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::Save>(const std::vector<std::string> &args, std::string &output)
+HRESULT CLIProtocol::doCommand<CommandTag::Save>(const std::string &, const std::vector<std::string> &args, std::string &output)
{
printf("Argument(s) required: see 'help save' for details.\n");
return S_FALSE;
}
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::SaveBreakpoints>(const std::vector<std::string> &args, std::string &output)
+HRESULT CLIProtocol::doCommand<CommandTag::SaveBreakpoints>(const std::string &, const std::vector<std::string> &args, std::string &output)
{
if (args.empty())
{
}
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::SaveHelp>(const std::vector<std::string> &args, std::string &output)
+HRESULT CLIProtocol::doCommand<CommandTag::SaveHelp>(const std::string &, const std::vector<std::string> &args, std::string &output)
{
printHelp(CommandsList::save_commands, args.empty() ? string_view{} : string_view{args[0]});
return S_OK;
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::SetArgs>(const std::vector<std::string> &args, std::string &output)
+HRESULT CLIProtocol::doCommand<CommandTag::SetArgs>(const std::string &, const std::vector<std::string> &args, std::string &output)
{
lock_guard lock(m_mutex);
m_execArgs = args;
}
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::SetJustMyCode>(const std::vector<std::string> &args, std::string &output)
+HRESULT CLIProtocol::doCommand<CommandTag::SetJustMyCode>(const std::string &, const std::vector<std::string> &args, std::string &output)
{
if (args.empty() || (args[0] != "0" && args[0] != "1"))
return E_INVALIDARG;
}
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::SetStepFiltering>(const std::vector<std::string> &args, std::string &output)
+HRESULT CLIProtocol::doCommand<CommandTag::SetStepFiltering>(const std::string &, const std::vector<std::string> &args, std::string &output)
{
if (args.empty() || (args[0] != "0" && args[0] != "1"))
return E_INVALIDARG;
}
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::SetHelp>(const std::vector<std::string> &args, std::string &output)
+HRESULT CLIProtocol::doCommand<CommandTag::SetHelp>(const std::string &, const std::vector<std::string> &args, std::string &output)
{
printHelp(CommandsList::set_commands, args.empty() ? string_view{} : string_view{args[0]});
return S_OK;
}
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::HelpInfo>(const std::vector<std::string> &args, std::string &output)
+HRESULT CLIProtocol::doCommand<CommandTag::HelpInfo>(const std::string &input, const std::vector<std::string> &args, std::string &output)
{
- return doCommand<CommandTag::InfoHelp>(args, output);
+ return doCommand<CommandTag::InfoHelp>(input, args, output);
}
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::HelpSet>(const std::vector<std::string> &args, std::string &output)
+HRESULT CLIProtocol::doCommand<CommandTag::HelpSet>(const std::string &input, const std::vector<std::string> &args, std::string &output)
{
- return doCommand<CommandTag::SetHelp>(args, output);
+ return doCommand<CommandTag::SetHelp>(input, args, output);
}
template <>
-HRESULT CLIProtocol::doCommand<CommandTag::HelpSave>(const std::vector<std::string> &args, std::string &output)
+HRESULT CLIProtocol::doCommand<CommandTag::HelpSave>(const std::string &input, const std::vector<std::string> &args, std::string &output)
{
- return doCommand<CommandTag::SaveHelp>(args, output);
+ return doCommand<CommandTag::SaveHelp>(input, args, output);
}
const static unsigned QueryLimit = 30;
auto thread = m_sharedDebugger->GetLastStoppedThreadId();
- auto frame = FrameLevel{0};
+ m_mutex.lock();
+ auto frame = FrameLevel{m_frameIdx};
+ m_mutex.unlock();
unsigned count;
auto counter = [&](const char *) { return ++count, true; };
while (tokenizer.Next(result))
args.push_back(result);
- hr = (this->*func)(args, output);
+ hr = (this->*func)(str, args, output);
have_result = true;
};