Ejemplo n.º 1
0
        internal StackFrame(Thread thread, ICorDebugILFrame corILFrame, uint chainIndex, uint frameIndex)
        {
            this.process                = thread.Process;
            this.thread                 = thread;
            this.appDomain              = process.AppDomains[corILFrame.GetFunction().GetClass().GetModule().GetAssembly().GetAppDomain()];
            this.corILFrame             = corILFrame;
            this.corILFramePauseSession = process.PauseSession;
            this.corFunction            = corILFrame.GetFunction();
            this.chainIndex             = chainIndex;
            this.frameIndex             = frameIndex;

            MetaDataImport metaData      = thread.Process.Modules[corFunction.GetClass().GetModule()].MetaData;
            int            methodGenArgs = metaData.EnumGenericParams(corFunction.GetToken()).Length;
            // Class parameters are first, then the method ones
            List <ICorDebugType> corGenArgs = ((ICorDebugILFrame2)corILFrame).EnumerateTypeParameters().ToList();

            // Remove method parametrs at the end
            corGenArgs.RemoveRange(corGenArgs.Count - methodGenArgs, methodGenArgs);
            List <DebugType> genArgs = new List <DebugType>(corGenArgs.Count);

            foreach (ICorDebugType corGenArg in corGenArgs)
            {
                genArgs.Add(DebugType.CreateFromCorType(this.AppDomain, corGenArg));
            }

            DebugType debugType = DebugType.CreateFromCorClass(
                this.AppDomain,
                null,
                corFunction.GetClass(),
                genArgs.ToArray()
                );

            this.methodInfo = (DebugMethodInfo)debugType.GetMember(corFunction.GetToken());
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Get a field or property of an object with a given name.
 /// </summary>
 public NamedValue GetMember(string name)
 {
     try
     {
         DebugType currentType = this.Type;
         while (currentType != null)
         {
             foreach (MemberInfo memberInfo in currentType.GetMember(name, BindingFlags.All))
             {
                 if (memberInfo is FieldInfo)
                 {
                     return(((FieldInfo)memberInfo).GetValue(this));
                 }
                 if (memberInfo is PropertyInfo)
                 {
                     return(((PropertyInfo)memberInfo).GetValue(this));
                 }
             }
             currentType = currentType.BaseType;
         }
     }
     catch
     {
     }
     return(null);
 }
Ejemplo n.º 3
0
        /// <summary> Get a field or property of an object with a given name. </summary>
        /// <returns> Null if not found </returns>
        public Value GetMemberValue(string name)
        {
            DebugType currentType = this.Type;

            while (currentType != null)
            {
                MemberInfo memberInfo = currentType.GetMember(name);
                if (memberInfo != null)
                {
                    if (memberInfo is FieldInfo)
                    {
                        return(this.GetFieldValue((FieldInfo)memberInfo));
                    }
                    if (memberInfo is PropertyInfo)
                    {
                        return(this.GetPropertyValue((PropertyInfo)memberInfo));
                    }
                }
                currentType = currentType.BaseType;
            }
            return(null);
        }
Ejemplo n.º 4
0
 public static PropertyInfo GetProperty(DebugType t, string name)
 {
     return t.GetMember(name, Debugger.BindingFlags.All)[0] as PropertyInfo;
 }
Ejemplo n.º 5
0
 public static MethodInfo GetMethod(DebugType t, string name)
 {
     return t.GetMember(name, Debugger.BindingFlags.All)[0] as MethodInfo;
 }