va_end (args);
}
+static void
+report_loader_error (MonoAotCompile *acfg, MonoError *error, const char *format, ...)
+{
+ FILE *output;
+ va_list args;
+
+ if (mono_error_ok (error))
+ return;
+
+ if (acfg->logfile)
+ output = acfg->logfile;
+ else
+ output = stderr;
+
+ va_start (args, format);
+ vfprintf (output, format, args);
+ va_end (args);
+ mono_error_cleanup (error);
+
+ g_error ("FullAOT cannot continue if there are loader errors");
+}
+
/* Wrappers around the image writer functions */
static inline void
* callers.
*/
for (i = 0; i < acfg->image->tables [MONO_TABLE_METHOD].rows; ++i) {
+ MonoError error;
MonoMethod *method;
guint32 token = MONO_TOKEN_METHOD_DEF | (i + 1);
gboolean skip = FALSE;
- method = mono_get_method (acfg->image, token, NULL);
+ method = mono_get_method_checked (acfg->image, token, NULL, NULL, &error);
+ report_loader_error (acfg, &error, "Failed to load method token 0x%x due to %s\n", i, mono_error_get_message (&error));
if ((method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) ||
(method->iflags & METHOD_IMPL_ATTRIBUTE_RUNTIME) ||
/* Synchronized wrappers */
for (i = 0; i < acfg->image->tables [MONO_TABLE_METHOD].rows; ++i) {
+ MonoError error;
token = MONO_TOKEN_METHOD_DEF | (i + 1);
- method = mono_get_method (acfg->image, token, NULL);
+ method = mono_get_method_checked (acfg->image, token, NULL, NULL, &error);
+ report_loader_error (acfg, &error, "Failed to load method token 0x%x due to %s\n", i, mono_error_get_message (&error));
if (method->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED) {
if (method->is_generic) {
/* pinvoke wrappers */
for (i = 0; i < acfg->image->tables [MONO_TABLE_METHOD].rows; ++i) {
+ MonoError error;
MonoMethod *method;
guint32 token = MONO_TOKEN_METHOD_DEF | (i + 1);
- method = mono_get_method (acfg->image, token, NULL);
+ method = mono_get_method_checked (acfg->image, token, NULL, NULL, &error);
+ report_loader_error (acfg, &error, "Failed to load method token 0x%x due to %s\n", i, mono_error_get_message (&error));
if ((method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) ||
(method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL)) {
/* native-to-managed wrappers */
for (i = 0; i < acfg->image->tables [MONO_TABLE_METHOD].rows; ++i) {
+ MonoError error;
MonoMethod *method;
guint32 token = MONO_TOKEN_METHOD_DEF | (i + 1);
MonoCustomAttrInfo *cattr;
int j;
- method = mono_get_method (acfg->image, token, NULL);
+ method = mono_get_method_checked (acfg->image, token, NULL, NULL, &error);
+ report_loader_error (acfg, &error, "Failed to load method token 0x%x due to %s\n", i, mono_error_get_message (&error));
/*
* Only generate native-to-managed wrappers for methods which have an
return;
for (i = 0; i < acfg->image->tables [MONO_TABLE_METHODSPEC].rows; ++i) {
+ MonoError error;
token = MONO_TOKEN_METHOD_SPEC | (i + 1);
- method = mono_get_method (acfg->image, token, NULL);
+ method = mono_get_method_checked (acfg->image, token, NULL, NULL, &error);
- if (!method)
+ if (!method) {
+ aot_printerrf (acfg, "Failed to load methodspec 0x%x due to %s.\n", token, mono_error_get_message (&error));
+ aot_printerrf (acfg, "Run with MONO_LOG_LEVEL=debug for more information.\n");
+ mono_error_cleanup (&error);
continue;
+ }
if (method->klass->image != acfg->image)
continue;
/* Collect methods */
for (i = 0; i < image->tables [MONO_TABLE_METHOD].rows; ++i) {
+ MonoError error;
MonoMethod *method;
guint32 token = MONO_TOKEN_METHOD_DEF | (i + 1);
- method = mono_get_method (acfg->image, token, NULL);
+ method = mono_get_method_checked (acfg->image, token, NULL, NULL, &error);
if (!method) {
- aot_printerrf (acfg, "Failed to load method 0x%x from '%s'.\n", token, image->name);
+ aot_printerrf (acfg, "Failed to load method 0x%x from '%s' due to %s.\n", token, image->name, mono_error_get_message (&error));
aot_printerrf (acfg, "Run with MONO_LOG_LEVEL=debug for more information.\n");
+ mono_error_cleanup (&error);
return FALSE;
}
/* gsharedvt methods */
for (mindex = 0; mindex < image->tables [MONO_TABLE_METHOD].rows; ++mindex) {
+ MonoError error;
MonoMethod *method;
guint32 token = MONO_TOKEN_METHOD_DEF | (mindex + 1);
if (!(acfg->opts & MONO_OPT_GSHAREDVT))
continue;
- method = mono_get_method (acfg->image, token, NULL);
- if (!method)
- continue;
+ method = mono_get_method_checked (acfg->image, token, NULL, NULL, &error);
+ report_loader_error (acfg, &error, "Failed to load method token 0x%x due to %s\n", i, mono_error_get_message (&error));
+
/*
if (strcmp (method->name, "gshared2"))
continue;