public CorDebugBacktrace(CorDebugThread thread, MicroFrameworkDebuggerSession session) : base(session.ObjectAdapter)
 {
     this.session  = session;
     this.thread   = thread;
     threadId      = thread.Id;
     frames        = new List <CorDebugFrame> (GetFrames(thread));
     evalTimestamp = MicroFrameworkDebuggerSession.EvaluationTimestamp;
 }
Ejemplo n.º 2
0
        public MethodSymbols GetMethodSymbols(MicroFrameworkDebuggerSession session)
        {
            if (Assembly.DebugData == null)
            {
                return(null);
            }
            var methodSymols = new MethodSymbols(new MetadataToken(PdbxMethod.Token.CLR));

            //Ugliest hack ever
            if (Assembly.DebugData is Mono.Cecil.Mdb.MdbReader)
            {
                for (int i = 0; i < 100; i++)
                {
                    methodSymols.Variables.Add(new VariableDefinition(null));
                }
            }
            Assembly.DebugData.Read(methodSymols);
            return(methodSymols);
        }
        internal static StackFrame CreateFrame(MicroFrameworkDebuggerSession session, CorDebugFrame frame)
        {
            string file   = "";
            int    line   = 0;
            string method = "";
            string lang   = "";

            if (frame.FrameType == CorFrameType.ILFrame)
            {
                if (frame.Function != null)
                {
                    uint tk = TinyCLR_TypeSystem.SymbollessSupport.TinyCLRTokenFromMethodDefToken(frame.Function.Token);
                    uint md = TinyCLR_TypeSystem.ClassMemberIndexFromTinyCLRToken(tk, frame.Function.Assembly);
                    method = session.Engine.GetMethodName(md, true);
                    var debugData = frame.Function.GetMethodInfo(session)?.DebugInformation;
                    if (debugData != null)
                    {
                        SequencePoint prevSp = null;
                        foreach (var sp in debugData.SequencePoints)
                        {
                            if (sp.Offset > frame.IP)
                            {
                                break;
                            }
                            prevSp = sp;
                        }
                        if (prevSp.Offset != -1)
                        {
                            line = prevSp.StartLine;
                            file = prevSp.Document.Url;
                        }
                    }
                }
                lang = "Managed";
            }
//			else if(frame.FrameType == CorFrameType.NativeFrame)
//			{
//				frame.GetNativeIP(out address);
//				method = "<Unknown>";
//				lang = "Native";
//			}
            else if (frame.FrameType == CorFrameType.InternalFrame)
            {
                switch (((CorDebugInternalFrame)frame).FrameInternalType)
                {
                case CorDebugInternalFrameType.STUBFRAME_M2U:
                    method = "[Managed to Native Transition]";
                    break;

                case CorDebugInternalFrameType.STUBFRAME_U2M:
                    method = "[Native to Managed Transition]";
                    break;

                case CorDebugInternalFrameType.STUBFRAME_LIGHTWEIGHT_FUNCTION:
                    method = "[Lightweight Method Call]";
                    break;

                case CorDebugInternalFrameType.STUBFRAME_APPDOMAIN_TRANSITION:
                    method = "[Application Domain Transition]";
                    break;

                case CorDebugInternalFrameType.STUBFRAME_FUNC_EVAL:
                    method = "[Function Evaluation]";
                    break;
                }
            }
            if (method == null)
            {
                method = "<Unknown>";
            }
            var loc = new SourceLocation(method, file, line);

            return(new StackFrame((long)0, loc, lang));
        }
 public MethodDefinition GetMethodInfo(MicroFrameworkDebuggerSession session)
 {
     return(Assembly.MetaData != null?Assembly.MetaData.LookupToken((int)Token) as MethodDefinition : null);
 }
Ejemplo n.º 5
0
        internal static StackFrame CreateFrame(MicroFrameworkDebuggerSession session, CorDebugFrame frame)
        {
            string file   = "";
            int    line   = 0;
            string method = "";
            string lang   = "";

            if (frame.FrameType == CorFrameType.ILFrame)
            {
                if (frame.Function != null)
                {
                    uint tk = TinyCLR_TypeSystem.SymbollessSupport.TinyCLRTokenFromMethodDefToken(frame.Function.Token);
                    uint md = TinyCLR_TypeSystem.ClassMemberIndexFromTinyCLRToken(tk, frame.Function.Assembly);
                    method = session.Engine.GetMethodName(md, true);
                    var reader = frame.Function.Assembly.DebugData;
                    if (reader != null)
                    {
                        var sim = new MethodSymbols(new Mono.Cecil.MetadataToken(frame.Function.Token));
                        //Ugliest hack ever
                        if (reader is Mono.Cecil.Mdb.MdbReader)
                        {
                            for (int i = 0; i < 100; i++)
                            {
                                sim.Variables.Add(new VariableDefinition(null));
                            }
                        }
                        reader.Read(sim);
                        InstructionSymbol prevSp = new InstructionSymbol(-1, null);
                        foreach (var sp in sim.Instructions)
                        {
                            if (sp.Offset > frame.IP)
                            {
                                break;
                            }
                            prevSp = sp;
                        }
                        if (prevSp.Offset != -1)
                        {
                            line = prevSp.SequencePoint.StartLine;
                            file = prevSp.SequencePoint.Document.Url;
                        }
                    }
                }
                lang = "Managed";
            }
//			else if(frame.FrameType == CorFrameType.NativeFrame)
//			{
//				frame.GetNativeIP(out address);
//				method = "<Unknown>";
//				lang = "Native";
//			}
            else if (frame.FrameType == CorFrameType.InternalFrame)
            {
                switch (((CorDebugInternalFrame)frame).FrameInternalType)
                {
                case CorDebugInternalFrameType.STUBFRAME_M2U:
                    method = "[Managed to Native Transition]";
                    break;

                case CorDebugInternalFrameType.STUBFRAME_U2M:
                    method = "[Native to Managed Transition]";
                    break;

                case CorDebugInternalFrameType.STUBFRAME_LIGHTWEIGHT_FUNCTION:
                    method = "[Lightweight Method Call]";
                    break;

                case CorDebugInternalFrameType.STUBFRAME_APPDOMAIN_TRANSITION:
                    method = "[Application Domain Transition]";
                    break;

                case CorDebugInternalFrameType.STUBFRAME_FUNC_EVAL:
                    method = "[Function Evaluation]";
                    break;
                }
            }
            if (method == null)
            {
                method = "<Unknown>";
            }
            var loc = new SourceLocation(method, file, line);

            return(new StackFrame((long)0, loc, lang));
        }
Ejemplo n.º 6
0
 public TypeDefinition GetTypeInfo(MicroFrameworkDebuggerSession session)
 {
     return(Class.Assembly.MetaData != null?Class.Assembly.MetaData.LookupToken((int)Class.PdbxClass.Token.CLR) as TypeDefinition : null);
 }