[Lldb-commits] [PATCH] D12968: Fix for lldb-mi crash in Listener code if -exec-abort MI command was invoked without getting process stopped
Kirill Lapshin via lldb-commits
lldb-commits at lists.llvm.org
Fri Sep 18 08:54:39 PDT 2015
KLapshin created this revision.
KLapshin added reviewers: dawn, ki.stfu, abidh.
KLapshin added a subscriber: lldb-commits.
KLapshin set the repository for this revision to rL LLVM.
This patch fixes lldb core crash in Listener waiting for process ended and operates with already invalid data if lldb-mi requested process destroy in -exec-abort command handler without getting process stopped at first.
To avoid crash in existing code MI user should do process stop explicitly:
-exec-interrupt
-exec-abort
With this patch MI ExecAbort handler make sure process stopped safely, then process destroyed, so MI user can invoke just -exec-abort MI command to finish debug session regardless of process running or stopped already.
-exec-abort use "process interrupt" command via command interpreter class.
Repository:
rL LLVM
http://reviews.llvm.org/D12968
Files:
tools/lldb-mi/MICmdCmdExec.cpp
tools/lldb-mi/MICmdCmdExec.h
Index: tools/lldb-mi/MICmdCmdExec.h
===================================================================
--- tools/lldb-mi/MICmdCmdExec.h
+++ tools/lldb-mi/MICmdCmdExec.h
@@ -328,4 +328,7 @@
bool Acknowledge() override;
// From CMICmnBase
/* dtor */ ~CMICmdCmdExecAbort() override;
+ // Attributes:
+ private:
+ lldb::SBCommandReturnObject m_lldbResult;
};
Index: tools/lldb-mi/MICmdCmdExec.cpp
===================================================================
--- tools/lldb-mi/MICmdCmdExec.cpp
+++ tools/lldb-mi/MICmdCmdExec.cpp
@@ -1167,6 +1167,18 @@
{
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
+ lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger();
+ CMIUtilString strCmd("process interrupt");
+ const lldb::ReturnStatus status = rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult, false);
+ MIunused(status);
+
+ if (!CMIDriver::Instance().SetDriverStateRunningNotDebugging())
+ {
+ const CMIUtilString &rErrMsg(CMIDriver::Instance().GetErrorDescription());
+ SetErrorDescription(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_SET_NEW_DRIVER_STATE), strCmd.c_str(), rErrMsg.c_str()));
+ return MIstatus::failure;
+ }
+
if (!sbProcess.IsValid())
{
SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PROCESS), m_cmdData.strMiCmd.c_str()));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12968.35089.patch
Type: text/x-patch
Size: 1466 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150918/e7fa3dac/attachment.bin>
More information about the lldb-commits
mailing list