예제 #1
0
		void WriteDocList(ISymbolReader reader)
		{
			xwriter.WriteComment("This is a list of all source files referred by the PDB.");

			int id = 0;
			// Write doc list
			xwriter.WriteStartElement("files");
			{
				ISymbolDocument[] docs = reader.GetDocuments();
				foreach (ISymbolDocument doc in docs)
				{
					string url = doc.URL;

					// Symbol store may give out duplicate documents. We'll fold them here
					if (m_fileMapping.ContainsKey(url))
					{
						xwriter.WriteComment("There is a duplicate entry for: " + url);
						continue;
					}
					id++;
					m_fileMapping.Add(doc.URL, id);

					xwriter.WriteStartElement("file");
					{
						xwriter.WriteAttributeString("id", id.ToString());
						xwriter.WriteAttributeString("name", doc.URL);
					}
					xwriter.WriteEndElement(); // file
				}
			}
			xwriter.WriteEndElement(); // files
		}
예제 #2
0
        // Write all docs, and add to the m_fileMapping list.
        // Other references to docs will then just refer to this list.
        private void WriteDocList(ISymbolReader reader)
        {
            int id = 0;

            xmlWriter.WriteStartElement("files");
            {
                foreach (ISymbolDocument doc in reader.GetDocuments())
                {
                    string url = doc.URL;

                    // Symbol store may give out duplicate documents
                    if (fileMapping.ContainsKey(url))
                    {
                        continue;
                    }
                    id++;
                    fileMapping.Add(doc.URL, id);

                    string srcFileName = doc.URL;
                    if (!string.IsNullOrEmpty(SourceBasePath) &&
                        srcFileName.StartsWith(SourceBasePath, StringComparison.OrdinalIgnoreCase))
                    {
                        srcFileName = srcFileName.Substring(SourceBasePath.Length).TrimStart('\\');
                    }

                    xmlWriter.WriteStartElement("file");
                    xmlWriter.WriteAttributeString("id", id.ToString());
                    xmlWriter.WriteAttributeString("name", srcFileName);
                    xmlWriter.WriteEndElement();                       // </file>
                }
            }
            xmlWriter.WriteEndElement();               // </files>
        }
예제 #3
0
        // Write all docs, and add to the m_fileMapping list.
        // Other references to docs will then just refer to this list.
        private List <Document> ReadDocList(ISymbolReader reader)
        {
            List <Document> docs = new List <Document>();

            int id = 0;

            foreach (ISymbolDocument doc in reader.GetDocuments())
            {
                Document docData = new Document();
                string   url     = doc.URL;

                // Symbol store may give out duplicate documents. We'll fold them here
                if (fileMapping.ContainsKey(url))
                {
                    continue;
                }
                id++;
                fileMapping.Add(url, id);

                docData.id             = id;
                docData.checksum       = Convert.ToBase64String(doc.GetCheckSum());
                docData.url            = url;
                docData.language       = doc.Language;
                docData.languageVendor = doc.LanguageVendor;
                docData.documentType   = doc.DocumentType;
                docs.Add(docData);
            }
            return(docs);
        }
예제 #4
0
        void OnModuleLoad(object sender, CorModuleEventArgs e)
        {
            CorMetadataImport mi = new CorMetadataImport(e.Module);

            // Required to avoid the jit to get rid of variables too early
            e.Module.JITCompilerFlags = CorDebugJITCompilerFlags.CORDEBUG_JIT_DISABLE_OPTIMIZATION;

            string file = e.Module.Assembly.Name;

            lock (documents) {
                ISymbolReader reader = null;
                if (file.IndexOfAny(System.IO.Path.InvalidPathChars) == -1 && System.IO.File.Exists(System.IO.Path.ChangeExtension(file, ".pdb")))
                {
                    try {
                        reader = symbolBinder.GetReaderForFile(mi.RawCOMObject, file, ".");
                        foreach (ISymbolDocument doc in reader.GetDocuments())
                        {
                            if (string.IsNullOrEmpty(doc.URL))
                            {
                                continue;
                            }
                            string  docFile = System.IO.Path.GetFullPath(doc.URL);
                            DocInfo di      = new DocInfo();
                            di.Document        = doc;
                            di.Reader          = reader;
                            di.Module          = e.Module;
                            documents[docFile] = di;
                            NotifySourceFileLoaded(docFile);
                        }
                    }
                    catch (Exception ex) {
                        OnDebuggerOutput(true, string.Format("Debugger Error: {0}\n", ex.Message));
                    }
                    e.Module.SetJmcStatus(true, null);
                }
                else
                {
                    // Flag modules without debug info as not JMC. In this way
                    // the debugger won't try to step into them
                    e.Module.SetJmcStatus(false, null);
                }

                ModuleInfo moi;

                if (modules.TryGetValue(e.Module.Name, out moi))
                {
                    moi.References++;
                }
                else
                {
                    moi                    = new ModuleInfo();
                    moi.Module             = e.Module;
                    moi.Reader             = reader;
                    moi.Importer           = mi;
                    moi.References         = 1;
                    modules[e.Module.Name] = moi;
                }
            }
            e.Continue = true;
        }
예제 #5
0
 private void setBreakpointThroughDocument(CorModule module, ISymbolReader reader)
 {
     foreach (var doc in reader.GetDocuments())
     {
         if (attemptSetBreakpoint(reader, doc, module))
             return;
     }
 }
예제 #6
0
        void OnUpdateModuleSymbols(object sender, CorUpdateModuleSymbolsEventArgs e)
        {
            SymbolBinder      binder = new SymbolBinder();
            CorMetadataImport mi     = new CorMetadataImport(e.Module);
            ISymbolReader     reader = binder.GetReaderFromStream(mi.RawCOMObject, e.Stream);

            foreach (ISymbolDocument doc in reader.GetDocuments())
            {
                Console.WriteLine(doc.URL);
            }
            e.Continue = true;
        }
예제 #7
0
파일: PdbState.cs 프로젝트: EmilZhou/dnlib
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="reader">A <see cref="ISymbolReader"/> instance</param>
		/// <param name="module">Owner module</param>
		public PdbState(ISymbolReader reader, ModuleDefMD module) {
			if (reader == null)
				throw new ArgumentNullException("reader");
			if (module == null)
				throw new ArgumentNullException("module");
			this.reader = reader;

			this.userEntryPoint = module.ResolveToken(reader.UserEntryPoint.GetToken()) as MethodDef;

			foreach (var doc in reader.GetDocuments())
				Add_NoLock(new PdbDocument(doc));
		}
예제 #8
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="reader">A <see cref="ISymbolReader"/> instance</param>
        /// <param name="module">Owner module</param>
        public PdbState(ISymbolReader reader, ModuleDefMD module)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            if (module == null)
            {
                throw new ArgumentNullException("module");
            }
            this.reader = reader;

            this.userEntryPoint = module.ResolveToken(reader.UserEntryPoint.GetToken()) as MethodDef;

            foreach (var doc in reader.GetDocuments())
            {
                Add_NoLock(new PdbDocument(doc));
            }
        }
예제 #9
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);
 }
예제 #10
0
        /// <summary>
        /// Called when receiving a report about an assembly
        /// </summary>
        /// <param name="domainIndex"></param>
        /// <param name="domainName"></param>
        /// <param name="assemblyName"></param>
        /// <param name="moduleName"></param>
        public void EnterAssembly(int domainIndex, string domainName, string assemblyName, string moduleName)
        {
            _symbolReader = _symbolReaderFactory.GetSymbolReader(moduleName);
            if (_symbolReader != null)
            {
                var docs = _symbolReader.GetDocuments();
                foreach (var doc in docs)
                {
                    RegisterFile(doc.URL);
                }
            }

            Report.Assemblies.Add(currentAssembly = new AssemblyEntry
            {
                AssemblyRef = Report.Assemblies.Count + 1,
                Module = moduleName,
                Name = assemblyName,
                Domain = domainName,
                DomainIndex = domainIndex
            });
        }
예제 #11
0
        /// <summary>
        /// Called when receiving a report about an assembly
        /// </summary>
        /// <param name="domainIndex"></param>
        /// <param name="domainName"></param>
        /// <param name="assemblyName"></param>
        /// <param name="moduleName"></param>
        public void EnterAssembly(int domainIndex, string domainName, string assemblyName, string moduleName)
        {
            _symbolReader = _symbolReaderFactory.GetSymbolReader(moduleName);
            if (_symbolReader != null)
            {
                var docs = _symbolReader.GetDocuments();
                foreach (var doc in docs)
                {
                    RegisterFile(doc.URL);
                }
            }

            Report.Assemblies.Add(currentAssembly = new AssemblyEntry
            {
                AssemblyRef = Report.Assemblies.Count + 1,
                Module      = moduleName,
                Name        = assemblyName,
                Domain      = domainName,
                DomainIndex = domainIndex
            });
        }
예제 #12
0
        // Write all docs, and add to the m_fileMapping list.
        // Other references to docs will then just refer to this list.
        private void WriteDocList(ISymbolReader reader)
        {
            m_writer.WriteComment("This is a list of all source files referred by the PDB.");

            int id = 0;

            // Write doc list
            m_writer.WriteStartElement("files");
            {
                ISymbolDocument[] docs = reader.GetDocuments();
                foreach (ISymbolDocument doc in docs)
                {
                    string url = doc.URL;

                    // Symbol store may give out duplicate documents. We'll fold them here
                    if (m_fileMapping.ContainsKey(url))
                    {
                        m_writer.WriteComment("There is a duplicate entry for: " + url);
                        continue;
                    }
                    id++;
                    m_fileMapping.Add(doc.URL, id);

                    m_writer.WriteStartElement("file");
                    {
                        m_writer.WriteAttributeString("id", Util.CultureInvariantToString(id));
                        m_writer.WriteAttributeString("name", doc.URL);
                        m_writer.WriteAttributeString("language", doc.Language.ToString());
                        m_writer.WriteAttributeString("languageVendor", doc.LanguageVendor.ToString());
                        m_writer.WriteAttributeString("documentType", doc.DocumentType.ToString());
                    }
                    m_writer.WriteEndElement(); // file
                }
            }
            m_writer.WriteEndElement(); // files
        }
예제 #13
0
        // Write all docs, and add to the m_fileMapping list.
        // Other references to docs will then just refer to this list.
        private List<Document> ReadDocList(ISymbolReader reader)
        {
            List<Document> docs = new List<Document>();

            int id = 0;
            foreach (ISymbolDocument doc in reader.GetDocuments())
            {
                Document docData = new Document();
                string url = doc.URL;

                // Symbol store may give out duplicate documents. We'll fold them here
                if (m_fileMapping.ContainsKey(url))
                {
                    continue;
                }
                id++;
                m_fileMapping.Add(url, id);

                docData.id = id;
                docData.url = url;
                docData.language = doc.Language;
                docData.languageVendor = doc.LanguageVendor;
                docData.documentType = doc.DocumentType;
                docs.Add(docData);
            }
            return docs;
        }
예제 #14
0
파일: pdb2xml.cs 프로젝트: pusp/o2platform
        // Write all docs, and add to the m_fileMapping list.
        // Other references to docs will then just refer to this list.
        private void WriteDocList(ISymbolReader reader)
        {
            m_writer.WriteComment("This is a list of all source files referred by the PDB.");

            int id = 0;
            // Write doc list
            m_writer.WriteStartElement("files");
            {
                ISymbolDocument[] docs = reader.GetDocuments();
                foreach (ISymbolDocument doc in docs)
                {
                    string url = doc.URL;

                    // Symbol store may give out duplicate documents. We'll fold them here
                    if (m_fileMapping.ContainsKey(url))
                    {
                        m_writer.WriteComment("There is a duplicate entry for: " + url);
                        continue;
                    }
                    id++;
                    m_fileMapping.Add(doc.URL, id);

                    m_writer.WriteStartElement("file");
                    {
                        m_writer.WriteAttributeString("id", Util.CultureInvariantToString(id));
                        m_writer.WriteAttributeString("name", doc.URL);
                        m_writer.WriteAttributeString("language", doc.Language.ToString());
                        m_writer.WriteAttributeString("languageVendor", doc.LanguageVendor.ToString());
                        m_writer.WriteAttributeString("documentType", doc.DocumentType.ToString());
                    }
                    m_writer.WriteEndElement(); // file
                }
            }
            m_writer.WriteEndElement(); // files
        }
예제 #15
0
        void WriteDocList(ISymbolReader reader)
        {
            xwriter.WriteComment("This is a list of all source files referred by the PDB.");

            int id = 0;
            // Write doc list
            xwriter.WriteStartElement("files");
            {
                ISymbolDocument[] docs = reader.GetDocuments();
                foreach (ISymbolDocument doc in docs)
                {
                    string url = doc.URL;

                    // Symbol store may give out duplicate documents. We'll fold them here
                    if (m_fileMapping.ContainsKey(url))
                    {
                        xwriter.WriteComment("There is a duplicate entry for: " + url);
                        continue;
                    }
                    id++;
                    m_fileMapping.Add(doc.URL, id);

                    xwriter.WriteStartElement("file");
                    {
                        xwriter.WriteAttributeString("id", id.ToString());
                        xwriter.WriteAttributeString("name", doc.URL);
                    }
                    xwriter.WriteEndElement(); // file
                }
            }
            xwriter.WriteEndElement(); // files
        }
예제 #16
0
        // Write all docs, and add to the m_fileMapping list.
        // Other references to docs will then just refer to this list.
        private void WriteDocList(ISymbolReader reader)
        {
            int id = 0;
            xmlWriter.WriteStartElement("files");
            {
                foreach (ISymbolDocument doc in reader.GetDocuments())
                {
                    string url = doc.URL;

                    // Symbol store may give out duplicate documents
                    if (fileMapping.ContainsKey(url)) continue;
                    id++;
                    fileMapping.Add(doc.URL, id);

                    string srcFileName = doc.URL;
                    if (!string.IsNullOrEmpty(SourceBasePath) &&
                        srcFileName.StartsWith(SourceBasePath, StringComparison.OrdinalIgnoreCase))
                    {
                        srcFileName = srcFileName.Substring(SourceBasePath.Length).TrimStart('\\');
                    }

                    xmlWriter.WriteStartElement("file");
                    xmlWriter.WriteAttributeString("id", id.ToString());
                    xmlWriter.WriteAttributeString("name", srcFileName);
                    xmlWriter.WriteEndElement();   // </file>
                }
            }
            xmlWriter.WriteEndElement();   // </files>
        }