mirror of
https://github.com/VSadov/Satori.git
synced 2025-06-10 01:50:53 +09:00
[wasm][debugger] Showing "Frame not in module" after vscode-js-debug bump on VS (#87154)
* We were sending the scriptId of a context that was already destroyed and vscode-js-debug extension started to consider this information that was ignored before. * addressing @radical comments
This commit is contained in:
parent
01f63e709a
commit
5fe7b06e1c
2 changed files with 38 additions and 14 deletions
|
@ -23,7 +23,7 @@ internal sealed class FirefoxMonoProxy : MonoProxy
|
||||||
|
|
||||||
public FirefoxExecutionContext GetContextFixefox(SessionId sessionId)
|
public FirefoxExecutionContext GetContextFixefox(SessionId sessionId)
|
||||||
{
|
{
|
||||||
if (contexts.TryGetValue(sessionId, out ExecutionContext context))
|
if (TryGetCurrentExecutionContextValue(sessionId, out ExecutionContext context))
|
||||||
return context as FirefoxExecutionContext;
|
return context as FirefoxExecutionContext;
|
||||||
throw new ArgumentException($"Invalid Session: \"{sessionId}\"", nameof(sessionId));
|
throw new ArgumentException($"Invalid Session: \"{sessionId}\"", nameof(sessionId));
|
||||||
}
|
}
|
||||||
|
@ -316,7 +316,7 @@ internal sealed class FirefoxMonoProxy : MonoProxy
|
||||||
{
|
{
|
||||||
case "resume":
|
case "resume":
|
||||||
{
|
{
|
||||||
if (!contexts.TryGetValue(sessionId, out ExecutionContext context))
|
if (!TryGetCurrentExecutionContextValue(sessionId, out ExecutionContext context))
|
||||||
return false;
|
return false;
|
||||||
context.PausedOnWasm = false;
|
context.PausedOnWasm = false;
|
||||||
if (context.CallStack == null)
|
if (context.CallStack == null)
|
||||||
|
@ -380,7 +380,7 @@ internal sealed class FirefoxMonoProxy : MonoProxy
|
||||||
}
|
}
|
||||||
case "setBreakpoint":
|
case "setBreakpoint":
|
||||||
{
|
{
|
||||||
if (!contexts.TryGetValue(sessionId, out ExecutionContext context))
|
if (!TryGetCurrentExecutionContextValue(sessionId, out ExecutionContext context))
|
||||||
return false;
|
return false;
|
||||||
var req = JObject.FromObject(new
|
var req = JObject.FromObject(new
|
||||||
{
|
{
|
||||||
|
@ -420,7 +420,7 @@ internal sealed class FirefoxMonoProxy : MonoProxy
|
||||||
}
|
}
|
||||||
case "removeBreakpoint":
|
case "removeBreakpoint":
|
||||||
{
|
{
|
||||||
if (!contexts.TryGetValue(sessionId, out ExecutionContext context))
|
if (!TryGetCurrentExecutionContextValue(sessionId, out ExecutionContext context))
|
||||||
return false;
|
return false;
|
||||||
Result resp = await SendCommand(sessionId, "", args, token);
|
Result resp = await SendCommand(sessionId, "", args, token);
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace Microsoft.WebAssembly.Diagnostics
|
||||||
internal string CachePathSymbolServer { get; private set; }
|
internal string CachePathSymbolServer { get; private set; }
|
||||||
private readonly HashSet<SessionId> sessions = new HashSet<SessionId>();
|
private readonly HashSet<SessionId> sessions = new HashSet<SessionId>();
|
||||||
private static readonly string[] s_executionContextIndependentCDPCommandNames = { "DotnetDebugger.setDebuggerProperty", "DotnetDebugger.runTests" };
|
private static readonly string[] s_executionContextIndependentCDPCommandNames = { "DotnetDebugger.setDebuggerProperty", "DotnetDebugger.runTests" };
|
||||||
protected Dictionary<SessionId, ExecutionContext> contexts = new Dictionary<SessionId, ExecutionContext>();
|
protected Dictionary<SessionId, List<ExecutionContext>> contexts = new Dictionary<SessionId, List<ExecutionContext>>();
|
||||||
|
|
||||||
public static HttpClient HttpClient => new HttpClient();
|
public static HttpClient HttpClient => new HttpClient();
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ namespace Microsoft.WebAssembly.Diagnostics
|
||||||
|
|
||||||
internal ExecutionContext GetContext(SessionId sessionId)
|
internal ExecutionContext GetContext(SessionId sessionId)
|
||||||
{
|
{
|
||||||
if (contexts.TryGetValue(sessionId, out ExecutionContext context))
|
if (TryGetCurrentExecutionContextValue(sessionId, out ExecutionContext context))
|
||||||
return context;
|
return context;
|
||||||
|
|
||||||
throw new ArgumentException($"Invalid Session: \"{sessionId}\"", nameof(sessionId));
|
throw new ArgumentException($"Invalid Session: \"{sessionId}\"", nameof(sessionId));
|
||||||
|
@ -53,16 +53,29 @@ namespace Microsoft.WebAssembly.Diagnostics
|
||||||
|
|
||||||
private bool UpdateContext(SessionId sessionId, ExecutionContext executionContext, out ExecutionContext previousExecutionContext)
|
private bool UpdateContext(SessionId sessionId, ExecutionContext executionContext, out ExecutionContext previousExecutionContext)
|
||||||
{
|
{
|
||||||
bool previous = contexts.TryGetValue(sessionId, out previousExecutionContext);
|
bool previous = TryGetCurrentExecutionContextValue(sessionId, out previousExecutionContext);
|
||||||
contexts[sessionId] = executionContext;
|
if (!previous)
|
||||||
|
contexts[sessionId] = new();
|
||||||
|
contexts[sessionId].Add(executionContext);
|
||||||
return previous;
|
return previous;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal bool TryGetCurrentExecutionContextValue(SessionId id, out ExecutionContext executionContext)
|
||||||
|
{
|
||||||
|
executionContext = null;
|
||||||
|
if (!contexts.TryGetValue(id, out List<ExecutionContext> contextList))
|
||||||
|
return false;
|
||||||
|
if (contextList.Count == 0)
|
||||||
|
return false;
|
||||||
|
executionContext = contextList.Last<ExecutionContext>();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
internal virtual Task<Result> SendMonoCommand(SessionId id, MonoCommands cmd, CancellationToken token) => SendCommand(id, "Runtime.evaluate", JObject.FromObject(cmd), token);
|
internal virtual Task<Result> SendMonoCommand(SessionId id, MonoCommands cmd, CancellationToken token) => SendCommand(id, "Runtime.evaluate", JObject.FromObject(cmd), token);
|
||||||
|
|
||||||
internal void SendLog(SessionId sessionId, string message, CancellationToken token, string type = "warning")
|
internal void SendLog(SessionId sessionId, string message, CancellationToken token, string type = "warning")
|
||||||
{
|
{
|
||||||
if (!contexts.TryGetValue(sessionId, out ExecutionContext context))
|
if (!TryGetCurrentExecutionContextValue(sessionId, out ExecutionContext context))
|
||||||
return;
|
return;
|
||||||
/*var o = JObject.FromObject(new
|
/*var o = JObject.FromObject(new
|
||||||
{
|
{
|
||||||
|
@ -151,6 +164,16 @@ namespace Microsoft.WebAssembly.Diagnostics
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
case "Runtime.executionContextDestroyed":
|
||||||
|
{
|
||||||
|
int id = args["executionContextId"].Value<int>();
|
||||||
|
if (!contexts.TryGetValue(sessionId, out var contextList))
|
||||||
|
return false;
|
||||||
|
contextList.RemoveAll(x => x.Id == id);
|
||||||
|
if (contextList.Count == 0)
|
||||||
|
contexts.Remove(sessionId);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
case "Debugger.paused":
|
case "Debugger.paused":
|
||||||
{
|
{
|
||||||
|
@ -188,7 +211,7 @@ namespace Microsoft.WebAssembly.Diagnostics
|
||||||
|
|
||||||
if (args["asyncStackTraceId"] != null)
|
if (args["asyncStackTraceId"] != null)
|
||||||
{
|
{
|
||||||
if (!contexts.TryGetValue(sessionId, out ExecutionContext context))
|
if (!TryGetCurrentExecutionContextValue(sessionId, out ExecutionContext context))
|
||||||
return false;
|
return false;
|
||||||
if (context.CopyDataFromParentContext())
|
if (context.CopyDataFromParentContext())
|
||||||
{
|
{
|
||||||
|
@ -254,7 +277,7 @@ namespace Microsoft.WebAssembly.Diagnostics
|
||||||
|
|
||||||
protected void CreateWorkerExecutionContext(SessionId workerSessionId, SessionId originSessionId)
|
protected void CreateWorkerExecutionContext(SessionId workerSessionId, SessionId originSessionId)
|
||||||
{
|
{
|
||||||
if (!contexts.TryGetValue(originSessionId, out ExecutionContext context))
|
if (!TryGetCurrentExecutionContextValue(originSessionId, out ExecutionContext context))
|
||||||
{
|
{
|
||||||
logger.LogDebug($"Origin sessionId does not exist - {originSessionId}");
|
logger.LogDebug($"Origin sessionId does not exist - {originSessionId}");
|
||||||
return;
|
return;
|
||||||
|
@ -264,7 +287,8 @@ namespace Microsoft.WebAssembly.Diagnostics
|
||||||
logger.LogDebug($"Worker sessionId already exists - {originSessionId}");
|
logger.LogDebug($"Worker sessionId already exists - {originSessionId}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
contexts[workerSessionId] = context.CreateChildAsyncExecutionContext(workerSessionId);
|
contexts[workerSessionId] = new();
|
||||||
|
contexts[workerSessionId].Add(context.CreateChildAsyncExecutionContext(workerSessionId));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual async Task SendResume(SessionId id, CancellationToken token)
|
protected virtual async Task SendResume(SessionId id, CancellationToken token)
|
||||||
|
@ -273,7 +297,7 @@ namespace Microsoft.WebAssembly.Diagnostics
|
||||||
}
|
}
|
||||||
protected async Task<bool> IsRuntimeAlreadyReadyAlready(SessionId sessionId, CancellationToken token)
|
protected async Task<bool> IsRuntimeAlreadyReadyAlready(SessionId sessionId, CancellationToken token)
|
||||||
{
|
{
|
||||||
if (contexts.TryGetValue(sessionId, out ExecutionContext context) && context.IsRuntimeReady)
|
if (TryGetCurrentExecutionContextValue(sessionId, out ExecutionContext context) && context.IsRuntimeReady)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
Result res = await SendMonoCommand(sessionId, MonoCommands.IsRuntimeReady(RuntimeId), token);
|
Result res = await SendMonoCommand(sessionId, MonoCommands.IsRuntimeReady(RuntimeId), token);
|
||||||
|
@ -298,7 +322,7 @@ namespace Microsoft.WebAssembly.Diagnostics
|
||||||
if (id == SessionId.Null)
|
if (id == SessionId.Null)
|
||||||
await AttachToTarget(id, token);
|
await AttachToTarget(id, token);
|
||||||
|
|
||||||
if (!contexts.TryGetValue(id, out ExecutionContext context) && !s_executionContextIndependentCDPCommandNames.Contains(method))
|
if (!TryGetCurrentExecutionContextValue(id, out ExecutionContext context) && !s_executionContextIndependentCDPCommandNames.Contains(method))
|
||||||
{
|
{
|
||||||
if (method == "Debugger.setPauseOnExceptions")
|
if (method == "Debugger.setPauseOnExceptions")
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue