[PATCH] D47415: [lldb, lldb-mi] Re-implement MI -exec-continue command.

Alexander Polyakov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat May 26 11:23:10 PDT 2018


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

Now -exec-continue command uses SB API t resume target's process.


Repository:
  rL LLVM

https://reviews.llvm.org/D47415

Files:
  lit/tools/lldb-mi/exec/exec-continue.test
  lit/tools/lldb-mi/exec/inputs/main.c
  lit/tools/lldb-mi/exec/lit.local.cfg
  tools/lldb-mi/MICmdCmdExec.cpp


Index: tools/lldb-mi/MICmdCmdExec.cpp
===================================================================
--- tools/lldb-mi/MICmdCmdExec.cpp
+++ tools/lldb-mi/MICmdCmdExec.cpp
@@ -219,33 +219,20 @@
 // Throws:  None.
 //--
 bool CMICmdCmdExecContinue::Execute() {
-  const char *pCmd = "continue";
-  CMICmnLLDBDebugSessionInfo &rSessionInfo(
-      CMICmnLLDBDebugSessionInfo::Instance());
-  const lldb::ReturnStatus rtn =
-      rSessionInfo.GetDebugger().GetCommandInterpreter().HandleCommand(
-          pCmd, m_lldbResult);
-  MIunused(rtn);
+  lldb::SBError sb_error = 
+      CMICmnLLDBDebugSessionInfo::Instance().GetProcess().Continue();
 
-  if (m_lldbResult.GetErrorSize() == 0) {
+  if (sb_error.Success()) {
     // 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()));
       return MIstatus::failure;
     }
-  } else {
-    // ToDo: Re-evaluate if this is required when application near finished as
-    // this is parsing LLDB error message
-    // which seems a hack and is code brittle
-    const char *pLldbErr = m_lldbResult.GetError();
-    const CMIUtilString strLldbMsg(CMIUtilString(pLldbErr).StripCREndOfLine());
-    if (strLldbMsg == "error: Process must be launched.") {
-      CMIDriver::Instance().SetExitApplicationFlag(true);
-    }
-  }
+  } else
+    m_lldbResult.SetError(sb_error.GetCString());
 
   return MIstatus::success;
 }
Index: lit/tools/lldb-mi/exec/lit.local.cfg
===================================================================
--- /dev/null
+++ lit/tools/lldb-mi/exec/lit.local.cfg
@@ -0,0 +1 @@
+config.suffixes = ['.test']
Index: lit/tools/lldb-mi/exec/inputs/main.c
===================================================================
--- /dev/null
+++ lit/tools/lldb-mi/exec/inputs/main.c
@@ -0,0 +1,4 @@
+int main(void) {
+  int x = 0;
+  return x;
+}
Index: lit/tools/lldb-mi/exec/exec-continue.test
===================================================================
--- /dev/null
+++ lit/tools/lldb-mi/exec/exec-continue.test
@@ -0,0 +1,17 @@
+# RUN: %cc %p/inputs/main.c -g
+# RUN: %lldbmi < %s | FileCheck %s
+
+# Test that lldb-mi can continue executing a program after stop.
+
+-file-exec-and-symbols a.out
+# CHECK: ^done
+
+-break-insert main
+# CHECK: ^done,bkpt={number="1"
+
+-exec-run
+# CHECK: ^running
+# CHECK: *stopped,reason="breakpoint-hit"
+
+-exec-continue
+# CHECK: ^running


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47415.148730.patch
Type: text/x-patch
Size: 2717 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180526/bb066bd3/attachment.bin>


More information about the llvm-commits mailing list