Index: test/tools/lldb-mi/stack/TestMiStack.py =================================================================== --- test/tools/lldb-mi/stack/TestMiStack.py +++ test/tools/lldb-mi/stack/TestMiStack.py @@ -30,23 +30,50 @@ 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") Index: tools/lldb-mi/MICmdCmdStack.h =================================================================== --- tools/lldb-mi/MICmdCmdStack.h +++ tools/lldb-mi/MICmdCmdStack.h @@ -179,6 +179,8 @@ const CMIUtilString m_constStrArgNoValues; const CMIUtilString m_constStrArgAllValues; const CMIUtilString m_constStrArgSimpleValues; + const CMIUtilString m_constStrArgFrameLow; + const CMIUtilString m_constStrArgFrameHigh; }; //++ ============================================================================ Index: tools/lldb-mi/MICmdCmdStack.cpp =================================================================== --- tools/lldb-mi/MICmdCmdStack.cpp +++ tools/lldb-mi/MICmdCmdStack.cpp @@ -462,6 +462,8 @@ , 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 @@ 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 @@ 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 @@ 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 @@ } 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);