Skip to content
Merged
Changes from 2 commits
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
71 changes: 33 additions & 38 deletions src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1475,61 +1475,56 @@ public IEnumerable<SourceFile> Add(SessionId id, string name, byte[] assembly_da
}
}

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

if (!useDebuggerProtocol)
var pdb_files = new List<string>();
foreach (string file_name in loaded_files)
{
var pdb_files = new List<string>();
foreach (string file_name in loaded_files)
{
if (file_name.EndsWith(".pdb", StringComparison.OrdinalIgnoreCase))
pdb_files.Add(file_name);
else
asm_files.Add(file_name);
}
if (file_name.EndsWith(".pdb", StringComparison.OrdinalIgnoreCase))
pdb_files.Add(file_name);
else
asm_files.Add(file_name);
}

foreach (string url in asm_files)
foreach (string url in asm_files)
{
try
{
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<byte[]>(null))
});
}
catch (Exception e)
{
logger.LogDebug($"Failed to read {url} ({e.Message})");
}
steps.Add(
new DebugItem
{
Url = url,
Data = Task.WhenAll(MonoProxy.HttpClient.GetByteArrayAsync(url, token), pdb != null ? MonoProxy.HttpClient.GetByteArrayAsync(pdb, token) : Task.FromResult<byte[]>(null))
});
}
}
else
{
foreach (string file_name in loaded_files)
catch (Exception e)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we check for more specific exception type(s)?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, the retry should be if either of the two tasks fail, right?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it logger.LogDebug if it goes down this new path?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont't think so, only if it fails in the retry process too, or if tryUseDebuggerProtocol is disabled.

{
if (file_name.EndsWith(".pdb", StringComparison.OrdinalIgnoreCase))
continue;
try
if (tryUseDebuggerProtocol)
{
string unescapedFileName = Uri.UnescapeDataString(file_name);
steps.Add(
try
{
string unescapedFileName = Uri.UnescapeDataString(url);
steps.Add(
new DebugItem
{
Url = file_name,
Url = url,
Data = context.SdbAgent.GetBytesFromAssemblyAndPdb(Path.GetFileName(unescapedFileName), token)
});
}
catch (Exception ex)
{
logger.LogDebug($"Failed to read {url} ({ex.Message})");
}
}
catch (Exception e)
else
{
logger.LogDebug($"Failed to read {file_name} ({e.Message})");
logger.LogDebug($"Failed to read {url} ({e.Message})");
Comment thread
thaystg marked this conversation as resolved.
}
}
}
Expand Down