2 Copyright (C) 2008, 2009 Jeroen Frijters
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
25 using System.Runtime.InteropServices;
26 using System.Diagnostics.SymbolStore;
27 using IKVM.Reflection.Emit;
29 namespace IKVM.Reflection.Impl
31 [StructLayout(LayoutKind.Sequential)]
32 struct IMAGE_DEBUG_DIRECTORY
34 public uint Characteristics;
35 public uint TimeDateStamp;
36 public ushort MajorVersion;
37 public ushort MinorVersion;
39 public uint SizeOfData;
40 public uint AddressOfRawData;
41 public uint PointerToRawData;
44 interface ISymbolWriterImpl : ISymbolWriter
46 byte[] GetDebugInfo(ref IMAGE_DEBUG_DIRECTORY idd);
47 void RemapToken(int oldToken, int newToken);
48 void DefineLocalVariable2(string name, FieldAttributes attributes, int signature, SymAddressKind addrKind, int addr1, int addr2, int addr3, int startOffset, int endOffset);
49 void OpenMethod(SymbolToken symbolToken, MethodBase mb);
52 static class SymbolSupport
54 internal static ISymbolWriterImpl CreateSymbolWriterFor(ModuleBuilder moduleBuilder)
57 throw new NotSupportedException("IKVM.Reflection compiled with NO_SYMBOL_WRITER does not support writing debugging symbols.");
59 if (Universe.MonoRuntime)
62 return new MdbWriter(moduleBuilder);
64 throw new NotSupportedException("IKVM.Reflection must be compiled with MONO defined to support writing Mono debugging symbols.");
69 return new PdbWriter(moduleBuilder);
74 internal static byte[] GetDebugInfo(ISymbolWriterImpl writer, ref IMAGE_DEBUG_DIRECTORY idd)
76 return writer.GetDebugInfo(ref idd);
79 internal static void RemapToken(ISymbolWriterImpl writer, int oldToken, int newToken)
81 writer.RemapToken(oldToken, newToken);