コード例 #1
0
ファイル: PdbWriter.cs プロジェクト: atykhyy/cecil
        public void Write(MethodBody body)
        {
            var method_token = body.Method.MetadataToken;
            var sym_token = new SymbolToken (method_token.ToInt32 ());

            var instructions = CollectInstructions (body);
            if (instructions.Count == 0 && !body.HasVariables)
                return;

            writer.OpenMethod (sym_token);

            DefineSequencePoints (instructions);

            if (body.Scope != null)
                WriteScope (body, body.Scope);
            else
            if (body.HasVariables)
            {
                var start_offset = 0;
                var end_offset = body.CodeSize;

                writer.OpenScope  (start_offset);
                DefineVariables   (body, body.Variables, start_offset, end_offset);
                writer.CloseScope (end_offset);
            }

            if (body.IteratorType != null)
                DefineIteratorType   (sym_token, body.IteratorType.Name);

            if (body.iterator_scopes != null)
                DefineIteratorScopes (sym_token, body.IteratorScopes, body.CodeSize);

            writer.CloseMethod ();
        }
コード例 #2
0
ファイル: PdbWriter.cs プロジェクト: pusp/o2platform
		void CreateScopes (MethodBody body, ScopeCollection scopes, SymbolToken localVarToken)
		{
			foreach (Scope s in scopes) {
				int startOffset = s.Start.Offset;
				int endOffset = s.End == body.Instructions.Outside ?
					body.Instructions[body.Instructions.Count - 1].Offset + 1 :
					s.End.Offset;

				m_writer.OpenScope (startOffset);
				m_writer.UsingNamespace (body.Method.DeclaringType.Namespace);
				m_writer.OpenNamespace (body.Method.DeclaringType.Namespace);

				int start = body.Instructions.IndexOf (s.Start);
				int end = s.End == body.Instructions.Outside ?
					body.Instructions.Count - 1 :
					body.Instructions.IndexOf (s.End);

				ArrayList instructions = CollectSequencePoints (body, start, end);
				DefineSequencePoints (instructions);

				CreateLocalVariable (s, startOffset, endOffset, localVarToken);

				CreateScopes (body, s.Scopes, localVarToken);
				m_writer.CloseNamespace ();

				m_writer.CloseScope (endOffset);
			}
		}
コード例 #3
0
ファイル: SymbolReader.cs プロジェクト: EmilZhou/dnlib
		public ISymbolMethod GetMethod(SymbolToken method, int version) {
			ISymUnmanagedMethod unMethod;
			int hr = reader.GetMethodByVersion((uint)method.GetToken(), version, out unMethod);
			if (hr == E_FAIL)
				return null;
			Marshal.ThrowExceptionForHR(hr);
			return unMethod == null ? null : new SymbolMethod(unMethod);
		}
コード例 #4
0
	public virtual void DefineField
				(SymbolToken parent, String name,
				 FieldAttributes attributes, 
				 byte[] signature, 
				 SymAddressKind addrKind, 
				 int addr1, int addr2, int addr3)
			{
				throw new NotSupportedException();
			}
コード例 #5
0
ファイル: SymReader.cs プロジェクト: elemk0vv/roslyn-1
 public int GetMethodByVersion(SymbolToken methodToken, int version, out ISymUnmanagedMethod retVal)
 {
     var hr = _reader.GetMethodByVersion(methodToken, version, out retVal);
     if (retVal != null)
     {
         retVal = new SymMethod(this, retVal);
     }
     return hr;
 }
コード例 #6
0
ファイル: PdbWriter.cs プロジェクト: peterwald/cecil
        public void Write(MethodBody body)
        {
            var method_token = body.Method.MetadataToken;
            var sym_token = new SymbolToken (method_token.ToInt32 ());

            writer.OpenMethod (sym_token);
            DefineSequencePoints (body);
            DefineVariables (body);
            writer.CloseMethod ();
        }
コード例 #7
0
 private ISymUnmanagedMethod GetSymMethod(SymbolToken token)
 {
     try
     {
         return _comReader.GetMethod(token);
     }
     catch
     {
         return null;
     }
 }
コード例 #8
0
		public void DefineLocalVariable2 (string name,
										  FieldAttributes attributes,
										  SymbolToken sigToken,
										  SymAddressKind addrKind,
										  int addr1,
										  int addr2,
										  int addr3,
										  int startOffset,
										  int endOffset)
		{
			((ISymUnmanagedWriter2)m_writer).DefineLocalVariable2 (name, (int)attributes, sigToken, (int)addrKind, addr1, addr2, addr3, startOffset, endOffset);
		}
コード例 #9
0
ファイル: PdbWriter.cs プロジェクト: jbevain/cecil
 void CreateLocalVariable(VariableDebugInformation variable, SymbolToken local_var_token, int start_offset, int end_offset)
 {
     writer.DefineLocalVariable2 (
         variable.Name,
         variable.Attributes,
         local_var_token,
         SymAddressKind.ILOffset,
         variable.Index,
         0,
         0,
         start_offset,
         end_offset);
 }
コード例 #10
0
ファイル: LowLevelApi.cs プロジェクト: xeno-by/truesight-lite
 public static ISymbolMethod GetSymReader(this MethodBase method)
 {
     var reader = method.Module.GetSymReader();
     if (reader == null)
     {
         return null;
     }
     else
     {
         var token = new SymbolToken(method.MetadataToken);
         return reader.GetMethod(token);
     }
 }
コード例 #11
0
ファイル: PdbWriter.cs プロジェクト: XQuantumForceX/Reflexil
		void DefineVariables (MethodBody body, int start_offset, int end_offset)
		{
			if (!body.HasVariables)
				return;

			var sym_token = new SymbolToken (body.LocalVarToken.ToInt32 ());

			var variables = body.Variables;
			for (int i = 0; i < variables.Count; i++) {
				var variable = variables [i];
				CreateLocalVariable (variable, sym_token, start_offset, end_offset);
			}
		}
コード例 #12
0
ファイル: PdbWriter.cs プロジェクト: jbevain/cecil
        public void Write(MethodDebugInformation info)
        {
            var method_token = info.method.MetadataToken;
            var sym_token = new SymbolToken (method_token.ToInt32 ());

            writer.OpenMethod (sym_token);

            if (!info.sequence_points.IsNullOrEmpty ())
                DefineSequencePoints (info.sequence_points);

            if (info.scope != null)
                DefineScope (info.scope, info);

            writer.CloseMethod ();
        }
コード例 #13
0
        public virtual ISymbolMethod GetMethod(SymbolToken method, int version)
        {
            ISymbolMethod meth;

            if (methodCache == null)
            {
                methodCache = new Hashtable();
            }
            else if ((meth = (ISymbolMethod)methodCache
                             [method.GetToken()]) != null)
            {
                return(meth);
            }
            meth = new SymMethod(this, method.GetToken());
            methodCache[method.GetToken()] = meth;
            return(meth);
        }
コード例 #14
0
ファイル: PdbWriter.cs プロジェクト: XQuantumForceX/Reflexil
		public void Write (MethodBody body)
		{
			var method_token = body.Method.MetadataToken;
			var sym_token = new SymbolToken (method_token.ToInt32 ());

			var instructions = CollectInstructions (body);
			if (instructions.Count == 0)
				return;

			var start_offset = 0;
			var end_offset = body.CodeSize;

			writer.OpenMethod (sym_token);
			writer.OpenScope (start_offset);

			DefineSequencePoints (instructions);
			DefineVariables (body, start_offset, end_offset);

			writer.CloseScope (end_offset);
			writer.CloseMethod ();
		}
コード例 #15
0
        public bool TryGetFunctionByLocation(SourceLocation location, out SymbolToken token)
        {
            token = default(SymbolToken);

            try
            {
                var document = _comReader.GetDocument(location.FilePath.FullPath, default(Guid), default(Guid), default(Guid));
                if (document == null)
                    return false;

                var method = _comReader.GetMethodFromDocumentPosition(document, location.Line, location.Column);
                if (method == null)
                    return false;

                token = method.GetToken();
                return true;
            }
            catch (COMException)
            {
                return false;
            }
        }
コード例 #16
0
ファイル: SymbolReader.cs プロジェクト: EmilZhou/dnlib
		public ISymbolVariable[] GetVariables(SymbolToken parent) {
			uint numVars;
			reader.GetVariables((uint)parent.GetToken(), 0, out numVars, null);
			var unVars = new ISymUnmanagedVariable[numVars];
			reader.GetVariables((uint)parent.GetToken(), (uint)unVars.Length, out numVars, unVars);
			var vars = new ISymbolVariable[numVars];
			for (uint i = 0; i < numVars; i++)
				vars[i] = new SymbolVariable(unVars[i]);
			return vars;
		}
コード例 #17
0
ファイル: SymWriter.cs プロジェクト: jredville/ipydbg
 /// <include file='doc\SymWriter.uex' path='docs/doc[@for="SymbolWriter.DefineLocalVariable1"]/*' />
 public void DefineLocalVariable([MarshalAs(UnmanagedType.LPWStr)] String name,
                                 int attributes,
                                 SymbolToken sigToken,
                                 int addressKind,
                                 int addr1,
                                 int addr2,
                                 int addr3,
                                 int startOffset,
                                 int endOffset)
 {
     ((ISymUnmanagedWriter2)m_target).DefineLocalVariable2(name, attributes, sigToken,
                                  addressKind, addr1, addr2, addr3, startOffset, endOffset);
 }
コード例 #18
0
ファイル: SymWriter.cs プロジェクト: jredville/ipydbg
 /// <include file='doc\SymWriter.uex' path='docs/doc[@for="SymbolWriter.RemapToken"]/*' />
 public void RemapToken(SymbolToken oldToken,
                     SymbolToken newToken)
 {
     m_target.RemapToken(oldToken, newToken);
 }
コード例 #19
0
		public void OpenMethod (SymbolToken method)
		{
			m_writer.OpenMethod (method);
		}
コード例 #20
0
ファイル: SymWriter.cs プロジェクト: jredville/ipydbg
 /// <include file='doc\SymWriter.uex' path='docs/doc[@for="SymbolWriter.DefineConstant1"]/*' />
 public void DefineConstant([MarshalAs(UnmanagedType.LPWStr)] String name,
                           Object value,
                           SymbolToken sigToken)
 {
     ((ISymUnmanagedWriter2)m_target).DefineConstant2(name, value, sigToken);
 }
コード例 #21
0
ファイル: SymWriter.cs プロジェクト: ForNeVeR/pnet
 public virtual void OpenMethod(SymbolToken method)
 {
     // Nothing to do here.
 }
コード例 #22
0
 public bool Equals(SymbolToken obj) // Method.
 {
     return(obj.m_token == this.m_token);
 }
コード例 #23
0
 public virtual byte[] GetSymAttribute(SymbolToken parent, String name)
 {
     throw new NotSupportedException();
 }
コード例 #24
0
ファイル: SymWriter.cs プロジェクト: jredville/ipydbg
 /// <include file='doc\SymWriter.uex' path='docs/doc[@for="SymbolWriter.SetUserEntryPoint"]/*' />
 public void SetUserEntryPoint(SymbolToken entryMethod)
 {
     m_target.SetUserEntryPoint(entryMethod);
 }
コード例 #25
0
 public virtual ISymbolVariable[] GetVariables(SymbolToken parent)
 {
     throw new NotSupportedException();
 }
コード例 #26
0
ファイル: Token.cs プロジェクト: alisci01/cs2cpp
 public bool Equals(SymbolToken obj)
 {
     return(obj.m_token == m_token);
 }
コード例 #27
0
 public bool Equals(SymbolToken obj)
 {
     return(obj.GetToken() == _val);
 }
コード例 #28
0
ファイル: SymWriter.cs プロジェクト: ForNeVeR/pnet
 public virtual void SetUserEntryPoint(SymbolToken entryMethod)
 {
     // Nothing to do here.
 }
コード例 #29
0
ファイル: PdbWriter.cs プロジェクト: atykhyy/cecil
        void DefineIteratorType(SymbolToken method_token, string name)
        {
            var buffer = new PE.ByteBuffer ();
            buffer.WriteByte (4);
            buffer.WriteByte (1);
            buffer.Align     (4);
            buffer.WriteByte (4);
            buffer.WriteByte (4);
            buffer.Align	 (4);

            var length = 10 + (uint) name.Length * 2;
            while (length % 4 > 0)
                length++;

            buffer.WriteUInt32 (length);
            buffer.WriteBytes (System.Text.Encoding.Unicode.GetBytes (name));
            buffer.WriteByte (0);
            buffer.Align	 (4);

            writer.SetSymAttribute (method_token, "MD2", buffer.length, buffer.buffer);
        }
コード例 #30
0
ファイル: MethodBuilder.cs プロジェクト: stabbylambda/mono
		internal void GenerateDebugInfo (ISymbolWriter symbolWriter)
		{
			if (ilgen != null && ilgen.HasDebugInfo) {
				SymbolToken token = new SymbolToken (GetToken().Token);
				symbolWriter.OpenMethod (token);
				symbolWriter.SetSymAttribute (token, "__name", System.Text.Encoding.UTF8.GetBytes (Name));
				ilgen.GenerateDebugInfo (symbolWriter);
				symbolWriter.CloseMethod ();
			}
		}
コード例 #31
0
ファイル: PdbWriter.cs プロジェクト: atykhyy/cecil
        void DefineVariables(MethodSymbols symbols, Collection<VariableDefinition> variables, int start_offset, int end_offset)
        {
            var sym_token = new SymbolToken (symbols.LocalVarToken.ToInt32 ());

            for (int i = 0; i < variables.Count; i++) {
                var variable = variables [i];
                CreateLocalVariable (variable, sym_token, start_offset, end_offset);
            }
        }
コード例 #32
0
ファイル: SymWriter.cs プロジェクト: ttRevan/cecil
 public void SetUserEntryPoint(SymbolToken method)
 {
     m_writer.SetUserEntryPoint (method);
 }
コード例 #33
0
 public virtual ISymbolMethod GetMethod(SymbolToken method)
 {
     return(GetMethod(method, 0));
 }
コード例 #34
0
ファイル: SymWriter.cs プロジェクト: ForNeVeR/pnet
 public virtual void SetSymAttribute
     (SymbolToken parent, String name, byte[] data)
 {
     // Nothing to do here.
 }
コード例 #35
0
ファイル: PdbWriter.cs プロジェクト: pusp/o2platform
		void CreateLocalVariable (IVariableDefinitionProvider provider, int startOffset, int endOffset, SymbolToken localVarToken)
		{
			for (int i = 0; i < provider.Variables.Count; i++) {
				VariableDefinition var = provider.Variables [i];
 				m_writer.DefineLocalVariable2(
  					var.Name,
  					0,
 					localVarToken,
  					SymAddressKind.ILOffset,
 					var.Index,
  					0,
  					0,
  					startOffset,
					endOffset);
			}
		}
コード例 #36
0
ファイル: SymWriter.cs プロジェクト: jredville/ipydbg
 /// <include file='doc\SymWriter.uex' path='docs/doc[@for="SymbolWriter.DefineField"]/*' />
 public void DefineField(SymbolToken parent,
                         String name,
                         FieldAttributes attributes,
                         byte[] signature,
                         SymAddressKind addressKind,
                         int addr1,
                         int addr2,
                         int addr3)
 {
     m_target.DefineField(parent, name, (int)attributes, signature.Length, signature,
                          (int)addressKind, addr1, addr2, addr3);
 }
 //
 // Summary:
 //     Determines whether obj is equal to this instance.
 //
 // Parameters:
 //   obj:
 //     The System.Diagnostics.SymbolStore.SymbolToken to check.
 //
 // Returns:
 //     true if obj is equal to this instance; otherwise, false.
 public bool Equals(SymbolToken obj);
コード例 #38
0
ファイル: SymWriter.cs プロジェクト: jredville/ipydbg
 /// <include file='doc\SymWriter.uex' path='docs/doc[@for="SymbolWriter.OpenMethod"]/*' />
 public void OpenMethod(SymbolToken method)
 {
     m_target.OpenMethod(method);
 }
コード例 #39
0
ファイル: SymbolReader.cs プロジェクト: EmilZhou/dnlib
		public byte[] GetSymAttribute(SymbolToken parent, string name) {
			uint bufSize;
			reader.GetSymAttribute((uint)parent.GetToken(), name, 0, out bufSize, null);
			var buffer = new byte[bufSize];
			reader.GetSymAttribute((uint)parent.GetToken(), name, (uint)buffer.Length, out bufSize, buffer);
			return buffer;
		}
コード例 #40
0
ファイル: SymWriter.cs プロジェクト: jredville/ipydbg
 /// <include file='doc\SymWriter.uex' path='docs/doc[@for="SymbolWriter.SetSymAttribute"]/*' />
 public void SetSymAttribute(SymbolToken parent, String name, byte[] data)
 {
     m_target.SetSymAttribute(parent, name, data.Length, data);
 }
コード例 #41
0
ファイル: SymbolToken.cs プロジェクト: PlumpMath/CIL2Java
 /// <summary>Determines whether <paramref name="obj" /> is equal to this instance.</summary><returns>true if <paramref name="obj" /> is equal to this instance; otherwise, false.</returns><param name="obj">The <see cref="T:System.Diagnostics.SymbolStore.SymbolToken" /> to check.</param>
 public bool Equals(SymbolToken obj)
 {
     throw new NotImplementedException();
 }
コード例 #42
0
        [System.Security.SecurityCritical]  // auto-generated
        private void SetUserEntryPointNoLock(MethodInfo entryPoint)
        {
            // Set the user entry point. Compiler may generate startup stub before calling user main.
            // The startup stub will be the entry point. While the user "main" will be the user entry
            // point so that debugger will not step into the compiler entry point.

            if (entryPoint == null)
            {
                throw new ArgumentNullException("entryPoint");
            }
            Contract.EndContractBlock();
        
            if (m_iSymWriter == null)
            {
                // Cannot set entry point when it is not a debug module
                throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotADebugModule"));
            }

            if (entryPoint.DeclaringType != null)
            {
                if (!entryPoint.Module.Equals(this))
                {
                    // you cannot pass in a MethodInfo that is not contained by this ModuleBuilder
                    throw new InvalidOperationException(Environment.GetResourceString("Argument_NotInTheSameModuleBuilder"));
                }
            }
            else
            {
                // unfortunately this check is missing for global function passed in as RuntimeMethodInfo. 
                // The problem is that Reflection does not 
                // allow us to get the containing module giving a global function
                MethodBuilder mb = entryPoint as MethodBuilder;
                if (mb != null && mb.GetModuleBuilder() != this)
                {
                    // you cannot pass in a MethodInfo that is not contained by this ModuleBuilder
                    throw new InvalidOperationException(Environment.GetResourceString("Argument_NotInTheSameModuleBuilder"));                    
                }                    
            }
                
            // get the metadata token value and create the SymbolStore's token value class
            SymbolToken       tkMethod = new SymbolToken(GetMethodTokenInternal(entryPoint).Token);

            // set the UserEntryPoint
            m_iSymWriter.SetUserEntryPoint(tkMethod);
        }
コード例 #43
0
ファイル: SymbolToken.cs プロジェクト: layomia/dotnet_runtime
 public bool Equals(SymbolToken obj) => obj._token == _token;