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 () public override string ToString ()
=> $"BreakpointRequest Assembly: {Assembly} File: {File} Line: {Line} Column: {Column}"; => $"BreakpointRequest Assembly: {Assembly} File: {File} Line: {Line} Column: {Column}";
public object AsSetBreakpointByUrlResponse () public object AsSetBreakpointByUrlResponse (IEnumerable<object> jsloc)
=> new { breakpointId = Id, locations = Locations.Select(l => l.Location.AsLocation ()) }; => new { breakpointId = Id, locations = Locations.Select(l => l.Location.AsLocation ()).Concat (jsloc) };
public BreakpointRequest () { public BreakpointRequest () {
} }
@ -171,6 +171,28 @@ namespace WebAssembly.Net.Debugging {
return new SourceLocation (id, line.Value, column.Value); 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 () internal object AsLocation ()
=> new { => new {
scriptId = id.ToString (), scriptId = id.ToString (),

View File

@ -184,6 +184,7 @@ namespace WebAssembly.Net.Debugging {
} }
var bpid = resp.Value["breakpointId"]?.ToString (); var bpid = resp.Value["breakpointId"]?.ToString ();
var locations = resp.Value["locations"]?.Values<object>();
var request = BreakpointRequest.Parse (bpid, args); var request = BreakpointRequest.Parse (bpid, args);
context.BreakpointRequests[bpid] = request; context.BreakpointRequests[bpid] = request;
if (await IsRuntimeAlreadyReadyAlready (id, token)) { if (await IsRuntimeAlreadyReadyAlready (id, token)) {
@ -193,7 +194,8 @@ namespace WebAssembly.Net.Debugging {
await SetBreakpoint (id, store, request, token); 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; return true;
} }
@ -765,17 +767,21 @@ namespace WebAssembly.Net.Debugging {
return; 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); logger.LogDebug ("BP request for '{req}' runtime ready {context.RuntimeReady}", req, GetContext (sessionId).IsRuntimeReady);
var breakpoints = new List<Breakpoint> (); var breakpoints = new List<Breakpoint> ();
// if column is specified the frontend wants the exact matches foreach (var sourceId in locations) {
// and will clear the bp if it isn't close enough var loc = sourceId.First ();
if (req.Column != 0)
locations = locations.Where (l => l.Column == req.Column).ToList ();
foreach (var loc in locations) {
var bp = await SetMonoBreakpoint (sessionId, req.Id, loc, token); var bp = await SetMonoBreakpoint (sessionId, req.Id, loc, token);
// If we didn't successfully enable the breakpoint // If we didn't successfully enable the breakpoint