Skip to content
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

[mono][debugger] Support debug after hot-reload #55220

Merged
merged 13 commits into from
Jul 13, 2021

Conversation

thaystg
Copy link
Member

@thaystg thaystg commented Jul 6, 2021

  • Implemented the runtime side.
  • And the client side for wasm.
  • Added tests for wasm.

To do in another PR, implement support on debugger-libs for Android.

thaystg added 7 commits July 1, 2021 17:58
* origin/main: (27 commits)
  [mono][llvm] Only emit 'LLVM failed' messages on verbosity > 0. (dotnet#55060)
  Http2Stream throws a wrapped Http2ConnectionException on GO_AWAY (dotnet#54625)
  [main] Update dependencies from dnceng/internal/dotnet-optimization dotnet/arcade dotnet/xharness dotnet/hotreload-utils (dotnet#55007)
  disable a failing test. (dotnet#55063)
  [mono][wasm] Disable some tests which crash on AOT. (dotnet#55054)
  Fix fix_allocation_context for regions (dotnet#54931)
  Delete stale references to System.IO.FileSystem.Primitives (dotnet#55041)
  Add binplaced analyzers to ASP.NET transport package (dotnet#55042)
  [mono] Enable many HardwareIntrinsic tests on wasm
  Delete `compQuirkForPPP`. (dotnet#55050)
  [Mono] Condition Workload AOT import to be osx only (dotnet#55040)
  package native quic library (dotnet#54992)
  Make GlobalizationMode code consistent (dotnet#55039)
  Expand PerfMap format to support metadata for symbol indexation (dotnet#53792)
  [debugger]Componentize debugger (dotnet#54887)
  [Mono] Include loaded interpreter methods as EventPipe session rundown method events. (dotnet#54953)
  Delete stale ActiveIssue from HttpHeadersTest (dotnet#55027)
  Poison address-exposed user variables in debug (dotnet#54685)
  Recategorize emsdk dependency (dotnet#55028)
  Remove the the wasm AOT specific test project exclusions (dotnet#54988)
  ...
@ghost
Copy link

ghost commented Jul 6, 2021

Tagging subscribers to this area: @thaystg
See info in area-owners.md if you want to be subscribed.

Issue Details

Implemented the runtime side.
And the client side for wasm.

To do in another PR, implement support on debugger-libs for Android.

Author: thaystg
Assignees: -
Labels:

area-Debugger-mono

Milestone: -

@thaystg thaystg changed the title [mono][debugger] Support debug after hotreload [mono][debugger] Support debug after hot-reload Jul 6, 2021
@thaystg thaystg added the arch-wasm WebAssembly architecture label Jul 6, 2021
@ghost
Copy link

ghost commented Jul 6, 2021

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

Issue Details

Implemented the runtime side.
And the client side for wasm.

To do in another PR, implement support on debugger-libs for Android.

Author: thaystg
Assignees: -
Labels:

arch-wasm, area-Debugger-mono

Milestone: -

@thaystg thaystg requested a review from radical July 6, 2021 18:21
static void
send_enc_delta (MonoImage *image, gconstpointer dmeta_bytes, int32_t dmeta_len, gconstpointer dpdb_bytes, int32_t dpdb_len)
{
//TODO: if it came from debugger we don't need to pass the parameters back, they are already on debugger client side.
Copy link
Member

Choose a reason for hiding this comment

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

This is related to issue #55228 - we can assume that if the debugger is attached, all updates are coming through the debugger command, not through the managed icall.

Copy link
Member Author

Choose a reason for hiding this comment

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

I cannot change this right now for WASM, am I right?
Because for wasm the updates are not coming through debugger.

Copy link
Member

Choose a reason for hiding this comment

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

That's right. I think for wasm the updates are always through dotnet watch, and not through the debugger.

@lambdageek lambdageek mentioned this pull request Jul 6, 2021
51 tasks
if (!cols [MONO_METHODBODY_SEQ_POINTS])
return NULL;

const char *ptr = mono_metadata_blob_heap (image_dppdb, cols [MONO_METHODBODY_SEQ_POINTS]);
Copy link
Member

@lambdageek lambdageek Jul 6, 2021

Choose a reason for hiding this comment

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

I'm a little bit surprised this is a heap offset in the delta pdb. For the metadata, the heap offset is in the combined baseline+delta heaps. (ie if originally the blob heap was 1000 bytes and the delta metadata has 500 more bytes, then the metadata tables in the delta will have offsets like 1001-1500, not 1-500.)

But these formats aren't very consistent. So I assume you saw in a testcase that it's always offsets in the delta pdb heap only.

@@ -9775,8 +9775,7 @@ mono_interp_transform_method (InterpMethod *imethod, ThreadContext *context, Mon

MonoJitMemoryManager *jit_mm = get_default_jit_mm ();
jit_mm_lock (jit_mm);
if (!g_hash_table_lookup (jit_mm->seq_points, imethod->method))
g_hash_table_insert (jit_mm->seq_points, imethod->method, imethod->jinfo->seq_points);
g_hash_table_replace (jit_mm->seq_points, imethod->method, imethod->jinfo->seq_points);
Copy link
Member

Choose a reason for hiding this comment

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

I think we also need to do something in copy_imethod_for_frame:

In hot reload, the existing version of a method that is already running will finish with the old body, and new calls will use the new method body. So it is possible to hit a breakpoint in an old version of the method. So I think we might need to make a copy of the old seq points in copy_imethod_for_frame. What do you think?

Copy link
Member Author

@thaystg thaystg Jul 7, 2021

Choose a reason for hiding this comment

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

I'm not sure, this seq_points would only be used to set breakpoint. So it would be possible to be debugging this method with old body?

Like: Thread A is running MethodA and it's stopped in a breakpoint.
In debugger we change something in MethodA so it will replace the MethodA body.
On Thread A we set another breakpoint in another line using the old body and then resume.

Would it be possible to do? While it is stopped in a breakpoint change something and send the deltas to runtime?

Copy link
Member

Choose a reason for hiding this comment

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

Like: Thread A is running MethodA and it's stopped in a breakpoint.
In debugger we change something in MethodA so it will replace the MethodA body.
On Thread A we set another breakpoint in another line using the old body and then resume.

I think this is possible. @tmat - VS can show the old and the new body of MethodA? Is that something that is already supported by VS, or something we are considering to do in the future?

@thaystg thaystg marked this pull request as ready for review July 7, 2021 18:19
@lewing
Copy link
Member

lewing commented Jul 10, 2021

/azp run

@azure-pipelines
Copy link

You have several pipelines (over 10) configured to build pull requests in this repository. Specify which pipelines you would like to run by using /azp run [pipelines] command. You can specify multiple pipelines using a comma separated list.

@lewing
Copy link
Member

lewing commented Jul 10, 2021

/azp run runtime

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@lambdageek lambdageek left a comment

Choose a reason for hiding this comment

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

:shipit: 🎉

@thaystg thaystg merged commit c786e4f into dotnet:main Jul 13, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Aug 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly architecture area-Debugger-mono
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants