Handle breakpoints without full file path
authorIgor Kulaychuk <i.kulaychuk@samsung.com>
Mon, 9 Apr 2018 15:50:26 +0000 (18:50 +0300)
committerIgor Kulaychuk <i.kulaychuk@samsung.com>
Mon, 9 Apr 2018 16:39:00 +0000 (19:39 +0300)
src/debug/netcoredbg/SymbolReader.cs
src/debug/netcoredbg/breakpoints.cpp

index 616859e1e6afc991c58be35f78e12933b45ed1c7..1edc75dd7667ac85ecd68751afbda05daba9e52e 100644 (file)
@@ -241,6 +241,14 @@ namespace SOS
 
             try
             {
+                // If incoming filePath is not a full path, then check file names only
+                Func<string, bool> FileNameMatches;
+                string fileName = GetFileName(filePath);
+                if (fileName == filePath)
+                    FileNameMatches = s => GetFileName(s) == fileName;
+                else
+                    FileNameMatches = s => s == filePath;
+
                 foreach (MethodDebugInformationHandle methodDebugInformationHandle in reader.MethodDebugInformation)
                 {
                     MethodDebugInformation methodDebugInfo = reader.GetMethodDebugInformation(methodDebugInformationHandle);
@@ -248,7 +256,7 @@ namespace SOS
                     foreach (SequencePoint point in sequencePoints)
                     {
                         string sourceName = reader.GetString(reader.GetDocument(point.Document).Name);
-                        if (point.StartLine == lineNumber && sourceName == filePath)
+                        if (point.StartLine == lineNumber && FileNameMatches(sourceName))
                         {
                             methodToken = MetadataTokens.GetToken(methodDebugInformationHandle.ToDefinitionHandle());
                             ilOffset = point.Offset;
index 36e7e99f8e02537cf489f9af2b9b82bc15199e70..46ba50fd821fa533c1704a9dc4b0f2c88752a143 100644 (file)
@@ -56,7 +56,12 @@ HRESULT Breakpoints::HitBreakpoint(
 
     auto breakpoints = m_breakpoints.find(sp.document);
     if (breakpoints == m_breakpoints.end())
-        return E_FAIL;
+    {
+        // try to find a match with file name only
+        breakpoints = m_breakpoints.find(GetFileName(sp.document));
+        if (breakpoints == m_breakpoints.end())
+            return E_FAIL;
+    }
 
     auto &breakpointsInSource = breakpoints->second;
     auto it = breakpointsInSource.find(sp.startLine);
@@ -371,8 +376,6 @@ HRESULT Breakpoints::SetBreakpoints(
         return S_OK;
     }
 
-    Source source(filename);
-
     auto &breakpointsInSource = m_breakpoints[filename];
 
     // Remove old breakpoints