Пример #1
0
		public static IEnumerable<SequencePoint> GetSequencePoints (this ISymbolMethod met)
		{
			int sc = met.SequencePointCount;
			int[] offsets = new int[sc];
			int[] lines = new int[sc];
			int[] endLines = new int[sc];
			int[] columns = new int[sc];
			int[] endColumns = new int[sc];
			ISymbolDocument[] docs = new ISymbolDocument[sc];
			met.GetSequencePoints (offsets, docs, lines, columns, endLines, endColumns);

			for (int n = 0; n < sc; n++) {
				if (columns[n] == 0)
					continue;
				SequencePoint sp = new SequencePoint ();
				sp.Document = docs[n];
				sp.Line = lines[n];
				sp.Offset = offsets[n];
				yield return sp;
			}
		}
Пример #2
0
        internal static StackFrame CreateFrame(CorDebuggerSession session, CorFrame frame)
        {
            // TODO: Fix remaining.
            uint address = 0;
            //string typeFQN;
            //string typeFullName;
            string addressSpace = "";
            string file         = "";
            int    line         = 0;
            int    column       = 0;
            string method       = "";
            string lang         = "";
            string module       = "";
            string type         = "";
            bool   hasDebugInfo = false;
            bool   hidden       = false;
            bool   external     = true;

            if (frame.FrameType == CorFrameType.ILFrame)
            {
                if (frame.Function != null)
                {
                    module = frame.Function.Module.Name;
                    CorMetadataImport importer = new CorMetadataImport(frame.Function.Module);
                    MethodInfo        mi       = importer.GetMethodInfo(frame.Function.Token);
                    method       = mi.DeclaringType.FullName + "." + mi.Name;
                    type         = mi.DeclaringType.FullName;
                    addressSpace = mi.Name;
                    ISymbolReader reader = session.GetReaderForModule(frame.Function.Module.Name);
                    if (reader != null)
                    {
                        ISymbolMethod met = reader.GetMethod(new SymbolToken(frame.Function.Token));
                        if (met != null)
                        {
                            CorDebugMappingResult mappingResult;
                            frame.GetIP(out address, out mappingResult);
                            SequencePoint prevSp = null;
                            foreach (SequencePoint sp in met.GetSequencePoints())
                            {
                                if (sp.Offset > address)
                                {
                                    break;
                                }
                                prevSp = sp;
                            }
                            if (prevSp != null)
                            {
                                line    = prevSp.Line;
                                column  = prevSp.Offset;
                                file    = prevSp.Document.URL;
                                address = (uint)prevSp.Offset;
                            }
                        }
                    }
                    // FIXME: Still steps into.
                    //hidden = mi.GetCustomAttributes (true).Any (v => v is System.Diagnostics.DebuggerHiddenAttribute);
                }
                lang         = "Managed";
                hasDebugInfo = true;
            }
            else if (frame.FrameType == CorFrameType.NativeFrame)
            {
                frame.GetNativeIP(out address);
                method = "<Unknown>";
                lang   = "Native";
            }
            else if (frame.FrameType == CorFrameType.InternalFrame)
            {
                switch (frame.InternalFrameType)
                {
                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, column);

            return(new StackFrame((long)address, addressSpace, loc, lang, external, hasDebugInfo, hidden, null, null));
        }
Пример #3
0
        void Step(bool into)
        {
            if (stepper != null)
            {
                stepper.IsActive();
                CorFrame      frame  = activeThread.ActiveFrame;
                ISymbolReader reader = GetReaderForModule(frame.Function.Module.Name);
                if (reader == null)
                {
                    RawContinue(into);
                    return;
                }
                ISymbolMethod met = reader.GetMethod(new SymbolToken(frame.Function.Token));
                if (met == null)
                {
                    RawContinue(into);
                    return;
                }

                uint offset;
                CorDebugMappingResult mappingResult;
                frame.GetIP(out offset, out mappingResult);

                // Find the current line
                SequencePoint currentSeq = null;
                foreach (SequencePoint sp in met.GetSequencePoints())
                {
                    if (sp.Offset > offset)
                    {
                        break;
                    }
                    currentSeq = sp;
                }

                if (currentSeq == null)
                {
                    RawContinue(into);
                    return;
                }

                // Exclude all ranges belonging to the current line
                List <COR_DEBUG_STEP_RANGE> ranges = new List <COR_DEBUG_STEP_RANGE> ();
                SequencePoint lastSeq = null;
                foreach (SequencePoint sp in met.GetSequencePoints())
                {
                    if (lastSeq != null && lastSeq.Line == currentSeq.Line)
                    {
                        COR_DEBUG_STEP_RANGE r = new COR_DEBUG_STEP_RANGE();
                        r.startOffset = (uint)lastSeq.Offset;
                        r.endOffset   = (uint)sp.Offset;
                        ranges.Add(r);
                    }
                    lastSeq = sp;
                }

                stepper.StepRange(into, ranges.ToArray());

                ClearEvalStatus();
                process.SetAllThreadsDebugState(CorDebugThreadState.THREAD_RUN, null);
                process.Continue(false);
            }
        }
Пример #4
0
        internal static StackFrame CreateFrame(CorDebuggerSession session, CorFrame frame)
        {
            uint   address = 0;
            string file    = "";
            int    line    = 0;
            string method  = "";
            string lang    = "";
            string module  = "";

            if (frame.FrameType == CorFrameType.ILFrame)
            {
                if (frame.Function != null)
                {
                    module = frame.Function.Module.Name;
                    CorMetadataImport importer = new CorMetadataImport(frame.Function.Module);
                    MethodInfo        mi       = importer.GetMethodInfo(frame.Function.Token);
                    method = mi.DeclaringType.FullName + "." + mi.Name;
                    ISymbolReader reader = session.GetReaderForModule(frame.Function.Module.Name);
                    if (reader != null)
                    {
                        ISymbolMethod met = reader.GetMethod(new SymbolToken(frame.Function.Token));
                        if (met != null)
                        {
                            uint offset;
                            CorDebugMappingResult mappingResult;
                            frame.GetIP(out offset, out mappingResult);
                            SequencePoint prevSp = null;
                            foreach (SequencePoint sp in met.GetSequencePoints())
                            {
                                if (sp.Offset > offset)
                                {
                                    break;
                                }
                                prevSp = sp;
                            }
                            if (prevSp != null)
                            {
                                line = prevSp.Line;
                                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 (frame.InternalFrameType)
                {
                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>";
            }
            return(new StackFrame((long)address, module, method, file, line, lang));
        }