Skip to content

Commit 062fd6f

Browse files
thaystgradical
andauthored
[release/7.0-staging][wasm][debugger] Improve debugger performance (#88602)
* fix debugger performance * Update src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs Co-authored-by: Ankit Jain <radical@gmail.com> * addressing @radical comments --------- Co-authored-by: Ankit Jain <radical@gmail.com>
1 parent eacc7bd commit 062fd6f

File tree

1 file changed

+33
-38
lines changed

1 file changed

+33
-38
lines changed

src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,61 +1475,56 @@ public IEnumerable<SourceFile> Add(SessionId id, string name, byte[] assembly_da
14751475
}
14761476
}
14771477

1478-
public async IAsyncEnumerable<SourceFile> Load(SessionId id, string[] loaded_files, ExecutionContext context, bool useDebuggerProtocol, [EnumeratorCancellation] CancellationToken token)
1478+
public async IAsyncEnumerable<SourceFile> Load(SessionId id, string[] loaded_files, ExecutionContext context, bool tryUseDebuggerProtocol, [EnumeratorCancellation] CancellationToken token)
14791479
{
14801480
var asm_files = new List<string>();
14811481
List<DebugItem> steps = new List<DebugItem>();
14821482

1483-
if (!useDebuggerProtocol)
1483+
var pdb_files = new List<string>();
1484+
foreach (string file_name in loaded_files)
14841485
{
1485-
var pdb_files = new List<string>();
1486-
foreach (string file_name in loaded_files)
1487-
{
1488-
if (file_name.EndsWith(".pdb", StringComparison.OrdinalIgnoreCase))
1489-
pdb_files.Add(file_name);
1490-
else
1491-
asm_files.Add(file_name);
1492-
}
1486+
if (file_name.EndsWith(".pdb", StringComparison.OrdinalIgnoreCase))
1487+
pdb_files.Add(file_name);
1488+
else
1489+
asm_files.Add(file_name);
1490+
}
14931491

1494-
foreach (string url in asm_files)
1492+
foreach (string url in asm_files)
1493+
{
1494+
try
14951495
{
1496-
try
1497-
{
1498-
string candidate_pdb = Path.ChangeExtension(url, "pdb");
1499-
string pdb = pdb_files.FirstOrDefault(n => n == candidate_pdb);
1496+
string candidate_pdb = Path.ChangeExtension(url, "pdb");
1497+
string pdb = pdb_files.FirstOrDefault(n => n == candidate_pdb);
15001498

1501-
steps.Add(
1502-
new DebugItem
1503-
{
1504-
Url = url,
1505-
Data = Task.WhenAll(MonoProxy.HttpClient.GetByteArrayAsync(url, token), pdb != null ? MonoProxy.HttpClient.GetByteArrayAsync(pdb, token) : Task.FromResult<byte[]>(null))
1506-
});
1507-
}
1508-
catch (Exception e)
1509-
{
1510-
logger.LogDebug($"Failed to read {url} ({e.Message})");
1511-
}
1499+
steps.Add(
1500+
new DebugItem
1501+
{
1502+
Url = url,
1503+
Data = Task.WhenAll(MonoProxy.HttpClient.GetByteArrayAsync(url, token), pdb != null ? MonoProxy.HttpClient.GetByteArrayAsync(pdb, token) : Task.FromResult<byte[]>(null))
1504+
});
15121505
}
1513-
}
1514-
else
1515-
{
1516-
foreach (string file_name in loaded_files)
1506+
catch (Exception e)
15171507
{
1518-
if (file_name.EndsWith(".pdb", StringComparison.OrdinalIgnoreCase))
1519-
continue;
1520-
try
1508+
if (tryUseDebuggerProtocol)
15211509
{
1522-
string unescapedFileName = Uri.UnescapeDataString(file_name);
1523-
steps.Add(
1510+
try
1511+
{
1512+
string unescapedFileName = Uri.UnescapeDataString(url);
1513+
steps.Add(
15241514
new DebugItem
15251515
{
1526-
Url = file_name,
1516+
Url = url,
15271517
Data = context.SdbAgent.GetBytesFromAssemblyAndPdb(Path.GetFileName(unescapedFileName), token)
15281518
});
1519+
}
1520+
catch (Exception ex)
1521+
{
1522+
logger.LogDebug($"Failed to get bytes using debugger protocol {url} ({ex.Message})");
1523+
}
15291524
}
1530-
catch (Exception e)
1525+
else
15311526
{
1532-
logger.LogDebug($"Failed to read {file_name} ({e.Message})");
1527+
logger.LogDebug($"Failed to read {url} ({e.Message})");
15331528
}
15341529
}
15351530
}

0 commit comments

Comments
 (0)