From 6b8eed792091a5dc1666d4365de9384b049e72a4 Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Tue, 3 Oct 2023 15:26:47 -0300 Subject: [PATCH 1/4] Fixing https://github.com/dotnet/aspnetcore/issues/51093 --- .../debugger/BrowserDebugProxy/DebugStore.cs | 62 ++++++++----------- 1 file changed, 26 insertions(+), 36 deletions(-) diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs b/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs index 5a2b3d2577f469..c02831ffa6d996 100644 --- a/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs +++ b/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs @@ -1491,50 +1491,24 @@ public async IAsyncEnumerable Load(SessionId id, string[] loaded_fil foreach (string url in asm_files) { - try - { - string candidate_pdb = Path.ChangeExtension(url, "pdb"); - string pdb = pdb_files.FirstOrDefault(n => n == candidate_pdb); + string candidate_pdb = Path.ChangeExtension(url, "pdb"); + string pdb = pdb_files.FirstOrDefault(n => n == candidate_pdb); - steps.Add( - new DebugItem - { - Url = url, - Data = Task.WhenAll(MonoProxy.HttpClient.GetByteArrayAsync(url, token), pdb != null ? MonoProxy.HttpClient.GetByteArrayAsync(pdb, token) : Task.FromResult(null)) - }); - } - catch (Exception e) - { - if (tryUseDebuggerProtocol) - { - try - { - string unescapedFileName = Uri.UnescapeDataString(url); - steps.Add( - new DebugItem - { - Url = url, - Data = context.SdbAgent.GetBytesFromAssemblyAndPdb(Path.GetFileName(unescapedFileName), token) - }); - } - catch (Exception ex) - { - logger.LogDebug($"Failed to get bytes using debugger protocol {url} ({ex.Message})"); - } - } - else + steps.Add( + new DebugItem { - logger.LogDebug($"Failed to read {url} ({e.Message})"); - } - } + Url = url, + Data = Task.WhenAll(MonoProxy.HttpClient.GetByteArrayAsync(url, token), pdb != null ? MonoProxy.HttpClient.GetByteArrayAsync(pdb, token) : Task.FromResult(null)) + }); } foreach (DebugItem step in steps) { AssemblyInfo assembly = null; + byte[][] bytes; try { - byte[][] bytes = await step.Data.ConfigureAwait(false); + bytes = await step.Data.ConfigureAwait(false); if (bytes[0] == null) { logger.LogDebug($"Bytes from assembly {step.Url} is NULL"); @@ -1544,7 +1518,23 @@ public async IAsyncEnumerable Load(SessionId id, string[] loaded_fil } catch (Exception e) { - logger.LogError($"Failed to load {step.Url} ({e.Message})"); + try + { + if (tryUseDebuggerProtocol) + { + string unescapedFileName = Uri.UnescapeDataString(step.Url); + bytes = await context.SdbAgent.GetBytesFromAssemblyAndPdb(Path.GetFileName(unescapedFileName), token); + assembly = new AssemblyInfo(monoProxy, id, step.Url, bytes[0], bytes[1], logger, token); + } + else + { + logger.LogDebug($"Failed to read {step.Url} ({e.Message})"); + } + } + catch (Exception ex) + { + logger.LogError($"Failed to load {step.Url} ({ex.Message})"); + } } if (assembly == null) continue; From 20576a49b80b6f3c29321ade8d0fa691f09a4b1d Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Tue, 3 Oct 2023 16:16:07 -0300 Subject: [PATCH 2/4] Addressing comments --- src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs b/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs index c02831ffa6d996..1b92f6ae5d15b7 100644 --- a/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs +++ b/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs @@ -1533,7 +1533,7 @@ public async IAsyncEnumerable Load(SessionId id, string[] loaded_fil } catch (Exception ex) { - logger.LogError($"Failed to load {step.Url} ({ex.Message})"); + logger.LogError($"Failed to load {step.Url} ({ex})"); } } if (assembly == null) From 2d985753db078fa32c57ed31d58ce2b494b32f08 Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Tue, 3 Oct 2023 16:33:26 -0300 Subject: [PATCH 3/4] Addressing comments --- src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs b/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs index 1b92f6ae5d15b7..e9e029b3e7597c 100644 --- a/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs +++ b/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs @@ -1528,7 +1528,7 @@ public async IAsyncEnumerable Load(SessionId id, string[] loaded_fil } else { - logger.LogDebug($"Failed to read {step.Url} ({e.Message})"); + logger.LogDebug($"Failed to read {step.Url} ({e})"); } } catch (Exception ex) From f4978c5cf523b8d638b1880adef9446443074d1d Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Tue, 3 Oct 2023 16:34:24 -0300 Subject: [PATCH 4/4] Addressing comments --- src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs b/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs index e9e029b3e7597c..cdd839648b379a 100644 --- a/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs +++ b/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs @@ -1523,7 +1523,7 @@ public async IAsyncEnumerable Load(SessionId id, string[] loaded_fil if (tryUseDebuggerProtocol) { string unescapedFileName = Uri.UnescapeDataString(step.Url); - bytes = await context.SdbAgent.GetBytesFromAssemblyAndPdb(Path.GetFileName(unescapedFileName), token); + bytes = await context.SdbAgent.GetBytesFromAssemblyAndPdb(Path.GetFileName(unescapedFileName), token).ConfigureAwait(false); assembly = new AssemblyInfo(monoProxy, id, step.Url, bytes[0], bytes[1], logger, token); } else