Example #1
0
        public void SetMetadataEmitter(MetadataWriter metadataWriter)
        {
            try
            {
                var symWriter = (ISymUnmanagedWriter2)(_symWriterFactory != null ? _symWriterFactory() : CreateSymWriterWorker());

                // Correctness: If the stream is not specified or if it is non-empty the SymWriter appends data to it (provided it contains valid PDB)
                // and the resulting PDB has Age = existing_age + 1.
                _pdbStream = new ComMemoryStream();

                if (_deterministic)
                {
                    var deterministicSymWriter = symWriter as ISymUnmanagedWriter6;
                    if (symWriter == null)
                    {
                        throw new NotSupportedException(CodeAnalysisResources.SymWriterNotDeterministic);
                    }

                    deterministicSymWriter.InitializeDeterministic(new PdbMetadataWrapper(metadataWriter), _pdbStream);
                }
                else
                {
                    symWriter.Initialize(new PdbMetadataWrapper(metadataWriter), _fileName, _pdbStream, fullBuild: true);
                }

                _metadataWriter = metadataWriter;
                _symWriter      = symWriter;
            }
            catch (Exception ex)
            {
                throw new PdbWritingException(ex);
            }
        }
Example #2
0
        public static unsafe void DefineConstant2(this ISymUnmanagedWriter2 writer, string name, object value, uint sigToken)
        {
            VariantStructure variant = new VariantStructure();

            Marshal.GetNativeVariantForObject(value, new IntPtr(&variant));
            writer.DefineConstant2(name, variant, sigToken);
        }
Example #3
0
        internal PDBHelper(CILAssemblyManipulator.API.EmittingArguments eArgs, String outPath)
        {
            Object writer;

            CoCreateInstance(ref UNMANAGED_WRITER_GUID, null, 1u, ref SYM_WRITER_GUID, out writer);
            this._unmanagedWriter = (ISymUnmanagedWriter2)writer;
            this._unmanagedDocs   = new Dictionary <String, ISymUnmanagedDocumentWriter>();

            this._tmpFN = System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.IO.Path.GetRandomFileName()) + ".pdb";
            this._fn    = System.IO.Path.ChangeExtension(outPath, "pdb");
            this._eArgs = eArgs;
            // Initialize writer
            this._unmanagedWriter.Initialize2(new MDHelper(eArgs), this._tmpFN, null, true, this._fn);

            // Get debug header data
            Int32 dbgHdrSize;
            ImageDebugDirectory debugDir;

            // Get size of debug directory
            this._unmanagedWriter.GetDebugInfo(out debugDir, 0, out dbgHdrSize, null);
            // Get the data of debug directory
            var debugDirContents = new byte[dbgHdrSize];

            this._unmanagedWriter.GetDebugInfo(out debugDir, dbgHdrSize, out dbgHdrSize, debugDirContents);
            // Set information for CILAssemblyManipulator emitter
            var dbgInfo = new CILAssemblyManipulator.API.EmittingDebugInformation();

            dbgInfo.Characteristics = debugDir.Characteristics;
            dbgInfo.Timestamp       = debugDir.TimeDateStamp;
            dbgInfo.VersionMajor    = debugDir.MajorVersion;
            dbgInfo.VersionMinor    = debugDir.MinorVersion;
            dbgInfo.DebugType       = debugDir.Type;
            dbgInfo.DebugData       = debugDirContents;
            eArgs.DebugInformation  = dbgInfo;
        }
Example #4
0
        public SymbolWriter(string binaryFile, string pdbFile)
        {
            Contract.Requires(binaryFile != null);
            Contract.Requires(pdbFile != null);
            IntPtr importer = IntPtr.Zero;

            try {
                object dispenser;
                OLE32.CoCreateInstance(ref XGuid.dispenserClassID, null, 1, ref XGuid.dispenserIID, out dispenser);
                object pUnknown;
                ((IMetaDataDispenserSubset)dispenser).OpenScope(binaryFile, 0, ref XGuid.importerIID, out pUnknown);
                importer = Marshal.GetComInterfaceForObject(pUnknown, typeof(IMetadataImport));

                object writer2;
                OLE32.CoCreateInstance(ref XGuid.symWriterClassID, null, 1, ref XGuid.symWriterIID, out writer2);
                writer = (ISymUnmanagedWriter2)writer2;
                writer.Initialize(importer, pdbFile, null, true);
            }
            catch (Exception x) {
                Console.WriteLine(x.Message);
            }
            finally {
                if (importer != IntPtr.Zero)
                {
                    Marshal.Release(importer);
                }
            }
        }
        public static ISymUnmanagedDocumentWriter DefineDocument(this ISymUnmanagedWriter2 instance, IntPtr url, ref Guid language, ref Guid languageVendor, ref Guid documentType)
        {
            ISymUnmanagedDocumentWriter returnValue = instance.__DefineDocument(url, ref language, ref languageVendor, ref documentType);

            ProcessOutParameter(returnValue);
            return(returnValue);
        }
Example #6
0
        public SymbolWriter(string binaryFile, string pdbFile)
        {
            Contract.Requires(binaryFile != null);
            Contract.Requires(pdbFile != null);
            IntPtr importer = IntPtr.Zero;

            try {
              object dispenser;
              OLE32.CoCreateInstance(ref XGuid.dispenserClassID, null, 1, ref XGuid.dispenserIID, out dispenser);
              object pUnknown;
              ((IMetaDataDispenserSubset)dispenser).OpenScope(binaryFile, 0, ref XGuid.importerIID, out pUnknown);
            importer = Marshal.GetComInterfaceForObject(pUnknown, typeof(IMetadataImport));

              object writer2;
              OLE32.CoCreateInstance(ref XGuid.symWriterClassID, null, 1, ref XGuid.symWriterIID, out writer2);
            writer = (ISymUnmanagedWriter2)writer2;
            writer.Initialize(importer, pdbFile, null, true);
              }
              catch (Exception x) {
            Console.WriteLine(x.Message);
              }
              finally {
            if (importer != IntPtr.Zero)
              Marshal.Release(importer);
              }
        }
Example #7
0
        public void Close()
        {
            InitWriter();

            foreach (Method method in methods)
            {
                int remappedToken = method.token;
                remap.TryGetValue(remappedToken, out remappedToken);
                symUnmanagedWriter.OpenMethod(remappedToken);
                if (method.document != null)
                {
                    ISymUnmanagedDocumentWriter doc = method.document.GetUnmanagedDocument(symUnmanagedWriter);
                    symUnmanagedWriter.DefineSequencePoints(doc, method.offsets.Length, method.offsets, method.lines, method.columns, method.endLines, method.endColumns);
                }
                foreach (Scope scope in method.scopes)
                {
                    scope.Do(symUnmanagedWriter);
                }
                symUnmanagedWriter.CloseMethod();
            }

            foreach (Document doc in documents.Values)
            {
                doc.Release();
            }

            symUnmanagedWriter.Close();
            Marshal.ReleaseComObject(symUnmanagedWriter);
            symUnmanagedWriter = null;
            documents.Clear();
            methods.Clear();
            remap.Clear();
            reversemap.Clear();
        }
		public PdbWriter(string fileName, IMetadataProvider metadataProvider)
		{
			this.pdb = new ISymUnmanagedWriter2();
			this.metadataProvider = metadataProvider;
			this.documentWriters = new Dictionary<string, ISymUnmanagedDocumentWriter>();

			this.pdb.Initialize(new Metadata(metadataProvider), fileName, pIStream: null, fFullBuild: true);
		}
Example #9
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="writer">Writer</param>
		/// <param name="pdbFileName">PDB file name</param>
		public SymbolWriter(ISymUnmanagedWriter2 writer, string pdbFileName) {
			if (writer == null)
				throw new ArgumentNullException("writer");
			if (pdbFileName == null)
				throw new ArgumentNullException("pdbFileName");
			this.writer = writer;
			this.pdbFileName = pdbFileName;
		}
Example #10
0
        public PdbWriter(string fileName, IMetadataProvider metadataProvider)
        {
            this.pdb = new ISymUnmanagedWriter2();
            this.metadataProvider = metadataProvider;
            this.documentWriters  = new Dictionary <string, ISymUnmanagedDocumentWriter>();

            this.pdb.Initialize(new Metadata(metadataProvider), fileName, pIStream: null, fFullBuild: true);
        }
Example #11
0
        public SymWriter()
        {
            object objWriter;
            CoCreateInstance (ref s_CorSymWriter_SxS_ClassID, null, 1, ref s_symUnmangedWriterIID, out objWriter);

            m_writer = (ISymUnmanagedWriter2) objWriter;
            documents = new Collection<ISymUnmanagedDocumentWriter> ();
        }
Example #12
0
 internal ISymUnmanagedDocumentWriter GetUnmanagedDocument(ISymUnmanagedWriter2 symUnmanagedWriter)
 {
     if (unmanagedDocument == null)
     {
         unmanagedDocument = symUnmanagedWriter.DefineDocument(url, ref language, ref languageVendor, ref documentType);
     }
     return(unmanagedDocument);
 }
 public SymbolWriterImpl(ISymUnmanagedWriter2 writer, string pdbFileName, Stream pdbStream, PdbWriterOptions options, bool ownsStream)
 {
     this.writer       = writer ?? throw new ArgumentNullException(nameof(writer));
     asyncMethodWriter = writer as ISymUnmanagedAsyncMethodPropertiesWriter;
     this.pdbStream    = pdbStream ?? throw new ArgumentNullException(nameof(pdbStream));
     this.pdbFileName  = pdbFileName;
     this.ownsStream   = ownsStream;
     isDeterministic   = (options & PdbWriterOptions.Deterministic) != 0 && writer is ISymUnmanagedWriter6;
 }
Example #14
0
        public SymWriter()
        {
            object objWriter;

            CoCreateInstance(ref s_CorSymWriter_SxS_ClassID, null, 1, ref s_symUnmangedWriterIID, out objWriter);

            m_writer  = (ISymUnmanagedWriter2)objWriter;
            documents = new Collection <ISymUnmanagedDocumentWriter> ();
        }
Example #15
0
 private void InitWriter()
 {
     if (symUnmanagedWriter == null)
     {
         string fileName = System.IO.Path.ChangeExtension(moduleBuilder.FullyQualifiedName, ".pdb");
         // pro-actively delete the .pdb to get a meaningful IOException, instead of COMInteropException if the file can't be overwritten (or is corrupt, or who knows what)
         System.IO.File.Delete(fileName);
         symUnmanagedWriter = new ISymUnmanagedWriter2();
         symUnmanagedWriter.Initialize(this, fileName, null, true);
     }
 }
Example #16
0
 public void Close()
 {
     try
     {
         _symWriter?.Close();
         _symWriter = null;
     }
     catch (Exception ex)
     {
         throw new PdbWritingException(ex);
     }
 }
Example #17
0
        public void SetMetadataEmitter(object metadataEmitter)
        {
            ISymUnmanagedWriter2 symWriter = null;
            Type t = Type.GetTypeFromProgID("CorSymWriter_SxS", false);

            if (t != null)
            {
                symWriter = (ISymUnmanagedWriter2)Activator.CreateInstance(t);
                symWriter.Initialize(metadataEmitter, this.fileName, null, true);
            }
            this.symWriter = symWriter;
        }
Example #18
0
 /// <summary>
 /// Close the PDB writer and write the PDB data to the stream provided by <see cref="_streamProvider"/>.
 /// </summary>
 public void WritePdbToOutput()
 {
     try
     {
         _symWriter?.Close();
         _symWriter = null;
     }
     catch (Exception ex)
     {
         throw new PdbWritingException(ex);
     }
 }
Example #19
0
 private void Close()
 {
     try
     {
         _symWriter?.Close();
         _symWriter = null;
         _pdbStream = null;
     }
     catch (Exception ex)
     {
         throw new PdbWritingException(ex);
     }
 }
Example #20
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="writer">Writer</param>
 /// <param name="pdbFileName">PDB file name</param>
 public SymbolWriter(ISymUnmanagedWriter2 writer, string pdbFileName)
 {
     if (writer == null)
     {
         throw new ArgumentNullException("writer");
     }
     if (pdbFileName == null)
     {
         throw new ArgumentNullException("pdbFileName");
     }
     this.writer      = writer;
     this.pdbFileName = pdbFileName;
 }
Example #21
0
 internal void Do(ISymUnmanagedWriter2 symUnmanagedWriter)
 {
     symUnmanagedWriter.OpenScope(startOffset);
     foreach (KeyValuePair <string, LocalVar> kv in locals)
     {
         symUnmanagedWriter.DefineLocalVariable2(kv.Key, (int)kv.Value.attributes, kv.Value.signature, (int)kv.Value.addrKind, kv.Value.addr1, kv.Value.addr2, kv.Value.addr3, kv.Value.startOffset, kv.Value.endOffset);
     }
     foreach (Scope scope in scopes)
     {
         scope.Do(symUnmanagedWriter);
     }
     symUnmanagedWriter.CloseScope(endOffset);
 }
Example #22
0
        public void SetMetadataEmitter(PeWriter peWriter)
        {
            try
            {
                var instance = (ISymUnmanagedWriter2)Activator.CreateInstance(GetCorSymWriterSxSType());
                instance.Initialize(new PdbMetadataWrapper(peWriter), this.fileName, this.stream, true);

                this.symWriter = instance;
            }
            catch (Exception ex)
            {
                throw new PdbWritingException(ex);
            }
        }
Example #23
0
 public SymbolWriterClass(EnCManager manager,ITokenTranslator transl)
 {
     // Create the writer from the COM catalog
     Type writerType = Type.GetTypeFromCLSID(typeof(CorSymWriter_SxSClass).GUID);
     object comWriterObj = Activator.CreateInstance(writerType);
     Type readerType = Type.GetTypeFromCLSID(typeof(CorSymReader_SxSClass).GUID);
     object comReaderObj = Activator.CreateInstance(readerType);
     mWriter = (ISymUnmanagedWriter2)comWriterObj;
     mReader = (ISymUnmanagedReader)comReaderObj;
     this.manager = manager;
     this.stream = new CorMemStream();
     this.translator = transl;
     State = WriterState.NotIninitialized;
 }
Example #24
0
        public void Dispose()
        {
            WriteEntryPoint();
            this.pdb.Close();
            Marshal.ReleaseComObject(this.pdb);

            foreach (var documentWriter in documentWriters.Values)
            {
                Marshal.ReleaseComObject(documentWriter);
            }

            this.documentWriters = null;
            this.pdb             = null;
        }
Example #25
0
        public SymbolWriterClass(EnCManager manager, ITokenTranslator transl)
        {
            // Create the writer from the COM catalog
            Type   writerType   = Type.GetTypeFromCLSID(typeof(CorSymWriter_SxSClass).GUID);
            object comWriterObj = Activator.CreateInstance(writerType);
            Type   readerType   = Type.GetTypeFromCLSID(typeof(CorSymReader_SxSClass).GUID);
            object comReaderObj = Activator.CreateInstance(readerType);

            mWriter         = (ISymUnmanagedWriter2)comWriterObj;
            mReader         = (ISymUnmanagedReader)comReaderObj;
            this.manager    = manager;
            this.stream     = new CorMemStream();
            this.translator = transl;
            State           = WriterState.NotIninitialized;
        }
Example #26
0
        public void SetMetadataEmitter(MetadataWriter metadataWriter)
        {
            try
            {
                var instance = (ISymUnmanagedWriter2)(_symWriterFactory != null ? _symWriterFactory() : Activator.CreateInstance(GetCorSymWriterSxSType()));
                instance.Initialize(new PdbMetadataWrapper(metadataWriter), _fileName, _stream, true);

                _metadataWriter = metadataWriter;
                _symWriter      = instance;
            }
            catch (Exception ex)
            {
                throw new PdbWritingException(ex);
            }
        }
Example #27
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="writer">Writer</param>
 /// <param name="pdbFileName">PDB file name</param>
 /// <param name="pdbStream">PDB output stream</param>
 public SymbolWriter(ISymUnmanagedWriter2 writer, string pdbFileName, Stream pdbStream)
 {
     if (writer == null)
     {
         throw new ArgumentNullException("writer");
     }
     if (pdbStream == null)
     {
         throw new ArgumentNullException("pdbStream");
     }
     this.writer            = writer;
     this.asyncMethodWriter = writer as ISymUnmanagedAsyncMethodPropertiesWriter;
     this.pdbStream         = pdbStream;
     this.pdbFileName       = pdbFileName;
 }
Example #28
0
        public void SetMetadataEmitter(MetadataWriter metadataWriter)
        {
            try
            {
                var instance  = (ISymUnmanagedWriter2)(_symWriterFactory != null ? _symWriterFactory() : Activator.CreateInstance(GetCorSymWriterSxSType()));
                var comStream = _pdbOutputInfo.Stream != null ? new ComStreamWrapper(_pdbOutputInfo.Stream) : null;
                instance.Initialize(new PdbMetadataWrapper(metadataWriter), _pdbOutputInfo.FileName, comStream, fullBuild: true);

                _metadataWriter = metadataWriter;
                _symWriter      = instance;
            }
            catch (Exception ex)
            {
                throw new PdbWritingException(ex);
            }
        }
Example #29
0
        public unsafe void WriteTo(Stream stream)
        {
            Debug.Assert(_pdbStream != null);
            Debug.Assert(_symWriter != null);

            try
            {
                // SymWriter flushes data to the native stream on close:
                _symWriter.Close();
                _symWriter = null;
                _pdbStream.CopyTo(stream);
            }
            catch (Exception ex)
            {
                throw new PdbWritingException(ex);
            }
        }
Example #30
0
        public unsafe void WriteTo(Stream stream)
        {
            Debug.Assert(_pdbStream != null);
            Debug.Assert(_symWriter != null);

            try
            {
                // SymWriter flushes data to the native stream on close:
                _symWriter.Close();
                _symWriter = null;
                _pdbStream.CopyTo(stream);
            }
            catch (Exception ex)
            {
                throw new PdbWritingException(ex);
            }
        }
Example #31
0
        /// <summary>
        /// Destroys <c>mWriter</c> and <c>mReader</c> if possible.
        /// </summary>
        public void Dispose()
        {
            // If the underlying symbol API supports the Destroy method, then call it.
            ISymUnmanagedDispose disposer = mWriter as ISymUnmanagedDispose;

            if (disposer != null)
            {
                disposer.__Destroy();
            }
            disposer = mReader as ISymUnmanagedDispose;
            if (disposer != null)
            {
                disposer.__Destroy();
            }
            mWriter = null;
            mReader = null;
        }
Example #32
0
        public void SetMetadataEmitter(MetadataWriter metadataWriter)
        {
            Stream streamOpt = _streamProvider();

            try
            {
                var instance  = (ISymUnmanagedWriter2)(_symWriterFactory != null ? _symWriterFactory() : Activator.CreateInstance(GetCorSymWriterSxSType()));
                var comStream = (streamOpt != null) ? new ComStreamWrapper(streamOpt) : null;

                instance.Initialize(new PdbMetadataWrapper(metadataWriter), _fileName, comStream, fullBuild: true);

                _metadataWriter = metadataWriter;
                _symWriter      = instance;
            }
            catch (Exception ex)
            {
                throw new PdbWritingException(ex);
            }
        }
Example #33
0
        public void SetMetadataEmitter(MetadataWriter metadataWriter)
        {
            Stream stream = _streamProvider() ?? new System.IO.MemoryStream();

            try
            {
                var instance = (ISymUnmanagedWriter2)(_symWriterFactory != null ? _symWriterFactory() : Activator.CreateInstance(GetCorSymWriterSxSType()));

                // Important: If the stream is not specified or if it is non-empty the SymWriter appends data to it (provided it contains valid PDB)
                // and the resulting PDB has Age = existing_age + 1.
                Debug.Assert(stream.Length == 0);

                instance.Initialize(new PdbMetadataWrapper(metadataWriter), _fileName, new ComStreamWrapper(stream), fullBuild: true);

                _metadataWriter = metadataWriter;
                _symWriter      = instance;
            }
            catch (Exception ex)
            {
                throw new PdbWritingException(ex);
            }
        }
Example #34
0
		public void Dispose()
		{
			WriteEntryPoint();
			this.pdb.Close();
			Marshal.ReleaseComObject(this.pdb);

			foreach (var documentWriter in documentWriters.Values)
				Marshal.ReleaseComObject(documentWriter);

			this.documentWriters = null;
			this.pdb = null;
		}
Example #35
0
 public void SetMetadataEmitter(object metadataEmitter)
 {
     ISymUnmanagedWriter2 symWriter = null;
       Type t = Type.GetTypeFromProgID("CorSymWriter_SxS", false);
       if (t != null) {
     symWriter = (ISymUnmanagedWriter2)Activator.CreateInstance(t);
     symWriter.Initialize(metadataEmitter, this.fileName, null, true);
       }
       this.symWriter = symWriter;
 }
Example #36
0
 private void InitWriter()
 {
     if (symUnmanagedWriter == null)
     {
         string fileName = System.IO.Path.ChangeExtension(moduleBuilder.FullyQualifiedName, ".pdb");
         // pro-actively delete the .pdb to get a meaningful IOException, instead of COMInteropException if the file can't be overwritten (or is corrupt, or who knows what)
         System.IO.File.Delete(fileName);
         symUnmanagedWriter = new ISymUnmanagedWriter2();
         symUnmanagedWriter.Initialize(this, fileName, null, true);
     }
 }
Example #37
0
 internal ISymUnmanagedDocumentWriter GetUnmanagedDocument(ISymUnmanagedWriter2 symUnmanagedWriter)
 {
     if (unmanagedDocument == null)
     {
         unmanagedDocument = symUnmanagedWriter.DefineDocument(url, ref language, ref languageVendor, ref documentType);
     }
     return unmanagedDocument;
 }
Example #38
0
        public void SetMetadataEmitter(PeWriter peWriter)
        {
            try
            {
                var instance = (ISymUnmanagedWriter2)Activator.CreateInstance(GetCorSymWriterSxSType());
                instance.Initialize(new PdbMetadataWrapper(peWriter), this.fileName, this.stream, true);

                this.symWriter = instance;
            }
            catch (Exception ex)
            {
                throw new PdbWritingException(ex);
            }
        }
Example #39
0
 internal void Do(ISymUnmanagedWriter2 symUnmanagedWriter)
 {
     symUnmanagedWriter.OpenScope(startOffset);
     foreach (KeyValuePair<string, LocalVar> kv in locals)
     {
         symUnmanagedWriter.DefineLocalVariable2(kv.Key, (int)kv.Value.attributes, kv.Value.signature, (int)kv.Value.addrKind, kv.Value.addr1, kv.Value.addr2, kv.Value.addr3, kv.Value.startOffset, kv.Value.endOffset);
     }
     foreach (Scope scope in scopes)
     {
         scope.Do(symUnmanagedWriter);
     }
     symUnmanagedWriter.CloseScope(endOffset);
 }
Example #40
0
        public void SetMetadataEmitter(MetadataWriter metadataWriter)
        {
            try
            {
                var symWriter = (ISymUnmanagedWriter2)(_symWriterFactory != null ? _symWriterFactory() : CreateSymWriterWorker());

                // Correctness: If the stream is not specified or if it is non-empty the SymWriter appends data to it (provided it contains valid PDB)
                // and the resulting PDB has Age = existing_age + 1.
                _pdbStream = new ComMemoryStream();

                if (_deterministic)
                {
                    var deterministicSymWriter = symWriter as ISymUnmanagedWriter6;
                    if (deterministicSymWriter == null)
                    {
                        throw new NotSupportedException(CodeAnalysisResources.SymWriterNotDeterministic);
                    }

                    deterministicSymWriter.InitializeDeterministic(new PdbMetadataWrapper(metadataWriter), _pdbStream);
                }
                else
                {
                    symWriter.Initialize(new PdbMetadataWrapper(metadataWriter), _fileName, _pdbStream, fullBuild: true);
                }

                _metadataWriter = metadataWriter;
                _symWriter = symWriter;
            }
            catch (Exception ex)
            {
                throw new PdbWritingException(ex);
            }
        }
Example #41
0
        public void Close()
        {
            InitWriter();

            foreach (Method method in methods)
            {
                int remappedToken = method.token;
                remap.TryGetValue(remappedToken, out remappedToken);
                symUnmanagedWriter.OpenMethod(remappedToken);
                if (method.document != null)
                {
                    ISymUnmanagedDocumentWriter doc = method.document.GetUnmanagedDocument(symUnmanagedWriter);
                    symUnmanagedWriter.DefineSequencePoints(doc, method.offsets.Length, method.offsets, method.lines, method.columns, method.endLines, method.endColumns);
                }
                foreach (Scope scope in method.scopes)
                {
                    scope.Do(symUnmanagedWriter);
                }
                symUnmanagedWriter.CloseMethod();
            }

            foreach (Document doc in documents.Values)
            {
                doc.Release();
            }

            symUnmanagedWriter.Close();
            Marshal.ReleaseComObject(symUnmanagedWriter);
            symUnmanagedWriter = null;
            documents.Clear();
            methods.Clear();
            remap.Clear();
            reversemap.Clear();
        }
Example #42
0
 /// <summary>
 /// Destroys <c>mWriter</c> and <c>mReader</c> if possible.
 /// </summary>
 public void Dispose()
 {
     // If the underlying symbol API supports the Destroy method, then call it.
     ISymUnmanagedDispose disposer = mWriter as ISymUnmanagedDispose;
     if (disposer != null)
         disposer.__Destroy();
     disposer = mReader as ISymUnmanagedDispose;
     if (disposer != null)
         disposer.__Destroy();
     mWriter = null;
     mReader = null;
 }
 public static void DefineConstant2(this ISymUnmanagedWriter2 instance, IntPtr name, object value, uint sigToken)
 {
     instance.__DefineConstant2(name, value, sigToken);
 }
 public static void DefineGlobalVariable2(this ISymUnmanagedWriter2 instance, IntPtr name, uint attributes, uint sigToken, uint addrKind, uint addr1, uint addr2, uint addr3)
 {
     instance.__DefineGlobalVariable2(name, attributes, sigToken, addrKind, addr1, addr2, addr3);
 }
 public static void DefineLocalVariable2(this ISymUnmanagedWriter2 instance, IntPtr name, uint attributes, uint sigToken, uint addrKind, uint addr1, uint addr2, uint addr3, uint startOffset, uint endOffset)
 {
     instance.__DefineLocalVariable2(name, attributes, sigToken, addrKind, addr1, addr2, addr3, startOffset, endOffset);
 }
 public static void Abort(this ISymUnmanagedWriter2 instance)
 {
     instance.__Abort();
 }
Example #47
0
 private void Close()
 {
     try
     {
         _symWriter?.Close();
         _symWriter = null;
         _pdbStream = null;
     }
     catch (Exception ex)
     {
         throw new PdbWritingException(ex);
     }
 }
Example #48
0
        public void SetMetadataEmitter(MetadataWriter metadataWriter)
        {
            try
            {
                var instance = (ISymUnmanagedWriter2)(_symWriterFactory != null ? _symWriterFactory() : Activator.CreateInstance(GetCorSymWriterSxSType()));
                instance.Initialize(new PdbMetadataWrapper(metadataWriter), _fileName, _stream, true);

                _metadataWriter = metadataWriter;
                _symWriter = instance;
            }
            catch (Exception ex)
            {
                throw new PdbWritingException(ex);
            }
        }