Ejemplo n.º 1
0
        public void WritePdb(SymbolData symData)
        {
            m_docWriters = new Dictionary <int, ISymbolDocumentWriter>();

            ImageDebugDirectory debugDirectory;

            byte[] debugInfo = null;
            // Rather than use the emitter here, we are just careful enough to emit pdb metadata that
            // matches what is already in the assembly image.
            object emitter = null;

            // We must be careful to close the writer before updating the debug headers.  The writer has an
            // open file handle on the assembly we want to update.
            m_writer = SymbolAccess.GetWriterForFile(m_symFormat, m_outputAssembly, ref emitter);

            // We don't actually need the emitter in managed code at all, so release the CLR reference on it
            Marshal.FinalReleaseComObject(emitter);

            try
            {
                WriteEntryPoint(symData.entryPointToken);
                WriteFiles(symData.sourceFiles);
                WriteMethods(symData.methods);
                debugInfo = m_writer.GetDebugInfo(out debugDirectory);
            }
            finally
            {
                m_writer.Close();
                ((IDisposable)m_writer).Dispose();
                m_writer = null;
                m_docWriters.Clear();
            }

            UpdatePEDebugHeaders(debugInfo);
        }
Ejemplo n.º 2
0
        public void WritePdb(SymbolData symData)
        {
            m_docWriters = new Dictionary<int, ISymbolDocumentWriter>();

            ImageDebugDirectory debugDirectory;
            byte[] debugInfo = null;
            // Rather than use the emitter here, we are just careful enough to emit pdb metadata that
            // matches what is already in the assembly image.
            object emitter = null;

            // We must be careful to close the writer before updating the debug headers.  The writer has an
            // open file handle on the assembly we want to update.
            m_writer = SymbolAccess.GetWriterForFile(m_symFormat, m_outputAssembly, ref emitter);

            // We don't actually need the emitter in managed code at all, so release the CLR reference on it
            Marshal.FinalReleaseComObject(emitter);

            try
            {
                WriteEntryPoint(symData.entryPointToken);
                WriteFiles(symData.sourceFiles);
                WriteMethods(symData.methods);
                debugInfo = m_writer.GetDebugInfo(out debugDirectory);
            }
            finally
            {
                m_writer.Close();
                ((IDisposable)m_writer).Dispose();
                m_writer = null;
                m_docWriters.Clear();
            }

            UpdatePEDebugHeaders(debugInfo);
        }
Ejemplo n.º 3
0
 /// <inheritdoc/>
 public void Dispose()
 {
     if (writer != null)
     {
         Close();
     }
     writer = null;
 }
Ejemplo n.º 4
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="writer">Symbol writer</param>
		/// <param name="pdbState">PDB state</param>
		/// <param name="metaData">Meta data</param>
		public PdbWriter(ISymbolWriter2 writer, PdbState pdbState, MetaData metaData) {
			if (writer == null)
				throw new ArgumentNullException("writer");
			if (pdbState == null)
				throw new ArgumentNullException("pdbState");
			if (metaData == null)
				throw new ArgumentNullException("metaData");
			this.writer = writer;
			this.pdbState = pdbState;
			this.metaData = metaData;
			this.module = metaData.Module;
			writer.Initialize(metaData);
		}
Ejemplo n.º 5
0
        internal Xml2PdbConverter(XmlDocument doc, string OutputAssembly)
        {
            m_doc            = doc;
            m_docWriters     = new Dictionary <int, ISymbolDocumentWriter>();
            m_sequencePoints = new Dictionary <int, List <int>[]>();

            string ext = Path.GetExtension(m_doc.DocumentElement.GetAttribute("file"));

            m_outputAssembly = Path.ChangeExtension(OutputAssembly, ext);

            object emitter = null;

            m_writer = SymbolAccess.GetWriterForFile(m_outputAssembly, ref emitter);
            // Rather than use the emitter here, we are just careful enough to emit pdb metadata that
            // matches what is already in the assembly image.
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="writer">Symbol writer</param>
 /// <param name="pdbState">PDB state</param>
 /// <param name="metaData">Meta data</param>
 public WindowsPdbWriter(ISymbolWriter3 writer, PdbState pdbState, MetaData metaData)
     : this(pdbState, metaData)
 {
     if (writer == null)
     {
         throw new ArgumentNullException("writer");
     }
     if (pdbState == null)
     {
         throw new ArgumentNullException("pdbState");
     }
     if (metaData == null)
     {
         throw new ArgumentNullException("metaData");
     }
     this.writer  = writer;
     this.writer3 = writer;
     writer.Initialize(metaData);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="writer">Symbol writer, it should implement <see cref="ISymbolWriter3"/></param>
 /// <param name="pdbState">PDB state</param>
 /// <param name="metaData">Meta data</param>
 public WindowsPdbWriter(ISymbolWriter2 writer, PdbState pdbState, MetaData metaData)
     : this(pdbState, metaData)
 {
     if (writer == null)
     {
         throw new ArgumentNullException("writer");
     }
     if (pdbState == null)
     {
         throw new ArgumentNullException("pdbState");
     }
     if (metaData == null)
     {
         throw new ArgumentNullException("metaData");
     }
     this.writer  = writer;
     this.writer3 = writer as ISymbolWriter3;
     Debug.Assert(writer3 != null, "Symbol writer doesn't implement interface ISymbolWriter3");
     writer.Initialize(metaData);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="writer">Symbol writer</param>
 /// <param name="pdbState">PDB state</param>
 /// <param name="metaData">Meta data</param>
 public PdbWriter(ISymbolWriter2 writer, PdbState pdbState, MetaData metaData)
 {
     if (writer == null)
     {
         throw new ArgumentNullException("writer");
     }
     if (pdbState == null)
     {
         throw new ArgumentNullException("pdbState");
     }
     if (metaData == null)
     {
         throw new ArgumentNullException("metaData");
     }
     this.writer   = writer;
     this.pdbState = pdbState;
     this.metaData = metaData;
     this.module   = metaData.Module;
     writer.Initialize(metaData);
 }
Ejemplo n.º 9
0
        internal Xml2PdbConverter(XmlDocument doc, string OutputAssembly)
        {
            m_doc = doc;
            m_docWriters = new Dictionary<int, ISymbolDocumentWriter>();
            m_sequencePoints = new Dictionary<int, List<int>[]>();

            string ext = Path.GetExtension(m_doc.DocumentElement.GetAttribute("file"));
            m_outputAssembly = Path.ChangeExtension(OutputAssembly, ext);

            object emitter = null;
            m_writer = SymbolAccess.GetWriterForFile(m_outputAssembly, ref emitter);
            // Rather than use the emitter here, we are just careful enough to emit pdb metadata that
            // matches what is already in the assembly image.
        }
Ejemplo n.º 10
0
		/// <inheritdoc/>
		public void Dispose() {
			if (writer != null)
				Close();
			writer = null;
		}