Пример #1
0
        void StartDebugAgent()
        {
            var startInfo = new ProcessStartInfo(Path.Combine(Path.GetDirectoryName(typeof(VSCodeDebuggerSession).Assembly.Location), "CoreClrAdaptor", "OpenDebugAD7"));

            startInfo.RedirectStandardOutput       = true;
            startInfo.RedirectStandardInput        = true;
            startInfo.StandardOutputEncoding       = Encoding.UTF8;
            startInfo.StandardOutputEncoding       = Encoding.UTF8;
            startInfo.UseShellExecute              = false;
            startInfo.EnvironmentVariables["PATH"] = "/usr/local/share/dotnet:" + Environment.GetEnvironmentVariable("PATH");
            debugAgentProcess       = Process.Start(startInfo);
            protocolClient          = new ProtocolClient();
            protocolClient.OnEvent += HandleAction;
            protocolClient.Start(debugAgentProcess.StandardOutput.BaseStream, debugAgentProcess.StandardInput.BaseStream)
            .ContinueWith((task) => {
                if (task.IsFaulted)
                {
                    Console.WriteLine(task.Exception);
                }
            });
            var initRequest = new InitializeRequest(new InitializeRequestArguments()
            {
                adapterID       = "coreclr",
                linesStartAt1   = true,
                columnsStartAt1 = true,
                pathFormat      = "path"
            });

            Capabilities = protocolClient.SendRequestAsync(initRequest).Result;
        }
Пример #2
0
        void UpdateBreakpoints()
        {
            var bks = breakpoints.Select(b => b.Key).OfType <Breakpoint>().GroupBy(b => b.FileName).ToArray();

            foreach (var sourceFile in bks)
            {
                protocolClient.SendRequestAsync(new SetBreakpointsRequest(new SetBreakpointsRequestArguments {
                    Source      = new Source(sourceFile.Key),
                    Breakpoints = sourceFile.Select(b => new SourceBreakpoint {
                        Line      = b.Line,
                        Column    = b.Column,
                        Condition = b.ConditionExpression
                    }).ToList()
                })).ContinueWith(t => {
                    if (t.IsFaulted)
                    {
                        return;
                    }
                    for (int i = 0; i < t.Result.breakpoints.Length; i++)
                    {
                        breakpoints[sourceFile.ElementAt(i)].SetStatus(t.Result.breakpoints[i].verified ? BreakEventStatus.Bound : BreakEventStatus.NotBound, "");
                        if (t.Result.breakpoints[i].line != sourceFile.ElementAt(i).OriginalLine)
                        {
                            breakpoints[sourceFile.ElementAt(i)].AdjustBreakpointLocation(t.Result.breakpoints[i].line, 1);
                        }
                    }
                });
            }
        }