polyakov.alex created this revision.
polyakov.alex added reviewers: aprantl, stella.stamenova.
Herald added subscribers: llvm-commits, ki.stfu.

-exec-run command hanged in case of invalid or dummy target.


Repository:
  rL LLVM

https://reviews.llvm.org/D47678

Files:
  tools/lldb-mi/MICmdCmdExec.cpp


Index: tools/lldb-mi/MICmdCmdExec.cpp
===================================================================
--- tools/lldb-mi/MICmdCmdExec.cpp
+++ tools/lldb-mi/MICmdCmdExec.cpp
@@ -99,6 +99,19 @@
 bool CMICmdCmdExecRun::Execute() {
   CMICmnLLDBDebugSessionInfo &rSessionInfo(
       CMICmnLLDBDebugSessionInfo::Instance());
+
+  {
+    // Check we have a valid target.
+    // Note: target created via 'file-exec-and-symbols' command.
+    lldb::SBTarget sbTarget = rSessionInfo.GetTarget();
+    if (sbTarget == rSessionInfo.GetDebugger().GetDummyTarget() ||
+        !sbTarget.IsValid()) {
+      
SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_TARGET_CURRENT),
+                                     m_cmdData.strMiCmd.c_str()));
+      return MIstatus::failure;
+    }
+  }
+
   lldb::SBError error;
   lldb::SBStream errMsg;
   lldb::SBLaunchInfo launchInfo = rSessionInfo.GetTarget().GetLaunchInfo();


Index: tools/lldb-mi/MICmdCmdExec.cpp
===================================================================
--- tools/lldb-mi/MICmdCmdExec.cpp
+++ tools/lldb-mi/MICmdCmdExec.cpp
@@ -99,6 +99,19 @@
 bool CMICmdCmdExecRun::Execute() {
   CMICmnLLDBDebugSessionInfo &rSessionInfo(
       CMICmnLLDBDebugSessionInfo::Instance());
+
+  {
+    // Check we have a valid target.
+    // Note: target created via 'file-exec-and-symbols' command.
+    lldb::SBTarget sbTarget = rSessionInfo.GetTarget();
+    if (sbTarget == rSessionInfo.GetDebugger().GetDummyTarget() ||
+        !sbTarget.IsValid()) {
+      SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_TARGET_CURRENT),
+                                     m_cmdData.strMiCmd.c_str()));
+      return MIstatus::failure;
+    }
+  }
+
   lldb::SBError error;
   lldb::SBStream errMsg;
   lldb::SBLaunchInfo launchInfo = rSessionInfo.GetTarget().GetLaunchInfo();
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to