diff options
author | Larry Ewing <lewing@microsoft.com> | 2020-02-27 08:07:57 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-27 08:07:57 +0300 |
commit | 7f6a9bb78317f9bfdd3e96abc8718baf16dffee1 (patch) | |
tree | 1de8c3be369429da2c199094ffe3a5c96c009ffd /sdks | |
parent | de54af770c47c6f308714fcac4402cc228033af7 (diff) |
[wasm][debugger] Always pass failed breakpoint requests to target (#19053)
* [wasm][debugger] Always pass failed breakpoint requests to target
Originally we had a simple way to detect that breakpoints were
meant for the runtime but that is no longer true. Now if we
can't location a breakpoint we need to pass the request on to the
target so it can make an attempt.
* Fix test byUrl is a logical breakpoint and should not fail
Diffstat (limited to 'sdks')
-rw-r--r-- | sdks/wasm/DebuggerTestSuite/Tests.cs | 6 | ||||
-rw-r--r-- | sdks/wasm/Mono.WebAssembly.DebuggerProxy/MonoProxy.cs | 55 |
2 files changed, 35 insertions, 26 deletions
diff --git a/sdks/wasm/DebuggerTestSuite/Tests.cs b/sdks/wasm/DebuggerTestSuite/Tests.cs index 8cce45e3480..a5755a9a9c9 100644 --- a/sdks/wasm/DebuggerTestSuite/Tests.cs +++ b/sdks/wasm/DebuggerTestSuite/Tests.cs @@ -106,9 +106,9 @@ namespace DebuggerTests var bp1_res = await cli.SendCommand ("Debugger.setBreakpointByUrl", bp1_req, token); - Assert.False (bp1_res.IsOk); - Assert.True (bp1_res.IsErr); - Assert.Equal ((int)MonoErrorCodes.BpNotFound, bp1_res.Error ["code"]?.Value<int> ()); + Assert.True (bp1_res.IsOk); + Assert.Empty (bp1_res.Value["locations"].Values<object>()); + //Assert.Equal ((int)MonoErrorCodes.BpNotFound, bp1_res.Error ["code"]?.Value<int> ()); }); } diff --git a/sdks/wasm/Mono.WebAssembly.DebuggerProxy/MonoProxy.cs b/sdks/wasm/Mono.WebAssembly.DebuggerProxy/MonoProxy.cs index c38705692c6..cc7d98b3f39 100644 --- a/sdks/wasm/Mono.WebAssembly.DebuggerProxy/MonoProxy.cs +++ b/sdks/wasm/Mono.WebAssembly.DebuggerProxy/MonoProxy.cs @@ -221,22 +221,36 @@ namespace WebAssembly.Net.Debugging { } case "Debugger.getPossibleBreakpoints": { + var resp = await SendCommand (id, method, args, token); + if (resp.IsOk && resp.Value["locations"].HasValues) { + SendResponse (id, resp, token); + return true; + } + var start = SourceLocation.Parse (args? ["start"] as JObject); //FIXME support variant where restrictToFunction=true and end is omitted var end = SourceLocation.Parse (args? ["end"] as JObject); - if (start != null && end != null) - return GetPossibleBreakpoints (id, start, end, token); - break; + if (start != null && end != null && await GetPossibleBreakpoints (id, start, end, token)) + return true; + + SendResponse (id, resp, token); + return true; } case "Debugger.setBreakpointByUrl": { - Log ("info", $"BP req {args}"); - var bp_req = BreakpointRequest.Parse (args, GetContext (id).Store); - if (bp_req != null) { - await SetBreakPoint (id, bp_req, token); + var resp = await SendCommand (id, method, args, token); + if (resp.IsOk && resp.Value ["locations"].HasValues) { + SendResponse (id, resp, token); return true; } - break; + + Log ("info", $"BP req {args}"); + var bp_req = BreakpointRequest.Parse (args, GetContext (id).Store); + if (bp_req != null && await SetBreakpoint (id, bp_req, token)) + return true; + + SendResponse (id, resp, token); + return true; } case "Debugger.removeBreakpoint": { @@ -579,7 +593,7 @@ namespace WebAssembly.Net.Debugging { } } - async Task<Result> EnableBreakPoint (SessionId sessionId, Breakpoint bp, CancellationToken token) + async Task<Result> EnableBreakpoint (SessionId sessionId, Breakpoint bp, CancellationToken token) { var asm_name = bp.Location.CliLocation.Method.Assembly.Name; var method_token = bp.Location.CliLocation.Method.Token; @@ -643,7 +657,7 @@ namespace WebAssembly.Net.Debugging { foreach (var bp in context.Breakpoints) { if (bp.State != BreakpointState.Pending) continue; - var res = await EnableBreakPoint (sessionId, bp, token); + var res = await EnableBreakpoint (sessionId, bp, token); var ret_code = res.Value? ["result"]? ["value"]?.Value<int> (); //if we fail we just buble that to the IDE (and let it panic over it) @@ -689,19 +703,14 @@ namespace WebAssembly.Net.Debugging { return res; } - async Task SetBreakPoint (MessageId msg_id, BreakpointRequest req, CancellationToken token) + async Task<bool> SetBreakpoint (MessageId msg_id, BreakpointRequest req, CancellationToken token) { var context = GetContext (msg_id); var bp_loc = context.Store.FindBestBreakpoint (req); Log ("info", $"BP request for '{req}' runtime ready {context.RuntimeReady} location '{bp_loc}'"); if (bp_loc == null) { - Log ("verbose", $"Could not resolve breakpoint request: {req}"); - SendResponse (msg_id, Result.Err(JObject.FromObject (new { - code = (int)MonoErrorCodes.BpNotFound, - message = $"C# Breakpoint at {req} not found." - })), token); - return; + return false; } Breakpoint bp = null; @@ -710,13 +719,12 @@ namespace WebAssembly.Net.Debugging { } else { bp = new Breakpoint (bp_loc, context.NextBreakpointId (), BreakpointState.Disabled); - var res = await EnableBreakPoint (msg_id, bp, token); + var res = await EnableBreakpoint (msg_id, bp, token); var ret_code = res.Value? ["result"]? ["value"]?.Value<int> (); //if we fail we just buble that to the IDE (and let it panic over it) if (!ret_code.HasValue) { - SendResponse (msg_id, res, token); - return; + return false; } } @@ -730,11 +738,12 @@ namespace WebAssembly.Net.Debugging { }; SendResponse (msg_id, Result.OkFromObject (ok), token); + return true; } - bool GetPossibleBreakpoints (MessageId msg_id, SourceLocation start, SourceLocation end, CancellationToken token) + async Task<bool> GetPossibleBreakpoints (MessageId msg_id, SourceLocation start, SourceLocation end, CancellationToken token) { - var bps = GetContext (msg_id).Store.FindPossibleBreakpoints (start, end); + var bps = (await LoadStore (msg_id, token)).FindPossibleBreakpoints (start, end); if (bps == null) return false; @@ -752,7 +761,7 @@ namespace WebAssembly.Net.Debugging { if (!SourceId.TryParse (script_id, out var id)) return false; - var src_file = GetContext (msg_id).Store.GetFileById (id); + var src_file = (await LoadStore (msg_id, token)).GetFileById (id); var res = new StringWriter (); try { |