[Lldb-commits] [lldb] r336009 - [lldb-mi] Clean up and update a few MI commands.
Alexander Polyakov via lldb-commits
lldb-commits at lists.llvm.org
Fri Jun 29 12:58:32 PDT 2018
Author: apolyakov
Date: Fri Jun 29 12:58:31 2018
New Revision: 336009
URL: http://llvm.org/viewvc/llvm-project?rev=336009&view=rev
Log:
[lldb-mi] Clean up and update a few MI commands.
Summary:
This patch updates a few MI commands using a new way of
handling an errors in lldb-mi and removes unnecessary
m_lldbResult variables.
Reviewers: aprantl, clayborg, labath
Reviewed By: aprantl, clayborg
Subscribers: ki.stfu, lldb-commits
Differential Revision: https://reviews.llvm.org/D47992
Modified:
lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp
lldb/trunk/tools/lldb-mi/MICmdCmdExec.h
Modified: lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp?rev=336009&r1=336008&r2=336009&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp Fri Jun 29 12:58:31 2018
@@ -126,21 +126,25 @@ bool CMICmdCmdExecRun::Execute() {
}
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());
+ 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;
+ };
+
+ return HandleSBErrorWithSuccess(error, successHandler);
}
//++
@@ -156,9 +160,8 @@ bool CMICmdCmdExecRun::Execute() {
// 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 +236,21 @@ CMICmdCmdExecContinue::~CMICmdCmdExecCon
// 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()));
+ 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;
- }
+ };
- SetError(error.GetCString());
- return MIstatus::failure;
+ return HandleSBErrorWithSuccess(
+ CMICmnLLDBDebugSessionInfo::Instance().GetProcess().Continue(),
+ successHandler);
}
//++
@@ -264,9 +265,8 @@ bool CMICmdCmdExecContinue::Execute() {
// 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 +358,7 @@ bool CMICmdCmdExecNext::Execute() {
CMICmnLLDBDebugSessionInfo &rSessionInfo(
CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBError error;
if (nThreadId != UINT64_MAX) {
lldb::SBThread sbThread = rSessionInfo.GetProcess().GetThreadByIndexID(nThreadId);
if (!sbThread.IsValid()) {
@@ -366,10 +367,12 @@ bool CMICmdCmdExecNext::Execute() {
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 +387,8 @@ bool CMICmdCmdExecNext::Execute() {
// 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 +489,11 @@ bool CMICmdCmdExecStep::Execute() {
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);
}
//++
Modified: lldb/trunk/tools/lldb-mi/MICmdCmdExec.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdExec.h?rev=336009&r1=336008&r2=336009&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdExec.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdExec.h Fri Jun 29 12:58:31 2018
@@ -66,7 +66,6 @@ public:
private:
const CMIUtilString m_constStrArgStart; // StopAtEntry - run to first
// instruction or main() if specified
- lldb::SBCommandReturnObject m_lldbResult;
};
//++
@@ -91,7 +90,6 @@ public:
bool Acknowledge() override;
// From CMICmnBase
/* dtor */ ~CMICmdCmdExecContinue() override;
-
// Attributes:
};
@@ -121,7 +119,6 @@ public:
// Attributes:
private:
- lldb::SBCommandReturnObject m_lldbResult;
const CMIUtilString m_constStrArgNumber; // Not specified in MI spec but
// Eclipse gives this option
};
More information about the lldb-commits
mailing list