[sdb] Add support for function pointers. (#42936)
authormonojenkins <jo.shields+jenkins@xamarin.com>
Mon, 5 Oct 2020 13:59:38 +0000 (09:59 -0400)
committerGitHub <noreply@github.com>
Mon, 5 Oct 2020 13:59:38 +0000 (09:59 -0400)
Co-authored-by: vargaz <vargaz@users.noreply.github.com>
src/mono/mono/mini/debugger-agent.c
src/mono/mono/mini/interp/interp.c

index 181b5d8..a7d2dc4 100644 (file)
@@ -5439,7 +5439,8 @@ buffer_add_value_full (Buffer *buf, MonoType *t, void *addr, MonoDomain *domain,
        case MONO_TYPE_U:
                /* Treat it as a vtype */
                goto handle_vtype;
-       case MONO_TYPE_PTR: {
+       case MONO_TYPE_PTR:
+       case MONO_TYPE_FNPTR: {
                gssize val = *(gssize*)addr;
                
                buffer_add_byte (buf, t->type);
@@ -5683,6 +5684,7 @@ decode_value_internal (MonoType *t, int type, MonoDomain *domain, guint8 *addr,
                !(type == VALUE_TYPE_ID_FIXED_ARRAY) &&
                !(t->type == MONO_TYPE_U && type == MONO_TYPE_VALUETYPE) &&
                !(t->type == MONO_TYPE_PTR && type == MONO_TYPE_I8) &&
+               !(t->type == MONO_TYPE_FNPTR && type == MONO_TYPE_I8) &&
                !(t->type == MONO_TYPE_GENERICINST && type == MONO_TYPE_VALUETYPE) &&
                !(t->type == MONO_TYPE_VALUETYPE && type == MONO_TYPE_OBJECT)) {
                char *name = mono_type_full_name (t);
@@ -5733,6 +5735,7 @@ decode_value_internal (MonoType *t, int type, MonoDomain *domain, guint8 *addr,
                *(guint64*)addr = decode_long (buf, &buf, limit);
                break;
        case MONO_TYPE_PTR:
+       case MONO_TYPE_FNPTR:
                /* We send these as I8, so we get them back as such */
                g_assert (type == MONO_TYPE_I8);
                *(gssize*)addr = decode_long (buf, &buf, limit);
@@ -8003,7 +8006,7 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint
                // FIXME: Can't decide whenever a class represents a byref type
                if (FALSE)
                        b |= (1 << 0);
-               if (type->type == MONO_TYPE_PTR)
+               if (type->type == MONO_TYPE_PTR || type->type == MONO_TYPE_FNPTR)
                        b |= (1 << 1);
                if (!type->byref && (((type->type >= MONO_TYPE_BOOLEAN) && (type->type <= MONO_TYPE_R8)) || (type->type == MONO_TYPE_I) || (type->type == MONO_TYPE_U)))
                        b |= (1 << 2);
index fe136bf..e985c60 100644 (file)
@@ -793,6 +793,7 @@ stackval_from_data (MonoType *type, stackval *result, const void *data, gboolean
                result->data.nati = *(mono_i*)data;
                return;
        case MONO_TYPE_PTR:
+       case MONO_TYPE_FNPTR:
                result->data.p = *(gpointer*)data;
                return;
        case MONO_TYPE_U4:
@@ -916,7 +917,8 @@ stackval_to_data (MonoType *type, stackval *val, void *data, gboolean pinvoke)
                mono_gc_wbarrier_generic_store_internal (p, val->data.o);
                return;
        }
-       case MONO_TYPE_PTR: {
+       case MONO_TYPE_PTR:
+       case MONO_TYPE_FNPTR: {
                gpointer *p = (gpointer *) data;
                *p = val->data.p;
                return;
@@ -987,6 +989,7 @@ stackval_to_data_addr (MonoType *type, stackval *val)
        case MONO_TYPE_OBJECT:
        case MONO_TYPE_ARRAY:
        case MONO_TYPE_PTR:
+       case MONO_TYPE_FNPTR:
                return &val->data.p;
        case MONO_TYPE_VALUETYPE:
                if (m_class_is_enumtype (type->data.klass))
@@ -1216,6 +1219,7 @@ static InterpMethodArguments* build_args_from_sig (MonoMethodSignature *sig, Int
                case MONO_TYPE_I:
                case MONO_TYPE_U:
                case MONO_TYPE_PTR:
+               case MONO_TYPE_FNPTR:
                case MONO_TYPE_SZARRAY:
                case MONO_TYPE_CLASS:
                case MONO_TYPE_OBJECT:
@@ -1284,6 +1288,7 @@ static InterpMethodArguments* build_args_from_sig (MonoMethodSignature *sig, Int
                case MONO_TYPE_I:
                case MONO_TYPE_U:
                case MONO_TYPE_PTR:
+               case MONO_TYPE_FNPTR:
                case MONO_TYPE_SZARRAY:
                case MONO_TYPE_CLASS:
                case MONO_TYPE_OBJECT:
@@ -1347,6 +1352,7 @@ static InterpMethodArguments* build_args_from_sig (MonoMethodSignature *sig, Int
                case MONO_TYPE_I:
                case MONO_TYPE_U:
                case MONO_TYPE_PTR:
+               case MONO_TYPE_FNPTR:
                case MONO_TYPE_SZARRAY:
                case MONO_TYPE_CLASS:
                case MONO_TYPE_OBJECT:
@@ -1709,6 +1715,7 @@ dump_stackval (GString *str, stackval *s, MonoType *type)
        case MONO_TYPE_OBJECT:
        case MONO_TYPE_ARRAY:
        case MONO_TYPE_PTR:
+       case MONO_TYPE_FNPTR:
        case MONO_TYPE_I:
        case MONO_TYPE_U:
                g_string_append_printf (str, "[%p] ", s->data.p);