[svn:parrot] r38071 - in trunk: include/parrot src t/op t/pmc

tene at svn.parrot.org tene at svn.parrot.org
Sun Apr 12 01:59:57 UTC 2009


Author: tene
Date: Sun Apr 12 01:59:55 2009
New Revision: 38071
URL: https://trac.parrot.org/parrot/changeset/38071

Log:
Revert recent changes from Tene--
These can't be applied until we also fix tests that check the literal
text of the uncaught exception message.

Modified:
   trunk/include/parrot/exceptions.h
   trunk/include/parrot/string_funcs.h
   trunk/src/exceptions.c
   trunk/t/op/exceptions.t
   trunk/t/pmc/exception.t

Modified: trunk/include/parrot/exceptions.h
==============================================================================
--- trunk/include/parrot/exceptions.h	Sun Apr 12 01:20:36 2009	(r38070)
+++ trunk/include/parrot/exceptions.h	Sun Apr 12 01:59:55 2009	(r38071)
@@ -222,10 +222,6 @@
     unsigned int line);
 
 void Parrot_print_backtrace(void);
-void print_hll_info_from_exception(PARROT_INTERP, ARGIN(PMC *exception))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2);
-
 #define ASSERT_ARGS_exit_fatal __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(format)
 #define ASSERT_ARGS_Parrot_assert __attribute__unused__ int _ASSERT_ARGS_CHECK = \
@@ -267,9 +263,6 @@
     || PARROT_ASSERT_ARG(exception)
 #define ASSERT_ARGS_do_panic __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
 #define ASSERT_ARGS_Parrot_print_backtrace __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
-#define ASSERT_ARGS_print_hll_info_from_exception __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp) \
-    || PARROT_ASSERT_ARG(exception)
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 /* HEADERIZER END: src/exceptions.c */
 

Modified: trunk/include/parrot/string_funcs.h
==============================================================================
--- trunk/include/parrot/string_funcs.h	Sun Apr 12 01:20:36 2009	(r38070)
+++ trunk/include/parrot/string_funcs.h	Sun Apr 12 01:59:55 2009	(r38071)
@@ -418,8 +418,7 @@
 
 PARROT_EXPORT
 PARROT_WARN_UNUSED_RESULT
-INTVAL Parrot_str_to_int(PARROT_INTERP, ARGIN_NULLOK(const STRING *s))
-        __attribute__nonnull__(1);
+INTVAL Parrot_str_to_int(SHIM_INTERP, ARGIN_NULLOK(const STRING *s));
 
 PARROT_EXPORT
 PARROT_WARN_UNUSED_RESULT
@@ -679,8 +678,7 @@
        PARROT_ASSERT_ARG(interp)
 #define ASSERT_ARGS_Parrot_str_to_hashval __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_Parrot_str_to_int __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_str_to_int __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
 #define ASSERT_ARGS_Parrot_str_to_num __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \
     || PARROT_ASSERT_ARG(s)

Modified: trunk/src/exceptions.c
==============================================================================
--- trunk/src/exceptions.c	Sun Apr 12 01:20:36 2009	(r38070)
+++ trunk/src/exceptions.c	Sun Apr 12 01:59:55 2009	(r38071)
@@ -90,52 +90,6 @@
 
 /*
 
-=item C<void print_hll_info_from_exception(PARROT_INTERP, PMC *exception)>
-
-Print hll line number for C<exception>, if present.
-
-=cut
-
-*/
-
-void
-print_hll_info_from_exception(PARROT_INTERP, ARGIN(PMC *exception))
-{
-    PMC * list;
-    PMC * line;
-    PMC * iter;
-    const STRING * const bt = CONST_STRING(interp, "backtrace");
-    STRING * message     = VTABLE_get_string(interp, exception);
-    if (STRING_IS_NULL(message) || Parrot_str_equal(interp, message, CONST_STRING(interp, ""))) {
-        const INTVAL   severity    = VTABLE_get_integer_keyed_str(interp, exception, CONST_STRING(interp, "severity"));
-        if (severity < EXCEPT_error) {
-            message = CONST_STRING(interp, "warning");
-        }
-        else {
-            message = CONST_STRING(interp, "died");
-        }
-    }
-    Parrot_PCCINVOKE(interp, exception, bt, "->P", &list);
-    iter = VTABLE_get_iter(interp, list);
-    while (VTABLE_get_bool(interp, iter)) {
-        const PMC * const frame = VTABLE_shift_pmc(interp, iter);
-        const PMC * const annotations = VTABLE_get_pmc_keyed_str(interp, frame, CONST_STRING(interp, "annotations"));
-        line = VTABLE_get_pmc_keyed_str(interp, annotations, CONST_STRING(interp, "line"));
-        if (!PMC_IS_NULL(line)) {
-            break;
-        }
-    }
-    Parrot_io_eprintf(interp, "%Ss", message);
-        fflush(stderr);
-    if (!PMC_IS_NULL(line)) {
-        Parrot_io_eprintf(interp, " at line %d", VTABLE_get_integer(interp, line));
-    }
-    Parrot_io_eprintf(interp, "\n");
-    return;
-}
-
-/*
-
 =item C<void die_from_exception(PARROT_INTERP, PMC *exception)>
 
 Print a stack trace for C<exception>, a message if there is one, and then exit.
@@ -166,7 +120,8 @@
     }
 
     if (Parrot_str_not_equal(interp, message, CONST_STRING(interp, ""))) {
-        print_hll_info_from_exception(interp, exception);
+        Parrot_io_eprintf(interp, "%S\n", message);
+
         /* caution against output swap (with PDB_backtrace) */
         fflush(stderr);
         PDB_backtrace(interp);
@@ -176,7 +131,7 @@
         exit_status = VTABLE_get_integer_keyed_str(interp, exception, CONST_STRING(interp, "exit_code"));
     }
     else {
-        print_hll_info_from_exception(interp, exception);
+        Parrot_io_eprintf(interp, "No exception handler and no message\n");
         /* caution against output swap (with PDB_backtrace) */
         fflush(stderr);
         PDB_backtrace(interp);
@@ -248,10 +203,16 @@
     opcode_t   *address;
     PMC * const handler = Parrot_cx_find_handler_local(interp, exception);
     if (PMC_IS_NULL(handler)) {
+        STRING * const message     = VTABLE_get_string(interp, exception);
         const INTVAL   severity    = VTABLE_get_integer_keyed_str(interp, exception, CONST_STRING(interp, "severity"));
         if (severity < EXCEPT_error) {
-            print_hll_info_from_exception(interp, exception);
             PMC * const resume = VTABLE_get_attr_str(interp, exception, CONST_STRING(interp, "resume"));
+            if (Parrot_str_not_equal(interp, message, CONST_STRING(interp, ""))) {
+                Parrot_io_eprintf(interp, "%S\n", message);
+            }
+            else {
+                Parrot_io_eprintf(interp, "%S\n", CONST_STRING(interp, "Warning"));
+            }
 
             /* caution against output swap (with PDB_backtrace) */
             fflush(stderr);

Modified: trunk/t/op/exceptions.t
==============================================================================
--- trunk/t/op/exceptions.t	Sun Apr 12 01:20:36 2009	(r38070)
+++ trunk/t/op/exceptions.t	Sun Apr 12 01:59:55 2009	(r38071)
@@ -198,7 +198,7 @@
 _handler:
     end
 CODE
-/died/
+/No exception handler and no message/
 OUTPUT
 
 pasm_error_output_like( <<'CODE', <<'OUTPUT', "throw - no handler, no message" );
@@ -207,7 +207,7 @@
     print "not reached\n"
     end
 CODE
-/died/
+/No exception handler and no message/
 OUTPUT
 
 pasm_output_is( <<'CODE', <<'OUTPUT', "2 exception handlers" );
@@ -311,7 +311,7 @@
     print "caught it\n"
     end
 CODE
-/died/
+/No exception handler and no message/
 OUT
 
 pasm_output_is( <<'CODE', '', "exit exception" );
@@ -420,7 +420,7 @@
 .end
 CODE
 /^main
-died/
+No exception handler/
 OUTPUT
 
 $ENV{TEST_PROG_ARGS} ||= '';

Modified: trunk/t/pmc/exception.t
==============================================================================
--- trunk/t/pmc/exception.t	Sun Apr 12 01:20:36 2009	(r38070)
+++ trunk/t/pmc/exception.t	Sun Apr 12 01:59:55 2009	(r38071)
@@ -269,7 +269,7 @@
 _handler:
     end
 CODE
-/died/
+/No exception handler and no message/
 OUTPUT
 
 pasm_error_output_like( <<'CODE', <<'OUTPUT', "throw - no handler, no message" );
@@ -278,7 +278,7 @@
     print "not reached\n"
     end
 CODE
-/died/
+/No exception handler and no message/
 OUTPUT
 
 pasm_output_is( <<'CODE', <<'OUTPUT', "2 exception handlers" );
@@ -387,7 +387,7 @@
     print "caught it\n"
     end
 CODE
-/died/
+/No exception handler and no message/
 OUT
 
 pasm_output_is( <<'CODE', '', "exit exception" );
@@ -499,7 +499,7 @@
 .end
 CODE
 /^main
-died/
+No exception handler/
 OUTPUT
 
 # exception handlers are still run in an inferior runloop, which messes up
@@ -531,7 +531,7 @@
 CODE
 /^main
 at_exit, flag = 1
-died/
+No exception handler/
 OUTPUT
 
 $ENV{TEST_PROG_ARGS} ||= '';


More information about the parrot-commits mailing list