Update debugger to 1a6e64a938 (#21524)

This commit is contained in:
Pranav K 2020-05-05 17:17:48 -07:00 committed by GitHub
parent 4e7665a27e
commit 2ca2a2d405
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 10 deletions

View File

@ -32,8 +32,8 @@ namespace WebAssembly.Net.Debugging {
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 () {
}
@ -171,6 +171,28 @@ namespace WebAssembly.Net.Debugging {
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 (),

View File

@ -184,6 +184,7 @@ namespace WebAssembly.Net.Debugging {
}
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)) {
@ -193,7 +194,8 @@ namespace WebAssembly.Net.Debugging {
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;
}
@ -765,17 +767,21 @@ namespace WebAssembly.Net.Debugging {
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