Ejemplo n.º 1
0
 public override void Threads(Response response, dynamic arguments)
 {
     OnAdapterMessage?.Invoke(this, "[Threads]");
     handleManager.Reset();
     SendResponse(response, new ThreadsResponseBody(new List <Thread>()
     {
         currentThread
     }));
 }
Ejemplo n.º 2
0
 private void DebuggingService_OnEngineReady(object sender, EventArgs e)
 {
     OnAdapterMessage?.Invoke(this, "Script ready, Waiting for debugger");
     engineReadyEvent.Set();
     if (waitForLaunch)
     {
         configurationDoneEvent.WaitOne();
     }
     OnAdapterMessage?.Invoke(this, "Script continue running");
     DebugAdapterStatus = DebugAdapterStatusEnum.Ready;
 }
Ejemplo n.º 3
0
 private void DebuggingService_OnException(object sender, RuntimeException e)
 {
     if (!IsConnected)
     {
         debuggingService.Step(JavaScriptDiagStepType.JsDiagStepTypeContinue);
         return;
     }
     OnAdapterMessage?.Invoke(this, $"Exception occured at  {e}");
     SendEvent(new StoppedEvent(currentThread.id, "exception", e.ExceptionObject.Display));
     DebugAdapterStatus = DebugAdapterStatusEnum.ExceptionOccured;
 }
Ejemplo n.º 4
0
 private void DebuggingService_OnStepComplete(object sender, BreakPoint e)
 {
     if (!IsConnected)
     {
         debuggingService.Step(JavaScriptDiagStepType.JsDiagStepTypeContinue);
         return;
     }
     OnAdapterMessage?.Invoke(this, $"Step complete at {e}");
     SendEvent(new StoppedEvent(currentThread.id, "step"));
     DebugAdapterStatus = DebugAdapterStatusEnum.StepComplete;
 }
Ejemplo n.º 5
0
 private void DebuggingService_OnBreakPoint(object sender, BreakPoint e)
 {
     if (!IsConnected)
     {
         clearBreakpointOnScript(e.ScriptId);
         debuggingService.Step(JavaScriptDiagStepType.JsDiagStepTypeContinue);
         return;
     }
     OnAdapterMessage?.Invoke(this, $"Breakpoint hit at {e}");
     SendEvent(new StoppedEvent(currentThread.id, "breakpoint", "breakpoint hit"));
     DebugAdapterStatus = DebugAdapterStatusEnum.BreakPointHit;
 }
Ejemplo n.º 6
0
 internal override void ConfigurationDone(Response response, dynamic args)
 {
     OnAdapterMessage?.Invoke(this, "ConfigurationDone");
     if (waitForLaunch)
     {
         configurationDoneEvent.Set();
     }
     if (postConfigurationDoneAction != null)
     {
         postConfigurationDoneAction();
         postConfigurationDoneAction = null;
     }
     sendLoadedScriptInfo();
     SendResponse(response);
 }
Ejemplo n.º 7
0
        public override void Initialize(Response response, dynamic args)
        {
            IsConnected = true;
            OnAdapterMessage?.Invoke(this, "Initialize called");
            SendResponse(response, new Capabilities()
            {
                exceptionBreakpointFilters       = new dynamic[0],
                supportsConditionalBreakpoints   = false,
                supportsEvaluateForHovers        = false,
                supportsConfigurationDoneRequest = true,
                supportsFunctionBreakpoints      = false,
                supportsLoadedSourcesRequest     = true
            });


            OnAdapterMessage?.Invoke(this, "InitializedEvent Sent");
            SendEvent(new InitializedEvent());
        }
Ejemplo n.º 8
0
        public override void Disconnect(Response response, dynamic arguments)
        {
            switch (DebugAdapterStatus)
            {
            case DebugAdapterStatusEnum.BreakPointHit:
            case DebugAdapterStatusEnum.StepComplete:
            case DebugAdapterStatusEnum.AsyncBreakHit:
            case DebugAdapterStatusEnum.ExceptionOccured:
                debuggingService.Step(JavaScriptDiagStepType.JsDiagStepTypeContinue);
                DebugAdapterStatus = DebugAdapterStatusEnum.Ready;
                break;

            default:
                break;
            }
            SendOutput("Debugger disconnected, continue script execution");
            IsConnected = false;
            OnAdapterMessage?.Invoke(this, "Disconnect");
        }
Ejemplo n.º 9
0
        public override void Attach(Response response, dynamic arguments)
        {
            switch (DebugAdapterStatus)
            {
            case DebugAdapterStatusEnum.WaitingForEngineReady:
                throw new InvalidOperationException("Attach failed, engine is waiting for Launch");

            case DebugAdapterStatusEnum.BreakPointHit:
            case DebugAdapterStatusEnum.StepComplete:
            case DebugAdapterStatusEnum.AsyncBreakHit:
            case DebugAdapterStatusEnum.ExceptionOccured:
                throw new InvalidOperationException($"Attach failed, engine is busy. Status={DebugAdapterStatus}");

            case DebugAdapterStatusEnum.Ready:
                ManualResetEventSlim mse = new ManualResetEventSlim(false);
                postAsyncBreakAction        = mse.Set;
                postConfigurationDoneAction = () =>     //continue the script excution when VSCode configuration is done
                {
                    debuggingService.Step(JavaScriptDiagStepType.JsDiagStepTypeContinue);
                };
                debuggingService.RequestAsyncBreak();
                SendOutput("AsyncBreak request sent, waiting for engine response");
                mse.Wait();
                SendOutput("AsyncBreak hit, continue Attach progress");
                break;

            default:
                break;
            }

            OnAdapterMessage?.Invoke(this, "[Attach]");
            OnAttach?.Invoke(this, arguments);
            sourceMap.Clear();
            if (arguments.sourceMap != null)
            {
                foreach (var item in arguments.sourceMap)
                {
                    sourceMap.Add((string)item.name, (string)item.value);
                }
            }
            SendResponse(response);
        }
Ejemplo n.º 10
0
        private void DebuggingService_OnAsyncBreak(object sender, BreakPoint e)
        {
            if (!IsConnected)
            {
                debuggingService.Step(JavaScriptDiagStepType.JsDiagStepTypeContinue);
                return;
            }
            OnAdapterMessage?.Invoke(this, $"Async break at  {e}");
            if (postAsyncBreakAction != null)//event is triggered by Attach command
            {
                postAsyncBreakAction();
                postAsyncBreakAction = null;
            }
            else
            {
                SendEvent(new StoppedEvent(currentThread.id, "async break"));
            }

            DebugAdapterStatus = DebugAdapterStatusEnum.AsyncBreakHit;
        }
Ejemplo n.º 11
0
        public override void SetBreakpoints(Response response, dynamic arguments)
        {
            string            fileName = arguments.source.name;
            List <Breakpoint> bps      = new List <Breakpoint>();

            OnAdapterMessage?.Invoke(this, "Waiting for script ready");
            engineReadyEvent.WaitOne();
            if (findSourceCode(fileName, out var sourceCode))
            {
                clearBreakpointOnScript(sourceCode.ScriptId);
                for (int i = 0; i < arguments.breakpoints.Count; i++)
                {
                    uint       line = (uint)ConvertDebuggerLineToClient((int)arguments.breakpoints[i].line);
                    BreakPoint bp   = debuggingService.SetBreakpoint(sourceCode.ScriptId, line, 0);
                    bps.Add(new Breakpoint(true, ConvertClientLineToDebugger((int)bp.Line)));
                }
            }
            OnAdapterMessage?.Invoke(this, $"BreakPoints on {fileName} Set");
            SendResponse(response, new SetBreakpointsResponseBody(bps));
        }
Ejemplo n.º 12
0
        public override void Launch(Response response, dynamic arguments)
        {
            OnAdapterMessage?.Invoke(this, "[Launch]");
            if (DebugAdapterStatus != DebugAdapterStatusEnum.WaitingForEngineReady)
            {
                throw new InvalidOperationException("Launch failed, engine already running");
            }
            OnLaunch?.Invoke(this, arguments);
            sourceMap.Clear();
            if (arguments.sourceMap != null)
            {
                foreach (var item in arguments.sourceMap)
                {
                    sourceMap.Add((string)item.name, (string)item.value);
                }
            }
            bool pauseOnLaunch = arguments.pauseOnLaunch ?? false;

            if (pauseOnLaunch)
            {
                debuggingService.RequestAsyncBreak();
            }
            SendResponse(response);
        }
Ejemplo n.º 13
0
 private void DebuggingService_OnDebugEvent(object sender, DebugEventArguments e)
 {
     OnAdapterMessage?.Invoke(this, $"[{e.EventType}],{e.EventData}");
 }
Ejemplo n.º 14
0
 private void DebuggingService_OnScriptLoad(object sender, SourceCode e)
 {
     sourceCodeList.Add(e);
     OnAdapterMessage?.Invoke(this, $"Script {e.FileName} Loaded");
 }