Example #1
0
            public CurrentMethod(PdbWriter pdbWriter, MethodDef method, Dictionary <Instruction, uint> toOffset)
            {
                this.pdbWriter = pdbWriter;
                Method         = method;
                this.toOffset  = toOffset;
                toOffset.Clear();
                uint offset = 0;

                foreach (var instr in method.Body.Instructions)
                {
                    toOffset[instr] = offset;
                    offset         += (uint)instr.GetSize();
                }
                BodySize = offset;
            }
Example #2
0
		/// <summary>
		/// Write the PDB file. The caller should send the PDB events before and after calling this
		/// method.
		/// </summary>
		protected void WritePdbFile() {
			if (!CanWritePdb())
				return;
			if (debugDirectory == null)
				throw new InvalidOperationException("debugDirectory is null but WritePdb is true");

			var pdbState = Module.PdbState;
			if (pdbState == null) {
				Error("TheOptions.WritePdb is true but module has no PdbState");
				debugDirectory.DontWriteAnything = true;
				return;
			}

			var symWriter = GetSymbolWriter2();
			if (symWriter == null) {
				Error("Could not create a PDB symbol writer. A Windows OS might be required.");
				debugDirectory.DontWriteAnything = true;
				return;
			}

			var pdbWriter = new PdbWriter(symWriter, pdbState, metaData);
			try {
				pdbWriter.Logger = TheOptions.Logger;
				pdbWriter.Write();

				debugDirectory.Data = pdbWriter.GetDebugInfo(out debugDirectory.debugDirData);
				debugDirectory.TimeDateStamp = GetTimeDateStamp();
				pdbWriter.Dispose();
			}
			catch {
				pdbWriter.Dispose();
				DeleteFileNoThrow(createdPdbFileName);
				throw;
			}
		}
Example #3
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);
                    }
                }
            }
Example #4
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);
				}
			}