Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
addressing @radical comments
  • Loading branch information
thaystg committed Oct 20, 2021
commit dd3a6cf3beddab2007afe4b3596fcc070aeb42cd
2 changes: 1 addition & 1 deletion src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ private async Task<DebugStore> RuntimeReady(SessionId sessionId, CancellationTok
DebugStore store = await LoadStore(sessionId, token);
context.ready.SetResult(store);
SendEvent(sessionId, "Mono.runtimeReady", new JObject(), token);
SdbHelper.SetStore(store);
SdbHelper.ResetStore(store);
return store;
}

Expand Down
31 changes: 15 additions & 16 deletions src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,11 @@ public TypeInfoWithDebugInformation(TypeInfo typeInfo, int debugId, string name)

internal class MonoBinaryReader : BinaryReader
{
public MonoBinaryReader(Stream stream) : base(stream) {}
public bool HasError { get; }
public MonoBinaryReader(Stream stream, bool hasError = false) : base(stream)
{
HasError = hasError;
}

internal static unsafe void PutBytesBE (byte *dest, byte *src, int count)
{
Expand Down Expand Up @@ -656,9 +660,9 @@ internal class MonoSDBHelper
private static int MINOR_VERSION = 61;
private static int MAJOR_VERSION = 2;

private Dictionary<int, MethodInfoWithDebugInformation> methods = new();
private Dictionary<int, AssemblyInfo> assemblies = new();
private Dictionary<int, TypeInfoWithDebugInformation> types = new();
private Dictionary<int, MethodInfoWithDebugInformation> methods;
private Dictionary<int, AssemblyInfo> assemblies;
private Dictionary<int, TypeInfoWithDebugInformation> types;

internal Dictionary<int, ValueTypeClass> valueTypes = new Dictionary<int, ValueTypeClass>();
internal Dictionary<int, PointerValue> pointerValues = new Dictionary<int, PointerValue>();
Expand All @@ -673,15 +677,16 @@ public MonoSDBHelper(MonoProxy proxy, ILogger logger)
{
this.proxy = proxy;
this.logger = logger;
this.store = null;
ResetStore(null);
}

public void SetStore(DebugStore store)
public void ResetStore(DebugStore store)
{
this.store = store;
this.methods = new();
this.assemblies = new();
this.types = new();
ClearCache();
}

public async Task<AssemblyInfo> GetAssemblyInfo(SessionId sessionId, int assemblyId, CancellationToken token)
Expand Down Expand Up @@ -824,7 +829,7 @@ internal async Task<MonoBinaryReader> SendDebuggerAgentCommandInternal(SessionId
newBytes = Convert.FromBase64String(res.Value?["result"]?["value"]?["value"]?.Value<string>());
}
var retDebuggerCmd = new MemoryStream(newBytes);
var retDebuggerCmdReader = new MonoBinaryReader(retDebuggerCmd);
var retDebuggerCmdReader = new MonoBinaryReader(retDebuggerCmd, res.IsErr);
return retDebuggerCmdReader;
}

Expand Down Expand Up @@ -862,7 +867,7 @@ internal async Task<MonoBinaryReader> SendDebuggerAgentCommandWithParmsInternal(
newBytes = Convert.FromBase64String(res.Value?["result"]?["value"]?["value"]?.Value<string>());
}
var retDebuggerCmd = new MemoryStream(newBytes);
var retDebuggerCmdReader = new MonoBinaryReader(retDebuggerCmd);
var retDebuggerCmdReader = new MonoBinaryReader(retDebuggerCmd, res.IsErr);
return retDebuggerCmdReader;
}

Expand Down Expand Up @@ -2533,15 +2538,9 @@ public async Task<bool> SetVariableValue(SessionId sessionId, int thread_id, int
JArray locals = new JArray();
retDebuggerCmdReader = await SendDebuggerAgentCommand<CmdFrame>(sessionId, CmdFrame.GetValues, commandParams, token);
int etype = retDebuggerCmdReader.ReadByte();
try
{
retDebuggerCmdReader = await SendDebuggerAgentCommandWithParms<CmdFrame>(sessionId, CmdFrame.SetValues, commandParams, etype, newValue, token);
}
catch (Exception)
{
retDebuggerCmdReader = await SendDebuggerAgentCommandWithParms<CmdFrame>(sessionId, CmdFrame.SetValues, commandParams, etype, newValue, token);
if (retDebuggerCmdReader.HasError)
return false;
}

return true;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -607,14 +607,14 @@ public async Task CreateGoodBreakpointAndHitGoToNonWasmPageComeBackAndHitAgain()
expression = "window.setTimeout(function() { load_non_wasm_page(); }, 1);"
});
await cli.SendCommand("Runtime.evaluate", run_method, token);
Thread.Sleep(1000);
await Task.Delay(1000, token);

run_method = JObject.FromObject(new
{
expression = "window.setTimeout(function() { reload_wasm_page(); }, 1);"
});
await cli.SendCommand("Runtime.evaluate", run_method, token);
Thread.Sleep(1000);
await insp.WaitFor(Inspector.READY);
await EvaluateAndCheck(
"window.setTimeout(function() { invoke_add(); }, 1);",
"dotnet://debugger-test.dll/debugger-test.cs", 10, 8,
Expand Down
20 changes: 10 additions & 10 deletions src/mono/wasm/debugger/tests/debugger-test/debugger-driver.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!doctype html>
<html lang="en-us">
<head>
</head>
<body>
<head>
</head>
<body>
<script type='text/javascript'>
var App = {
init: function () {
Expand Down Expand Up @@ -87,10 +87,10 @@
console.log("load_non_wasm_page")
window.location.replace("http://localhost:9400/non-wasm-page.html");
}
</script>
<script type="text/javascript" src="runtime-debugger.js"></script>
<script type="text/javascript" src="other.js"></script>
<script async type="text/javascript" src="dotnet.js"></script>
Stuff goes here
</body>
</html>
</script>
<script type="text/javascript" src="runtime-debugger.js"></script>
<script type="text/javascript" src="other.js"></script>
<script async type="text/javascript" src="dotnet.js"></script>
Stuff goes here
</body>
</html>
12 changes: 6 additions & 6 deletions src/mono/wasm/debugger/tests/debugger-test/non-wasm-page.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<!doctype html>
<html lang="en-us">
<head>
</head>
<body>
<head>
</head>
<body>
<script type='text/javascript'>
function reload_wasm_page () {
window.location.replace("http://localhost:9400/debugger-driver.html");
}
</script>
</body>
</html>
</script>
</body>
</html>