Skip to content

Update debugger to https://github.com/mono/mono/commit/1a6e64a9381c61 #21524

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
1 commit merged into from
May 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ internal class BreakpointRequest {
public override string ToString ()
=> $"BreakpointRequest Assembly: {Assembly} File: {File} Line: {Line} Column: {Column}";

public object AsSetBreakpointByUrlResponse ()
=> new { breakpointId = Id, locations = Locations.Select(l => l.Location.AsLocation ()) };
public object AsSetBreakpointByUrlResponse (IEnumerable<object> jsloc)
=> new { breakpointId = Id, locations = Locations.Select(l => l.Location.AsLocation ()).Concat (jsloc) };

public BreakpointRequest () {
}
Expand Down Expand Up @@ -171,6 +171,28 @@ public static SourceLocation Parse (JObject obj)
return new SourceLocation (id, line.Value, column.Value);
}


internal class LocationComparer : EqualityComparer<SourceLocation>
{
public override bool Equals (SourceLocation l1, SourceLocation l2)
{
if (l1 == null && l2 == null)
return true;
else if (l1 == null || l2 == null)
return false;

return (l1.Line == l2.Line &&
l1.Column == l2.Column &&
l1.Id == l2.Id);
}

public override int GetHashCode (SourceLocation loc)
{
int hCode = loc.Line ^ loc.Column;
return loc.Id.GetHashCode () ^ hCode.GetHashCode ();
}
}

internal object AsLocation ()
=> new {
scriptId = id.ToString (),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ protected override async Task<bool> AcceptCommand (MessageId id, string method,
}

var bpid = resp.Value["breakpointId"]?.ToString ();
var locations = resp.Value["locations"]?.Values<object>();
var request = BreakpointRequest.Parse (bpid, args);
context.BreakpointRequests[bpid] = request;
if (await IsRuntimeAlreadyReadyAlready (id, token)) {
Expand All @@ -193,7 +194,8 @@ protected override async Task<bool> AcceptCommand (MessageId id, string method,
await SetBreakpoint (id, store, request, token);
}

SendResponse (id, Result.OkFromObject (request.AsSetBreakpointByUrlResponse()), token);
var result = Result.OkFromObject (request.AsSetBreakpointByUrlResponse (locations));
SendResponse (id, result, token);
return true;
}

Expand Down Expand Up @@ -765,17 +767,21 @@ async Task SetBreakpoint (SessionId sessionId, DebugStore store, BreakpointReque
return;
}

var locations = store.FindBreakpointLocations (req).ToList ();
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> ();

// if column is specified the frontend wants the exact matches
// and will clear the bp if it isn't close enough
if (req.Column != 0)
locations = locations.Where (l => l.Column == req.Column).ToList ();

foreach (var loc in locations) {
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
Expand Down