Merge pull request #2763 from esdrubal/mono-symbolicate-standalone2
authorMarcos Henrich <marcoshenrich@gmail.com>
Wed, 30 Mar 2016 07:55:15 +0000 (08:55 +0100)
committerMarcos Henrich <marcoshenrich@gmail.com>
Wed, 30 Mar 2016 07:55:15 +0000 (08:55 +0100)
Mono-symbolicate standalone

1  2 
mcs/class/corlib/corlib.dll.sources
mono/metadata/icall-def.h
mono/metadata/icall.c

index 35ed33617c26884fa55a28c2d058cfb533a30179,f49db8501d29151ad1b7ece11e6b004540d2aea2..9a2b075df8837573163a5a1b72119eb1210281a2
@@@ -1,7 -1,6 +1,7 @@@
  Assembly/AssemblyInfo.cs
  ../../build/common/Consts.cs
  ../../build/common/Locale.cs
 +../../build/common/AssemblyRef.cs
  Microsoft.Win32/IRegistryApi.cs
  Microsoft.Win32/RegistryKey.cs
  Microsoft.Win32/RegistryKeyPermissionCheck.cs
@@@ -161,6 -160,7 +161,7 @@@ System.Deployment.Internal/InternalAppl
  System.Diagnostics/Debugger.cs
  System.Diagnostics/StackFrame.cs
  System.Diagnostics/StackTrace.cs
+ System.Diagnostics/StackTraceHelper.cs
  System.Diagnostics.Tracing/EventAttribute.cs
  System.Diagnostics.Tracing/EventCommand.cs
  System.Diagnostics.Tracing/EventSource.cs
@@@ -399,6 -399,7 +400,6 @@@ System.Runtime.InteropServices/Registra
  System.Runtime.InteropServices/SEHException.cs
  System.Runtime.InteropServices/STATSTG.cs
  System.Runtime.InteropServices/RegistrationServices.cs
 -System.Runtime.InteropServices/RuntimeEnvironment.cs
  System.Runtime.InteropServices/SafeArrayRankMismatchException.cs
  System.Runtime.InteropServices/SafeArrayTypeMismatchException.cs
  System.Runtime.InteropServices/SafeBuffer.cs
@@@ -1286,7 -1287,6 +1287,7 @@@ ReferenceSources/SecurityContext.c
  ../../../external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs
  
  ../../../external/referencesource/mscorlib/system/runtime/interopservices/attributes.cs
 +../../../external/referencesource/mscorlib/system/runtime/interopservices/runtimeenvironment.cs
  ../../../external/referencesource/mscorlib/system/runtime/interopservices/safehandle.cs
  ../../../external/referencesource/mscorlib/system/runtime/interopservices/ucomienumconnections.cs
  
index b8a9cd97a80f46892e8128e4095bd79a7d749337,3dd49f236e8000ffebae868a9ab39c1c5b5ce769..5ca728a0489c0ee158e1279b326d7646411a1c5c
@@@ -210,9 -210,6 +210,6 @@@ ICALL(PROCESS_10, "ProcessName_internal
  ICALL(PROCESS_13, "ShellExecuteEx_internal(System.Diagnostics.ProcessStartInfo,System.Diagnostics.Process/ProcInfo&)", ves_icall_System_Diagnostics_Process_ShellExecuteEx_internal)
  #endif /* !DISABLE_PROCESS_HANDLING */
  
- ICALL_TYPE(SFRAME, "System.Diagnostics.StackFrame", SFRAME_1)
- ICALL(SFRAME_1, "GetILOffsetFromFile", ves_icall_System_StackFrame_GetILOffsetFromFile)
  ICALL_TYPE(STOPWATCH, "System.Diagnostics.Stopwatch", STOPWATCH_1)
  ICALL(STOPWATCH_1, "GetTimestamp", mono_100ns_ticks)
  
@@@ -503,7 -500,7 +500,7 @@@ ICALL(ASSEMB_1, "InternalAddModule", ve
  ICALL(ASSEMB_2, "basic_init", mono_image_basic_init)
  
  ICALL_TYPE(CATTRB, "System.Reflection.Emit.CustomAttributeBuilder", CATTRB_1)
 -ICALL(CATTRB_1, "GetBlob", mono_reflection_get_custom_attrs_blob)
 +ICALL(CATTRB_1, "GetBlob", ves_icall_System_Reflection_Emit_CustomAttributeBuilder_GetBlob)
  
  #ifndef DISABLE_REFLECTION_EMIT
  ICALL_TYPE(DERIVEDTYPE, "System.Reflection.Emit.DerivedType", DERIVEDTYPE_1)
diff --combined mono/metadata/icall.c
index 7b2d955ce7783cf5ce9bea727fe3005ff92286f8,d5a846bf9a4afee0656a25f73c60d032596e39fc..01be8d10162465eebda5aec982653fd6c1f7bc8e
@@@ -138,23 -138,19 +138,23 @@@ mono_class_init_checked (MonoClass *kla
  ICALL_EXPORT MonoObject *
  ves_icall_System_Array_GetValueImpl (MonoArray *arr, guint32 pos)
  {
 +      MonoError error;
        MonoClass *ac;
        gint32 esize;
        gpointer *ea;
 +      MonoObject *result = NULL;
  
        ac = (MonoClass *)arr->obj.vtable->klass;
  
        esize = mono_array_element_size (ac);
        ea = (gpointer*)((char*)arr->vector + (pos * esize));
  
 -      if (ac->element_class->valuetype)
 -              return mono_value_box (arr->obj.vtable->domain, ac->element_class, ea);
 -      else
 -              return (MonoObject *)*ea;
 +      if (ac->element_class->valuetype) {
 +              result = mono_value_box_checked (arr->obj.vtable->domain, ac->element_class, ea, &error);
 +              mono_error_set_pending_exception (&error);
 +      } else
 +              result = (MonoObject *)*ea;
 +      return result;
  }
  
  ICALL_EXPORT MonoObject *
@@@ -207,7 -203,6 +207,7 @@@ ves_icall_System_Array_GetValue (MonoAr
  ICALL_EXPORT void
  ves_icall_System_Array_SetValueImpl (MonoArray *arr, MonoObject *value, guint32 pos)
  {
 +      MonoError error;
        MonoClass *ac, *vc, *ec;
        gint32 esize, vsize;
        gpointer *ea, *va;
        gint64 i64 = 0;
        gdouble r64 = 0;
  
 +      mono_error_init (&error);
 +
        if (value)
                vc = value->vtable->klass;
        else
        }
  
        if (!ec->valuetype) {
 -              if (!mono_object_isinst (value, ec))
 +              gboolean castOk = (NULL != mono_object_isinst_checked (value, ec, &error));
 +              if (mono_error_set_pending_exception (&error))
 +                      return;
 +              if (!castOk)
                        INVALID_CAST;
                mono_gc_wbarrier_set_arrayref (arr, ea, (MonoObject*)value);
                return;
        }
  
 -      if (mono_object_isinst (value, ec)) {
 +      if (mono_object_isinst_checked (value, ec, &error)) {
                if (ec->has_references)
                        mono_value_copy (ea, (char*)value + sizeof (MonoObject), ec);
                else
                        mono_gc_memmove_atomic (ea, (char *)value + sizeof (MonoObject), esize);
                return;
        }
 +      if (mono_error_set_pending_exception (&error))
 +              return;
  
        if (!vc->valuetype)
                INVALID_CAST;
@@@ -1268,15 -1256,6 +1268,15 @@@ ves_icall_System_Reflection_Emit_Assemb
        return result;
  }
  
 +ICALL_EXPORT MonoArray*
 +ves_icall_System_Reflection_Emit_CustomAttributeBuilder_GetBlob (MonoReflectionAssembly *assembly, MonoObject *ctor, MonoArray *ctorArgs, MonoArray *properties, MonoArray *propValues, MonoArray *fields, MonoArray* fieldValues)
 +{
 +      MonoError error;
 +      MonoArray *result = mono_reflection_get_custom_attrs_blob_checked (assembly, ctor, ctorArgs, properties, propValues, fields, fieldValues, &error);
 +      mono_error_set_pending_exception (&error);
 +      return result;
 +}
 +
  static gboolean
  get_caller (MonoMethod *m, gint32 no, gint32 ilo, gboolean managed, gpointer data)
  {
@@@ -1638,13 -1617,8 +1638,13 @@@ ves_icall_RuntimeTypeHandle_IsInstanceO
        MonoError error;
        MonoClass *klass = mono_class_from_mono_type (type->type);
        mono_class_init_checked (klass, &error);
 -      mono_error_raise_exception (&error);
 -      return mono_object_isinst (obj, klass) != NULL;
 +      if (!is_ok (&error)) {
 +              mono_error_set_pending_exception (&error);
 +              return FALSE;
 +      }
 +      guint32 result = (mono_object_isinst_checked (obj, klass, &error) != NULL);
 +      mono_error_set_pending_exception (&error);
 +      return result;
  }
  
  ICALL_EXPORT guint32
@@@ -2727,12 -2701,10 +2727,12 @@@ ves_icall_Type_MakeGenericType (MonoRef
                types [i] = t->type;
        }
  
 -      geninst = mono_reflection_bind_generic_parameters (type, count, types);
 +      geninst = mono_reflection_bind_generic_parameters (type, count, types, &error);
        g_free (types);
 -      if (!geninst)
 +      if (!geninst) {
 +              mono_error_set_pending_exception (&error);
                return NULL;
 +      }
  
        klass = mono_class_from_mono_type (geninst);
  
@@@ -3080,11 -3052,7 +3080,11 @@@ ves_icall_InternalInvoke (MonoReflectio
                }
  
                if (this_arg) {
 -                      if (!mono_object_isinst (this_arg, m->klass)) {
 +                      if (!mono_object_isinst_checked (this_arg, m->klass, &error)) {
 +                              if (!is_ok (&error)) {
 +                                      mono_gc_wbarrier_generic_store (exc, (MonoObject*) mono_error_convert_to_exception (&error));
 +                                      return NULL;
 +                              }
                                char *this_name = mono_type_get_full_name (mono_object_get_class (this_arg));
                                char *target_name = mono_type_get_full_name (m->klass);
                                char *msg = g_strdup_printf ("Object of type '%s' doesn't match target type '%s'", this_name, target_name);
  ICALL_EXPORT MonoObject *
  ves_icall_InternalExecute (MonoReflectionMethod *method, MonoObject *this_arg, MonoArray *params, MonoArray **outArgs) 
  {
 +      MonoError error;
        MonoDomain *domain = mono_object_domain (method); 
        MonoMethod *m = method->method;
        MonoMethodSignature *sig = mono_method_signature (m);
                                MonoClassField* field = mono_class_get_field_from_name (k, str);
                                if (field) {
                                        MonoClass *field_klass =  mono_class_from_mono_type (field->type);
 -                                      if (field_klass->valuetype)
 -                                              result = mono_value_box (domain, field_klass, (char *)this_arg + field->offset);
 -                                      else 
 +                                      if (field_klass->valuetype) {
 +                                              result = mono_value_box_checked (domain, field_klass, (char *)this_arg + field->offset, &error);
 +                                              mono_error_set_pending_exception (&error);
 +                                              /* fallthru to cleanup */
 +                                      } else 
                                                result = (MonoObject *)*((gpointer *)((char *)this_arg + field->offset));
                                
                                        out_args = mono_array_new (domain, mono_defaults.object_class, 1);
@@@ -4390,7 -4355,8 +4390,7 @@@ ves_icall_Type_GetNestedTypes (MonoRefl
  
        mono_ptr_array_destroy (tmp_array);
  
 -      if (!str)
 -              g_free (str);
 +      g_free (str);
  
        return res;
  }
@@@ -5550,6 -5516,7 +5550,6 @@@ mono_module_get_types (MonoDomain *doma
                if (!exportedOnly || mono_module_type_is_visible (tdef, image, i + 1)) {
                        klass = mono_class_get_checked (image, (i + 1) | MONO_TOKEN_TYPE_DEF, error);
                        mono_loader_assert_no_error (); /* Plug any leaks */
 -                      mono_error_assert_ok (error);
                        
                        if (klass) {
                                rt = mono_type_get_object_checked (domain, &klass->byval_arg, error);
@@@ -5825,13 -5792,10 +5825,13 @@@ mono_memberref_is_method (MonoImage *im
                mono_metadata_decode_blob_size (sig, &sig);
                return (*sig != 0x6);
        } else {
 +              MonoError error;
                MonoClass *handle_class;
  
 -              if (!mono_lookup_dynamic_token_class (image, token, FALSE, &handle_class, NULL))
 +              if (!mono_lookup_dynamic_token_class (image, token, FALSE, &handle_class, NULL, &error)) {
 +                      mono_error_cleanup (&error); /* just probing, ignore error */
                        return FALSE;
 +              }
  
                return mono_defaults.methodhandle_class == handle_class;
        }
@@@ -5872,14 -5836,12 +5872,14 @@@ ves_icall_System_Reflection_Module_Reso
  
        if (image_is_dynamic (image)) {
                if ((table == MONO_TABLE_TYPEDEF) || (table == MONO_TABLE_TYPEREF)) {
 -                      klass = (MonoClass *)mono_lookup_dynamic_token_class (image, token, FALSE, NULL, NULL);
 +                      klass = (MonoClass *)mono_lookup_dynamic_token_class (image, token, FALSE, NULL, NULL, &error);
 +                      mono_error_cleanup (&error);
                        return klass ? &klass->byval_arg : NULL;
                }
  
                init_generic_context_from_args (&context, type_args, method_args);
 -              klass = (MonoClass *)mono_lookup_dynamic_token_class (image, token, FALSE, NULL, &context);
 +              klass = (MonoClass *)mono_lookup_dynamic_token_class (image, token, FALSE, NULL, &context, &error);
 +              mono_error_cleanup (&error);
                return klass ? &klass->byval_arg : NULL;
        }
  
@@@ -5922,11 -5884,8 +5922,11 @@@ ves_icall_System_Reflection_Module_Reso
        }
  
        if (image_is_dynamic (image)) {
 -              if (table == MONO_TABLE_METHOD)
 -                      return (MonoMethod *)mono_lookup_dynamic_token_class (image, token, FALSE, NULL, NULL);
 +              if (table == MONO_TABLE_METHOD) {
 +                      method = (MonoMethod *)mono_lookup_dynamic_token_class (image, token, FALSE, NULL, NULL, &error);
 +                      mono_error_cleanup (&error);
 +                      return method;
 +              }
  
                if ((table == MONO_TABLE_MEMBERREF) && !(mono_memberref_is_method (image, token))) {
                        *resolve_error = ResolveTokenError_BadTable;
                }
  
                init_generic_context_from_args (&context, type_args, method_args);
 -              return (MonoMethod *)mono_lookup_dynamic_token_class (image, token, FALSE, NULL, &context);
 +              method = (MonoMethod *)mono_lookup_dynamic_token_class (image, token, FALSE, NULL, &context, &error);
 +              mono_error_cleanup (&error);
 +              return method;
        }
  
        if ((index <= 0) || (index > image->tables [table].rows)) {
  }
  
  ICALL_EXPORT MonoString*
 -ves_icall_System_Reflection_Module_ResolveStringToken (MonoImage *image, guint32 token, MonoResolveTokenError *error)
 +ves_icall_System_Reflection_Module_ResolveStringToken (MonoImage *image, guint32 token, MonoResolveTokenError *resolve_error)
  {
 +      MonoError error;
        int index = mono_metadata_token_index (token);
  
 -      *error = ResolveTokenError_Other;
 +      *resolve_error = ResolveTokenError_Other;
  
        /* Validate token */
        if (mono_metadata_token_code (token) != MONO_TOKEN_STRING) {
 -              *error = ResolveTokenError_BadTable;
 +              *resolve_error = ResolveTokenError_BadTable;
                return NULL;
        }
  
 -      if (image_is_dynamic (image))
 -              return (MonoString *)mono_lookup_dynamic_token_class (image, token, FALSE, NULL, NULL);
 +      if (image_is_dynamic (image)) {
 +              MonoString * result = (MonoString *)mono_lookup_dynamic_token_class (image, token, FALSE, NULL, NULL, &error);
 +              mono_error_cleanup (&error);
 +              return result;
 +      }
  
        if ((index <= 0) || (index >= image->heap_us.size)) {
 -              *error = ResolveTokenError_OutOfRange;
 +              *resolve_error = ResolveTokenError_OutOfRange;
                return NULL;
        }
  
@@@ -6004,11 -5957,8 +6004,11 @@@ ves_icall_System_Reflection_Module_Reso
        }
  
        if (image_is_dynamic (image)) {
 -              if (table == MONO_TABLE_FIELD)
 -                      return (MonoClassField *)mono_lookup_dynamic_token_class (image, token, FALSE, NULL, NULL);
 +              if (table == MONO_TABLE_FIELD) {
 +                      field = (MonoClassField *)mono_lookup_dynamic_token_class (image, token, FALSE, NULL, NULL, &error);
 +                      mono_error_cleanup (&error);
 +                      return field;
 +              }
  
                if (mono_memberref_is_method (image, token)) {
                        *resolve_error = ResolveTokenError_BadTable;
                }
  
                init_generic_context_from_args (&context, type_args, method_args);
 -              return (MonoClassField *)mono_lookup_dynamic_token_class (image, token, FALSE, NULL, &context);
 +              field = (MonoClassField *)mono_lookup_dynamic_token_class (image, token, FALSE, NULL, &context, &error);
 +              mono_error_cleanup (&error);
 +              return field;
        }
  
        if ((index <= 0) || (index > image->tables [table].rows)) {
@@@ -6317,14 -6265,7 +6317,14 @@@ ves_icall_System_Delegate_CreateDelegat
        mono_class_init_checked (delegate_class, &error);
        mono_error_raise_exception (&error);
  
 -      mono_assert (delegate_class->parent == mono_defaults.multicastdelegate_class);
 +      if (!(delegate_class->parent == mono_defaults.multicastdelegate_class)) {
 +              /* FIXME improve this exception message */
 +              mono_error_set_execution_engine (&error, "file %s: line %d (%s): assertion failed: (%s)", __FILE__, __LINE__,
 +                                               __func__,
 +                                               "delegate_class->parent == mono_defaults.multicastdelegate_class");
 +              mono_error_set_pending_exception (&error);
 +              return NULL;
 +      }
  
        if (mono_security_core_clr_enabled ()) {
                if (!mono_security_core_clr_ensure_delegate_creation (method, throwOnBindFailure))
@@@ -6494,16 -6435,8 +6494,16 @@@ ves_icall_Remoting_RealProxy_GetTranspa
                return NULL;
        }
  
 -      tp->custom_type_info = (mono_object_isinst (this_obj, mono_defaults.iremotingtypeinfo_class) != NULL);
 -      tp->remote_class = mono_remote_class (domain, class_name, klass);
 +      tp->custom_type_info = (mono_object_isinst_checked (this_obj, mono_defaults.iremotingtypeinfo_class, &error) != NULL);
 +      if (!is_ok (&error)) {
 +              mono_error_set_pending_exception (&error);
 +              return NULL;
 +      }
 +      tp->remote_class = mono_remote_class (domain, class_name, klass, &error);
 +      if (!is_ok (&error)) {
 +              mono_error_set_pending_exception (&error);
 +              return NULL;
 +      }
  
        res->vtable = (MonoVTable *)mono_remote_class_vtable (domain, tp->remote_class, rp);
        return res;
@@@ -7657,16 -7590,12 +7657,16 @@@ mono_ArgIterator_IntGetNextArgType (Mon
  ICALL_EXPORT MonoObject*
  mono_TypedReference_ToObject (MonoTypedRef* tref)
  {
 +      MonoError error;
 +      MonoObject *result = NULL;
        if (MONO_TYPE_IS_REFERENCE (tref->type)) {
                MonoObject** objp = (MonoObject **)tref->value;
                return *objp;
        }
  
 -      return mono_value_box (mono_domain_get (), tref->klass, tref->value);
 +      result = mono_value_box_checked (mono_domain_get (), tref->klass, tref->value, &error);
 +      mono_error_set_pending_exception (&error);
 +      return result;
  }
  
  ICALL_EXPORT MonoTypedRef
@@@ -8022,20 -7951,6 +8022,6 @@@ ves_icall_System_ComponentModel_Win32Ex
        return message;
  }
  
- ICALL_EXPORT int
- ves_icall_System_StackFrame_GetILOffsetFromFile (MonoString *path, guint32 method_token, guint32 method_index, int native_offset)
- {
-       guint32 il_offset;
-       char *path_str = mono_string_to_utf8 (path);
-       if (!mono_seq_point_data_get_il_offset (path_str, method_token, method_index, native_offset, &il_offset))
-               il_offset = -1;
-       g_free (path_str);
-       return il_offset;
- }
  ICALL_EXPORT gpointer
  ves_icall_Microsoft_Win32_NativeMethods_GetCurrentProcess (void)
  {