Index: tools/lldb-mi/MICmdCmdExec.h =================================================================== --- tools/lldb-mi/MICmdCmdExec.h +++ tools/lldb-mi/MICmdCmdExec.h @@ -66,7 +66,6 @@ private: const CMIUtilString m_constStrArgStart; // StopAtEntry - run to first // instruction or main() if specified - lldb::SBCommandReturnObject m_lldbResult; }; //++ @@ -91,7 +90,6 @@ bool Acknowledge() override; // From CMICmnBase /* dtor */ ~CMICmdCmdExecContinue() override; - // Attributes: }; @@ -121,7 +119,6 @@ // Attributes: private: - lldb::SBCommandReturnObject m_lldbResult; const CMIUtilString m_constStrArgNumber; // Not specified in MI spec but // Eclipse gives this option }; Index: tools/lldb-mi/MICmdCmdExec.cpp =================================================================== --- tools/lldb-mi/MICmdCmdExec.cpp +++ tools/lldb-mi/MICmdCmdExec.cpp @@ -126,21 +126,26 @@ } lldb::SBProcess process = rSessionInfo.GetTarget().Launch(launchInfo, error); - if ((!process.IsValid()) || (error.Fail())) { + if (!process.IsValid()) { SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PROCESS), m_cmdData.strMiCmd.c_str(), errMsg.GetData())); return MIstatus::failure; } - if (!CMIDriver::Instance().SetDriverStateRunningDebugging()) { - const CMIUtilString &rErrMsg(CMIDriver::Instance().GetErrorDescription()); - SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_SET_NEW_DRIVER_STATE), - m_cmdData.strMiCmd.c_str(), - rErrMsg.c_str())); - return MIstatus::failure; - } - return MIstatus::success; + const auto successHandler = [this] { + if (!CMIDriver::Instance().SetDriverStateRunningDebugging()) { + const CMIUtilString &rErrMsg(CMIDriver::Instance().GetErrorDescription()); + this->SetError(CMIUtilString::Format( + MIRSRC(IDS_CMD_ERR_SET_NEW_DRIVER_STATE), + this->m_cmdData.strMiCmd.c_str(), + rErrMsg.c_str())); + return MIstatus::failure; + } + return MIstatus::success; + }; + + return HandleSBErrorWithSuccess(error, successHandler); } //++ @@ -156,9 +161,8 @@ // Throws: None. //-- bool CMICmdCmdExecRun::Acknowledge() { - const CMICmnMIResultRecord miRecordResult( + m_miResultRecord = CMICmnMIResultRecord( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running); - m_miResultRecord = miRecordResult; CMICmnLLDBDebugSessionInfo &rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance()); @@ -233,23 +237,22 @@ // Throws: None. //-- bool CMICmdCmdExecContinue::Execute() { - lldb::SBError error = - CMICmnLLDBDebugSessionInfo::Instance().GetProcess().Continue(); - - if (error.Success()) { + const auto successHandler = [this] { // CODETAG_DEBUG_SESSION_RUNNING_PROG_RECEIVED_SIGINT_PAUSE_PROGRAM if (!CMIDriver::Instance().SetDriverStateRunningDebugging()) { const CMIUtilString &rErrMsg(CMIDriver::Instance().GetErrorDescription()); - SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_SET_NEW_DRIVER_STATE), - m_cmdData.strMiCmd.c_str(), - rErrMsg.c_str())); + this->SetError(CMIUtilString::Format( + MIRSRC(IDS_CMD_ERR_SET_NEW_DRIVER_STATE), + this->m_cmdData.strMiCmd.c_str(), + rErrMsg.c_str())); return MIstatus::failure; } return MIstatus::success; - } + }; - SetError(error.GetCString()); - return MIstatus::failure; + return HandleSBErrorWithSuccess( + CMICmnLLDBDebugSessionInfo::Instance().GetProcess().Continue(), + successHandler); } //++ @@ -264,9 +267,8 @@ // Throws: None. //-- bool CMICmdCmdExecContinue::Acknowledge() { - const CMICmnMIResultRecord miRecordResult( + m_miResultRecord = CMICmnMIResultRecord( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running); - m_miResultRecord = miRecordResult; return MIstatus::success; } @@ -358,6 +360,7 @@ CMICmnLLDBDebugSessionInfo &rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance()); + lldb::SBError error; if (nThreadId != UINT64_MAX) { lldb::SBThread sbThread = rSessionInfo.GetProcess().GetThreadByIndexID(nThreadId); if (!sbThread.IsValid()) { @@ -366,10 +369,12 @@ m_constStrArgThread.c_str())); return MIstatus::failure; } - sbThread.StepOver(); - } else rSessionInfo.GetProcess().GetSelectedThread().StepOver(); + sbThread.StepOver(lldb::eOnlyDuringStepping, error); + } else + rSessionInfo.GetProcess().GetSelectedThread().StepOver( + lldb::eOnlyDuringStepping, error); - return MIstatus::success; + return HandleSBError(error); } //++ @@ -384,21 +389,8 @@ // Throws: None. //-- bool CMICmdCmdExecNext::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; } @@ -499,14 +491,11 @@ 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; + } else + rSessionInfo.GetProcess().GetSelectedThread().StepInto( + nullptr, LLDB_INVALID_LINE_NUMBER, error); - SetError(error.GetCString()); - return MIstatus::failure; + return HandleSBError(error); } //++