public override void StackTrace(Response response, dynamic arguments) { Log.Write($"UnityDebug: StackTrace: {response} ; {arguments}"); int maxLevels = GetInt(arguments, "levels", 10); int startFrame = GetInt(arguments, "startFrame", 0); int threadReference = GetInt(arguments, "threadId", 0); WaitForSuspend(); ThreadInfo thread = DebuggerActiveThread(); if (thread.Id != threadReference) { // Console.Error.WriteLine("stackTrace: unexpected: active thread should be the one requested"); thread = FindThread(threadReference); if (thread != null) { thread.SetActive(); } } var stackFrames = new List <VSCodeDebug.StackFrame>(); var totalFrames = 0; var bt = thread.Backtrace; if (bt != null && bt.FrameCount >= 0) { totalFrames = bt.FrameCount; for (var i = startFrame; i < Math.Min(totalFrames, startFrame + maxLevels); i++) { var frame = bt.GetFrame(i); string path = frame.SourceLocation.FileName; var hint = "subtle"; Source source = null; if (!string.IsNullOrEmpty(path)) { string sourceName = Path.GetFileName(path); if (!string.IsNullOrEmpty(sourceName)) { if (File.Exists(path)) { source = new Source(sourceName, ConvertDebuggerPathToClient(path), 0, "normal"); hint = "normal"; } else { source = new Source(sourceName, null, 1000, "deemphasize"); } } } var frameHandle = m_FrameHandles.Create(frame); string name = frame.SourceLocation.MethodName; int line = frame.SourceLocation.Line; stackFrames.Add(new VSCodeDebug.StackFrame(frameHandle, name, source, ConvertDebuggerLineToClient(line), 0, hint)); } } SetResponse(response, new StackTraceResponseBody(stackFrames, totalFrames)); }
public override void StackTrace(Response response, dynamic args) { int maxLevels = getInt(args, "levels", 10); int threadReference = getInt(args, "threadId", 0); CommandLine.WaitForSuspend(); var stackFrames = new List<StackFrame>(); ThreadInfo thread = Debugger.ActiveThread; if (thread.Id != threadReference) { // Console.Error.WriteLine("stackTrace: unexpected: active thread should be the one requested"); thread = FindThread(threadReference); if (thread != null) { thread.SetActive(); } } var bt = thread.Backtrace; if (bt != null && bt.FrameCount >= 0) { for (var i = 0; i < Math.Min(bt.FrameCount, maxLevels); i++) { var frame = bt.GetFrame(i); var frameHandle = _frameHandles.Create(frame); string name = frame.SourceLocation.MethodName; string path = frame.SourceLocation.FileName; int line = frame.SourceLocation.Line; string sourceName = Path.GetFileName(path); var source = new Source(sourceName, ConvertDebuggerPathToClient(path)); stackFrames.Add(new StackFrame(frameHandle, name, source, ConvertDebuggerLineToClient(line), 0)); } } SendResponse(response, new StackTraceResponseBody(stackFrames)); }
public StackFrame(int id, string name, Source source, int line, int column) { this.id = id; this.name = name; this.source = source; this.line = line; this.column = column; }