예제 #1
0
        private bool attemptSetBreakpoint(ISymbolReader reader, ISymbolDocument doc, CorModule module)
        {
            if (!doc.URL.Equals(_breakpoint.File))
                return false;

            var line = doc.FindClosestLine(_breakpoint.Line);
            var method = reader.GetMethodFromDocumentPosition(doc, line, _breakpoint.Column);
            var function = module.GetFunctionFromToken(method.Token.GetToken());

            var wasSet = attemptToSetBreakpointThroughSequencePoints(doc, line, method, function);
            if (!wasSet)
                setBreakpointThroughFunction(function);
            return true;
        }
예제 #2
0
파일: CorProcess.cs 프로젝트: tylike/mindbg
 /// <summary>
 /// Resolves code location after the source file name and the code line number.
 /// </summary>
 /// <param name="fileName">source file name</param>
 /// <param name="lineNumber">line number in the source file</param>
 /// <param name="iloffset">returns the offset in the il code (based on the line number)</param>
 /// <returns></returns>
 public CorCode ResolveCodeLocation(String fileName, Int32 lineNumber, out Int32 iloffset)
 {
     // find module
     foreach (CorModule module in Modules)
     {
         ISymbolReader symreader = module.GetSymbolReader();
         if (symreader != null)
         {
             foreach (ISymbolDocument symdoc in symreader.GetDocuments())
             {
                 if (String.Compare(symdoc.URL, fileName, true, CultureInfo.InvariantCulture) == 0 ||
                     String.Compare(System.IO.Path.GetFileName(symdoc.URL), fileName, true, CultureInfo.InvariantCulture) == 0)
                 {
                     Int32 line = 0;
                     try
                     {
                         line = symdoc.FindClosestLine(lineNumber);
                     }
                     catch (System.Runtime.InteropServices.COMException ex)
                     {
                         if (ex.ErrorCode == (Int32)HResult.E_FAIL)
                         {
                             continue; // it's not this document
                         }
                     }
                     ISymbolMethod symmethod = symreader.GetMethodFromDocumentPosition(symdoc, line, 0);
                     CorFunction   func      = module.GetFunctionFromToken(symmethod.Token.GetToken());
                     // IL offset in function code
                     iloffset = func.GetIPFromPosition(symdoc, line);
                     if (iloffset == -1)
                     {
                         return(null);
                     }
                     // finally return the code
                     return(func.GetILCode());
                 }
             }
         }
     }
     iloffset = -1;
     return(null);
 }