Skip to content

[wasm][debugger] Support new hot reload features#70097

Merged
thaystg merged 19 commits intodotnet:mainfrom
thaystg:thays_support_new_hot_reload_features
Jun 7, 2022
Merged

[wasm][debugger] Support new hot reload features#70097
thaystg merged 19 commits intodotnet:mainfrom
thaystg:thays_support_new_hot_reload_features

Conversation

@thaystg
Copy link
Member

@thaystg thaystg commented Jun 1, 2022

Supporting new hotreload features on wasm debugger:

  1. If you have an existing class, you can add a non-virtual method (static or instance) to the class.
  2. If you have an existing class, you can add a static field to it.
  3. If you add a new class, the new class can have fields, properties, methods, events, base classes, interfaces, generic parameters

Also fixed when try to update a class adding a new static field and the class wasn't initialized yet.
Also fixed information passed to BrowserDebugProxy, we need metadata delta and pdb delta, we were only receiving pdb delta.

@thaystg thaystg requested review from lambdageek, lewing and radical June 1, 2022 17:47
@ghost ghost assigned thaystg Jun 1, 2022
@ghost ghost added the area-EnC-mono Hot Reload for WebAssembly, iOS/Android, etc label Jun 1, 2022
@ghost
Copy link

ghost commented Jun 1, 2022

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

Issue Details

Supporting new hotreload features on wasm debugger:

  1. If you have an existing class, you can add a non-virtual method (static or instance) to the class.
  2. If you have an existing class, you can add a static field to it.
  3. If you add a new class, the new class can have fields, properties, methods, events, base classes, interfaces, generic parameters

Also fixed when try to update a class adding a new static field and the class wasn't initialized yet.
Also fixed information passed to BrowserDebugProxy, we need metadata delta and pdb delta, we were only receiving pdb delta.

Author: thaystg
Assignees: thaystg
Labels:

area-Debugger-mono, area-EnC-mono

Milestone: -

@thaystg thaystg added the arch-wasm WebAssembly architecture label Jun 1, 2022
@ghost
Copy link

ghost commented Jun 1, 2022

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

Issue Details

Supporting new hotreload features on wasm debugger:

  1. If you have an existing class, you can add a non-virtual method (static or instance) to the class.
  2. If you have an existing class, you can add a static field to it.
  3. If you add a new class, the new class can have fields, properties, methods, events, base classes, interfaces, generic parameters

Also fixed when try to update a class adding a new static field and the class wasn't initialized yet.
Also fixed information passed to BrowserDebugProxy, we need metadata delta and pdb delta, we were only receiving pdb delta.

Author: thaystg
Assignees: thaystg
Labels:

arch-wasm, area-Debugger-mono, area-EnC-mono

Milestone: -

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.

Changes in hot_reload and debugger-agent lgtm. I don't understand the DebugStore changes yet, need to read a bit more of the debug proxy source.

@ilonatommy could you review, also

@thaystg thaystg requested a review from ilonatommy June 2, 2022 06:21
Copy link
Member

@ilonatommy ilonatommy left a comment

Choose a reason for hiding this comment

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

Good job! I focused mostly on .cs sources.

Copy link
Member

@radical radical left a comment

Choose a reason for hiding this comment

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

I'm new to the hot reload bits, but tried to review what I could.

typeInfo = new TypeInfo(this, typeHandle, typeDefinition, asmMetadataReaderParm, logger);
TypesByName[typeInfo.FullName] = typeInfo;
TypesByToken[typeInfo.Token] = typeInfo;
}
Copy link
Member

Choose a reason for hiding this comment

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

This should continue after this.

TypesByToken[typeInfo.Token] = typeInfo;
}
}
else
Copy link
Member

Choose a reason for hiding this comment

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

And else block should run only when operation == Default.

Comment on lines +934 to +936
if (methods.TryGetValue(asmMetadataReader.GetRowNumber(entry.Handle), out MethodInfo method))
method.UpdateEnC(asmMetadataReaderParm, pdbMetadataReaderParm, methodIdx);
else if (typeInfo != null)
Copy link
Member

Choose a reason for hiding this comment

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

Would typeInfo == null here indicate a bug? should we log a message then?

{
var methodDefinition = asmMetadataReaderParm.GetMethodDefinition(MetadataTokens.MethodDefinitionHandle(methodIdxAsm));
int methodIdx = GetMethodDebugInformationIdx(pdbMetadataReaderParm, asmMetadataReader.GetRowNumber(entry.Handle));
if (methods.TryGetValue(asmMetadataReader.GetRowNumber(entry.Handle), out MethodInfo method))
Copy link
Member

Choose a reason for hiding this comment

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

nit: this is used in a few places here, so can be extracted to a local.

Comment on lines +947 to +948
if (source != null)
source.AddMethod(methodInfo);
Copy link
Member

Choose a reason for hiding this comment

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

source will never be null here, since GetOrAddSourceFile creates a new one if needed. Is there a case where it shouldn't do that?

thaystg and others added 2 commits June 3, 2022 21:42
Co-authored-by: Ankit Jain <radical@gmail.com>
@thaystg thaystg merged commit da573d1 into dotnet:main Jun 7, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Jul 7, 2022
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 area-EnC-mono Hot Reload for WebAssembly, iOS/Android, etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants