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] Fix inspect gchandle #102637

Merged
merged 1 commit into from
May 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 35 additions & 3 deletions src/mono/mono/component/debugger-agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -3286,6 +3286,7 @@ dbg_path_get_basename (const char *filename)
static GENERATE_TRY_GET_CLASS_WITH_CACHE (hidden_klass, "System.Diagnostics", "DebuggerHiddenAttribute")
static GENERATE_TRY_GET_CLASS_WITH_CACHE (step_through_klass, "System.Diagnostics", "DebuggerStepThroughAttribute")
static GENERATE_TRY_GET_CLASS_WITH_CACHE (non_user_klass, "System.Diagnostics", "DebuggerNonUserCodeAttribute")
static GENERATE_TRY_GET_CLASS_WITH_CACHE (intptr_klass, "System", "IntPtr")

static void
init_jit_info_dbg_attrs (MonoJitInfo *ji)
Expand Down Expand Up @@ -5578,6 +5579,7 @@ decode_value_compute_size (MonoType *t, int type, MonoDomain *domain, guint8 *bu
int ret = 0;
if (type != t->type && !MONO_TYPE_IS_REFERENCE (t) &&
!(t->type == MONO_TYPE_I && type == MONO_TYPE_VALUETYPE) &&
!(t->type == MONO_TYPE_I && type == MONO_TYPE_I8) &&
!(type == VALUE_TYPE_ID_FIXED_ARRAY) &&
!(type == MDBGPROT_VALUE_TYPE_ID_NULL) &&
!(t->type == MONO_TYPE_U && type == MONO_TYPE_VALUETYPE) &&
Expand Down Expand Up @@ -5640,7 +5642,13 @@ decode_value_compute_size (MonoType *t, int type, MonoDomain *domain, guint8 *bu
case MONO_TYPE_I:
case MONO_TYPE_U:
/* We send these as vtypes, so we get them back as such */
g_assert (type == MONO_TYPE_VALUETYPE);
if (type == MONO_TYPE_I8)
{
ret += sizeof(guint64);
goto end;
}
else
g_assert (type == MONO_TYPE_VALUETYPE);
/* Fall through */
handle_vtype:
case MONO_TYPE_VALUETYPE:
Expand Down Expand Up @@ -5697,6 +5705,7 @@ decode_value_internal (MonoType *t, int type, MonoDomain *domain, guint8 *addr,

if (type != t->type && !MONO_TYPE_IS_REFERENCE (t) &&
!(t->type == MONO_TYPE_I && type == MONO_TYPE_VALUETYPE) &&
!(t->type == MONO_TYPE_I && type == MONO_TYPE_I8) &&
!(type == VALUE_TYPE_ID_FIXED_ARRAY) &&
!(t->type == MONO_TYPE_U && type == MONO_TYPE_VALUETYPE) &&
!(t->type == MONO_TYPE_PTR && type == MONO_TYPE_I8) &&
Expand Down Expand Up @@ -5769,8 +5778,31 @@ decode_value_internal (MonoType *t, int type, MonoDomain *domain, guint8 *addr,
break;
case MONO_TYPE_I:
case MONO_TYPE_U:
/* We send these as vtypes, so we get them back as such */
g_assert (type == MONO_TYPE_VALUETYPE);
if (type == MONO_TYPE_I8) //sometimes we send as a PTR because it's a IntPtr then the debugger will send back as I8
{
MonoClassField *f = NULL;
gpointer iter = NULL;
MonoClass *intptr_klass = mono_class_try_get_intptr_klass_class ();
while ((f = mono_class_get_fields_internal (intptr_klass, &iter))) {
if (G_UNLIKELY (!f->type)) {
ERROR_DECL(error);
mono_field_resolve_type (f, error);
mono_error_cleanup (error);
if (!f->type)
continue;
}
if (f->type->attrs & FIELD_ATTRIBUTE_STATIC)
continue;
if (mono_field_is_deleted (f))
continue;
guint8 * fieldAddr = mono_vtype_get_field_addr (addr, f);
*(gint64*)fieldAddr = decode_long (buf, &buf, limit);
}
*endbuf = buf;
return ERR_NONE;
}
else /* We send these as vtypes, so we get them back as such */
g_assert (type == MONO_TYPE_VALUETYPE);
/* Fall through */
handle_vtype:
case MONO_TYPE_VALUETYPE:
Expand Down
Loading