[runtime] Avoid mono_error_raise_exception in icalls and debugging utilities
authorAleksey Kliger <aleksey@xamarin.com>
Fri, 27 May 2016 19:38:15 +0000 (15:38 -0400)
committerAleksey Kliger <aleksey@xamarin.com>
Fri, 27 May 2016 19:54:47 +0000 (15:54 -0400)
mono/metadata/debug-helpers.c
mono/metadata/icall.c

index 9e933a64bb4b6605e3d8134042d10f6f9c5bea82..449895a56106a2a0e3efbbc97230cd3bfe938712 100644 (file)
@@ -928,14 +928,18 @@ mono_object_describe (MonoObject *obj)
        klass = mono_object_class (obj);
        if (klass == mono_defaults.string_class) {
                char *utf8 = mono_string_to_utf8_checked ((MonoString*)obj, &error);
-               mono_error_raise_exception (&error); /* FIXME don't raise here */
-               if (strlen (utf8) > 60) {
+               mono_error_cleanup (&error); /* FIXME don't swallow the error */
+               if (utf8 && strlen (utf8) > 60) {
                        utf8 [57] = '.';
                        utf8 [58] = '.';
                        utf8 [59] = '.';
                        utf8 [60] = 0;
                }
-               g_print ("String at %p, length: %d, '%s'\n", obj, mono_string_length ((MonoString*) obj), utf8);
+               if (utf8) {
+                       g_print ("String at %p, length: %d, '%s'\n", obj, mono_string_length ((MonoString*) obj), utf8);
+               } else {
+                       g_print ("String at %p, length: %d, unable to decode UTF16\n", obj, mono_string_length ((MonoString*) obj));
+               }
                g_free (utf8);
        } else if (klass->rank) {
                MonoArray *array = (MonoArray*)obj;
index e8ab22e843ba4d407624233854a7ae7a191bbc64..5f9cabfc9e8d4a39ef68a917a57c7a06a64c5b23 100644 (file)
@@ -7549,6 +7549,7 @@ ves_icall_System_Configuration_DefaultConfig_get_machine_config_path (void)
        return mcpath;
 }
 
+/* this is an icall */
 static MonoString *
 get_bundled_app_config (void)
 {
@@ -7567,7 +7568,8 @@ get_bundled_app_config (void)
 
        // Retrieve config file and remove the extension
        config_file_name = mono_string_to_utf8_checked (file, &error);
-       mono_error_raise_exception (&error); /* FIXME don't raise here */
+       if (mono_error_set_pending_exception (&error))
+               return NULL;
        config_file_path = mono_portability_find_file (config_file_name, TRUE);
        if (!config_file_path)
                config_file_path = config_file_name;