[Lldb-commits] [PATCH] D46588: [LLDB][lldb-mi] Add possibility to set breakpoints without selecting a target.

2018-05-19 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl accepted this revision.
aprantl added a comment.

LGTM!


Repository:
  rL LLVM

https://reviews.llvm.org/D46588



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D47110: [LLDB, lldb-mi] Add option --synchronous.

2018-05-19 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl accepted this revision.
aprantl added a comment.
This revision is now accepted and ready to land.

Looks good!


Repository:
  rL LLVM

https://reviews.llvm.org/D47110



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D46588: [LLDB][lldb-mi] Add possibility to set breakpoints without selecting a target.

2018-05-19 Thread Alexander Polyakov via Phabricator via lldb-commits
polyakov.alex updated this revision to Diff 147681.
polyakov.alex added a comment.

This version of commit uses the new lldb-mi option that I added to review 
https://reviews.llvm.org/D47110.


Repository:
  rL LLVM

https://reviews.llvm.org/D46588

Files:
  lit/lit.cfg
  lit/tools/lldb-mi/breakpoint/break-insert.test
  lit/tools/lldb-mi/breakpoint/inputs/break-insert.c
  lit/tools/lldb-mi/breakpoint/lit.local.cfg
  tools/lldb-mi/MICmdCmdBreak.cpp
  tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp

Index: tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp
===
--- tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp
+++ tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp
@@ -871,7 +871,10 @@
 // Throws:  None.
 //--
 lldb::SBTarget CMICmnLLDBDebugSessionInfo::GetTarget() const {
-  return GetDebugger().GetSelectedTarget();
+  auto target = GetDebugger().GetSelectedTarget();
+  if (target.IsValid())
+return target;
+  return GetDebugger().GetDummyTarget();
 }
 
 //++
Index: tools/lldb-mi/MICmdCmdBreak.cpp
===
--- tools/lldb-mi/MICmdCmdBreak.cpp
+++ tools/lldb-mi/MICmdCmdBreak.cpp
@@ -148,6 +148,11 @@
   CMICMDBASE_GETOPTION(pArgRestrictBrkPtToThreadId, OptionShort,
m_constStrArgNamedRestrictBrkPtToThreadId);
 
+  // Ask LLDB for the target to check if we have valid or dummy one.
+  CMICmnLLDBDebugSessionInfo (
+  CMICmnLLDBDebugSessionInfo::Instance());
+  lldb::SBTarget sbTarget = rSessionInfo.GetTarget();
+
   m_bBrkPtEnabled = !pArgDisableBrkPt->GetFound();
   m_bBrkPtIsTemp = pArgTempBrkPt->GetFound();
   m_bHaveArgOptionThreadGrp = pArgThreadGroup->GetFound();
@@ -157,7 +162,12 @@
 nThreadGrp);
 m_strArgOptionThreadGrp = CMIUtilString::Format("i%d", nThreadGrp);
   }
-  m_bBrkPtIsPending = pArgPendingBrkPt->GetFound();
+
+  if (sbTarget == rSessionInfo.GetDebugger().GetDummyTarget())
+m_bBrkPtIsPending = true;
+  else
+m_bBrkPtIsPending = pArgPendingBrkPt->GetFound();
+
   if (pArgLocation->GetFound())
 m_brkName = pArgLocation->GetValue();
   else if (m_bBrkPtIsPending) {
@@ -225,9 +235,6 @@
 
   // Ask LLDB to create a breakpoint
   bool bOk = MIstatus::success;
-  CMICmnLLDBDebugSessionInfo (
-  CMICmnLLDBDebugSessionInfo::Instance());
-  lldb::SBTarget sbTarget = rSessionInfo.GetTarget();
   switch (eBrkPtType) {
   case eBreakPoint_ByAddress:
 m_brkPt = sbTarget.BreakpointCreateByAddress(nAddress);
Index: lit/tools/lldb-mi/breakpoint/lit.local.cfg
===
--- /dev/null
+++ lit/tools/lldb-mi/breakpoint/lit.local.cfg
@@ -0,0 +1 @@
+config.suffixes = ['.test']
Index: lit/tools/lldb-mi/breakpoint/inputs/break-insert.c
===
--- /dev/null
+++ lit/tools/lldb-mi/breakpoint/inputs/break-insert.c
@@ -0,0 +1,7 @@
+int breakpoint() { // Breakpoint will be set here.
+  return 0;
+}
+
+int main() {
+  return breakpoint();
+}
Index: lit/tools/lldb-mi/breakpoint/break-insert.test
===
--- /dev/null
+++ lit/tools/lldb-mi/breakpoint/break-insert.test
@@ -0,0 +1,15 @@
+# RUN: %cc %p/inputs/break-insert.c -g
+# RUN: %lldb_mi < %s | FileCheck %s
+
+# Test that a breakpoint can be inserted before creating a target.
+
+-break-insert breakpoint
+# CHECK: ^done,bkpt={number="1"
+
+-file-exec-and-symbols a.out
+# CHECK: ^done
+
+-exec-run
+# CHECK: ^running
+# CHECK: *stopped,reason="breakpoint-hit"
+
Index: lit/lit.cfg
===
--- lit/lit.cfg
+++ lit/lit.cfg
@@ -58,6 +58,8 @@
 lldb = "%s -S %s/lit-lldb-init" % (lit.util.which('lldb', lldb_tools_dir),
config.test_source_root)
 
+lldb_mi = lit.util.which('lldb-mi', lldb_tools_dir)
+
 if not os.path.exists(config.cc):
 config.cc = lit.util.which(config.cc, config.environment['PATH'])
 
@@ -79,6 +81,7 @@
 config.substitutions.append(('%cc', config.cc))
 config.substitutions.append(('%cxx', config.cxx))
 
+config.substitutions.append(('%lldb_mi', lldb_mi + " --synchronous"))
 config.substitutions.append(('%lldb', lldb))
 
 if debugserver is not None:
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D47110: [LLDB, lldb-mi] Add option --synchronous.

2018-05-19 Thread Alexander Polyakov via Phabricator via lldb-commits
polyakov.alex added a comment.

This option is needed by https://reviews.llvm.org/D46588.


Repository:
  rL LLVM

https://reviews.llvm.org/D47110



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D47110: [LLDB, lldb-mi] Add option --synchronous.

2018-05-19 Thread Alexander Polyakov via Phabricator via lldb-commits
polyakov.alex created this revision.
polyakov.alex added reviewers: aprantl, clayborg, labath.
Herald added subscribers: llvm-commits, ki.stfu.

Option --synchronous disables asynchronous mode in the lldb-mi driver. Used for 
testing only.


Repository:
  rL LLVM

https://reviews.llvm.org/D47110

Files:
  tools/lldb-mi/MICmnResources.cpp
  tools/lldb-mi/MICmnResources.h
  tools/lldb-mi/MIDriver.cpp
  tools/lldb-mi/MIDriverMgr.cpp


Index: tools/lldb-mi/MIDriverMgr.cpp
===
--- tools/lldb-mi/MIDriverMgr.cpp
+++ tools/lldb-mi/MIDriverMgr.cpp
@@ -640,6 +640,7 @@
   MIRSRC(IDE_MI_APP_ARG_VERSION), MIRSRC(IDE_MI_APP_ARG_VERSION_LONG),
   MIRSRC(IDE_MI_APP_ARG_INTERPRETER), MIRSRC(IDE_MI_APP_ARG_SOURCE),
   MIRSRC(IDE_MI_APP_ARG_EXECUTEABLE),
+  MIRSRC(IDE_MI_APP_ARG_SYNCHRONOUS),
   CMIUtilString::Format(
   MIRSRC(IDE_MI_APP_ARG_APP_LOG),
   CMICmnLogMediumFile::Instance().GetFileName().c_str()),
Index: tools/lldb-mi/MIDriver.cpp
===
--- tools/lldb-mi/MIDriver.cpp
+++ tools/lldb-mi/MIDriver.cpp
@@ -382,6 +382,7 @@
 //  that are only handled by *this driver:
 //  --executable 
 //  --source  or -s 
+//  --synchronous
 //  The application's options --interpreter and --executable in code 
act
 //  very similar.
 //  The --executable is necessary to differentiate whether the MI 
Driver
@@ -397,6 +398,7 @@
 //  argument for a debug session. Using --interpreter on the command
 //  line does not
 //  issue additional commands to initialise a debug session.
+//  Option --synchronous disables an asynchronous mode in the lldb-mi 
driver.
 // Type:Overridden.
 // Args:argc- (R)   An integer that contains the count of arguments
 // that follow in
@@ -436,6 +438,10 @@
   const CMIUtilString strArg(argv[i]);
   const CMICmdArgValFile argFile;
 
+  if (strArg.compare("--synchronous") == 0) {
+CMICmnLLDBDebugSessionInfo::Instance().GetDebugger().SetAsync(false);
+  }
+
   // Check for a filename
   if (argFile.IsFilePath(strArg) ||
   CMICmdArgValString(true, false, true).IsStringArg(strArg)) {
Index: tools/lldb-mi/MICmnResources.h
===
--- tools/lldb-mi/MICmnResources.h
+++ tools/lldb-mi/MICmnResources.h
@@ -77,6 +77,7 @@
   IDE_MI_APP_ARG_APP_LOG_DIR,
   IDE_MI_APP_ARG_EXAMPLE,
   IDE_MI_APP_ARG_EXECUTABLE,
+  IDE_MI_APP_ARG_SYNCHRONOUS,
 
   IDS_STDIN_ERR_INVALID_PROMPT,
   IDS_STDIN_ERR_THREAD_CREATION_FAILED,
Index: tools/lldb-mi/MICmnResources.cpp
===
--- tools/lldb-mi/MICmnResources.cpp
+++ tools/lldb-mi/MICmnResources.cpp
@@ -110,6 +110,8 @@
 {IDE_MI_APP_ARG_EXECUTABLE, "executable (NOT IMPLEMENTED)\n\tThe file "
 "path to the executable i.e. '\"C:\\My "
 "Dev\\foo.exe\"'."},
+{IDE_MI_APP_ARG_SYNCHRONOUS, "--synchronous\n\tBlock until each 
command "
+ "has finished executing.\n\tUsed for 
testing only."},
 {IDS_STDIN_ERR_INVALID_PROMPT,
  "Stdin. Invalid prompt description '%s'"},
 {IDS_STDIN_ERR_THREAD_CREATION_FAILED,


Index: tools/lldb-mi/MIDriverMgr.cpp
===
--- tools/lldb-mi/MIDriverMgr.cpp
+++ tools/lldb-mi/MIDriverMgr.cpp
@@ -640,6 +640,7 @@
   MIRSRC(IDE_MI_APP_ARG_VERSION), MIRSRC(IDE_MI_APP_ARG_VERSION_LONG),
   MIRSRC(IDE_MI_APP_ARG_INTERPRETER), MIRSRC(IDE_MI_APP_ARG_SOURCE),
   MIRSRC(IDE_MI_APP_ARG_EXECUTEABLE),
+  MIRSRC(IDE_MI_APP_ARG_SYNCHRONOUS),
   CMIUtilString::Format(
   MIRSRC(IDE_MI_APP_ARG_APP_LOG),
   CMICmnLogMediumFile::Instance().GetFileName().c_str()),
Index: tools/lldb-mi/MIDriver.cpp
===
--- tools/lldb-mi/MIDriver.cpp
+++ tools/lldb-mi/MIDriver.cpp
@@ -382,6 +382,7 @@
 //  that are only handled by *this driver:
 //  --executable 
 //  --source  or -s 
+//  --synchronous
 //  The application's options --interpreter and --executable in code act
 //  very similar.
 //  The --executable is necessary to differentiate whether the MI Driver
@@ -397,6 +398,7 @@
 //  argument for a debug session. Using --interpreter on the command
 //  line does not
 //  issue additional commands to initialise a debug session.
+//  Option --synchronous disables an asynchronous mode in the lldb-mi driver.
 // Type:Overridden.
 // Args:argc- (R)   An integer that contains the count of arguments
 // that follow in
@@ -436,6 +438,10 @@
   const