Skip to content

Commit 2ca2a2d

Browse files
authored
Update debugger to mono/mono@1a6e64a (#21524)
1 parent 4e7665a commit 2ca2a2d

File tree

2 files changed

+38
-10
lines changed

2 files changed

+38
-10
lines changed

src/Components/WebAssembly/DebugProxy/src/MonoDebugProxy/ws-proxy/DebugStore.cs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ internal class BreakpointRequest {
3232
public override string ToString ()
3333
=> $"BreakpointRequest Assembly: {Assembly} File: {File} Line: {Line} Column: {Column}";
3434

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

3838
public BreakpointRequest () {
3939
}
@@ -171,6 +171,28 @@ public static SourceLocation Parse (JObject obj)
171171
return new SourceLocation (id, line.Value, column.Value);
172172
}
173173

174+
175+
internal class LocationComparer : EqualityComparer<SourceLocation>
176+
{
177+
public override bool Equals (SourceLocation l1, SourceLocation l2)
178+
{
179+
if (l1 == null && l2 == null)
180+
return true;
181+
else if (l1 == null || l2 == null)
182+
return false;
183+
184+
return (l1.Line == l2.Line &&
185+
l1.Column == l2.Column &&
186+
l1.Id == l2.Id);
187+
}
188+
189+
public override int GetHashCode (SourceLocation loc)
190+
{
191+
int hCode = loc.Line ^ loc.Column;
192+
return loc.Id.GetHashCode () ^ hCode.GetHashCode ();
193+
}
194+
}
195+
174196
internal object AsLocation ()
175197
=> new {
176198
scriptId = id.ToString (),

src/Components/WebAssembly/DebugProxy/src/MonoDebugProxy/ws-proxy/MonoProxy.cs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ protected override async Task<bool> AcceptCommand (MessageId id, string method,
184184
}
185185

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

196-
SendResponse (id, Result.OkFromObject (request.AsSetBreakpointByUrlResponse()), token);
197+
var result = Result.OkFromObject (request.AsSetBreakpointByUrlResponse (locations));
198+
SendResponse (id, result, token);
197199
return true;
198200
}
199201

@@ -765,17 +767,21 @@ async Task SetBreakpoint (SessionId sessionId, DebugStore store, BreakpointReque
765767
return;
766768
}
767769

768-
var locations = store.FindBreakpointLocations (req).ToList ();
770+
var comparer = new SourceLocation.LocationComparer ();
771+
// if column is specified the frontend wants the exact matches
772+
// and will clear the bp if it isn't close enoug
773+
var locations = store.FindBreakpointLocations (req)
774+
.Distinct (comparer)
775+
.Where (l => l.Line == req.Line && (req.Column == 0 || l.Column == req.Column))
776+
.OrderBy (l => l.Column)
777+
.GroupBy (l => l.Id);
778+
769779
logger.LogDebug ("BP request for '{req}' runtime ready {context.RuntimeReady}", req, GetContext (sessionId).IsRuntimeReady);
770780

771781
var breakpoints = new List<Breakpoint> ();
772782

773-
// if column is specified the frontend wants the exact matches
774-
// and will clear the bp if it isn't close enough
775-
if (req.Column != 0)
776-
locations = locations.Where (l => l.Column == req.Column).ToList ();
777-
778-
foreach (var loc in locations) {
783+
foreach (var sourceId in locations) {
784+
var loc = sourceId.First ();
779785
var bp = await SetMonoBreakpoint (sessionId, req.Id, loc, token);
780786

781787
// If we didn't successfully enable the breakpoint

0 commit comments

Comments
 (0)