aboutsummaryrefslogtreecommitdiff
path: root/tools/lldb-mi/MICmdCmdExec.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lldb-mi/MICmdCmdExec.cpp')
-rw-r--r--tools/lldb-mi/MICmdCmdExec.cpp245
1 files changed, 224 insertions, 21 deletions
diff --git a/tools/lldb-mi/MICmdCmdExec.cpp b/tools/lldb-mi/MICmdCmdExec.cpp
index eec62c8d37e8..f0208c83d58d 100644
--- a/tools/lldb-mi/MICmdCmdExec.cpp
+++ b/tools/lldb-mi/MICmdCmdExec.cpp
@@ -7,9 +7,6 @@
//
//===----------------------------------------------------------------------===//
-//++
-// File: MICmdCmdExec.cpp
-//
// Overview: CMICmdCmdExecRun implementation.
// CMICmdCmdExecContinue implementation.
// CMICmdCmdExecNext implementation.
@@ -18,13 +15,8 @@
// CMICmdCmdExecStepInstruction implementation.
// CMICmdCmdExecFinish implementation.
// CMICmdCmdExecInterrupt implementation.
-//
-// Environment: Compilers: Visual C++ 12.
-// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
-// Libraries: See MIReadmetxt.
-//
-// Copyright: None.
-//--
+// CMICmdCmdExecArguments implementation.
+// CMICmdCmdExecAbort implementation.
// Third Party Headers:
#include "lldb/API/SBCommandInterpreter.h"
@@ -90,10 +82,9 @@ CMICmdCmdExecRun::Execute(void)
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
lldb::SBError error;
lldb::SBStream errMsg;
- uint32_t launch_flags = lldb::LaunchFlags::eLaunchFlagDebug;
- lldb::SBProcess process = rSessionInfo.GetTarget().Launch(rSessionInfo.GetListener(), nullptr, nullptr, nullptr, nullptr,
- nullptr, nullptr, launch_flags, false, error);
-
+ lldb::SBLaunchInfo launchInfo = rSessionInfo.GetTarget().GetLaunchInfo();
+ launchInfo.SetListener(rSessionInfo.GetListener());
+ lldb::SBProcess process = rSessionInfo.GetTarget().Launch(launchInfo, error);
if ((!process.IsValid()) || (error.Fail()))
{
SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PROCESS), m_cmdData.strMiCmd.c_str(), errMsg.GetData()));
@@ -207,7 +198,7 @@ CMICmdCmdExecContinue::~CMICmdCmdExecContinue(void)
bool
CMICmdCmdExecContinue::Execute(void)
{
- const MIchar *pCmd = "continue";
+ const char *pCmd = "continue";
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
const lldb::ReturnStatus rtn = rSessionInfo.GetDebugger().GetCommandInterpreter().HandleCommand(pCmd, m_lldbResult);
MIunused(rtn);
@@ -226,7 +217,7 @@ CMICmdCmdExecContinue::Execute(void)
{
// ToDo: Re-evaluate if this is required when application near finished as this is parsing LLDB error message
// which seems a hack and is code brittle
- const MIchar *pLldbErr = m_lldbResult.GetError();
+ const char *pLldbErr = m_lldbResult.GetError();
const CMIUtilString strLldbMsg(CMIUtilString(pLldbErr).StripCREndOfLine());
if (strLldbMsg == "error: Process must be launched.")
{
@@ -376,7 +367,7 @@ CMICmdCmdExecNext::Acknowledge(void)
{
if (m_lldbResult.GetErrorSize() > 0)
{
- const MIchar *pLldbErr = m_lldbResult.GetError();
+ const char *pLldbErr = m_lldbResult.GetError();
MIunused(pLldbErr);
const CMICmnMIValueConst miValueConst(m_lldbResult.GetError());
const CMICmnMIValueResult miValueResult("message", miValueConst);
@@ -503,7 +494,7 @@ CMICmdCmdExecStep::Acknowledge(void)
{
if (m_lldbResult.GetErrorSize() > 0)
{
- const MIchar *pLldbErr = m_lldbResult.GetError();
+ const char *pLldbErr = m_lldbResult.GetError();
MIunused(pLldbErr);
const CMICmnMIValueConst miValueConst(m_lldbResult.GetError());
const CMICmnMIValueResult miValueResult("message", miValueConst);
@@ -630,7 +621,7 @@ CMICmdCmdExecNextInstruction::Acknowledge(void)
{
if (m_lldbResult.GetErrorSize() > 0)
{
- const MIchar *pLldbErr = m_lldbResult.GetError();
+ const char *pLldbErr = m_lldbResult.GetError();
MIunused(pLldbErr);
const CMICmnMIValueConst miValueConst(m_lldbResult.GetError());
const CMICmnMIValueResult miValueResult("message", miValueConst);
@@ -757,7 +748,7 @@ CMICmdCmdExecStepInstruction::Acknowledge(void)
{
if (m_lldbResult.GetErrorSize() > 0)
{
- const MIchar *pLldbErr = m_lldbResult.GetError();
+ const char *pLldbErr = m_lldbResult.GetError();
MIunused(pLldbErr);
const CMICmnMIValueConst miValueConst(m_lldbResult.GetError());
const CMICmnMIValueResult miValueResult("message", miValueConst);
@@ -885,7 +876,7 @@ CMICmdCmdExecFinish::Acknowledge(void)
{
if (m_lldbResult.GetErrorSize() > 0)
{
- const MIchar *pLldbErr = m_lldbResult.GetError();
+ const char *pLldbErr = m_lldbResult.GetError();
MIunused(pLldbErr);
const CMICmnMIValueConst miValueConst(m_lldbResult.GetError());
const CMICmnMIValueResult miValueResult("message", miValueConst);
@@ -1016,3 +1007,215 @@ CMICmdCmdExecInterrupt::CreateSelf(void)
{
return new CMICmdCmdExecInterrupt();
}
+
+//---------------------------------------------------------------------------------------
+//---------------------------------------------------------------------------------------
+//---------------------------------------------------------------------------------------
+
+//++ ------------------------------------------------------------------------------------
+// Details: CMICmdCmdExecArguments constructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
+//--
+CMICmdCmdExecArguments::CMICmdCmdExecArguments(void)
+ : m_constStrArgArguments("arguments")
+{
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "exec-arguments";
+
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdExecArguments::CreateSelf;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: CMICmdCmdExecArguments destructor.
+// Type: Overrideable.
+// Args: None.
+// Return: None.
+// Throws: None.
+//--
+CMICmdCmdExecArguments::~CMICmdCmdExecArguments(void)
+{
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: The invoker requires this function. The parses the command line options
+// arguments to extract values for each of those arguments.
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Function succeeded.
+// MIstatus::failure - Function failed.
+// Throws: None.
+//--
+bool
+CMICmdCmdExecArguments::ParseArgs(void)
+{
+ bool bOk = m_setCmdArgs.Add(
+ *(new CMICmdArgValListOfN(m_constStrArgArguments, false, true, CMICmdArgValListBase::eArgValType_StringAnything)));
+ return (bOk && ParseValidateCmdOptions());
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: The invoker requires this function. The command does work in this function.
+// The command is likely to communicate with the LLDB SBDebugger in here.
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Function succeeded.
+// MIstatus::failure - Function failed.
+// Throws: None.
+//--
+bool
+CMICmdCmdExecArguments::Execute(void)
+{
+ CMICMDBASE_GETOPTION(pArgArguments, ListOfN, m_constStrArgArguments);
+
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBTarget sbTarget = rSessionInfo.GetTarget();
+ if (!sbTarget.IsValid())
+ {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_TARGET_CURRENT), m_cmdData.strMiCmd.c_str()));
+ return MIstatus::failure;
+ }
+
+ lldb::SBLaunchInfo sbLaunchInfo = sbTarget.GetLaunchInfo();
+ sbLaunchInfo.SetArguments(NULL, false);
+
+ CMIUtilString strArg;
+ size_t nArgIndex = 0;
+ while (pArgArguments->GetExpectedOption<CMICmdArgValString, CMIUtilString>(strArg, nArgIndex))
+ {
+ const char *argv[2] = { strArg.c_str(), NULL };
+ sbLaunchInfo.SetArguments(argv, true);
+ ++nArgIndex;
+ }
+
+ sbTarget.SetLaunchInfo(sbLaunchInfo);
+
+ return MIstatus::success;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: The invoker requires this function. The command prepares a MI Record Result
+// for the work carried out in the Execute().
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Function succeeded.
+// MIstatus::failure - Function failed.
+// Throws: None.
+//--
+bool
+CMICmdCmdExecArguments::Acknowledge(void)
+{
+ const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
+ m_miResultRecord = miRecordResult;
+
+ return MIstatus::success;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Required by the CMICmdFactory when registering *this command. The factory
+// calls this function to create an instance of *this command.
+// Type: Static method.
+// Args: None.
+// Return: CMICmdBase * - Pointer to a new command.
+// Throws: None.
+//--
+CMICmdBase *
+CMICmdCmdExecArguments::CreateSelf(void)
+{
+ return new CMICmdCmdExecArguments();
+}
+
+//---------------------------------------------------------------------------------------
+//---------------------------------------------------------------------------------------
+//---------------------------------------------------------------------------------------
+
+//++ ------------------------------------------------------------------------------------
+// Details: CMICmdCmdExecAbort constructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
+//--
+CMICmdCmdExecAbort::CMICmdCmdExecAbort(void)
+{
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "exec-abort";
+
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdExecAbort::CreateSelf;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: CMICmdCmdExecAbort destructor.
+// Type: Overrideable.
+// Args: None.
+// Return: None.
+// Throws: None.
+//--
+CMICmdCmdExecAbort::~CMICmdCmdExecAbort(void)
+{
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: The invoker requires this function. The command does work in this function.
+// The command is likely to communicate with the LLDB SBDebugger in here.
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Function succeeded.
+// MIstatus::failure - Function failed.
+// Throws: None.
+//--
+bool
+CMICmdCmdExecAbort::Execute(void)
+{
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
+ if (!sbProcess.IsValid())
+ {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PROCESS), m_cmdData.strMiCmd.c_str()));
+ return MIstatus::failure;
+ }
+
+ lldb::SBError sbError = sbProcess.Destroy();
+ if (sbError.Fail())
+ {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_LLDBPROCESS_DESTROY), m_cmdData.strMiCmd.c_str(), sbError.GetCString()));
+ return MIstatus::failure;
+ }
+
+ return MIstatus::success;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: The invoker requires this function. The command prepares a MI Record Result
+// for the work carried out in the Execute().
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Function succeeded.
+// MIstatus::failure - Function failed.
+// Throws: None.
+//--
+bool
+CMICmdCmdExecAbort::Acknowledge(void)
+{
+ const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
+ m_miResultRecord = miRecordResult;
+ return MIstatus::success;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Required by the CMICmdFactory when registering *this command. The factory
+// calls this function to create an instance of *this command.
+// Type: Static method.
+// Args: None.
+// Return: CMICmdBase * - Pointer to a new command.
+// Throws: None.
+//--
+CMICmdBase *
+CMICmdCmdExecAbort::CreateSelf(void)
+{
+ return new CMICmdCmdExecAbort();
+}