Example #1
0
 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;
 }
Example #2
0
 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;
 }
        public byte[] GetSymAttribute(SymbolToken parent, string name)
        {
            int buffSize;

            HRESULT.ThrowOnFailure(_unmanaged.GetSymAttribute(parent.GetToken(), name, 0, out buffSize, null));

            byte[] buff = new byte[buffSize];

            HRESULT.ThrowOnFailure(_unmanaged.GetSymAttribute(parent.GetToken(), name, buff.Length, out buffSize, buff));

            return(buff);
        }
 public void DefineField(SymbolToken parent, string name, System.Reflection.FieldAttributes attributes,
                         byte[] signature, SymAddressKind addrKind, int addr1, int addr2, int addr3)
 {
     HRESULT.ThrowOnFailure(_unmanaged.DefineField(
                                parent.GetToken(), name, (int)attributes,
                                signature.Length, signature, (int)addrKind, addr1, addr2, addr3));
 }
Example #5
0
        public void Ctor_Value(int value)
        {
            var symbolToken = new SymbolToken(value);

            Assert.Equal(value, symbolToken.GetToken());
            Assert.Equal(value, symbolToken.GetHashCode());
        }
Example #6
0
        // Write out a reference to the entry point method (if one exists)
        private void WriteEntryPoint(ISymbolReader reader)
        {
            // If there is no entry point token (such as in a dll), this will throw.
            SymbolToken token = reader.UserEntryPoint;

            if (token.GetToken() == 0)
            {
                // If the Symbol APIs fail when looking for an entry point token, there is no entry point.
                m_writer.WriteComment(
                    "There is no entry point token such as a 'Main' method. This module is probably a '.dll'");
                return;
            }
            ISymbolMethod m = reader.GetMethod(token);

            Debug.Assert(m != null); // would have thrown by now.

            // Should not throw past this point
            m_writer.WriteComment(
                "This is the token for the 'entry point' method, which is the method that will be called when the assembly is loaded." +
                " This usually corresponds to 'Main'");

            m_writer.WriteStartElement("EntryPoint");
            WriteMethod(m);
            m_writer.WriteEndElement();
        }
        public ISymbolMethod GetMethod(SymbolToken method)
        {
            ISymUnmanagedMethod unmanagedMethod;

            HRESULT.ThrowOnFailure(_unmanaged.GetMethod(method.GetToken(), out unmanagedMethod));

            return(new SymbolMethod(unmanagedMethod));
        }
Example #8
0
        public ISymbolMethod GetMethod(SymbolToken method)
        {
            SymbolMethod result = null;

            methodTokenLookup.TryGetValue(method.GetToken(), out result);

            return(result);
        }
Example #9
0
 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);
 }
Example #10
0
            //------------------------------------------------------------------------------
            // SetSymAttribute() wrapper
            //------------------------------------------------------------------------------
            void ISymbolWriter.SetSymAttribute(SymbolToken parent, string name, byte[] data)
            {
                int hr = m_vtable.SetSymAttribute(m_pWriter, parent.GetToken(), name, data.Length, data);

                if (hr < 0)
                {
                    throw Marshal.GetExceptionForHR(hr) !;
                }
            }
Example #11
0
            //------------------------------------------------------------------------------
            // OpenMethod() wrapper
            //------------------------------------------------------------------------------
            void ISymbolWriter.OpenMethod(SymbolToken method)
            {
                int hr = m_vtable.OpenMethod(m_pWriter, method.GetToken());

                if (hr < 0)
                {
                    throw Marshal.GetExceptionForHR(hr) !;
                }
            }
Example #12
0
            [System.Security.SecurityCritical] // auto-generated
            #endif
            void ISymbolWriter.SetUserEntryPoint(SymbolToken entryMethod)
            {
                int hr = m_vtable.SetUserEntryPoint(m_pWriter, entryMethod.GetToken());

                if (hr < 0)
                {
                    throw Marshal.GetExceptionForHR(hr);
                }
            }
        public ISymbolVariable[] GetVariables(SymbolToken parent)
        {
            int varCount;

            HRESULT.ThrowOnFailure(_unmanaged.GetVariables(parent.GetToken(), 0, out varCount, null));

            var unmanagedVars = new ISymUnmanagedVariable[varCount];

            HRESULT.ThrowOnFailure(_unmanaged.GetVariables(parent.GetToken(), unmanagedVars.Length, out varCount, unmanagedVars));

            var variables = new ISymbolVariable[varCount];

            for (int i = 0; i < varCount; i++)
            {
                variables[i] = new SymbolVariable(unmanagedVars[i]);
            }

            return(variables);
        }
Example #14
0
        ISymbolMethod ISymbolReader.GetMethod(SymbolToken method)
        {
            DbiFunction symMethod;

            if (functions.TryGetValue((uint)method.GetToken(), out symMethod))
            {
                return(symMethod);
            }
            return(null);
        }
Example #15
0
        public ISymbolMethod GetMethod(SymbolToken method)
        {
            ISymUnmanagedMethod unMethod;
            int hr = reader.GetMethod((uint)method.GetToken(), out unMethod);

            if (hr == E_FAIL)
            {
                return(null);
            }
            Marshal.ThrowExceptionForHR(hr);
            return(unMethod == null ? null : new SymbolMethod(unMethod));
        }
Example #16
0
        int ISymUnmanagedReader.GetSymAttribute(SymbolToken token, string name, int bytesDesired, out int bytesRead, byte[] buffer)
        {
            Assert.Equal("MD2", name);

            MethodDebugInfo info;

            if (!_methodDebugInfoMap.TryGetValue(token.GetToken(), out info))
            {
                bytesRead = 0;
                return(SymUnmanagedReaderExtensions.S_FALSE); // This is a guess.  We're not consuming it, so it doesn't really matter.
            }

            Assert.NotNull(info);
            info.Bytes.TwoPhaseCopy(bytesDesired, out bytesRead, buffer);
            return(SymUnmanagedReaderExtensions.S_OK);
        }
Example #17
0
        int ISymUnmanagedReader.GetMethodByVersion(SymbolToken methodToken, int version, out ISymUnmanagedMethod retVal)
        {
            Assert.Equal(1, version);

            MethodDebugInfo info;

            if (!_methodDebugInfoMap.TryGetValue(methodToken.GetToken(), out info))
            {
                retVal = null;
                return(SymUnmanagedReaderExtensions.E_FAIL);
            }

            Assert.NotNull(info);
            retVal = info.Method;
            return(SymUnmanagedReaderExtensions.S_OK);
        }
Example #18
0
        public RuntimeValue CallMemberFunction(RuntimeThread thread, SymbolToken token, params RuntimeValue[] arguments)
        {
            ICorDebugFunction comFunction;

            ComObjectValue.GetVirtualMethod((uint)token.GetToken(), out comFunction);

            var evaluation = thread.CreateEvaluation();

            evaluation.Call(comFunction, arguments.GetComValues().ToArray());

            if (evaluation.WaitForResult(1000))
            {
                return(evaluation.Result);
            }

            throw new TimeoutException("Evaluation timed out.");
        }
Example #19
0
        // Write out a reference to the entry point method (if one exists)
        private void WriteEntryPoint(ISymbolReader reader)
        {
            // If there is no entry point token (such as in a dll), this will throw.
            SymbolToken token = reader.UserEntryPoint;

            if (token.GetToken() == 0)
            {
                // If the Symbol APIs fail when looking for an entry point token, there is no entry point.
                return;
            }

            ISymbolMethod m = reader.GetMethod(token);

            xmlWriter.WriteStartElement("entryPoint");
            WriteMethod(m);
            xmlWriter.WriteEndElement();               // </entryPoint>
        }
Example #20
0
        byte[] ISymbolReader.GetSymAttribute(SymbolToken parent, string name)
        {
            DbiFunction func;
            bool        b = functions.TryGetValue((uint)parent.GetToken(), out func);

            Debug.Assert(b);
            if (!b)
            {
                return(emptyByteArray);
            }
            var res = func.Root.GetSymAttribute(name);

            if (res == null)
            {
                return(emptyByteArray);
            }
            return(res);
        }
Example #21
0
        public RuntimeValue GetFieldValue(RuntimeThread thread, SymbolToken token)
        {
            // TODO: static members

            if (!IsObject)
            {
                throw new InvalidOperationException("Value must be an object in order to get values of fields.");
            }

            RuntimeValue value;

            if (!_fieldValues.TryGetValue(token, out value))
            {
                ICorDebugValue comValue;
                ComObjectValue.GetFieldValue(Type.Class.ComClass, (uint)token.GetToken(), out comValue);
                _fieldValues.Add(token, value = new RuntimeValue(Session, comValue));
            }
            return(value);
        }
Example #22
0
 public void SetSymAttribute(SymbolToken parent, string name, byte[] data)
 {
     writer.SetSymAttribute((uint)parent.GetToken(), name, (uint)data.Length, data);
 }
Example #23
0
 public void OpenMethod(SymbolToken method)
 {
     currentToken = method.GetToken();
 }
 public void OpenMethod(SymbolToken method)
 {
     currentToken = method.GetToken ();
 }
 public void SetUserEntryPoint(SymbolToken entryMethod)
 {
     HRESULT.ThrowOnFailure(_unmanaged.SetUserEntryPoint(entryMethod.GetToken()));
 }
Example #26
0
 public void OpenMethod(SymbolToken method)
 {
     writer.OpenMethod((uint)method.GetToken());
 }
Example #27
0
        public void Ctor_Default()
        {
            var symbolToken = new SymbolToken();

            Assert.Equal(0, symbolToken.GetToken());
        }
Example #28
0
 public void DefineField(SymbolToken parent, string name, System.Reflection.FieldAttributes attributes, byte[] signature, SymAddressKind addrKind, int addr1, int addr2, int addr3)
 {
     writer.DefineField((uint)parent.GetToken(), name, (uint)attributes, (uint)signature.Length, signature, (uint)addrKind, (uint)addr1, (uint)addr2, (uint)addr3);
 }
Example #29
0
 public void SetUserEntryPoint(SymbolToken entryMethod)
 {
     writer.SetUserEntryPoint((uint)entryMethod.GetToken());
 }
Example #30
0
 protected override Token CreateToken(string literal)
 {
     return(SymbolToken.GetToken(literal));
 }
 public void SetSymAttribute(SymbolToken parent, string name, byte[] data)
 {
     HRESULT.ThrowOnFailure(_unmanaged.SetSymAttribute(
                                parent.GetToken(), name, data.Length, data));
 }