Beispiel #1
0
        public virtual IDebugSession GetDebugSession()
        {
            if (debugSession == null)
            {
                var variableExpanderFactory =
                    new VariableExpander.Factory(GetDebugSessionContext(),
                                                 _watchWindowExpandBatchSize);

                var variableEntryFactory = new VariableEntry.Factory(GetJobQueue(),
                                                                     new RefreshVariableJob.
                                                                     Factory(),
                                                                     GetDebugSessionContext(),
                                                                     variableExpanderFactory);

                variableExpanderFactory.SetVariableEntryFactory(variableEntryFactory);

                var watchWindow = new SyncWatchWindow(GetDebugSessionContext(),
                                                      variableEntryFactory);

                var controlFlowView = GetAPIDecorator().Decorate <IControlFlowView>(
                    new ControlFlowView(GetDebugSessionContext()));

                debugSession = new DebugSession(GetDebugSessionContext(), GetBreakpointView(),
                                                controlFlowView, watchWindow);
            }

            return(debugSession);
        }
Beispiel #2
0
 public SessionDebugManager(JobExecutor jobExecutor, IJobQueue jobQueue,
                            LaunchAndAttachFlow launchAndAttachFlow,
                            IDebugSession debugSession)
 {
     _jobExecutor         = jobExecutor;
     _jobQueue            = jobQueue;
     _launchAndAttachFlow = launchAndAttachFlow;
     Session = debugSession;
 }
Beispiel #3
0
 public VSFake(ITargetAdapter targetAdapter, IProjectAdapter projectAdapter,
               ISessionDebugManager sessionDebugManager, ISolutionExplorer solutionExplorer,
               IDebugSession debugSession, VSFakeTimeoutSource timeouts)
 {
     TargetAdapter       = targetAdapter;
     ProjectAdapter      = projectAdapter;
     SessionDebugManager = sessionDebugManager;
     SolutionExplorer    = solutionExplorer;
     DebugSession        = debugSession;
     Timeouts            = timeouts;
 }
 public void AssociateDebugSession(IDebugSession session)
 {
     this.session = session;
 }
Beispiel #5
0
 public void AssociateDebugSession(IDebugSession session)
 {
     this._session = session;
 }
Beispiel #6
0
        private static void Dispatch(Stream inputStream, Stream outputStream)
        {
            DispatcherProtocol protocol = new DispatcherProtocol(inputStream, outputStream);

            Action <string> traceResponseCallback = s => Console.Error.WriteLine(s);

            if (s_trace_requests)
            {
                protocol.TraceCallback = traceResponseCallback;
            }

            if (s_trace_responses)
            {
                protocol.ResponseCallback = traceResponseCallback;
            }

            if (s_engine_logging && HostLogger.Instance?.LogFilePath == null)
            {
                HostLogger.Instance.LogCallback = s => Console.WriteLine(s);
            }

            IDebugSession debugSession = null;

            protocol.Start((string command, dynamic args, IResponder responder) =>
            {
                if (args == null)
                {
                    args = new { };
                }

                if (command == "initialize")
                {
                    string adapterID = Utilities.GetString(args, "adapterID");
                    if (adapterID == null)
                    {
                        responder.SetBody(new ErrorResponseBody(new Message(1101, "initialize: property 'adapterID' is missing or empty")));
                        return;
                    }

                    DebugProtocolCallbacks debugProtocolCallbacks = new DebugProtocolCallbacks()
                    {
                        Send              = e => protocol.SendEvent(e.type, e),
                        SendRaw           = e => protocol.SendRawEvent(e.type, e),
                        SendLater         = e => protocol.SendEventLater(e.type, e),
                        SetTraceLogger    = t => protocol.TraceCallback = t,
                        SetResponseLogger = t => protocol.ResponseCallback = t,
                        SetEngineLogger   = t =>
                        {
                            HostLogger.EnableHostLogging();
                            HostLogger.Instance.LogCallback = t;
                        }
                    };

                    debugSession = OpenDebugAD7.EngineFactory.CreateDebugSession(adapterID, debugProtocolCallbacks);
                    if (debugSession == null)
                    {
                        responder.SetBody(new ErrorResponseBody(new Message(1103, "initialize: can't create debug session for adapter '{_id}'", new { _id = adapterID })));
                        return;
                    }
                }

                if (debugSession != null)
                {
                    try
                    {
                        DebugResult dr = debugSession.Dispatch(command, args);
                        if (dr != null)
                        {
                            responder.SetBody(dr.Body);

                            if (dr.Events != null)
                            {
                                foreach (var e in dr.Events)
                                {
                                    responder.AddEvent(e.type, e);
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        AggregateException aggregateException = e as AggregateException;
                        bool bodySet = false;
                        if (aggregateException != null)
                        {
                            if (aggregateException.InnerExceptions.Count == 1)
                            {
                                e = aggregateException.InnerException;
                            }
                            else
                            {
                                string exceptionMessages = string.Join(", ", aggregateException.InnerExceptions.Select((x) => Utilities.GetExceptionDescription(x)));
                                responder.SetBody(new ErrorResponseBody(new Message(1104, "error while processing request '{_request}' (exceptions: {_messages})", new { _request = command, _messages = exceptionMessages })));
                                bodySet = true;
                            }
                        }

                        if (!bodySet)
                        {
                            if (Utilities.IsCorruptingException(e))
                            {
                                Utilities.ReportException(e);
                            }

                            if (e is OpenDebugAD7.AD7Exception)
                            {
                                responder.SetBody(new ErrorResponseBody(new Message(1104, e.Message)));
                            }
                            else
                            {
                                responder.SetBody(new ErrorResponseBody(new Message(1104, "error while processing request '{_request}' (exception: {_exception})", new { _request = command, _exception = Utilities.GetExceptionDescription(e) })));
                            }
                        }
                    }

                    if (command == "disconnect")
                    {
                        protocol.Stop();
                    }
                }
            }).Wait();
        }
Beispiel #7
0
        static void Dispatch(Stream inputStream, Stream outputStream)
        {
            V8ServerProtocol protocol = new V8ServerProtocol(inputStream, outputStream);

            protocol.TRACE          = false;
            protocol.TRACE_RESPONSE = false;

            IDebugSession debugSession = null;

            var r = protocol.Start((string command, dynamic args, IResponder responder) => {
                if (args == null)
                {
                    args = new { };
                }

                if (command == "initialize")
                {
                    string adapterID = Utilities.GetString(args, "adapterID");
                    if (adapterID == null)
                    {
                        responder.SetBody(new ErrorResponseBody(new Message(1101, "initialize: property 'adapterID' is missing or empty")));
                        return;
                    }

                    debugSession = EngineFactory.CreateDebugSession(adapterID, (e) => protocol.SendEvent(e.type, e));
                    if (debugSession == null)
                    {
                        responder.SetBody(new ErrorResponseBody(new Message(1103, "initialize: can't create debug session for adapter '{_id}'", new { _id = adapterID })));
                        return;
                    }
                }

                if (debugSession != null)
                {
                    try {
                        DebugResult dr = debugSession.Dispatch(command, args);
                        if (dr != null)
                        {
                            responder.SetBody(dr.Body);

                            if (dr.Events != null)
                            {
                                foreach (var e in dr.Events)
                                {
                                    responder.AddEvent(e.type, e);

                                    var outputEvent = e as OutputEvent;
                                    if (outputEvent != null)
                                    {
                                        Log.Write(outputEvent.output);
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception e) {
                        responder.SetBody(new ErrorResponseBody(new Message(1104, "error while processing request '{_request}' (exception: {_exception})", new { _request = command, _exception = e.Message })));

                        var message     = string.Format("error while processing request '{0}' (exception: {1})\n{2}", command, e.Message, e);
                        var outputEvent = new OutputEvent(message);

                        responder.AddEvent(outputEvent.type, outputEvent);
                        Log.Write(message);
                    }

                    if (command == "disconnect")
                    {
                        protocol.Stop();
                    }
                }
            }).Result;
        }