dawn updated this revision to Diff 30609.
dawn added a comment.

Comment about "::func" syntax not working in lldb added as requested.  Please 
accept this patch - it fixes namespace tokens used in lldb-mi breakpoints like 
"-break-insert ns::func".   Patches to lldb and other issues are not intended 
to be part of this patch and should be handled separately.  Thank you.


Repository:
  rL LLVM

http://reviews.llvm.org/D11396

Files:
  test/tools/lldb-mi/breakpoint/TestMiBreak.py
  tools/lldb-mi/MICmdCmdBreak.cpp

Index: tools/lldb-mi/MICmdCmdBreak.cpp
===================================================================
--- tools/lldb-mi/MICmdCmdBreak.cpp
+++ tools/lldb-mi/MICmdCmdBreak.cpp
@@ -108,6 +108,25 @@
 }
 
 //++ 
------------------------------------------------------------------------------------
+// Helper function for CMICmdCmdBreakInsert::Execute(void).
+//
+// Given a string, return the position of the ':' separator in 'file:func'
+// or 'file:line', if any.  If not found, return npos.  For example, return
+// 5 for 'foo.c:std::string'.
+//--
+static size_t findFileSeparatorPos(const std::string& x)
+{
+    // Full paths in windows can have ':' after a drive letter, so we
+    // search backwards, taking care to skip C++ namespace tokens '::'.
+    size_t n = x.find_last_of(':');
+    while (n != std::string::npos && n > 1 && x[n-1] == ':')
+    {
+        n = x.find_last_of(':', n - 2);
+    }
+    return n;
+}
+
+//++ 
------------------------------------------------------------------------------------
 // Details: The invoker requires this function. The command does work in this 
function.
 //          The command is likely to communicate with the LLDB SBDebugger in 
here.
 // Type:    Overridden.
@@ -161,17 +180,16 @@
 
     // Determine if break on a file line or at a function
     BreakPoint_e eBrkPtType = eBreakPoint_NotDefineYet;
-    const CMIUtilString cColon = ":";
     CMIUtilString fileName;
     MIuint nFileLine = 0;
     CMIUtilString strFileFn;
     CMIUtilString rStrLineOrFn;
-    // Full path in windows can have : after drive letter. So look for the
-    // last colon
-    const size_t nPosColon = m_brkName.find_last_of(cColon);
+    // Is the string in the form 'file:func' or 'file:line'?
+    // If so, find the position of the ':' separator.
+    const size_t nPosColon = findFileSeparatorPos(m_brkName);
     if (nPosColon != std::string::npos)
     {
-        // extract file name and line number from it
+        // Extract file name and line number from it
         fileName = m_brkName.substr(0, nPosColon);
         rStrLineOrFn = m_brkName.substr(nPosColon + 1, m_brkName.size() - 
nPosColon - 1);
 
Index: test/tools/lldb-mi/breakpoint/TestMiBreak.py
===================================================================
--- test/tools/lldb-mi/breakpoint/TestMiBreak.py
+++ test/tools/lldb-mi/breakpoint/TestMiBreak.py
@@ -75,6 +75,11 @@
         self.expect("\^running")
         self.expect("\*stopped,reason=\"breakpoint-hit\"")
 
+        # Test that we can set a BP using the global namespace token
+        #FIXME: this test is disabled due to a bug in lldb.
+        #self.runCmd("-break-insert ::main")
+        #self.expect("\^done,bkpt={number=\"3\"")
+
     @lldbmi_test
     @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for 
windows")
     @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread 
races
@@ -206,7 +211,7 @@
         self.expect("\^running")
         
self.expect("\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"3\"")
 
-        # Test that the target.language=pascal setting works and that BP #5 is 
not set
+        # Test that the target.language=pascal setting works and that BP #5 is 
NOT set
         self.runCmd("-interpreter-exec console \"settings set target.language 
c\"")
         self.expect("\^done")
         self.runCmd("-break-insert ns.foo1")
@@ -213,14 +218,13 @@
         self.expect("\^error")
 
         # Test that the target.language=c++ setting works and that BP #6 is hit
-        # FIXME: lldb-mi interprets 'ns::func' as file:func where file='ns:'.
-        #self.runCmd("-interpreter-exec console \"settings set target.language 
c++\"")
-        #self.expect("\^done")
-        #self.runCmd("-break-insert ns::foo1")
-        #self.expect("\^done,bkpt={number=\"6\"")
-        #self.runCmd("-exec-run")
-        #self.expect("\^running")
-        
#self.expect("\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"6\"")
+        self.runCmd("-interpreter-exec console \"settings set target.language 
c++\"")
+        self.expect("\^done")
+        self.runCmd("-break-insert ns::foo1")
+        self.expect("\^done,bkpt={number=\"6\"")
+        self.runCmd("-exec-continue")
+        self.expect("\^running")
+        
self.expect("\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"6\"")
 
         # Test that BP #1 and #2 weren't set by running to program exit
         self.runCmd("-exec-continue")


Index: tools/lldb-mi/MICmdCmdBreak.cpp
===================================================================
--- tools/lldb-mi/MICmdCmdBreak.cpp
+++ tools/lldb-mi/MICmdCmdBreak.cpp
@@ -108,6 +108,25 @@
 }
 
 //++ ------------------------------------------------------------------------------------
+// Helper function for CMICmdCmdBreakInsert::Execute(void).
+//
+// Given a string, return the position of the ':' separator in 'file:func'
+// or 'file:line', if any.  If not found, return npos.  For example, return
+// 5 for 'foo.c:std::string'.
+//--
+static size_t findFileSeparatorPos(const std::string& x)
+{
+    // Full paths in windows can have ':' after a drive letter, so we
+    // search backwards, taking care to skip C++ namespace tokens '::'.
+    size_t n = x.find_last_of(':');
+    while (n != std::string::npos && n > 1 && x[n-1] == ':')
+    {
+        n = x.find_last_of(':', n - 2);
+    }
+    return n;
+}
+
+//++ ------------------------------------------------------------------------------------
 // Details: The invoker requires this function. The command does work in this function.
 //          The command is likely to communicate with the LLDB SBDebugger in here.
 // Type:    Overridden.
@@ -161,17 +180,16 @@
 
     // Determine if break on a file line or at a function
     BreakPoint_e eBrkPtType = eBreakPoint_NotDefineYet;
-    const CMIUtilString cColon = ":";
     CMIUtilString fileName;
     MIuint nFileLine = 0;
     CMIUtilString strFileFn;
     CMIUtilString rStrLineOrFn;
-    // Full path in windows can have : after drive letter. So look for the
-    // last colon
-    const size_t nPosColon = m_brkName.find_last_of(cColon);
+    // Is the string in the form 'file:func' or 'file:line'?
+    // If so, find the position of the ':' separator.
+    const size_t nPosColon = findFileSeparatorPos(m_brkName);
     if (nPosColon != std::string::npos)
     {
-        // extract file name and line number from it
+        // Extract file name and line number from it
         fileName = m_brkName.substr(0, nPosColon);
         rStrLineOrFn = m_brkName.substr(nPosColon + 1, m_brkName.size() - nPosColon - 1);
 
Index: test/tools/lldb-mi/breakpoint/TestMiBreak.py
===================================================================
--- test/tools/lldb-mi/breakpoint/TestMiBreak.py
+++ test/tools/lldb-mi/breakpoint/TestMiBreak.py
@@ -75,6 +75,11 @@
         self.expect("\^running")
         self.expect("\*stopped,reason=\"breakpoint-hit\"")
 
+        # Test that we can set a BP using the global namespace token
+        #FIXME: this test is disabled due to a bug in lldb.
+        #self.runCmd("-break-insert ::main")
+        #self.expect("\^done,bkpt={number=\"3\"")
+
     @lldbmi_test
     @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
     @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@@ -206,7 +211,7 @@
         self.expect("\^running")
         self.expect("\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"3\"")
 
-        # Test that the target.language=pascal setting works and that BP #5 is not set
+        # Test that the target.language=pascal setting works and that BP #5 is NOT set
         self.runCmd("-interpreter-exec console \"settings set target.language c\"")
         self.expect("\^done")
         self.runCmd("-break-insert ns.foo1")
@@ -213,14 +218,13 @@
         self.expect("\^error")
 
         # Test that the target.language=c++ setting works and that BP #6 is hit
-        # FIXME: lldb-mi interprets 'ns::func' as file:func where file='ns:'.
-        #self.runCmd("-interpreter-exec console \"settings set target.language c++\"")
-        #self.expect("\^done")
-        #self.runCmd("-break-insert ns::foo1")
-        #self.expect("\^done,bkpt={number=\"6\"")
-        #self.runCmd("-exec-run")
-        #self.expect("\^running")
-        #self.expect("\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"6\"")
+        self.runCmd("-interpreter-exec console \"settings set target.language c++\"")
+        self.expect("\^done")
+        self.runCmd("-break-insert ns::foo1")
+        self.expect("\^done,bkpt={number=\"6\"")
+        self.runCmd("-exec-continue")
+        self.expect("\^running")
+        self.expect("\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"6\"")
 
         # Test that BP #1 and #2 weren't set by running to program exit
         self.runCmd("-exec-continue")
_______________________________________________
lldb-commits mailing list
lldb-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits

Reply via email to