[Lldb-commits] [lldb] r232048 - Add low-frame/high-frame options to -stack-list-arguments (MI)
Ilia K
ki.stfu at gmail.com
Thu Mar 12 08:35:59 PDT 2015
Author: ki.stfu
Date: Thu Mar 12 10:35:58 2015
New Revision: 232048
URL: http://llvm.org/viewvc/llvm-project?rev=232048&view=rev
Log:
Add low-frame/high-frame options to -stack-list-arguments (MI)
Summary:
Add low-frame/high-frame options to -stack-list-arguments
All tests pass on OS X.
Reviewers: clayborg, abidh
Reviewed By: abidh
Subscribers: lldb-commits, clayborg, abidh
Differential Revision: http://reviews.llvm.org/D8282
Modified:
lldb/trunk/test/tools/lldb-mi/stack/TestMiStack.py
lldb/trunk/tools/lldb-mi/MICmdCmdStack.cpp
lldb/trunk/tools/lldb-mi/MICmdCmdStack.h
Modified: lldb/trunk/test/tools/lldb-mi/stack/TestMiStack.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tools/lldb-mi/stack/TestMiStack.py?rev=232048&r1=232047&r2=232048&view=diff
==============================================================================
--- lldb/trunk/test/tools/lldb-mi/stack/TestMiStack.py (original)
+++ lldb/trunk/test/tools/lldb-mi/stack/TestMiStack.py Thu Mar 12 10:35:58 2015
@@ -30,23 +30,50 @@ class MiStackTestCase(lldbmi_testcase.Mi
self.expect("\^running")
self.expect("\*stopped,reason=\"breakpoint-hit\"")
- # Test -stack-list-arguments: use 0 or --no-values
+ # Test that -stack-list-arguments lists empty stack arguments if range is empty
+ self.runCmd("-stack-list-arguments 0 1 0")
+ self.expect("\^done,stack-args=\[\]")
+
+ # Test that -stack-list-arguments lists stack arguments without values
+ # (and that low-frame and high-frame are optional)
self.runCmd("-stack-list-arguments 0")
self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[name=\"argc\",name=\"argv\"\]}")
self.runCmd("-stack-list-arguments --no-values")
self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[name=\"argc\",name=\"argv\"\]}")
- # Test -stack-list-arguments: use 1 or --all-values
- self.runCmd("-stack-list-arguments 1")
- self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",value=\"1\"},{name=\"argv\",value=\".*\"}\]}")
- self.runCmd("-stack-list-arguments --all-values")
- self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",value=\"1\"},{name=\"argv\",value=\".*\"}\]}")
+ # Test that -stack-list-arguments lists stack arguments with all values
+ self.runCmd("-stack-list-arguments 1 0 0")
+ self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",value=\"1\"},{name=\"argv\",value=\".*\"}\]}\]")
+ # FIXME: first 0 is treated as --no-values
+ self.runCmd("-stack-list-arguments --all-values 0 0")
+ #self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",value=\"1\"},{name=\"argv\",value=\".*\"}\]}\]")
- # Test -stack-list-arguments: use 2 or --simple-values
- self.runCmd("-stack-list-arguments 2")
- self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",value=\"1\"},{name=\"argv\",value=\".*\"}\]}")
- self.runCmd("-stack-list-arguments --simple-values")
+ # Test that -stack-list-arguments lists stack arguments with simple values
+ self.runCmd("-stack-list-arguments 2 0 1")
self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",value=\"1\"},{name=\"argv\",value=\".*\"}\]}")
+ # FIXME: first 0 is treated as --no-values
+ self.runCmd("-stack-list-arguments --simple-values 0 1")
+ #self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",value=\"1\"},{name=\"argv\",value=\".*\"}\]}")
+
+ # Test that an invalid low-frame is handled
+ # FIXME: -1 is treated as unsigned int
+ self.runCmd("-stack-list-arguments 0 -1 0")
+ #self.expect("\^error")
+ self.runCmd("-stack-list-arguments 0 0")
+ self.expect("\^error,msg=\"Command 'stack-list-arguments'. Thread frame range invalid\"")
+
+ # Test that an invalid high-frame is handled
+ # FIXME: -1 is treated as unsigned int
+ self.runCmd("-stack-list-arguments 0 0 -1")
+ #self.expect("\^error")
+
+ # Test that a missing low-frame or high-frame is handled
+ self.runCmd("-stack-list-arguments 0 0")
+ self.expect("\^error,msg=\"Command 'stack-list-arguments'. Thread frame range invalid\"")
+
+ # Test that an invalid low-frame is handled
+ self.runCmd("-stack-list-arguments 0 0")
+ self.expect("\^error,msg=\"Command 'stack-list-arguments'. Thread frame range invalid\"")
@lldbmi_test
@expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
Modified: lldb/trunk/tools/lldb-mi/MICmdCmdStack.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdStack.cpp?rev=232048&r1=232047&r2=232048&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdStack.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdStack.cpp Thu Mar 12 10:35:58 2015
@@ -462,6 +462,8 @@ CMICmdCmdStackListArguments::CMICmdCmdSt
, 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";
@@ -499,6 +501,8 @@ CMICmdCmdStackListArguments::ParseArgs(v
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 CMICmdArgValNumber(m_constStrArgFrameLow, false, true)));
+ bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgFrameHigh, false, true)));
return (bOk && ParseValidateCmdOptions());
}
@@ -519,6 +523,8 @@ CMICmdCmdStackListArguments::Execute(voi
CMICMDBASE_GETOPTION(pArgNoValues, OptionLong, m_constStrArgNoValues);
CMICMDBASE_GETOPTION(pArgAllValues, OptionLong, m_constStrArgAllValues);
CMICMDBASE_GETOPTION(pArgSimpleValues, OptionLong, m_constStrArgSimpleValues);
+ 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;
@@ -554,6 +560,20 @@ CMICmdCmdStackListArguments::Execute(voi
return MIstatus::failure;
}
+ MIuint nFrameLow = 0;
+ MIuint nFrameHigh = UINT32_MAX;
+ if (pArgFrameLow->GetFound() && pArgFrameHigh->GetFound())
+ {
+ nFrameLow = pArgFrameLow->GetValue();
+ nFrameHigh = pArgFrameHigh->GetValue() + 1;
+ }
+ else if (pArgFrameLow->GetFound() || pArgFrameHigh->GetFound())
+ {
+ // 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;
+ }
+
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
lldb::SBThread thread = (nThreadId != UINT64_MAX) ? sbProcess.GetThreadByIndexID(nThreadId) : sbProcess.GetSelectedThread();
@@ -569,7 +589,15 @@ CMICmdCmdStackListArguments::Execute(voi
}
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);
Modified: lldb/trunk/tools/lldb-mi/MICmdCmdStack.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdStack.h?rev=232048&r1=232047&r2=232048&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdStack.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdStack.h Thu Mar 12 10:35:58 2015
@@ -179,6 +179,8 @@ class CMICmdCmdStackListArguments : publ
const CMIUtilString m_constStrArgNoValues;
const CMIUtilString m_constStrArgAllValues;
const CMIUtilString m_constStrArgSimpleValues;
+ const CMIUtilString m_constStrArgFrameLow;
+ const CMIUtilString m_constStrArgFrameHigh;
};
//++ ============================================================================
More information about the lldb-commits
mailing list