Ejemplo n.º 1
0
        async Task SetBreakpoint(SessionId sessionId, DebugStore store, BreakpointRequest req, bool sendResolvedEvent, CancellationToken token)
        {
            var context = GetContext(sessionId);

            if (req.Locations.Any())
            {
                Log("debug", $"locations already loaded for {req.Id}");
                return;
            }

            var comparer = new SourceLocation.LocationComparer();
            // if column is specified the frontend wants the exact matches
            // and will clear the bp if it isn't close enoug
            var locations = store.FindBreakpointLocations(req)
                            .Distinct(comparer)
                            .Where(l => l.Line == req.Line && (req.Column == 0 || l.Column == req.Column))
                            .OrderBy(l => l.Column)
                            .GroupBy(l => l.Id);

            logger.LogDebug("BP request for '{req}' runtime ready {context.RuntimeReady}", req, GetContext(sessionId).IsRuntimeReady);

            var breakpoints = new List <Breakpoint>();

            foreach (var sourceId in locations)
            {
                var loc = sourceId.First();
                var bp  = await SetMonoBreakpoint(sessionId, req.Id, loc, token);

                // If we didn't successfully enable the breakpoint
                // don't add it to the list of locations for this id
                if (bp.State != BreakpointState.Active)
                {
                    continue;
                }

                breakpoints.Add(bp);

                var resolvedLocation = new
                {
                    breakpointId = req.Id,
                    location     = loc.AsLocation()
                };

                if (sendResolvedEvent)
                {
                    SendEvent(sessionId, "Debugger.breakpointResolved", JObject.FromObject(resolvedLocation), token);
                }
            }

            req.Locations.AddRange(breakpoints);
            return;
        }
Ejemplo n.º 2
0
        async Task SetBreakpoint(SessionId sessionId, DebugStore store, BreakpointRequest req, CancellationToken token)
        {
            var context = GetContext(sessionId);

            if (req.Locations.Any())
            {
                Log("debug", $"locations already loaded for {req.Id}");
                return;
            }

            var locations = store.FindBreakpointLocations(req).ToList();

            logger.LogDebug("BP request for '{req}' runtime ready {context.RuntimeReady}", req, GetContext(sessionId).IsRuntimeReady);

            var breakpoints = new List <Breakpoint> ();

            foreach (var loc in locations)
            {
                var bp = await SetMonoBreakpoint(sessionId, req, loc, token);

                // If we didn't successfully enable the breakpoint
                // don't add it to the list of locations for this id
                if (bp.State != BreakpointState.Active)
                {
                    continue;
                }

                breakpoints.Add(bp);

                var resolvedLocation = new {
                    breakpointId = req.Id,
                    location     = loc.AsLocation()
                };

                SendEvent(sessionId, "Debugger.breakpointResolved", JObject.FromObject(resolvedLocation), token);
            }

            req.Locations.AddRange(breakpoints);
            return;
        }