public EmonicInterpreter.backtraceData Backtrace(bool execute) { if (execute) { EmonicInterpreter.backtraceList.Clear(); // remove all previous elements from the list EmonicLineInterpreter.AddCmd("backtrace"); } EmonicInterpreter.backtraceData btd = EmonicInterpreter.GetNextBacktraceLine(); return(btd); }
protected override object DoExecute(ScriptingContext context) { Backtrace backtrace = null; if ((mode == Backtrace.Mode.Default) && (max_frames == -1)) backtrace = CurrentThread.CurrentBacktrace; if (backtrace == null) backtrace = CurrentThread.GetBacktrace (mode, max_frames); for (int i = 0; i < backtrace.Count; i++) { string prefix = i == backtrace.CurrentFrameIndex ? "(*)" : " "; context.Print ("{0} {1}", prefix, backtrace [i]); EmonicInterpreter.backtraceData bt = new EmonicInterpreter.backtraceData(); bt.frameNumber = backtrace[i].Level; bt.currentFrame = i == backtrace.CurrentFrameIndex; if (backtrace[i].Method != null) { bt.method = backtrace[i].Method.Name; if (bt.method == null) bt.method = ""; } else { if (backtrace[i].Name == null) bt.method = ""; else { bt.method = backtrace[i].Name.ToString(); if (bt.method == null) bt.method = ""; } } if (backtrace[i].SourceAddress != null && backtrace[i].SourceAddress.SourceFile != null) bt.file = backtrace[i].SourceAddress.SourceFile.FileName; else bt.file = ""; if (backtrace[i].SourceAddress != null) bt.lineNumber = backtrace[i].SourceAddress.Row; else bt.lineNumber = -1; if (i+1 < backtrace.Count) bt.moreData = true; else bt.moreData = false; EmonicInterpreter.backtraceList.Add(bt); } return backtrace; }
protected override object DoExecute(ScriptingContext context) { Backtrace backtrace = null; if ((mode == Backtrace.Mode.Default) && (max_frames == -1)) { backtrace = CurrentThread.CurrentBacktrace; } if (backtrace == null) { backtrace = CurrentThread.GetBacktrace(mode, max_frames); } for (int i = 0; i < backtrace.Count; i++) { string prefix = i == backtrace.CurrentFrameIndex ? "(*)" : " "; context.Print("{0} {1}", prefix, backtrace [i]); EmonicInterpreter.backtraceData bt = new EmonicInterpreter.backtraceData(); bt.frameNumber = backtrace[i].Level; bt.currentFrame = i == backtrace.CurrentFrameIndex; if (backtrace[i].Method != null) { bt.method = backtrace[i].Method.Name; if (bt.method == null) { bt.method = ""; } } else { if (backtrace[i].Name == null) { bt.method = ""; } else { bt.method = backtrace[i].Name.ToString(); if (bt.method == null) { bt.method = ""; } } } if (backtrace[i].SourceAddress != null && backtrace[i].SourceAddress.SourceFile != null) { bt.file = backtrace[i].SourceAddress.SourceFile.FileName; } else { bt.file = ""; } if (backtrace[i].SourceAddress != null) { bt.lineNumber = backtrace[i].SourceAddress.Row; } else { bt.lineNumber = -1; } if (i + 1 < backtrace.Count) { bt.moreData = true; } else { bt.moreData = false; } EmonicInterpreter.backtraceList.Add(bt); } return(backtrace); }