public override Task <DebugResult> Scopes(int frameId) { var scopes = new List <Scope>(); var frame = _frameHandles.Get(frameId, null); if (frame.Index == 0 && _exception != null) { scopes.Add(new Scope("Exception", _variableHandles.Create(new ObjectValue[] { _exception }))); } var parameters = new[] { frame.GetThisReference() }.Concat(frame.GetParameters()).Where(x => x != null); if (parameters.Any()) { scopes.Add(new Scope("Argument", _variableHandles.Create(parameters.ToArray()))); } var locals = frame.GetLocalVariables(); if (locals.Length > 0) { scopes.Add(new Scope("Local", _variableHandles.Create(locals))); } return(Task.FromResult(new DebugResult(new ScopesResponseBody(scopes)))); }
public override void Scopes(Response response, dynamic args) { int frameId = getInt(args, "frameId", 0); var frame = _frameHandles.Get(frameId, null); var scopes = new List <Scope>(); if (frame.Index == 0 && _exception != null) { scopes.Add(new Scope("Exception", _variableHandles.Create(new ObjectValue[] { _exception }))); } var parameters = new[] { frame.GetThisReference() }.Concat(frame.GetParameters()).Where(x => x != null); if (parameters.Any()) { scopes.Add(new Scope("Argument", _variableHandles.Create(parameters.ToArray()))); } var locals = frame.GetLocalVariables(); if (locals.Length > 0) { scopes.Add(new Scope("Local", _variableHandles.Create(locals))); } SendResponse(response, new ScopesResponseBody(scopes)); }
public override void Scopes(Response response, dynamic args) { int frameId = GetInt(args, "frameId", 0); var frame = m_FrameHandles.Get(frameId, null); var scopes = new List <Scope>(); if (frame.Index == 0 && m_Exception != null) { scopes.Add(new Scope("Exception", m_VariableHandles.Create(new[] { m_Exception }))); } var locals = new[] { frame.GetThisReference() }.Concat(frame.GetParameters()).Concat(frame.GetLocalVariables()).Where(x => x != null).ToArray(); if (locals.Length > 0) { scopes.Add(new Scope("Local", m_VariableHandles.Create(locals))); } SetResponse(response, new ScopesResponseBody(scopes)); }
/// <inheritdoc/> public void StackTrace(IStackTraceCommand cmd) { var threadState = m_state.GetThreadState(cmd.ThreadId); int startFrame = cmd.StartFrame ?? 0; int maxNumberOfFrames = cmd.Levels ?? int.MaxValue; var frames = threadState.StackTrace.Skip(startFrame).Take(maxNumberOfFrames).Select((entry, idx) => { var functionName = entry.FunctionName; var source = new Source(TranslateBuildXLPath(entry.File)); var id = m_scopeHandles.Create(new FrameContext(cmd.ThreadId, startFrame + idx, threadState)); return((IStackFrame) new StackFrame(id, functionName, source, entry.Line, entry.Position)); }).ToList(); cmd.SendResult(new StackTraceResult(frames)); }
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 <VSCodeDebug.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); if (sourceName == null) { sourceName = string.Empty; } var source = new Source(sourceName, ConvertDebuggerPathToClient(path)); stackFrames.Add(new VSCodeDebug.StackFrame(frameHandle, name, source, ConvertDebuggerLineToClient(line), 0)); } } SendResponse(response, new StackTraceResponseBody(stackFrames)); }
public override Task <DebugResult> StackTrace(int threadReference, int maxLevels) { CommandLine.WaitForSuspend(); var stackFrames = new List <OpenDebug.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 < bt.FrameCount; 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 OpenDebug.StackFrame(frameHandle, name, source, ConvertDebuggerLineToClient(line), 0)); } } return(Task.FromResult(new DebugResult(new StackTraceResponseBody(stackFrames)))); }
/// <summary> /// A shortcut for creating a <code cref="Scope"/> from an <code cref="ObjectContext"/>. /// </summary> internal Scope CreateScope(ObjectContext objContext) { return(new Scope(GetObjectInfo(objContext).Preview, m_handles.Create(objContext))); }
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)); }