[svn:parrot] r47688 - branches/gsoc_instrument/src/dynpmc

khairul at svn.parrot.org khairul at svn.parrot.org
Fri Jun 18 16:44:14 UTC 2010


Author: khairul
Date: Fri Jun 18 16:44:14 2010
New Revision: 47688
URL: https://trac.parrot.org/parrot/changeset/47688

Log:
Handle exit/exceptions thrown in inner runloops.

Modified:
   branches/gsoc_instrument/src/dynpmc/instrument.pmc

Modified: branches/gsoc_instrument/src/dynpmc/instrument.pmc
==============================================================================
--- branches/gsoc_instrument/src/dynpmc/instrument.pmc	Fri Jun 18 16:31:45 2010	(r47687)
+++ branches/gsoc_instrument/src/dynpmc/instrument.pmc	Fri Jun 18 16:44:14 2010	(r47688)
@@ -54,6 +54,7 @@
     INTVAL                   flags;
 
     /* End of common members */
+    INTVAL                    has_ended;
     Parrot_Interp             supervisor_interp;
     PMC                      *supervisor_pmc;
     probe_list_t            **op_hooks;
@@ -636,25 +637,34 @@
     /* Setup an exception handler to handle exits and unhandled exceptions. */
     if (setjmp(exc_handler.resume)) {
         /* Check for exit or unhandled exception. */
+        Parrot_Context_info info;
+        INTVAL ret = Parrot_Context_get_info(interp, CURRENT_CONTEXT(interp), &info);
+
         if (*pc == enum_ops_exit_i || *pc == enum_ops_exit_ic) {
-            /* Exit called. Do nothing but return so we
-               can go on to finalize the instruments. */
+            /* Exit called. */
+            Parrot_io_eprintf(supervisor, "Exit called in file \"%Ss\" line %d.\n",
+                             info.file, info.line);
         }
         else {
-            /* Unhandled exception found.
-               Print the exception type for now. */
-            Parrot_io_printf(supervisor,
-                            "Unhandled exception of type %i found\n",
-                            VTABLE_get_integer_keyed_str(interp, exc_handler.exception,
-                                                         CONST_STRING(interp, "type")));
+            /* Unhandled exception found. */
+            INTVAL type = VTABLE_get_integer_keyed_str(interp, exc_handler.exception,
+                                                         CONST_STRING(interp, "type"));
+            STRING *message = VTABLE_get_string(interp, exc_handler.exception);
+            Parrot_io_eprintf(supervisor,
+                            "Unhandled exception of type (%d) thrown in file \"%Ss\" line %d,\n"
+                            "with message \"%Ss\".\n",
+                            type, info.file, info.line, message);
         }
 
+         /* Set the flag to exit all runloops. */
+         core->has_ended = 1;
+
         return pc;
     }
 
     Parrot_ex_add_c_handler(interp, &exc_handler);
 
-    while (pc) {
+    while (pc && !(core->has_ended)) {
         opcode_t *pc_copy = pc;
         Parrot_pcc_set_pc(interp, CURRENT_CONTEXT(interp), pc);
 
@@ -709,6 +719,7 @@
     coredata->op_hooks           = NULL;
     coredata->op_catchall        = NULL;
     coredata->old_dynlibs        = VTABLE_clone(supervisor, dynlibs);
+    coredata->has_ended          = 0;
 
     PARROT_RUNCORE_FUNC_TABLE_SET((Parrot_runcore_t *)coredata);
 


More information about the parrot-commits mailing list