diff options
-rw-r--r-- | lldb/lit/tools/lldb-mi/exec/exec-step.test | 30 | ||||
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py | 4 | ||||
-rw-r--r-- | lldb/tools/lldb-mi/MICmdCmdExec.cpp | 43 | ||||
-rw-r--r-- | lldb/tools/lldb-mi/MICmdCmdExec.h | 1 |
4 files changed, 53 insertions, 25 deletions
diff --git a/lldb/lit/tools/lldb-mi/exec/exec-step.test b/lldb/lit/tools/lldb-mi/exec/exec-step.test new file mode 100644 index 00000000000..095bba714ec --- /dev/null +++ b/lldb/lit/tools/lldb-mi/exec/exec-step.test @@ -0,0 +1,30 @@ +# XFAIL: windows +# -> llvm.org/pr24452 +# +# RUN: %cc -o %t %p/inputs/main.c -g +# RUN: %lldbmi %t < %s | FileCheck %s + +# Test lldb-mi -exec-step command. + +# Check that we have a valid target created via '%lldbmi %t'. +# CHECK: ^done + +-break-insert main +# CHECK: ^done,bkpt={number="1" + +-exec-run +# CHECK: ^running +# CHECK: *stopped,reason="breakpoint-hit" + +-exec-step --thread 0 +# Check that exec-step can process the case of invalid thread ID. +# CHECK: ^error,msg="Command 'exec-step'. Thread ID invalid" + +-exec-step --thread 1 +# CHECK: ^running +# CHECK: *stopped,reason="end-stepping-range" + +-exec-step +# Check that exec-step can step-in in a selected thread. +# CHECK: ^running +# CHECK: *stopped,reason="end-stepping-range" diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py index 15455f8cf3b..fb1e10473fe 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py @@ -330,9 +330,9 @@ class MiExecTestCase(lldbmi_testcase.MiTestCaseBase): # Test that an invalid --thread is handled self.runCmd("-exec-step --thread 0") - self.expect("\^error,message=\"error: Thread index 0 is out of range") + self.expect("\^error,msg=\"Command 'exec-step'. Thread ID invalid") self.runCmd("-exec-step --thread 10") - self.expect("\^error,message=\"error: Thread index 10 is out of range") + self.expect("\^error,msg=\"Command 'exec-step'. Thread ID invalid") # Test that an invalid --frame is handled # FIXME: no error is returned diff --git a/lldb/tools/lldb-mi/MICmdCmdExec.cpp b/lldb/tools/lldb-mi/MICmdCmdExec.cpp index 784307c4e72..229e05c0915 100644 --- a/lldb/tools/lldb-mi/MICmdCmdExec.cpp +++ b/lldb/tools/lldb-mi/MICmdCmdExec.cpp @@ -487,14 +487,26 @@ bool CMICmdCmdExecStep::Execute() { CMICmnLLDBDebugSessionInfo &rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance()); - lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger(); - CMIUtilString strCmd("thread step-in"); - if (nThreadId != UINT64_MAX) - strCmd += CMIUtilString::Format(" %llu", nThreadId); - rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult, - false); - return MIstatus::success; + lldb::SBError error; + if (nThreadId != UINT64_MAX) { + lldb::SBThread sbThread = + rSessionInfo.GetProcess().GetThreadByIndexID(nThreadId); + if (!sbThread.IsValid()) { + SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_THREAD_INVALID), + m_cmdData.strMiCmd.c_str(), + m_constStrArgThread.c_str())); + return MIstatus::failure; + } + sbThread.StepInto(nullptr, LLDB_INVALID_LINE_NUMBER, error); + } else rSessionInfo.GetProcess().GetSelectedThread().StepInto( + nullptr, LLDB_INVALID_LINE_NUMBER, error); + + if (error.Success()) + return MIstatus::success; + + SetError(error.GetCString()); + return MIstatus::failure; } //++ @@ -509,21 +521,8 @@ bool CMICmdCmdExecStep::Execute() { // Throws: None. //-- bool CMICmdCmdExecStep::Acknowledge() { - if (m_lldbResult.GetErrorSize() > 0) { - const char *pLldbErr = m_lldbResult.GetError(); - MIunused(pLldbErr); - const CMICmnMIValueConst miValueConst(m_lldbResult.GetError()); - const CMICmnMIValueResult miValueResult("message", miValueConst); - const CMICmnMIResultRecord miRecordResult( - m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, - miValueResult); - m_miResultRecord = miRecordResult; - } else { - const CMICmnMIResultRecord miRecordResult( - m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running); - m_miResultRecord = miRecordResult; - } - + m_miResultRecord = CMICmnMIResultRecord( + m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running); return MIstatus::success; } diff --git a/lldb/tools/lldb-mi/MICmdCmdExec.h b/lldb/tools/lldb-mi/MICmdCmdExec.h index 75e511ed29b..810ca64724e 100644 --- a/lldb/tools/lldb-mi/MICmdCmdExec.h +++ b/lldb/tools/lldb-mi/MICmdCmdExec.h @@ -152,7 +152,6 @@ public: // Attributes: private: - lldb::SBCommandReturnObject m_lldbResult; const CMIUtilString m_constStrArgNumber; // Not specified in MI spec but // Eclipse gives this option }; |