Merge pull request #2687 from lambdageek/dev/monoerror-mono_param_get_objects_internal
[mono.git] / mono / mini / debugger-agent.c
index 718cec686fcee855e4d72af8a87755a4b11537a1..140fbfb689b1f89ea0ef61570ed56b0c51bf9c01 100644 (file)
@@ -3323,6 +3323,7 @@ static void
 init_jit_info_dbg_attrs (MonoJitInfo *ji)
 {
        static MonoClass *hidden_klass, *step_through_klass, *non_user_klass;
+       MonoError error;
        MonoCustomAttrInfo *ainfo;
 
        if (ji->dbg_attrs_inited)
@@ -3337,7 +3338,8 @@ init_jit_info_dbg_attrs (MonoJitInfo *ji)
        if (!non_user_klass)
                non_user_klass = mono_class_load_from_name (mono_defaults.corlib, "System.Diagnostics", "DebuggerNonUserCodeAttribute");
 
-       ainfo = mono_custom_attrs_from_method (jinfo_get_method (ji));
+       ainfo = mono_custom_attrs_from_method_checked (jinfo_get_method (ji), &error);
+       mono_error_cleanup (&error); /* FIXME don't swallow the error? */
        if (ainfo) {
                if (mono_custom_attrs_has_attr (ainfo, hidden_klass))
                        ji->dbg_hidden = TRUE;
@@ -3348,7 +3350,8 @@ init_jit_info_dbg_attrs (MonoJitInfo *ji)
                mono_custom_attrs_free (ainfo);
        }
 
-       ainfo = mono_custom_attrs_from_class (jinfo_get_method (ji)->klass);
+       ainfo = mono_custom_attrs_from_class_checked (jinfo_get_method (ji)->klass, &error);
+       mono_error_cleanup (&error); /* FIXME don't swallow the error? */
        if (ainfo) {
                if (mono_custom_attrs_has_attr (ainfo, step_through_klass))
                        ji->dbg_step_through = TRUE;
@@ -8030,7 +8033,11 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint
                if (err != ERR_NONE)
                        return err;
 
-               cinfo = mono_custom_attrs_from_class (klass);
+               cinfo = mono_custom_attrs_from_class_checked (klass, &error);
+               if (!is_ok (&error)) {
+                       mono_error_cleanup (&error); /* FIXME don't swallow the error message */
+                       return ERR_LOADER_ERROR;
+               }
 
                err = buffer_add_cattrs (buf, domain, klass->image, attr_klass, cinfo);
                if (err != ERR_NONE)
@@ -8049,7 +8056,11 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint
                if (err != ERR_NONE)
                        return err;
 
-               cinfo = mono_custom_attrs_from_field (klass, field);
+               cinfo = mono_custom_attrs_from_field_checked (klass, field, &error);
+               if (!is_ok (&error)) {
+                       mono_error_cleanup (&error); /* FIXME don't swallow the error message */
+                       return ERR_LOADER_ERROR;
+               }
 
                err = buffer_add_cattrs (buf, domain, klass->image, attr_klass, cinfo);
                if (err != ERR_NONE)
@@ -8068,7 +8079,11 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint
                if (err != ERR_NONE)
                        return err;
 
-               cinfo = mono_custom_attrs_from_property (klass, prop);
+               cinfo = mono_custom_attrs_from_property_checked (klass, prop, &error);
+               if (!is_ok (&error)) {
+                       mono_error_cleanup (&error); /* FIXME don't swallow the error message */
+                       return ERR_LOADER_ERROR;
+               }
 
                err = buffer_add_cattrs (buf, domain, klass->image, attr_klass, cinfo);
                if (err != ERR_NONE)
@@ -8360,6 +8375,7 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g
                break;
        }
        case CMD_METHOD_GET_DEBUG_INFO: {
+               MonoError error;
                MonoDebugMethodInfo *minfo;
                char *source_file;
                int i, j, n_il_offsets;
@@ -8367,8 +8383,9 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g
                GPtrArray *source_file_list;
                MonoSymSeqPoint *sym_seq_points;
 
-               header = mono_method_get_header (method);
+               header = mono_method_get_header_checked (method, &error);
                if (!header) {
+                       mono_error_cleanup (&error); /* FIXME don't swallow the error */
                        buffer_add_int (buf, 0);
                        buffer_add_string (buf, "");
                        buffer_add_int (buf, 0);
@@ -8455,13 +8472,16 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g
                break;
        }
        case CMD_METHOD_GET_LOCALS_INFO: {
+               MonoError error;
                int i, num_locals;
                MonoDebugLocalsInfo *locals;
                int *locals_map = NULL;
 
-               header = mono_method_get_header (method);
-               if (!header)
+               header = mono_method_get_header_checked (method, &error);
+               if (!header) {
+                       mono_error_cleanup (&error); /* FIXME don't swallow the error */
                        return ERR_INVALID_ARGUMENT;
+               }
 
                locals = mono_debug_lookup_locals (method);
                if (!locals) {
@@ -8582,10 +8602,12 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g
                }
                break;
        case CMD_METHOD_GET_BODY: {
+               MonoError error;
                int i;
 
-               header = mono_method_get_header (method);
+               header = mono_method_get_header_checked (method, &error);
                if (!header) {
+                       mono_error_cleanup (&error); /* FIXME don't swallow the error */
                        buffer_add_int (buf, 0);
 
                        if (CHECK_PROTOCOL_VERSION (2, 18))
@@ -8684,6 +8706,7 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g
                break;
        }
        case CMD_METHOD_GET_CATTRS: {
+               MonoError error;
                MonoClass *attr_klass;
                MonoCustomAttrInfo *cinfo;
 
@@ -8692,7 +8715,11 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g
                if (err != ERR_NONE)
                        return err;
 
-               cinfo = mono_custom_attrs_from_method (method);
+               cinfo = mono_custom_attrs_from_method_checked (method, &error);
+               if (!is_ok (&error)) {
+                       mono_error_cleanup (&error); /* FIXME don't swallow the error message */
+                       return ERR_LOADER_ERROR;
+               }
 
                err = buffer_add_cattrs (buf, domain, method->klass->image, attr_klass, cinfo);
                if (err != ERR_NONE)
@@ -8979,8 +9006,10 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
 
        switch (command) {
        case CMD_STACK_FRAME_GET_VALUES: {
+               MonoError error;
                len = decode_int (p, &p, end);
-               header = mono_method_get_header (frame->actual_method);
+               header = mono_method_get_header_checked (frame->actual_method, &error);
+               mono_error_assert_ok (&error); /* FIXME report error */
 
                for (i = 0; i < len; ++i) {
                        pos = decode_int (p, &p, end);
@@ -9031,12 +9060,14 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
                break;
        }
        case CMD_STACK_FRAME_SET_VALUES: {
+               MonoError error;
                guint8 *val_buf;
                MonoType *t;
                MonoDebugVarInfo *var;
 
                len = decode_int (p, &p, end);
-               header = mono_method_get_header (frame->actual_method);
+               header = mono_method_get_header_checked (frame->actual_method, &error);
+               mono_error_assert_ok (&error); /* FIXME report error */
 
                for (i = 0; i < len; ++i) {
                        pos = decode_int (p, &p, end);