aboutsummaryrefslogtreecommitdiff
path: root/tools/lldb-mi/MICmdCmdStack.cpp
diff options
context:
space:
mode:
authorEd Maste <emaste@FreeBSD.org>2015-07-03 16:57:06 +0000
committerEd Maste <emaste@FreeBSD.org>2015-07-03 16:57:06 +0000
commit5e95aa85bb660d45e9905ef1d7180b2678280660 (patch)
tree3c2e41c3be19b7fc7666ed45a5f91ec3b6e35f2a /tools/lldb-mi/MICmdCmdStack.cpp
parent12bd4897ff0678fa663e09d78ebc22dd255ceb86 (diff)
downloadsrc-5e95aa85bb660d45e9905ef1d7180b2678280660.tar.gz
src-5e95aa85bb660d45e9905ef1d7180b2678280660.zip
Import LLDB as of upstream SVN 241361 (git 612c075f)vendor/lldb/lldb-r241361
Notes
Notes: svn path=/vendor/lldb/dist/; revision=285101 svn path=/vendor/lldb/lldb-r241361/; revision=285102; tag=vendor/lldb/lldb-r241361
Diffstat (limited to 'tools/lldb-mi/MICmdCmdStack.cpp')
-rw-r--r--tools/lldb-mi/MICmdCmdStack.cpp501
1 files changed, 427 insertions, 74 deletions
diff --git a/tools/lldb-mi/MICmdCmdStack.cpp b/tools/lldb-mi/MICmdCmdStack.cpp
index 4ab7164a30b7..7f767e727f97 100644
--- a/tools/lldb-mi/MICmdCmdStack.cpp
+++ b/tools/lldb-mi/MICmdCmdStack.cpp
@@ -7,20 +7,12 @@
//
//===----------------------------------------------------------------------===//
-//++
-// File: MICmdCmdStack.cpp
-//
// Overview: CMICmdCmdStackInfoDepth implementation.
+// CMICmdCmdStackInfoFrame implementation.
// CMICmdCmdStackListFrames implementation.
// CMICmdCmdStackListArguments implementation.
// CMICmdCmdStackListLocals implementation.
-//
-// Environment: Compilers: Visual C++ 12.
-// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
-// Libraries: See MIReadmetxt.
-//
-// Copyright: None.
-//--
+// CMICmdCmdStackSelectFrame implementation.
// Third Party Headers:
#include "lldb/API/SBThread.h"
@@ -37,6 +29,7 @@
#include "MICmdArgValThreadGrp.h"
#include "MICmdArgValOptionLong.h"
#include "MICmdArgValOptionShort.h"
+#include "MICmdArgValPrintValues.h"
#include "MICmdArgValListOfN.h"
//++ ------------------------------------------------------------------------------------
@@ -158,6 +151,113 @@ CMICmdCmdStackInfoDepth::CreateSelf(void)
//---------------------------------------------------------------------------------------
//++ ------------------------------------------------------------------------------------
+// Details: CMICmdCmdStackInfoFrame constructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
+//--
+CMICmdCmdStackInfoFrame::CMICmdCmdStackInfoFrame(void)
+{
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "stack-info-frame";
+
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdStackInfoFrame::CreateSelf;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: CMICmdCmdStackInfoFrame destructor.
+// Type: Overrideable.
+// Args: None.
+// Return: None.
+// Throws: None.
+//--
+CMICmdCmdStackInfoFrame::~CMICmdCmdStackInfoFrame(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
+CMICmdCmdStackInfoFrame::ParseArgs(void)
+{
+ return 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
+CMICmdCmdStackInfoFrame::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::SBThread sbThread = sbProcess.GetSelectedThread();
+ MIuint nFrameId = sbThread.GetSelectedFrame().GetFrameID();
+ if (!rSessionInfo.MIResponseFormFrameInfo(sbThread, nFrameId, CMICmnLLDBDebugSessionInfo::eFrameInfoFormat_NoArguments, m_miValueTuple))
+ 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
+CMICmdCmdStackInfoFrame::Acknowledge(void)
+{
+ const CMICmnMIValueResult miValueResult("frame", m_miValueTuple);
+ const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult);
+ 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 *
+CMICmdCmdStackInfoFrame::CreateSelf(void)
+{
+ return new CMICmdCmdStackInfoFrame();
+}
+
+//---------------------------------------------------------------------------------------
+//---------------------------------------------------------------------------------------
+//---------------------------------------------------------------------------------------
+
+//++ ------------------------------------------------------------------------------------
// Details: CMICmdCmdStackListFrames constructor.
// Type: Method.
// Args: None.
@@ -257,7 +357,7 @@ CMICmdCmdStackListFrames::Execute(void)
for (MIuint nLevel = nFrameLow; nLevel < nThreadFrames; nLevel++)
{
CMICmnMIValueTuple miValueTuple;
- if (!rSessionInfo.MIResponseFormFrameInfo(thread, nLevel, miValueTuple))
+ if (!rSessionInfo.MIResponseFormFrameInfo(thread, nLevel, CMICmnLLDBDebugSessionInfo::eFrameInfoFormat_NoArguments, miValueTuple))
return MIstatus::failure;
const CMICmnMIValueResult miValueResult8("frame", miValueTuple);
@@ -350,9 +450,8 @@ CMICmdCmdStackListArguments::CMICmdCmdStackListArguments(void)
, m_miValueList(true)
, m_constStrArgThread("thread")
, m_constStrArgPrintValues("print-values")
- , m_constStrArgNoValues("no-values")
- , m_constStrArgAllValues("all-values")
- , m_constStrArgSimpleValues("simple-values")
+ , m_constStrArgFrameLow("low-frame")
+ , m_constStrArgFrameHigh("high-frame")
{
// Command factory matches this name with that received from the stdin stream
m_strMiCmd = "stack-list-arguments";
@@ -386,10 +485,9 @@ CMICmdCmdStackListArguments::ParseArgs(void)
{
bool bOk =
m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, true, CMICmdArgValListBase::eArgValType_Number, 1)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgPrintValues, false, true)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgNoValues, false, true)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgAllValues, false, true)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgSimpleValues, false, true)));
+ bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValPrintValues(m_constStrArgPrintValues, true, true)));
+ bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgFrameLow, false, true)));
+ bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgFrameHigh, false, true)));
return (bOk && ParseValidateCmdOptions());
}
@@ -406,10 +504,9 @@ bool
CMICmdCmdStackListArguments::Execute(void)
{
CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread);
- CMICMDBASE_GETOPTION(pArgPrintValues, Number, m_constStrArgPrintValues);
- CMICMDBASE_GETOPTION(pArgNoValues, OptionLong, m_constStrArgNoValues);
- CMICMDBASE_GETOPTION(pArgAllValues, OptionLong, m_constStrArgAllValues);
- CMICMDBASE_GETOPTION(pArgSimpleValues, OptionLong, m_constStrArgSimpleValues);
+ CMICMDBASE_GETOPTION(pArgPrintValues, PrintValues, m_constStrArgPrintValues);
+ CMICMDBASE_GETOPTION(pArgFrameLow, Number, m_constStrArgFrameLow);
+ CMICMDBASE_GETOPTION(pArgFrameHigh, Number, m_constStrArgFrameHigh);
// Retrieve the --thread option's thread ID (only 1)
MIuint64 nThreadId = UINT64_MAX;
@@ -422,26 +519,19 @@ CMICmdCmdStackListArguments::Execute(void)
}
}
- CMICmnLLDBDebugSessionInfo::VariableInfoFormat_e eVarInfoFormat;
- if (pArgPrintValues->GetFound())
+ const CMICmnLLDBDebugSessionInfo::VariableInfoFormat_e eVarInfoFormat = static_cast<CMICmnLLDBDebugSessionInfo::VariableInfoFormat_e>(pArgPrintValues->GetValue());
+
+ MIuint nFrameLow = 0;
+ MIuint nFrameHigh = UINT32_MAX;
+ if (pArgFrameLow->GetFound() && pArgFrameHigh->GetFound())
{
- const MIuint nPrintValues = pArgPrintValues->GetValue();
- if (nPrintValues >= CMICmnLLDBDebugSessionInfo::kNumVariableInfoFormats)
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PRINT_VALUES), m_cmdData.strMiCmd.c_str()));
- return MIstatus::failure;
- }
- eVarInfoFormat = static_cast<CMICmnLLDBDebugSessionInfo::VariableInfoFormat_e>(nPrintValues);
+ nFrameLow = pArgFrameLow->GetValue();
+ nFrameHigh = pArgFrameHigh->GetValue() + 1;
}
- else if (pArgNoValues->GetFound())
- eVarInfoFormat = CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_NoValues;
- else if (pArgAllValues->GetFound())
- eVarInfoFormat = CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_AllValues;
- else if (pArgSimpleValues->GetFound())
- eVarInfoFormat = CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_SimpleValues;
- else
+ else if (pArgFrameLow->GetFound() || pArgFrameHigh->GetFound())
{
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PRINT_VALUES), m_cmdData.strMiCmd.c_str()));
+ // Only low-frame or high-frame was specified but both are required
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_THREAD_FRAME_RANGE_INVALID), m_cmdData.strMiCmd.c_str()));
return MIstatus::failure;
}
@@ -460,12 +550,20 @@ CMICmdCmdStackListArguments::Execute(void)
}
const MIuint nFrames = thread.GetNumFrames();
- for (MIuint i = 0; i < nFrames; i++)
+ if (nFrameLow >= nFrames)
+ {
+ // The low-frame is larger than the actual number of frames
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_THREAD_FRAME_RANGE_INVALID), m_cmdData.strMiCmd.c_str()));
+ return MIstatus::failure;
+ }
+
+ nFrameHigh = std::min(nFrameHigh, nFrames);
+ for (MIuint i = nFrameLow; i < nFrameHigh; i++)
{
lldb::SBFrame frame = thread.GetFrameAtIndex(i);
CMICmnMIValueList miValueList(true);
const MIuint maskVarTypes = CMICmnLLDBDebugSessionInfo::eVariableType_Arguments;
- if (!rSessionInfo.MIResponseFormVariableInfo3(frame, maskVarTypes, eVarInfoFormat, miValueList))
+ if (!rSessionInfo.MIResponseFormVariableInfo(frame, maskVarTypes, eVarInfoFormat, miValueList))
return MIstatus::failure;
const CMICmnMIValueConst miValueConst(CMIUtilString::Format("%d", i));
const CMICmnMIValueResult miValueResult("level", miValueConst);
@@ -540,9 +638,6 @@ CMICmdCmdStackListLocals::CMICmdCmdStackListLocals(void)
, m_constStrArgThread("thread")
, m_constStrArgFrame("frame")
, m_constStrArgPrintValues("print-values")
- , m_constStrArgNoValues("no-values")
- , m_constStrArgAllValues("all-values")
- , m_constStrArgSimpleValues("simple-values")
{
// Command factory matches this name with that received from the stdin stream
m_strMiCmd = "stack-list-locals";
@@ -578,10 +673,7 @@ CMICmdCmdStackListLocals::ParseArgs(void)
m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, true, CMICmdArgValListBase::eArgValType_Number, 1)));
bOk = bOk &&
m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgFrame, false, true, CMICmdArgValListBase::eArgValType_Number, 1)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgPrintValues, false, true)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgNoValues, false, true)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgAllValues, false, true)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgSimpleValues, false, true)));
+ bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValPrintValues(m_constStrArgPrintValues, true, true)));
return (bOk && ParseValidateCmdOptions());
}
@@ -599,10 +691,7 @@ CMICmdCmdStackListLocals::Execute(void)
{
CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread);
CMICMDBASE_GETOPTION(pArgFrame, OptionLong, m_constStrArgFrame);
- CMICMDBASE_GETOPTION(pArgPrintValues, Number, m_constStrArgPrintValues);
- CMICMDBASE_GETOPTION(pArgNoValues, OptionLong, m_constStrArgNoValues);
- CMICMDBASE_GETOPTION(pArgAllValues, OptionLong, m_constStrArgAllValues);
- CMICMDBASE_GETOPTION(pArgSimpleValues, OptionLong, m_constStrArgSimpleValues);
+ CMICMDBASE_GETOPTION(pArgPrintValues, PrintValues, m_constStrArgPrintValues);
// Retrieve the --thread option's thread ID (only 1)
MIuint64 nThreadId = UINT64_MAX;
@@ -625,28 +714,7 @@ CMICmdCmdStackListLocals::Execute(void)
}
}
- CMICmnLLDBDebugSessionInfo::VariableInfoFormat_e eVarInfoFormat;
- if (pArgPrintValues->GetFound())
- {
- const MIuint nPrintValues = pArgPrintValues->GetValue();
- if (nPrintValues >= CMICmnLLDBDebugSessionInfo::kNumVariableInfoFormats)
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PRINT_VALUES), m_cmdData.strMiCmd.c_str()));
- return MIstatus::failure;
- }
- eVarInfoFormat = static_cast<CMICmnLLDBDebugSessionInfo::VariableInfoFormat_e>(nPrintValues);
- }
- else if (pArgNoValues->GetFound())
- eVarInfoFormat = CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_NoValues;
- else if (pArgAllValues->GetFound())
- eVarInfoFormat = CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_AllValues;
- else if (pArgSimpleValues->GetFound())
- eVarInfoFormat = CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_SimpleValues;
- else
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PRINT_VALUES), m_cmdData.strMiCmd.c_str()));
- return MIstatus::failure;
- }
+ const CMICmnLLDBDebugSessionInfo::VariableInfoFormat_e eVarInfoFormat = static_cast<CMICmnLLDBDebugSessionInfo::VariableInfoFormat_e>(pArgPrintValues->GetValue());
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
@@ -717,3 +785,288 @@ CMICmdCmdStackListLocals::CreateSelf(void)
{
return new CMICmdCmdStackListLocals();
}
+
+//---------------------------------------------------------------------------------------
+//---------------------------------------------------------------------------------------
+//---------------------------------------------------------------------------------------
+
+//++ ------------------------------------------------------------------------------------
+// Details: CMICmdCmdStackListVariables constructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
+//--
+CMICmdCmdStackListVariables::CMICmdCmdStackListVariables(void)
+ : m_bThreadInvalid(false)
+ , m_miValueList(true)
+ , m_constStrArgThread("thread")
+ , m_constStrArgFrame("frame")
+ , m_constStrArgPrintValues("print-values")
+{
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "stack-list-variables";
+
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdStackListVariables::CreateSelf;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: CMICmdCmdStackListVariables destructor.
+// Type: Overrideable.
+// Args: None.
+// Return: None.
+// Throws: None.
+//--
+CMICmdCmdStackListVariables::~CMICmdCmdStackListVariables(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 - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
+//--
+bool
+CMICmdCmdStackListVariables::ParseArgs(void)
+{
+ bool bOk =
+ m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, true, CMICmdArgValListBase::eArgValType_Number, 1)));
+ bOk = bOk &&
+ m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgFrame, false, true, CMICmdArgValListBase::eArgValType_Number, 1)));
+ bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValPrintValues(m_constStrArgPrintValues, true, true)));
+ 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 - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
+//--
+bool
+CMICmdCmdStackListVariables::Execute(void)
+{
+ CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread);
+ CMICMDBASE_GETOPTION(pArgFrame, OptionLong, m_constStrArgFrame);
+ CMICMDBASE_GETOPTION(pArgPrintValues, PrintValues, m_constStrArgPrintValues);
+
+ // Retrieve the --thread option's thread ID (only 1)
+ MIuint64 nThreadId = UINT64_MAX;
+ if (pArgThread->GetFound())
+ {
+ if (!pArgThread->GetExpectedOption<CMICmdArgValNumber, MIuint64>(nThreadId))
+ {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_OPTION_NOT_FOUND), m_cmdData.strMiCmd.c_str(), m_constStrArgThread.c_str()));
+ return MIstatus::failure;
+ }
+ }
+
+ MIuint64 nFrame = UINT64_MAX;
+ if (pArgFrame->GetFound())
+ {
+ if (!pArgFrame->GetExpectedOption<CMICmdArgValNumber, MIuint64>(nFrame))
+ {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_OPTION_NOT_FOUND), m_cmdData.strMiCmd.c_str(), m_constStrArgFrame.c_str()));
+ return MIstatus::failure;
+ }
+ }
+
+ const CMICmnLLDBDebugSessionInfo::VariableInfoFormat_e eVarInfoFormat = static_cast<CMICmnLLDBDebugSessionInfo::VariableInfoFormat_e>(pArgPrintValues->GetValue());
+
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
+ lldb::SBThread thread = (nThreadId != UINT64_MAX) ? sbProcess.GetThreadByIndexID(nThreadId) : sbProcess.GetSelectedThread();
+ m_bThreadInvalid = !thread.IsValid();
+ if (m_bThreadInvalid)
+ return MIstatus::success;
+
+ const lldb::StopReason eStopReason = thread.GetStopReason();
+ if ((eStopReason == lldb::eStopReasonNone) || (eStopReason == lldb::eStopReasonInvalid))
+ {
+ m_bThreadInvalid = true;
+ return MIstatus::success;
+ }
+
+ lldb::SBFrame frame = (nFrame != UINT64_MAX) ? thread.GetFrameAtIndex(nFrame) : thread.GetSelectedFrame();
+
+ CMICmnMIValueList miValueList(true);
+ const MIuint maskVarTypes = CMICmnLLDBDebugSessionInfo::eVariableType_Arguments | CMICmnLLDBDebugSessionInfo::eVariableType_Locals;
+ if (!rSessionInfo.MIResponseFormVariableInfo(frame, maskVarTypes, eVarInfoFormat, miValueList, 10, true))
+ return MIstatus::failure;
+ m_miValueList = miValueList;
+
+ 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 - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
+//--
+bool
+CMICmdCmdStackListVariables::Acknowledge(void)
+{
+ if (m_bThreadInvalid)
+ {
+ // MI print "%s^done,variables=[]"
+ const CMICmnMIValueList miValueList(true);
+ const CMICmnMIValueResult miValueResult("variables", miValueList);
+ const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult);
+ m_miResultRecord = miRecordResult;
+ return MIstatus::success;
+ }
+
+ // MI print "%s^done,variables=[%s]"
+ const CMICmnMIValueResult miValueResult("variables", m_miValueList);
+ const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult);
+ 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 *
+CMICmdCmdStackListVariables::CreateSelf(void)
+{
+ return new CMICmdCmdStackListVariables();
+}
+
+//---------------------------------------------------------------------------------------
+//---------------------------------------------------------------------------------------
+//---------------------------------------------------------------------------------------
+
+//++ ------------------------------------------------------------------------------------
+// Details: CMICmdCmdStackSelectFrame constructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
+//--
+CMICmdCmdStackSelectFrame::CMICmdCmdStackSelectFrame(void)
+ : m_bFrameInvalid(false)
+ , m_constStrArgFrame("frame")
+{
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "stack-select-frame";
+
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdStackSelectFrame::CreateSelf;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: CMICmdCmdStackSelectFrame destructor.
+// Type: Overrideable.
+// Args: None.
+// Return: None.
+// Throws: None.
+//--
+CMICmdCmdStackSelectFrame::~CMICmdCmdStackSelectFrame(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
+CMICmdCmdStackSelectFrame::ParseArgs(void)
+{
+ bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgFrame, true, false)));
+ 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
+CMICmdCmdStackSelectFrame::Execute(void)
+{
+ CMICMDBASE_GETOPTION(pArgFrame, Number, m_constStrArgFrame);
+
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBThread sbThread = rSessionInfo.GetProcess().GetSelectedThread();
+
+ const MIuint nFrameId = pArgFrame->GetValue();
+ m_bFrameInvalid = (nFrameId >= sbThread.GetNumFrames());
+ if (m_bFrameInvalid)
+ return MIstatus::success;
+
+ lldb::SBFrame sbFrame = sbThread.SetSelectedFrame(nFrameId);
+ m_bFrameInvalid = !sbFrame.IsValid();
+
+ 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
+CMICmdCmdStackSelectFrame::Acknowledge(void)
+{
+ if (m_bFrameInvalid)
+ {
+ // MI print "%s^error,msg=\"Command '-stack-select-frame'. Frame ID invalid\""
+ const CMICmnMIValueConst miValueConst(
+ CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_FRAME_INVALID), m_cmdData.strMiCmd.c_str()));
+ const CMICmnMIValueResult miValueResult("msg", miValueConst);
+ const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult);
+ m_miResultRecord = miRecordResult;
+
+ return MIstatus::success;
+ }
+
+ 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 *
+CMICmdCmdStackSelectFrame::CreateSelf(void)
+{
+ return new CMICmdCmdStackSelectFrame();
+}