From e96d3637392cb38ebeed812f0db0f2f484b934a7 Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Fri, 21 Jul 2023 14:02:17 +0000 Subject: [PATCH 1/4] Adding more information about the array type. --- src/mono/mono/component/debugger-agent.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/mono/mono/component/debugger-agent.c b/src/mono/mono/component/debugger-agent.c index 91a2ee0fe3d8ae..0ab9f6ce4df181 100644 --- a/src/mono/mono/component/debugger-agent.c +++ b/src/mono/mono/component/debugger-agent.c @@ -8690,11 +8690,6 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint goto invalid_object; } buffer_add_objid (buf, o); - if (CHECK_ICORDBG (TRUE)) - { - MonoType *object_type = m_class_get_byval_arg (m_class_get_element_class (klass)); - buffer_add_value (buf, object_type, o, domain); - } break; } case CMD_TYPE_GET_SOURCE_FILES: @@ -8839,7 +8834,7 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint obj = mono_object_new_checked (klass, error); mono_error_assert_ok (error); - buffer_add_objid (buf, obj); + buffer_add_objid (buf, obj); break; } case CMD_TYPE_GET_VALUE_SIZE: { @@ -10089,10 +10084,14 @@ array_commands (int command, guint8 *p, guint8 *end, Buffer *buf) switch (command) { case CMD_ARRAY_REF_GET_TYPE: { - buffer_add_byte(buf, m_class_get_byval_arg (m_class_get_element_class (arr->obj.vtable->klass))->type); + MonoTypeEnum type = m_class_get_byval_arg (m_class_get_element_class (arr->obj.vtable->klass))->type; + buffer_add_byte(buf, type); buffer_add_int (buf, m_class_get_rank (arr->obj.vtable->klass)); - if (m_class_get_byval_arg (m_class_get_element_class (arr->obj.vtable->klass))->type == MONO_TYPE_CLASS) + if (type == MONO_TYPE_CLASS || type == MONO_TYPE_GENERICINST || type == MONO_TYPE_OBJECT) + { buffer_add_typeid (buf, arr->obj.vtable->domain, m_class_get_element_class (arr->obj.vtable->klass)); + buffer_add_byte (buf, MONO_TYPE_ISSTRUCT (m_class_get_byval_arg (m_class_get_element_class (arr->obj.vtable->klass)))); + } } break; case CMD_ARRAY_REF_GET_LENGTH: From f03b0adf2cb30d209d1ecd8e465eab675852849b Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Fri, 21 Jul 2023 18:57:28 +0000 Subject: [PATCH 2/4] Adding more changes --- src/mono/mono/component/debugger-agent.c | 31 ++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/mono/mono/component/debugger-agent.c b/src/mono/mono/component/debugger-agent.c index 0ab9f6ce4df181..3e7af092e4745b 100644 --- a/src/mono/mono/component/debugger-agent.c +++ b/src/mono/mono/component/debugger-agent.c @@ -8831,10 +8831,37 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint } case CMD_TYPE_CREATE_INSTANCE: { MonoObject *obj; - obj = mono_object_new_checked (klass, error); mono_error_assert_ok (error); - buffer_add_objid (buf, obj); + buffer_add_objid (buf, obj); + if (CHECK_ICORDBG (TRUE)) + { + buffer_add_byte(buf, m_class_is_valuetype (klass)); + if (m_class_is_valuetype (klass)) + { + int nfields = 0; + gpointer iter = NULL; + MonoClassField *f; + while ((f = mono_class_get_fields_internal (klass, &iter))) { + if (f->type->attrs & FIELD_ATTRIBUTE_STATIC) + continue; + if (mono_field_is_deleted (f)) + continue; + nfields ++; + } + buffer_add_int (buf, nfields); + + iter = NULL; + while ((f = mono_class_get_fields_internal (klass, &iter))) { + if (f->type->attrs & FIELD_ATTRIBUTE_STATIC) + continue; + if (mono_field_is_deleted (f)) + continue; + buffer_add_int (buf, mono_class_get_field_token (f)); + buffer_add_byte (buf, f->type->type); + } + } + } break; } case CMD_TYPE_GET_VALUE_SIZE: { From eeb09234e5e74889a5e982a3358d06d0e7637ca4 Mon Sep 17 00:00:00 2001 From: Larry Ewing Date: Fri, 21 Jul 2023 17:30:00 -0500 Subject: [PATCH 3/4] Update src/mono/mono/component/debugger-agent.c --- src/mono/mono/component/debugger-agent.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mono/mono/component/debugger-agent.c b/src/mono/mono/component/debugger-agent.c index 3e7af092e4745b..95371baf488d81 100644 --- a/src/mono/mono/component/debugger-agent.c +++ b/src/mono/mono/component/debugger-agent.c @@ -8841,7 +8841,6 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint { int nfields = 0; gpointer iter = NULL; - MonoClassField *f; while ((f = mono_class_get_fields_internal (klass, &iter))) { if (f->type->attrs & FIELD_ATTRIBUTE_STATIC) continue; From 9fe406f6f6a82608ed7065e7c3caffc36b5bec8e Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Mon, 14 Aug 2023 12:01:49 -0300 Subject: [PATCH 4/4] Only add this info for icordbg. --- src/mono/mono/component/debugger-agent.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mono/mono/component/debugger-agent.c b/src/mono/mono/component/debugger-agent.c index 81759a1d83a758..a210242c1eb691 100644 --- a/src/mono/mono/component/debugger-agent.c +++ b/src/mono/mono/component/debugger-agent.c @@ -10140,7 +10140,8 @@ array_commands (int command, guint8 *p, guint8 *end, Buffer *buf) if (type == MONO_TYPE_CLASS || type == MONO_TYPE_GENERICINST || type == MONO_TYPE_OBJECT) { buffer_add_typeid (buf, arr->obj.vtable->domain, m_class_get_element_class (arr->obj.vtable->klass)); - buffer_add_byte (buf, MONO_TYPE_ISSTRUCT (m_class_get_byval_arg (m_class_get_element_class (arr->obj.vtable->klass)))); + if (CHECK_ICORDBG (TRUE)) + buffer_add_byte (buf, MONO_TYPE_ISSTRUCT (m_class_get_byval_arg (m_class_get_element_class (arr->obj.vtable->klass)))); } } break;