Support loading assemblies and symbols into debugger via callback (#42255)
authorSafia Abdalla <safia@microsoft.com>
Fri, 18 Sep 2020 19:27:30 +0000 (19:27 +0000)
committerGitHub <noreply@github.com>
Fri, 18 Sep 2020 19:27:30 +0000 (12:27 -0700)
commitbe4a89d8cd296fefab5512aa48ba195df5c61b72
tree635fb79024c8c8854206b8a7f7b8830264148516
parentcf6b06b1d36d545e37b00bf1a6311b7fff33ff4e
Support loading assemblies and symbols into debugger via callback (#42255)

* Add test setup for debugging lazy-loaded assemblies
* Add mono_wasm_add_lazy_load_files callback
* Rely on assembly_load callback to register PDBs
* Address feedback on formatting
* Fix spacing on method invocations
* Address second round of feedback
* Transport assembly data as base64 string
* Revert automated whitespace changes
* [wasm][debugger] Fix some issues with lazy loading assemblies
- One of the problems I found was that we were sending lot of duplicate
assemblies.
    - this is a problem because we are converting them to base64, then
    sending them over the wire, unnecessarily.
    - Also, the proxy wasn't correctly dealing with them, and ended up
    processing them, and then sending out duplicate `scriptParsed`
    events!
- So, we try to solve this at the `mono_wasm_asm_loaded` point:
    - issue: the `MONO.mono_wasm_runtime_is_ready` check wasn't enough
    - What we want to do is to send the events only for assemblies that
      were not in the bundle, list of which we can get in
      `MONO.loaded_files`.
    - but that has the filename
    - But we don't seem to be getting the filename from the MonoImage,
      so we use the assembly name as a workaround.
    - So, as a heuristic (and trying not too add too much new stuff this
    close to rc2!), we check if the assembly name begins with `System.`,
    or `Microsoft.`, and if it does then we look for `$assembly_name.dll`
    in the the loaded filenames.
        - If found, then we can skip these!
- The other point in the Proxy:
    - where we avoid adding duplicate assemblies if we already have one
    keyed by the assembly name.
* Fix spacing in function definition
* [wasm][debugger] Handle errors in downloading from symbol servers
* [wasm][debugger] MonoProxy: Don't skip assembly if no pdb is available
- this caused such assemblies not getting added `DebugStore.assemblies`
- which broke download symbols on demand, because it couldn't find the
corresponding assembly in the list
* [wasm][debugger] Use the correct assembly name for the search
* Fixing and changes things related to Embedded Pdb.
* Update check for loaded assemblies and initialize resolver once
* Changing the order of the checks.
* Fix indentation.
* [wasm][debugger][tests] Improve tests a bit
.. which includes setting breakpoint using a url, before loading the
dynamic assembly. This essentially tests that the bp request gets resolved
automatically when the assembly gets loaded.
- And add the embedded pdb test for `DuplicateAssemblyLoadedEvent*`
tests
* Add back types to DebugStore
* Comply with new code style requirements

Co-authored-by: Ankit Jain <radical@gmail.com>
Co-authored-by: Thays <thaystg@gmail.com>
31 files changed:
src/mono/mono/metadata/debug-mono-ppdb.c
src/mono/mono/metadata/debug-mono-ppdb.h
src/mono/mono/mini/mini-wasm-debugger.c
src/mono/wasm/Makefile
src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs
src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs
src/mono/wasm/debugger/DebuggerTestSuite/MonoJsTests.cs
src/mono/wasm/debugger/DebuggerTestSuite/Support.cs
src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs
src/mono/wasm/debugger/tests/debugger-test/debugger-array-test.cs [moved from src/mono/wasm/debugger/tests/debugger-array-test.cs with 100% similarity]
src/mono/wasm/debugger/tests/debugger-test/debugger-cfo-test.cs [moved from src/mono/wasm/debugger/tests/debugger-cfo-test.cs with 100% similarity]
src/mono/wasm/debugger/tests/debugger-test/debugger-datetime-test.cs [moved from src/mono/wasm/debugger/tests/debugger-datetime-test.cs with 100% similarity]
src/mono/wasm/debugger/tests/debugger-test/debugger-driver.html [moved from src/mono/wasm/debugger/tests/debugger-driver.html with 100% similarity]
src/mono/wasm/debugger/tests/debugger-test/debugger-evaluate-test.cs [moved from src/mono/wasm/debugger/tests/debugger-evaluate-test.cs with 100% similarity]
src/mono/wasm/debugger/tests/debugger-test/debugger-exception-test.cs [moved from src/mono/wasm/debugger/tests/debugger-exception-test.cs with 100% similarity]
src/mono/wasm/debugger/tests/debugger-test/debugger-get-properties-test.cs [moved from src/mono/wasm/debugger/tests/debugger-get-properties-test.cs with 100% similarity]
src/mono/wasm/debugger/tests/debugger-test/debugger-nullable-test.cs [moved from src/mono/wasm/debugger/tests/debugger-nullable-test.cs with 100% similarity]
src/mono/wasm/debugger/tests/debugger-test/debugger-pointers-test.cs [moved from src/mono/wasm/debugger/tests/debugger-pointers-test.cs with 100% similarity]
src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs [moved from src/mono/wasm/debugger/tests/debugger-test.cs with 96% similarity]
src/mono/wasm/debugger/tests/debugger-test/debugger-test.csproj [moved from src/mono/wasm/debugger/tests/debugger-test.csproj with 100% similarity]
src/mono/wasm/debugger/tests/debugger-test/debugger-test2.cs [moved from src/mono/wasm/debugger/tests/debugger-test2.cs with 100% similarity]
src/mono/wasm/debugger/tests/debugger-test/debugger-valuetypes-test.cs [moved from src/mono/wasm/debugger/tests/debugger-valuetypes-test.cs with 100% similarity]
src/mono/wasm/debugger/tests/debugger-test/dependency.cs [moved from src/mono/wasm/debugger/tests/dependency.cs with 100% similarity]
src/mono/wasm/debugger/tests/debugger-test/other.js [moved from src/mono/wasm/debugger/tests/other.js with 100% similarity]
src/mono/wasm/debugger/tests/debugger-test/runtime-debugger.js [moved from src/mono/wasm/debugger/tests/runtime-debugger.js with 100% similarity]
src/mono/wasm/debugger/tests/lazy-debugger-test-embedded/lazy-debugger-test-embedded.cs [new file with mode: 0644]
src/mono/wasm/debugger/tests/lazy-debugger-test-embedded/lazy-debugger-test-embedded.csproj [new file with mode: 0644]
src/mono/wasm/debugger/tests/lazy-debugger-test/lazy-debugger-test.cs [new file with mode: 0644]
src/mono/wasm/debugger/tests/lazy-debugger-test/lazy-debugger-test.csproj [new file with mode: 0644]
src/mono/wasm/runtime/driver.c
src/mono/wasm/runtime/library_mono.js