[Lldb-commits] [PATCH] Fix break-insert command on Windows.

Hafiz Abid Qadeer abidh.haq at gmail.com
Tue Feb 3 10:02:56 PST 2015


Hi ki.stfu, clayborg,

For some time, eclipse (CDT) uses full path of the file in break-insert command when putting breakpoint on a source line. On windows, a typical command looks like the following.
56-break-insert -f F:\\work\\ws\\test\\main.c:49

Current implementation in lldb-mi have problem in 2 ways. It was assuming that there will be only one : in the path which is wrong if full path is supplied. Also CDT sends out path with double backslashes in windows which gives error on resolution. I am replacing \\ with / to handle this issue.

Tested on both Windows and Linux using CDT and seems to work.

http://reviews.llvm.org/D7379

Files:
  MICmdCmdBreak.cpp

Index: MICmdCmdBreak.cpp
===================================================================
--- MICmdCmdBreak.cpp
+++ MICmdCmdBreak.cpp
@@ -180,19 +180,24 @@
     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)
+        // 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);
+
+        // Replace \\ with /
+        size_t pos = 0;
+        while ((pos = fileName.find("\\\\", pos)) != std::string::npos)
         {
-            SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_LOCATION_FORMAT), m_cmdData.strMiCmd.c_str(), m_brkName.c_str()));
-            return MIstatus::failure;
+            fileName.replace(pos, 2, "/");
+            pos += 1;
         }
-        fileName = vecFileAndLocation.at(0);
-        const CMIUtilString &rStrLineOrFn(vecFileAndLocation.at(1));
+
         if (rStrLineOrFn.empty())
             eBrkPtType = eBreakPoint_ByName;
         else

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7379.19237.patch
Type: text/x-patch
Size: 1594 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150203/1e7fc162/attachment.bin>


More information about the lldb-commits mailing list