Author: Maciej Fijalkowski <fij...@gmail.com> Branch: jit-applevel-info Changeset: r44261:53a68f64c59d Date: 2011-05-17 19:33 +0200 http://bitbucket.org/pypy/pypy/changeset/53a68f64c59d/
Log: implement debug_flush, no tests checking if it works :-/ diff --git a/pypy/rlib/debug.py b/pypy/rlib/debug.py --- a/pypy/rlib/debug.py +++ b/pypy/rlib/debug.py @@ -157,6 +157,23 @@ hop.exception_cannot_occur() return hop.genop('debug_offset', [], resulttype=lltype.Signed) + +def debug_flush(): + """ Flushes the debug file + """ + pass + +class Entry(ExtRegistryEntry): + _about_ = debug_flush + + def compute_result_annotation(self): + return None + + def specialize_call(self, hop): + hop.exception_cannot_occur() + return hop.genop('debug_flush', []) + + def llinterpcall(RESTYPE, pythonfunction, *args): """When running on the llinterp, this causes the llinterp to call to the provided Python function with the run-time value of the given args. diff --git a/pypy/rlib/test/test_debug.py b/pypy/rlib/test/test_debug.py --- a/pypy/rlib/test/test_debug.py +++ b/pypy/rlib/test/test_debug.py @@ -60,6 +60,7 @@ debug_start("mycat") debug_print("foo", 2, "bar", x) debug_stop("mycat") + debug_flush() # does nothing debug_offset() # should not explode at least return have_debug_prints() diff --git a/pypy/rpython/lltypesystem/lloperation.py b/pypy/rpython/lltypesystem/lloperation.py --- a/pypy/rpython/lltypesystem/lloperation.py +++ b/pypy/rpython/lltypesystem/lloperation.py @@ -554,6 +554,7 @@ 'debug_stop': LLOp(canrun=True), 'have_debug_prints': LLOp(canrun=True), 'debug_offset': LLOp(canrun=True), + 'debug_flush': LLOp(canrun=True), 'debug_pdb': LLOp(), 'debug_assert': LLOp(tryfold=True), 'debug_fatalerror': LLOp(), diff --git a/pypy/rpython/lltypesystem/opimpl.py b/pypy/rpython/lltypesystem/opimpl.py --- a/pypy/rpython/lltypesystem/opimpl.py +++ b/pypy/rpython/lltypesystem/opimpl.py @@ -516,6 +516,9 @@ def op_debug_offset(): return debug.debug_offset() +def op_debug_flush(): + pass + def op_have_debug_prints(): return debug.have_debug_prints() diff --git a/pypy/translator/c/src/debug_print.h b/pypy/translator/c/src/debug_print.h --- a/pypy/translator/c/src/debug_print.h +++ b/pypy/translator/c/src/debug_print.h @@ -28,7 +28,7 @@ #define PYPY_DEBUG_STOP(cat) pypy_debug_stop(cat) #define OP_DEBUG_OFFSET(res) res = pypy_debug_offset() #define OP_HAVE_DEBUG_PRINTS(r) r = (pypy_have_debug_prints & 1) - +#define OP_DEBUG_FLUSH() fflush(pypy_debug_file) /************************************************************/ diff --git a/pypy/translator/c/test/test_standalone.py b/pypy/translator/c/test/test_standalone.py --- a/pypy/translator/c/test/test_standalone.py +++ b/pypy/translator/c/test/test_standalone.py @@ -3,7 +3,7 @@ from pypy.rlib.objectmodel import keepalive_until_here from pypy.rlib.rarithmetic import r_longlong -from pypy.rlib.debug import ll_assert, have_debug_prints +from pypy.rlib.debug import ll_assert, have_debug_prints, debug_flush from pypy.rlib.debug import debug_print, debug_start, debug_stop, debug_offset from pypy.translator.translator import TranslationContext from pypy.translator.backendopt import all @@ -284,6 +284,7 @@ debug_stop ("mycat") if have_debug_prints(): x += "a" debug_print("toplevel") + debug_flush() os.write(1, x + "." + str(debug_offset()) + '.\n') return 0 t, cbuilder = self.compile(entry_point) _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit