Fixed the : issue in lldb-mi. Changed FileSpec::Normalize to make sure that it 
handles the path with \\ correctly. Added test cases to check for full path in 
both lldb-mi and lldb.

zturner suggested to add test case for SBFileSpec that creates it with 
PathSyntaxWindows. But PathSyntax enum is in internal class FileSpec. It is not 
available at the SBFileSpec level. I have added tests that check the breakpoint 
with full path in lldb and lldb-mi.


http://reviews.llvm.org/D7379

Files:
  source/Host/common/FileSpec.cpp
  test/functionalities/breakpoint/breakpoint_command/TestRegexpBreakCommand.py
  test/tools/lldb-mi/TestMiBreakpoint.py
  test/tools/lldb-mi/main.c
  tools/lldb-mi/MICmdCmdBreak.cpp

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
Index: source/Host/common/FileSpec.cpp
===================================================================
--- source/Host/common/FileSpec.cpp
+++ source/Host/common/FileSpec.cpp
@@ -240,6 +240,12 @@
         return;
 
     std::replace(path.begin(), path.end(), '\\', '/');
+    // Windows path can have \\ slashes which can be changed by replace
+    // call above to //. Here we remove the duplicate.
+    auto iter = std::unique ( path.begin(), path.end(),
+                               []( char &c1, char &c2 ){
+                                  return (c1 == '/' && c2 == '/');});
+    path.erase(iter, path.end());
 }
 
 void FileSpec::DeNormalize(llvm::SmallVectorImpl<char> &path, PathSyntax syntax)
Index: test/functionalities/breakpoint/breakpoint_command/TestRegexpBreakCommand.py
===================================================================
--- test/functionalities/breakpoint/breakpoint_command/TestRegexpBreakCommand.py
+++ test/functionalities/breakpoint/breakpoint_command/TestRegexpBreakCommand.py
@@ -43,6 +43,11 @@
         break_results = lldbutil.run_break_set_command (self, "b %s:%d" % (self.source, self.line))
         lldbutil.check_breakpoint_result (self, break_results, file_name='main.c', line_number=self.line, num_locations=1)
 
+        # Check breakpoint with full file path.
+        full_path = os.path.join(os.getcwd(), self.source)
+        break_results = lldbutil.run_break_set_command (self, "b %s:%d" % (full_path, self.line))
+        lldbutil.check_breakpoint_result (self, break_results, file_name='main.c', line_number=self.line, num_locations=1)
+
         self.runCmd("run", RUN_SUCCEEDED)
 
         # The stop reason of the thread should be breakpoint.
Index: test/tools/lldb-mi/TestMiBreakpoint.py
===================================================================
--- test/tools/lldb-mi/TestMiBreakpoint.py
+++ test/tools/lldb-mi/TestMiBreakpoint.py
@@ -83,10 +83,21 @@
         self.runCmd("-break-insert main.c:%d" % line)
         self.expect("\^done,bkpt={number=\"3\"")
 
+        // Check with full path. TODO, figure out why this commands fails
+        // if -f is not given
+        line = line_number('main.c', '// BP_doloop')
+        full_path = os.path.join(os.getcwd(), "main.c")
+        self.runCmd("-break-insert -f %s:%d" % (full_path, line))
+        #self.expect("\^done,bkpt={number=\"4\"")
+
         self.runCmd("-exec-continue")
         self.expect("\^running")
         self.expect("\*stopped,reason=\"breakpoint-hit\"")
 
+        self.runCmd("-exec-continue")
+        self.expect("\^running")
+        self.expect("\*stopped,reason=\"breakpoint-hit\"")
+
         # Run to exit
         self.runCmd("-exec-continue")
         self.expect("\^running")
Index: test/tools/lldb-mi/main.c
===================================================================
--- test/tools/lldb-mi/main.c
+++ test/tools/lldb-mi/main.c
@@ -22,7 +22,7 @@
     a = a_MyFunction();          //BP_a_MyFunction_call
     b = b_MyFunction();          //BP_b_MyFunction_call
     //BP_localstest -- it must be at line #24 (or fix it in main*.micmds)
-    if (doloop)
+    if (doloop) // BP_doloop
         infloop();
     if (argc > 1 && *argv[1] == 'l') {
         a++;
Index: tools/lldb-mi/MICmdCmdBreak.cpp
===================================================================
--- tools/lldb-mi/MICmdCmdBreak.cpp
+++ tools/lldb-mi/MICmdCmdBreak.cpp
@@ -180,19 +180,16 @@
     CMIUtilString fileName;
     MIuint nFileLine = 0;
     CMIUtilString strFileFn;
-    const MIint nPosColon = m_brkName.find(cColon);
-    if (nPosColon != (MIint)std::string::npos)
+    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);
+    if (nPosColon != std::string::npos)
     {
-        CMIUtilString::VecString_t vecFileAndLocation;
-        const MIuint nSplits = m_brkName.Split(cColon, vecFileAndLocation);
-        MIunused(nSplits);
-        if (vecFileAndLocation.size() != 2)
-        {
-            SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_LOCATION_FORMAT), m_cmdData.strMiCmd.c_str(), m_brkName.c_str()));
-            return MIstatus::failure;
-        }
-        fileName = vecFileAndLocation.at(0);
-        const CMIUtilString &rStrLineOrFn(vecFileAndLocation.at(1));
+        // 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);
+
         if (rStrLineOrFn.empty())
             eBrkPtType = eBreakPoint_ByName;
         else
_______________________________________________
lldb-commits mailing list
lldb-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits

Reply via email to