Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8c32e44

Browse files
lambdageekthaystg
andauthored
[hot reload][debugger] Resolve field types before use (#93558)
* adding test case failing * fixup test - expect null value, not empty string * [debugger] resolve field types before use * don't shadow names * rename unused field in test to make it more obvious that it should stay unused --------- Co-authored-by: Thays Grazia <[email protected]>
1 parent de9aef3 commit 8c32e44

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

src/mono/mono/component/debugger-agent.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5233,6 +5233,13 @@ buffer_add_value_full (Buffer *buf, MonoType *t, void *addr, MonoDomain *domain,
52335233
nfields = 0;
52345234
iter = NULL;
52355235
while ((f = mono_class_get_fields_internal (klass, &iter))) {
5236+
if (G_UNLIKELY (!f->type)) {
5237+
ERROR_DECL(error);
5238+
mono_field_resolve_type (f, error);
5239+
mono_error_cleanup (error);
5240+
if (!f->type)
5241+
continue;
5242+
}
52365243
if (f->type->attrs & FIELD_ATTRIBUTE_STATIC)
52375244
continue;
52385245
if (mono_field_is_deleted (f))
@@ -5250,6 +5257,13 @@ buffer_add_value_full (Buffer *buf, MonoType *t, void *addr, MonoDomain *domain,
52505257

52515258
iter = NULL;
52525259
while ((f = mono_class_get_fields_internal (klass, &iter))) {
5260+
if (G_UNLIKELY (!f->type)) {
5261+
ERROR_DECL(error);
5262+
mono_field_resolve_type (f, error);
5263+
mono_error_cleanup (error);
5264+
if (!f->type)
5265+
continue;
5266+
}
52535267
if (f->type->attrs & FIELD_ATTRIBUTE_STATIC)
52545268
continue;
52555269
if (mono_field_is_deleted (f))
@@ -5351,6 +5365,13 @@ decode_vtype (MonoType *t, MonoDomain *domain, gpointer void_addr, gpointer void
53515365

53525366
nfields = decode_int (buf, &buf, limit);
53535367
while ((f = mono_class_get_fields_internal (klass, &iter))) {
5368+
if (G_UNLIKELY (!f->type)) {
5369+
ERROR_DECL(error);
5370+
mono_field_resolve_type (f, error);
5371+
mono_error_cleanup (error);
5372+
if (!f->type)
5373+
continue;
5374+
}
53545375
if (f->type->attrs & FIELD_ATTRIBUTE_STATIC)
53555376
continue;
53565377
if (mono_field_is_deleted (f))
@@ -5459,6 +5480,13 @@ decode_vtype_compute_size (MonoType *t, MonoDomain *domain, gpointer void_buf, g
54595480

54605481
nfields = decode_int (buf, &buf, limit);
54615482
while ((f = mono_class_get_fields_internal (klass, &iter))) {
5483+
if (G_UNLIKELY (!f->type)) {
5484+
ERROR_DECL(error);
5485+
mono_field_resolve_type (f, error);
5486+
mono_error_cleanup (error);
5487+
if (!f->type)
5488+
continue;
5489+
}
54625490
if (f->type->attrs & FIELD_ATTRIBUTE_STATIC)
54635491
continue;
54645492
if (mono_field_is_deleted (f))
@@ -8476,6 +8504,13 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint
84768504
buffer_add_int (buf, nfields);
84778505

84788506
while ((f = mono_class_get_fields_internal (klass, &iter))) {
8507+
if (G_UNLIKELY (!f->type)) {
8508+
ERROR_DECL(field_error);
8509+
mono_field_resolve_type (f, field_error);
8510+
mono_error_cleanup (field_error);
8511+
if (!f->type)
8512+
continue;
8513+
}
84798514
buffer_add_fieldid (buf, domain, f);
84808515
buffer_add_string (buf, f->name);
84818516
buffer_add_typeid (buf, domain, mono_class_from_mono_type_internal (f->type));
@@ -8856,6 +8891,13 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint
88568891
int nfields = 0;
88578892
gpointer iter = NULL;
88588893
while ((f = mono_class_get_fields_internal (klass, &iter))) {
8894+
if (G_UNLIKELY (!f->type)) {
8895+
ERROR_DECL(field_error);
8896+
mono_field_resolve_type (f, field_error);
8897+
mono_error_cleanup (field_error);
8898+
if (!f->type)
8899+
continue;
8900+
}
88598901
if (f->type->attrs & FIELD_ATTRIBUTE_STATIC)
88608902
continue;
88618903
if (mono_field_is_deleted (f))
@@ -8866,6 +8908,13 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint
88668908

88678909
iter = NULL;
88688910
while ((f = mono_class_get_fields_internal (klass, &iter))) {
8911+
if (G_UNLIKELY (!f->type)) {
8912+
ERROR_DECL(field_error);
8913+
mono_field_resolve_type (f, field_error);
8914+
mono_error_cleanup (field_error);
8915+
if (!f->type)
8916+
continue;
8917+
}
88698918
if (f->type->attrs & FIELD_ATTRIBUTE_STATIC)
88708919
continue;
88718920
if (mono_field_is_deleted (f))

src/mono/wasm/debugger/DebuggerTestSuite/HotReloadTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,8 @@ await SendCommandAndCheck (JObject.FromObject(new { }), "Debugger.resume", scrip
596596
await CheckProps (c, new {
597597
Field1 = TNumber(123),
598598
Field2 = TString("spqr"),
599-
}, "c", num_fields: 2);
599+
Field3Unused = TString(null),
600+
}, "c", num_fields: 3);
600601
});
601602
}
602603

src/mono/wasm/debugger/tests/ApplyUpdateReferencedAssembly3/MethodBody2_v2.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public C()
2222
}
2323
public double Field1;
2424
public string Field2;
25+
public string Field3Unused;
2526
}
2627
}
2728

0 commit comments

Comments
 (0)