Skip to content

Commit 22522a0

Browse files
authored
1 parent e07b939 commit 22522a0

File tree

1 file changed

+23
-7
lines changed
  • src/Components/WebAssembly/DebugProxy/src/MonoDebugProxy/ws-proxy

1 file changed

+23
-7
lines changed

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

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,16 +186,31 @@ protected override async Task<bool> AcceptCommand (MessageId id, string method,
186186
var bpid = resp.Value["breakpointId"]?.ToString ();
187187
var locations = resp.Value["locations"]?.Values<object>();
188188
var request = BreakpointRequest.Parse (bpid, args);
189-
context.BreakpointRequests[bpid] = request;
189+
190+
// is the store done loading?
191+
var loaded = context.Source.Task.IsCompleted;
192+
if (!loaded) {
193+
// Send and empty response immediately if not
194+
// and register the breakpoint for resolution
195+
context.BreakpointRequests [bpid] = request;
196+
SendResponse (id, resp, token);
197+
}
198+
190199
if (await IsRuntimeAlreadyReadyAlready (id, token)) {
191200
var store = await RuntimeReady (id, token);
192201

193202
Log ("verbose", $"BP req {args}");
194-
await SetBreakpoint (id, store, request, token);
203+
await SetBreakpoint (id, store, request, !loaded, token);
195204
}
196205

197-
var result = Result.OkFromObject (request.AsSetBreakpointByUrlResponse (locations));
198-
SendResponse (id, result, token);
206+
if (loaded) {
207+
// we were already loaded so we should send a response
208+
// with the locations included and register the request
209+
context.BreakpointRequests [bpid] = request;
210+
var result = Result.OkFromObject (request.AsSetBreakpointByUrlResponse (locations));
211+
SendResponse (id, result, token);
212+
213+
}
199214
return true;
200215
}
201216

@@ -709,7 +724,7 @@ async Task<DebugStore> LoadStore (SessionId sessionId, CancellationToken token)
709724

710725
foreach (var req in context.BreakpointRequests.Values) {
711726
if (req.TryResolve (source)) {
712-
await SetBreakpoint (sessionId, context.store, req, token);
727+
await SetBreakpoint (sessionId, context.store, req, true, token);
713728
}
714729
}
715730
}
@@ -759,7 +774,7 @@ async Task RemoveBreakpoint(MessageId msg_id, JObject args, CancellationToken to
759774
breakpointRequest.Locations.Clear ();
760775
}
761776

762-
async Task SetBreakpoint (SessionId sessionId, DebugStore store, BreakpointRequest req, CancellationToken token)
777+
async Task SetBreakpoint (SessionId sessionId, DebugStore store, BreakpointRequest req, bool sendResolvedEvent, CancellationToken token)
763778
{
764779
var context = GetContext (sessionId);
765780
if (req.Locations.Any ()) {
@@ -796,7 +811,8 @@ async Task SetBreakpoint (SessionId sessionId, DebugStore store, BreakpointReque
796811
location = loc.AsLocation ()
797812
};
798813

799-
SendEvent (sessionId, "Debugger.breakpointResolved", JObject.FromObject (resolvedLocation), token);
814+
if (sendResolvedEvent)
815+
SendEvent (sessionId, "Debugger.breakpointResolved", JObject.FromObject (resolvedLocation), token);
800816
}
801817

802818
req.Locations.AddRange (breakpoints);

0 commit comments

Comments
 (0)