[pypy-svn] r70592 - in pypy/branch/c-traceback/pypy: jit/metainterp rlib rpython rpython/lltypesystem translator/c/src translator/c/test translator/cli translator/jvm

arigo at codespeak.net arigo at codespeak.net
Thu Jan 14 17:54:43 CET 2010


Author: arigo
Date: Thu Jan 14 17:54:42 2010
New Revision: 70592

Modified:
   pypy/branch/c-traceback/pypy/jit/metainterp/history.py
   pypy/branch/c-traceback/pypy/jit/metainterp/warmspot.py
   pypy/branch/c-traceback/pypy/rlib/debug.py
   pypy/branch/c-traceback/pypy/rpython/llinterp.py
   pypy/branch/c-traceback/pypy/rpython/lltypesystem/lloperation.py
   pypy/branch/c-traceback/pypy/translator/c/src/debug_traceback.h
   pypy/branch/c-traceback/pypy/translator/c/test/test_standalone.py
   pypy/branch/c-traceback/pypy/translator/cli/opcodes.py
   pypy/branch/c-traceback/pypy/translator/jvm/opcodes.py
Log:
Random progress, in-progress.


Modified: pypy/branch/c-traceback/pypy/jit/metainterp/history.py
==============================================================================
--- pypy/branch/c-traceback/pypy/jit/metainterp/history.py	(original)
+++ pypy/branch/c-traceback/pypy/jit/metainterp/history.py	Thu Jan 14 17:54:42 2010
@@ -926,10 +926,6 @@
             loops.append(loop)
         display_loops(loops, errmsg, extraloops)
 
-
-class CrashInJIT(Exception):
-    pass
-
 # ----------------------------------------------------------------
 
 class Options:

Modified: pypy/branch/c-traceback/pypy/jit/metainterp/warmspot.py
==============================================================================
--- pypy/branch/c-traceback/pypy/jit/metainterp/warmspot.py	(original)
+++ pypy/branch/c-traceback/pypy/jit/metainterp/warmspot.py	Thu Jan 14 17:54:42 2010
@@ -11,7 +11,7 @@
 from pypy.rlib.objectmodel import we_are_translated
 from pypy.rlib.unroll import unrolling_iterable
 from pypy.rlib.rarithmetic import r_uint, intmask
-from pypy.rlib.debug import debug_print
+from pypy.rlib.debug import debug_print, fatalerror
 from pypy.rpython.lltypesystem.lloperation import llop
 from pypy.translator.simplify import get_funcobj, get_functype
 from pypy.translator.unsimplify import call_final_function
@@ -344,9 +344,7 @@
                 if sys.stdout == sys.__stdout__:
                     import pdb; pdb.post_mortem(sys.exc_info()[2])
                 raise
-            debug_print('~~~ Crash in JIT!')
-            debug_print('~~~ %s' % (e,))
-            raise history.CrashInJIT("crash in JIT")
+            fatalerror('~~~ Crash in JIT! %s' % (e,), traceback=True)
         crash_in_jit._dont_inline_ = True
 
         if self.translator.rtyper.type_system.name == 'lltypesystem':

Modified: pypy/branch/c-traceback/pypy/rlib/debug.py
==============================================================================
--- pypy/branch/c-traceback/pypy/rlib/debug.py	(original)
+++ pypy/branch/c-traceback/pypy/rlib/debug.py	Thu Jan 14 17:54:42 2010
@@ -19,6 +19,14 @@
         hop.exception_cannot_occur()
         hop.genop('debug_assert', vlist)
 
+def fatalerror(msg, traceback=False):
+    from pypy.rpython.lltypesystem import lltype
+    from pypy.rpython.lltypesystem.lloperation import llop
+    if traceback:
+        llop.debug_print_traceback(lltype.Void)
+    llop.debug_fatalerror(lltype.Void, msg)
+fatalerror._dont_inline_ = True
+
 
 class DebugLog(list):
     def debug_print(self, *args):

Modified: pypy/branch/c-traceback/pypy/rpython/llinterp.py
==============================================================================
--- pypy/branch/c-traceback/pypy/rpython/llinterp.py	(original)
+++ pypy/branch/c-traceback/pypy/rpython/llinterp.py	Thu Jan 14 17:54:42 2010
@@ -543,6 +543,18 @@
     def op_debug_llinterpcall(self, pythonfunction, *args_ll):
         return pythonfunction(*args_ll)
 
+    def op_debug_start_traceback(self, *args):
+        pass    # xxx write debugging code here?
+
+    def op_debug_record_traceback(self, *args):
+        pass    # xxx write debugging code here?
+
+    def op_debug_print_traceback(self, *args):
+        pass    # xxx write debugging code here?
+
+    def op_debug_catch_exception(self, *args):
+        pass    # xxx write debugging code here?
+
     def op_jit_marker(self, *args):
         pass
 

Modified: pypy/branch/c-traceback/pypy/rpython/lltypesystem/lloperation.py
==============================================================================
--- pypy/branch/c-traceback/pypy/rpython/lltypesystem/lloperation.py	(original)
+++ pypy/branch/c-traceback/pypy/rpython/lltypesystem/lloperation.py	Thu Jan 14 17:54:42 2010
@@ -539,6 +539,7 @@
     'debug_start_traceback':LLOp(),
     'debug_record_traceback':LLOp(),
     'debug_catch_exception':LLOp(),
+    'debug_print_traceback':LLOp(),
 
     # __________ instrumentation _________
     'instrument_count':     LLOp(),

Modified: pypy/branch/c-traceback/pypy/translator/c/src/debug_traceback.h
==============================================================================
--- pypy/branch/c-traceback/pypy/translator/c/src/debug_traceback.h	(original)
+++ pypy/branch/c-traceback/pypy/translator/c/src/debug_traceback.h	Thu Jan 14 17:54:42 2010
@@ -7,6 +7,9 @@
 #define OP_DEBUG_START_TRACEBACK()                              \
   pypy_debug_traceback_count = PYPY_DEBUG_TRACEBACK_DEPTH
 
+#define OP_DEBUG_PRINT_TRACEBACK()                              \
+  pypy_debug_traceback_print()
+
 #define PYPY_DEBUG_RECORD_TRACEBACK(funcname)                           \
   if ((--pypy_debug_traceback_count) >= 0) {                            \
     static struct pydtentry_s entry = { PYPY_FILE_NAME, funcname, __LINE__ }; \
@@ -25,6 +28,7 @@
 extern int pypy_debug_traceback_count;
 extern struct pydtentry_s *pypy_debug_tracebacks[PYPY_DEBUG_TRACEBACK_DEPTH];
 
+void pypy_debug_traceback_print(void);
 void pypy_debug_catch_exception(void);
 
 

Modified: pypy/branch/c-traceback/pypy/translator/c/test/test_standalone.py
==============================================================================
--- pypy/branch/c-traceback/pypy/translator/c/test/test_standalone.py	(original)
+++ pypy/branch/c-traceback/pypy/translator/c/test/test_standalone.py	Thu Jan 14 17:54:42 2010
@@ -10,6 +10,7 @@
 from pypy.annotation.listdef import s_list_of_strings
 from pypy.tool.udir import udir
 from pypy.tool.autopath import pypydir
+from pypy.conftest import option
 
 
 class StandaloneTests(object):
@@ -23,6 +24,8 @@
         cbuilder = CStandaloneBuilder(t, entry_point, t.config)
         cbuilder.generate_source(defines=cbuilder.DEBUG_DEFINES)
         cbuilder.compile()
+        if option.view:
+            t.view()
         return t, cbuilder
 
 
@@ -410,6 +413,34 @@
         assert lines2[-2] != lines[-2]    # different line number
         assert lines2[-3] == lines[-3]    # same line number
 
+    def test_fatal_error_finally(self):
+        def g(x):
+            if x == 1:
+                raise KeyError
+        def h(x):
+            try:
+                g(x)
+            finally:
+                print 'done.'
+        def entry_point(argv):
+            if len(argv) < 3:
+                h(len(argv))
+            return 0
+        t, cbuilder = self.compile(entry_point)
+        #
+        out, err = cbuilder.cmdexec("", expect_crash=True)
+        assert out.strip() == 'done.'
+        lines = err.strip().splitlines()
+        assert lines[-1] == 'Fatal RPython error: KeyError'
+        assert len(lines) >= 6
+        l0, l1, l2, l3, l4 = lines[-6:-1]
+        assert l0 == 'RPython traceback:'
+        assert re.match(r'  File "\w+.c", line \d+, in pypy_g_entry_point', l1)
+        assert re.match(r'  File "\w+.c", line \d+, in pypy_g_h', l2)
+        assert re.match(r'  File "\w+.c", line \d+, in pypy_g_h', l3)
+        assert re.match(r'  File "\w+.c", line \d+, in pypy_g_g', l4)
+        assert l2 != l3    # different line number
+
     def test_assertion_error(self):
         def g(x):
             assert x != 1

Modified: pypy/branch/c-traceback/pypy/translator/cli/opcodes.py
==============================================================================
--- pypy/branch/c-traceback/pypy/translator/cli/opcodes.py	(original)
+++ pypy/branch/c-traceback/pypy/translator/cli/opcodes.py	Thu Jan 14 17:54:42 2010
@@ -79,6 +79,7 @@
     'debug_assert':             Ignore,
     'debug_start_traceback':    Ignore,
     'debug_record_traceback':   Ignore,
+    'debug_print_traceback':    Ignore,
     'debug_catch_exception':    Ignore,
     'debug_print':              [DebugPrint],
     'debug_start':              [PushAllArgs, 'call void [pypylib]pypy.runtime.DebugPrint::DEBUG_START(string)'],

Modified: pypy/branch/c-traceback/pypy/translator/jvm/opcodes.py
==============================================================================
--- pypy/branch/c-traceback/pypy/translator/jvm/opcodes.py	(original)
+++ pypy/branch/c-traceback/pypy/translator/jvm/opcodes.py	Thu Jan 14 17:54:42 2010
@@ -103,6 +103,7 @@
     'debug_assert':              [], # TODO: implement?
     'debug_start_traceback':    Ignore,
     'debug_record_traceback':   Ignore,
+    'debug_print_traceback':    Ignore,
     'debug_catch_exception':    Ignore,
 
     # __________ numeric operations __________



More information about the Pypy-commit mailing list