Пример #1
0
        public override void Initialize(Response response, dynamic args)
        {
            SessionLog.WriteLine("Initialize:" + args);
            AdapterID = (string)args.adapterID;

            _process = DebugeeFactory.CreateProcess(AdapterID, PathStrategy);

            SendResponse(response, new Capabilities()
            {
                supportsConditionalBreakpoints   = false,
                supportsFunctionBreakpoints      = false,
                supportsConfigurationDoneRequest = true,
                exceptionBreakpointFilters       = new dynamic[0],
                supportsEvaluateForHovers        = true
            });

            SendEvent(new InitializedEvent());
        }
Пример #2
0
        public override void Launch(Response response, dynamic args)
        {
            SessionLog.WriteLine("Launch command accepted");

            try
            {
                _process.Init(args);
            }
            catch (InvalidDebugeeOptionsException e)
            {
                SendErrorResponse(response, e.ErrorCode, e.Message);
                return;
            }

            _process.OutputReceived += (s, e) =>
            {
                SessionLog.WriteLine("output received: " + e.Content);
                SendOutput(e.Category, e.Content);
            };

            _process.ProcessExited += (s, e) =>
            {
                SessionLog.WriteLine("_process exited");
                SendEvent(new TerminatedEvent());
            };

            try
            {
                _process.Start();
                SessionLog.WriteLine("Debuggee started");
            }
            catch (Exception e)
            {
                SessionLog.WriteLine(e.ToString());
                SendErrorResponse(response, 3012, "Can't launch debugee ({reason}).", new { reason = e.Message });
                return;
            }

            try
            {
                IDebuggerService service;
                if (_process.DebugProtocol == "wcf")
                {
                    var wcfConnector = new WcfDebuggerConnection(_process.DebugPort, this);
                    wcfConnector.Connect();
                    service = wcfConnector;
                }
                else
                {
                    var tcpConnector = new TcpDebugConnector(_process.DebugPort, this);
                    tcpConnector.Connect();
                    service = tcpConnector;
                }

                _process.SetConnection(service);
            }
            catch (Exception e)
            {
                _process.Kill();
                _process = null;
                SessionLog.WriteLine(e.ToString());
                SendErrorResponse(response, 4550, "Can't connect: " + e.ToString());
                return;
            }

            SendResponse(response);
        }