[Lldb-commits] [lldb] r333205 - [lldb-mi] Add possibility to set breakpoints without selecting a target.

Adrian Prantl via lldb-commits lldb-commits at lists.llvm.org
Thu May 24 09:45:59 PDT 2018


Author: adrian
Date: Thu May 24 09:45:59 2018
New Revision: 333205

URL: http://llvm.org/viewvc/llvm-project?rev=333205&view=rev
Log:
[lldb-mi] Add possibility to set breakpoints without selecting a target.

Now it's possible to set breakpoints before selecting a target, they
will be set to the dummy target and then copied to an each added one.

Patch by Alexander Polyakov!

Differential Revision: https://reviews.llvm.org/D46588

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

Modified: lldb/trunk/lit/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/lit.cfg?rev=333205&r1=333204&r2=333205&view=diff
==============================================================================
--- lldb/trunk/lit/lit.cfg (original)
+++ lldb/trunk/lit/lit.cfg Thu May 24 09:45:59 2018
@@ -58,6 +58,8 @@ debugserver = lit.util.which('debugserve
 lldb = "%s -S %s/lit-lldb-init" % (lit.util.which('lldb', lldb_tools_dir),
                                config.test_source_root)
 
+lldbmi = 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 @@ if platform.system() in ['Darwin']:
 config.substitutions.append(('%cc', config.cc))
 config.substitutions.append(('%cxx', config.cxx))
 
+config.substitutions.append(('%lldbmi', lldbmi + " --synchronous"))
 config.substitutions.append(('%lldb', lldb))
 
 if debugserver is not None:

Added: lldb/trunk/lit/tools/lldb-mi/breakpoint/break-insert.test
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/tools/lldb-mi/breakpoint/break-insert.test?rev=333205&view=auto
==============================================================================
--- lldb/trunk/lit/tools/lldb-mi/breakpoint/break-insert.test (added)
+++ lldb/trunk/lit/tools/lldb-mi/breakpoint/break-insert.test Thu May 24 09:45:59 2018
@@ -0,0 +1,15 @@
+# RUN: %cc %p/inputs/break-insert.c -g
+# RUN: %lldbmi < %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"
+

Added: lldb/trunk/lit/tools/lldb-mi/breakpoint/inputs/break-insert.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/tools/lldb-mi/breakpoint/inputs/break-insert.c?rev=333205&view=auto
==============================================================================
--- lldb/trunk/lit/tools/lldb-mi/breakpoint/inputs/break-insert.c (added)
+++ lldb/trunk/lit/tools/lldb-mi/breakpoint/inputs/break-insert.c Thu May 24 09:45:59 2018
@@ -0,0 +1,7 @@
+int breakpoint() { // Breakpoint will be set here.
+  return 0;
+}
+
+int main() {
+  return breakpoint();
+}

Added: lldb/trunk/lit/tools/lldb-mi/breakpoint/lit.local.cfg
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/tools/lldb-mi/breakpoint/lit.local.cfg?rev=333205&view=auto
==============================================================================
--- lldb/trunk/lit/tools/lldb-mi/breakpoint/lit.local.cfg (added)
+++ lldb/trunk/lit/tools/lldb-mi/breakpoint/lit.local.cfg Thu May 24 09:45:59 2018
@@ -0,0 +1 @@
+config.suffixes = ['.test']

Modified: lldb/trunk/tools/lldb-mi/MICmdCmdBreak.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdBreak.cpp?rev=333205&r1=333204&r2=333205&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdBreak.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdBreak.cpp Thu May 24 09:45:59 2018
@@ -148,6 +148,11 @@ bool CMICmdCmdBreakInsert::Execute() {
   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 @@ bool CMICmdCmdBreakInsert::Execute() {
         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 @@ bool CMICmdCmdBreakInsert::Execute() {
 
   // 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);

Modified: lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp?rev=333205&r1=333204&r2=333205&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp Thu May 24 09:45:59 2018
@@ -871,7 +871,10 @@ lldb::SBListener &CMICmnLLDBDebugSession
 // Throws:  None.
 //--
 lldb::SBTarget CMICmnLLDBDebugSessionInfo::GetTarget() const {
-  return GetDebugger().GetSelectedTarget();
+  auto target = GetDebugger().GetSelectedTarget();
+  if (target.IsValid())
+    return target;
+  return GetDebugger().GetDummyTarget();
 }
 
 //++




More information about the lldb-commits mailing list