GetDebugInfo() public method

public GetDebugInfo ( int instructionIndex ) : Microsoft.Scripting.Interpreter.DebugInfo
instructionIndex int
return Microsoft.Scripting.Interpreter.DebugInfo
Beispiel #1
0
        private static RubyArray/*!*/ AddBacktrace(RubyArray/*!*/ result, IEnumerable<StackFrame> stackTrace,
            ref InterpretedFrame interpretedFrame, InterpretedFrame handlerFrame,
            bool hasFileAccessPermission, int skipFrames, bool exceptionDetail) {

            if (stackTrace != null) {
                foreach (StackFrame frame in stackTrace) {
                    string methodName, file;
                    int line;

                    if (InterpretedFrame.IsInterpretedFrame(frame.GetMethod())) {
                        // TODO: get language context, ask for method name?
                        // TODO: the trace can get corrupted if Python frame are in the middle - we need to move frame tracing to the interpreter
                        if (interpretedFrame == null) {
                            continue;
                        }

                        var debugInfo = interpretedFrame.GetDebugInfo(
                            (interpretedFrame == handlerFrame) ? interpretedFrame.FaultingInstruction : interpretedFrame.InstructionIndex
                        );

                        if (debugInfo != null) {
                            file = debugInfo.FileName;
                            line = debugInfo.StartLine;
                        } else {
                            file = null;
                            line = 0;
                        }
                        methodName = interpretedFrame.Lambda.Name;
                        TryParseRubyMethodName(ref methodName, ref file, ref line);
                        
                        interpretedFrame = interpretedFrame.Parent;                        
                    } else if (!TryGetStackFrameInfo(frame, hasFileAccessPermission, exceptionDetail, out methodName, out file, out line)) {
                        continue;
                    }

                    if (skipFrames == 0) {
                        result.Add(MutableString.Create(FormatFrame(file, line, methodName), RubyEncoding.UTF8));
                    } else {
                        skipFrames--;
                    }
                }
            }

            return result;
        }