-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[wasm][debugger] Implement get bytes from loaded_files using debugger protocol. #69072
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
thaystg
merged 8 commits into
dotnet:main
from
thaystg:thays_implement_loaded_files_over_debugger_protocol
Jun 14, 2022
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
347a41c
Implement get bytes from loaded_files using debugger protocol.
thaystg 1f22eba
fix pdb size == nul
thaystg 72c1295
Merge branch 'main' into thays_implement_loaded_files_over_debugger_p…
radical 9a5d9b7
Merge branch 'dotnet:main' into thays_implement_loaded_files_over_deb…
thaystg 8b2a01c
Adressing @radical comments.
thaystg a948989
Fix build.
thaystg b441863
fix compilation
thaystg e41a8aa
Addressing @radical comments.
thaystg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1279,36 +1279,61 @@ public IEnumerable<SourceFile> Add(SessionId id, string name, byte[] assembly_da | |
| } | ||
| } | ||
|
|
||
| public async IAsyncEnumerable<SourceFile> Load(SessionId id, string[] loaded_files, [EnumeratorCancellation] CancellationToken token) | ||
| public async IAsyncEnumerable<SourceFile> Load(SessionId id, string[] loaded_files, ExecutionContext context, bool useDebuggerProtocol, [EnumeratorCancellation] CancellationToken token) | ||
| { | ||
| var asm_files = new List<string>(); | ||
| 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); | ||
| } | ||
|
|
||
| List<DebugItem> steps = new List<DebugItem>(); | ||
| foreach (string url in asm_files) | ||
|
|
||
| if (!useDebuggerProtocol) | ||
| { | ||
| try | ||
| var pdb_files = new List<string>(); | ||
| foreach (string file_name in loaded_files) | ||
| { | ||
| string candidate_pdb = Path.ChangeExtension(url, "pdb"); | ||
| string pdb = pdb_files.FirstOrDefault(n => n == candidate_pdb); | ||
| if (file_name.EndsWith(".pdb", StringComparison.OrdinalIgnoreCase)) | ||
| pdb_files.Add(file_name); | ||
| else | ||
| asm_files.Add(file_name); | ||
| } | ||
|
|
||
| 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)) | ||
| }); | ||
| foreach (string url in asm_files) | ||
| { | ||
| try | ||
| { | ||
| 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})"); | ||
| } | ||
| } | ||
| catch (Exception e) | ||
| } | ||
| else | ||
| { | ||
| foreach (string file_name in loaded_files) | ||
| { | ||
| logger.LogDebug($"Failed to read {url} ({e.Message})"); | ||
| if (file_name.EndsWith(".pdb", StringComparison.OrdinalIgnoreCase)) | ||
| continue; | ||
| try | ||
| { | ||
| steps.Add( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. try/catch to handle exceptions |
||
| new DebugItem | ||
| { | ||
| Url = file_name, | ||
| Data = context.SdbAgent.GetBytesFromAssemblyAndPdb(Path.GetFileName(file_name), token) | ||
| }); | ||
| } | ||
| catch (Exception e) | ||
| { | ||
| logger.LogDebug($"Failed to read {file_name} ({e.Message})"); | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -1318,6 +1343,11 @@ public async IAsyncEnumerable<SourceFile> Load(SessionId id, string[] loaded_fil | |
| try | ||
| { | ||
| byte[][] bytes = await step.Data.ConfigureAwait(false); | ||
| if (bytes[0] == null) | ||
| { | ||
| logger.LogDebug($"Bytes from assembly {step.Url} is NULL"); | ||
| continue; | ||
| } | ||
| assembly = new AssemblyInfo(monoProxy, id, step.Url, bytes[0], bytes[1], logger, token); | ||
| } | ||
| catch (Exception e) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.