polyakov.alex updated this revision to Diff 146487.
polyakov.alex added a comment.

Moved tests to lit.


Repository:
  rL LLVM

https://reviews.llvm.org/D46588

Files:
  lit/Breakpoint/Inputs/break-insert.c
  lit/Breakpoint/Inputs/break-insert.input
  lit/Breakpoint/break-insert.test
  lit/lit.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 &rSessionInfo(
+      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 &rSessionInfo(
-      CMICmnLLDBDebugSessionInfo::Instance());
-  lldb::SBTarget sbTarget = rSessionInfo.GetTarget();
   switch (eBrkPtType) {
   case eBreakPoint_ByAddress:
     m_brkPt = sbTarget.BreakpointCreateByAddress(nAddress);
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))
 config.substitutions.append(('%lldb', lldb))
 
 if debugserver is not None:
Index: lit/Breakpoint/break-insert.test
===================================================================
--- /dev/null
+++ lit/Breakpoint/break-insert.test
@@ -0,0 +1,7 @@
+# RUN: %cc %p/Inputs/break-insert.c -g 
+# RUN: %lldb_mi < %p/Inputs/break-insert.input | FileCheck %s
+# CHECK: ^done,bkpt={number="1"
+# CHECK: ^done
+# CHECK: ^running
+# CHECK-AFTER: *stopped,reason="breakpoint-hit"
+
Index: lit/Breakpoint/Inputs/break-insert.input
===================================================================
--- /dev/null
+++ lit/Breakpoint/Inputs/break-insert.input
@@ -0,0 +1,3 @@
+-break-insert breakpoint
+-file-exec-and-symbols a.out
+-exec-run
Index: lit/Breakpoint/Inputs/break-insert.c
===================================================================
--- /dev/null
+++ lit/Breakpoint/Inputs/break-insert.c
@@ -0,0 +1,7 @@
+int breakpoint() { // Breakpoint will be set here.
+  return 0;
+}
+
+int main() {
+  return breakpoint();
+}
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to