Esempio n. 1
0
		/// <summary>
		/// Adds <paramref name="pdbDoc"/> if it doesn't exist
		/// </summary>
		/// <param name="pdbDoc">PDB document</param>
		/// <returns>A <see cref="ISymbolDocumentWriter"/> instance</returns>
		ISymbolDocumentWriter Add(PdbDocument pdbDoc) {
			ISymbolDocumentWriter docWriter;
			if (pdbDocs.TryGetValue(pdbDoc, out docWriter))
				return docWriter;
			docWriter = writer.DefineDocument(pdbDoc.Url, pdbDoc.Language, pdbDoc.LanguageVendor, pdbDoc.DocumentType);
			docWriter.SetCheckSum(pdbDoc.CheckSumAlgorithmId, pdbDoc.CheckSum);
			pdbDocs.Add(pdbDoc, docWriter);
			return docWriter;
		}
Esempio n. 2
0
        PdbDocument Add_NoLock(PdbDocument doc)
        {
            PdbDocument orig;

            if (docDict.TryGetValue(doc, out orig))
            {
                return(orig);
            }
            docDict.Add(doc, doc);
            return(doc);
        }
Esempio n. 3
0
        /// <summary>
        /// Removes <paramref name="doc"/>
        /// </summary>
        /// <param name="doc">Document</param>
        /// <returns><c>true</c> if it was removed, <c>false</c> if it wasn't inserted.</returns>
        public bool Remove(PdbDocument doc)
        {
#if THREAD_SAFE
            theLock.EnterWriteLock(); try {
#endif
            return(docDict.Remove(doc));

#if THREAD_SAFE
        }
        finally { theLock.ExitWriteLock(); }
#endif
        }
Esempio n. 4
0
        /// <summary>
        /// Adds <paramref name="doc"/>
        /// </summary>
        /// <param name="doc">New document</param>
        /// <returns><paramref name="doc"/> if it wasn't inserted, or the already existing document
        /// if it was already inserted.</returns>
        public PdbDocument Add(PdbDocument doc)
        {
#if THREAD_SAFE
            theLock.EnterWriteLock(); try {
#endif
            return(Add_NoLock(doc));

#if THREAD_SAFE
        }
        finally { theLock.ExitWriteLock(); }
#endif
        }
Esempio n. 5
0
        /// <summary>
        /// Adds <paramref name="pdbDoc"/> if it doesn't exist
        /// </summary>
        /// <param name="pdbDoc">PDB document</param>
        /// <returns>A <see cref="ISymbolDocumentWriter"/> instance</returns>
        ISymbolDocumentWriter Add(PdbDocument pdbDoc)
        {
            ISymbolDocumentWriter docWriter;

            if (pdbDocs.TryGetValue(pdbDoc, out docWriter))
            {
                return(docWriter);
            }
            docWriter = writer.DefineDocument(pdbDoc.Url, pdbDoc.Language, pdbDoc.LanguageVendor, pdbDoc.DocumentType);
            docWriter.SetCheckSum(pdbDoc.CheckSumAlgorithmId, pdbDoc.CheckSum);
            pdbDocs.Add(pdbDoc, docWriter);
            return(docWriter);
        }
Esempio n. 6
0
        /// <summary>
        /// Returns an inserted <see cref="PdbDocument"/> instance or <c>null</c> if it's not been
        /// inserted yet.
        /// </summary>
        /// <param name="doc">A PDB document</param>
        /// <returns>The existing <see cref="PdbDocument"/> or <c>null</c> if it doesn't exist.</returns>
        public PdbDocument GetExisting(PdbDocument doc)
        {
#if THREAD_SAFE
            theLock.EnterWriteLock(); try {
#endif
            PdbDocument orig;
            docDict.TryGetValue(doc, out orig);
            return(orig);

#if THREAD_SAFE
        }
        finally { theLock.ExitWriteLock(); }
#endif
        }
Esempio n. 7
0
            public void Write(PdbWriter pdbWriter, IList <Instruction> instrs)
            {
                checkedPdbDocs.Clear();
                while (true)
                {
                    PdbDocument currPdbDoc = null;
                    bool        otherDocsAvailable = false;
                    int         index = 0, instrOffset = 0;
                    Instruction instr = null;
                    for (int i = 0; i < instrs.Count; i++, instrOffset += instr.GetSize())
                    {
                        instr = instrs[i];
                        var seqp = instr.SequencePoint;
                        if (seqp == null || seqp.Document == null)
                        {
                            continue;
                        }
                        if (checkedPdbDocs.ContainsKey(seqp.Document))
                        {
                            continue;
                        }
                        if (currPdbDoc == null)
                        {
                            currPdbDoc = seqp.Document;
                        }
                        else if (currPdbDoc != seqp.Document)
                        {
                            otherDocsAvailable = true;
                            continue;
                        }

                        if (index >= instrOffsets.Length)
                        {
                            int newSize = index * 2;
                            if (newSize < 64)
                            {
                                newSize = 64;
                            }
                            Array.Resize(ref instrOffsets, newSize);
                            Array.Resize(ref startLines, newSize);
                            Array.Resize(ref startColumns, newSize);
                            Array.Resize(ref endLines, newSize);
                            Array.Resize(ref endColumns, newSize);
                        }

                        instrOffsets[index] = instrOffset;
                        startLines[index]   = seqp.StartLine;
                        startColumns[index] = seqp.StartColumn;
                        endLines[index]     = seqp.EndLine;
                        endColumns[index]   = seqp.EndColumn;
                        index++;
                    }
                    if (index != 0)
                    {
                        pdbWriter.writer.DefineSequencePoints(pdbWriter.Add(currPdbDoc), (uint)index, instrOffsets, startLines, startColumns, endLines, endColumns);
                    }

                    if (!otherDocsAvailable)
                    {
                        break;
                    }
                    if (currPdbDoc != null)
                    {
                        checkedPdbDocs.Add(currPdbDoc, true);
                    }
                }
            }
Esempio n. 8
0
		/// <summary>
		/// Adds <paramref name="doc"/>
		/// </summary>
		/// <param name="doc">New document</param>
		/// <returns><paramref name="doc"/> if it wasn't inserted, or the already existing document
		/// if it was already inserted.</returns>
		public PdbDocument Add(PdbDocument doc) {
#if THREAD_SAFE
			theLock.EnterWriteLock(); try {
#endif
			return Add_NoLock(doc);
#if THREAD_SAFE
			} finally { theLock.ExitWriteLock(); }
#endif
		}
Esempio n. 9
0
		/// <summary>
		/// Returns an inserted <see cref="PdbDocument"/> instance or <c>null</c> if it's not been
		/// inserted yet.
		/// </summary>
		/// <param name="doc">A PDB document</param>
		/// <returns>The existing <see cref="PdbDocument"/> or <c>null</c> if it doesn't exist.</returns>
		public PdbDocument GetExisting(PdbDocument doc) {
#if THREAD_SAFE
			theLock.EnterWriteLock(); try {
#endif
			PdbDocument orig;
			docDict.TryGetValue(doc, out orig);
			return orig;
#if THREAD_SAFE
			} finally { theLock.ExitWriteLock(); }
#endif
		}
Esempio n. 10
0
		/// <summary>
		/// Removes <paramref name="doc"/>
		/// </summary>
		/// <param name="doc">Document</param>
		/// <returns><c>true</c> if it was removed, <c>false</c> if it wasn't inserted.</returns>
		public bool Remove(PdbDocument doc) {
#if THREAD_SAFE
			theLock.EnterWriteLock(); try {
#endif
			return docDict.Remove(doc);
#if THREAD_SAFE
			} finally { theLock.ExitWriteLock(); }
#endif
		}
Esempio n. 11
0
		PdbDocument Add_NoLock(PdbDocument doc) {
			PdbDocument orig;
			if (docDict.TryGetValue(doc, out orig))
				return orig;
			docDict.Add(doc, doc);
			return doc;
		}