Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>2022-09-14 07:12:57 +0300
committerGitHub <noreply@github.com>2022-09-14 07:12:57 +0300
commitc623d96fe33cc360bd9981c9e6f6a646d7881d9e (patch)
tree83bd7cf156c973b19eae6c82ec685b6927e84173
parent6297d411861944cc29590e1ecbe79a57c9e6a7fd (diff)
[release/7.0] [wasm][debugger] fixing setting a breakpoint in an invalid IL offset after hotreload (#75564)
* fixing setting a breakpoint in an invalid IL offset * addressing @radical comments * Update src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs Co-authored-by: Ankit Jain <radical@gmail.com> * Update src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs Co-authored-by: Ankit Jain <radical@gmail.com> * addressing @radical comments * addressing @radical comments Co-authored-by: Thays Grazia <thaystg@gmail.com> Co-authored-by: Ankit Jain <radical@gmail.com>
-rw-r--r--src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs65
-rw-r--r--src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs6
2 files changed, 42 insertions, 29 deletions
diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs b/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs
index 1130f53efc9..cf4bb725cdc 100644
--- a/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs
+++ b/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs
@@ -361,37 +361,44 @@ namespace Microsoft.WebAssembly.Diagnostics
SendResponse(id, resp, token);
return true;
}
+ try
+ {
+ string bpid = resp.Value["breakpointId"]?.ToString();
+ IEnumerable<object> locations = resp.Value["locations"]?.Values<object>();
+ var request = BreakpointRequest.Parse(bpid, args);
- string bpid = resp.Value["breakpointId"]?.ToString();
- IEnumerable<object> locations = resp.Value["locations"]?.Values<object>();
- var request = BreakpointRequest.Parse(bpid, args);
+ // is the store done loading?
+ bool loaded = context.Source.Task.IsCompleted;
+ if (!loaded)
+ {
+ // Send and empty response immediately if not
+ // and register the breakpoint for resolution
+ context.BreakpointRequests[bpid] = request;
+ SendResponse(id, resp, token);
+ }
- // is the store done loading?
- bool loaded = context.Source.Task.IsCompleted;
- if (!loaded)
- {
- // Send and empty response immediately if not
- // and register the breakpoint for resolution
- context.BreakpointRequests[bpid] = request;
- SendResponse(id, resp, token);
- }
+ if (await IsRuntimeAlreadyReadyAlready(id, token))
+ {
+ DebugStore store = await RuntimeReady(id, token);
- if (await IsRuntimeAlreadyReadyAlready(id, token))
- {
- DebugStore store = await RuntimeReady(id, token);
+ Log("verbose", $"BP req {args}");
+ await SetBreakpoint(id, store, request, !loaded, false, token);
+ }
- Log("verbose", $"BP req {args}");
- await SetBreakpoint(id, store, request, !loaded, false, token);
- }
+ if (loaded)
+ {
+ // we were already loaded so we should send a response
+ // with the locations included and register the request
+ context.BreakpointRequests[bpid] = request;
+ var result = Result.OkFromObject(request.AsSetBreakpointByUrlResponse(locations));
+ SendResponse(id, result, token);
- if (loaded)
+ }
+ }
+ catch (Exception e)
{
- // we were already loaded so we should send a response
- // with the locations included and register the request
- context.BreakpointRequests[bpid] = request;
- var result = Result.OkFromObject(request.AsSetBreakpointByUrlResponse(locations));
- SendResponse(id, result, token);
-
+ logger.LogDebug($"Debugger.setBreakpointByUrl - {args} - failed with exception: {e}");
+ SendResponse(id, Result.Err($"Debugger.setBreakpointByUrl - {args} - failed with exception: {e}"), token);
}
return true;
}
@@ -1449,7 +1456,8 @@ namespace Microsoft.WebAssembly.Diagnostics
var assembly_id = await context.SdbAgent.GetAssemblyId(asm_name, token);
var methodId = await context.SdbAgent.GetMethodIdByToken(assembly_id, method_token, token);
- var breakpoint_id = await context.SdbAgent.SetBreakpoint(methodId, il_offset, token);
+ //the breakpoint can be invalid because a race condition between the changes already applied on runtime and not applied yet on debugger side
+ var breakpoint_id = await context.SdbAgent.SetBreakpointNoThrow(methodId, il_offset, token);
if (breakpoint_id > 0)
{
@@ -1726,7 +1734,10 @@ namespace Microsoft.WebAssembly.Diagnostics
if (!ret)
return false;
- var breakpointId = await context.SdbAgent.SetBreakpoint(scope.Method.DebugId, ilOffset.Offset, token);
+ var breakpointId = await context.SdbAgent.SetBreakpointNoThrow(scope.Method.DebugId, ilOffset.Offset, token);
+ if (breakpointId == -1)
+ return false;
+
context.TempBreakpointForSetNextIP = breakpointId;
await SendResume(sessionId, token);
return true;
diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs b/src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs
index 3a25a7fac07..8ff9f8ae9af 100644
--- a/src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs
+++ b/src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs
@@ -1356,7 +1356,7 @@ namespace Microsoft.WebAssembly.Diagnostics
return parameters;
}
- public async Task<int> SetBreakpoint(int methodId, long il_offset, CancellationToken token)
+ public async Task<int> SetBreakpointNoThrow(int methodId, long il_offset, CancellationToken token)
{
using var commandParamsWriter = new MonoBinaryWriter();
commandParamsWriter.Write((byte)EventKind.Breakpoint);
@@ -1365,7 +1365,9 @@ namespace Microsoft.WebAssembly.Diagnostics
commandParamsWriter.Write((byte)ModifierKind.LocationOnly);
commandParamsWriter.Write(methodId);
commandParamsWriter.Write(il_offset);
- using var retDebuggerCmdReader = await SendDebuggerAgentCommand(CmdEventRequest.Set, commandParamsWriter, token);
+ using var retDebuggerCmdReader = await SendDebuggerAgentCommand(CmdEventRequest.Set, commandParamsWriter, token, throwOnError: false);
+ if (retDebuggerCmdReader.HasError)
+ return -1;
return retDebuggerCmdReader.ReadInt32();
}