[pypy-commit] pypy reverse-debugger: Catch exceptions from RPython commands
arigo
pypy.commits at gmail.com
Sat Jun 11 15:22:41 EDT 2016
Author: Armin Rigo <arigo at tunes.org>
Branch: reverse-debugger
Changeset: r85101:2e1c0f9240a3
Date: 2016-06-11 21:23 +0200
http://bitbucket.org/pypy/pypy/changeset/2e1c0f9240a3/
Log: Catch exceptions from RPython commands
diff --git a/rpython/config/translationoption.py b/rpython/config/translationoption.py
--- a/rpython/config/translationoption.py
+++ b/rpython/config/translationoption.py
@@ -284,6 +284,7 @@
requires=[('translation.split_gc_address_space', True),
('translation.jit', False),
('translation.gc', 'boehm'),
+ ("translation.rweakref", False),
('translation.thread', False),
('translation.continuation', False)]),
])
diff --git a/rpython/translator/revdb/rdb-src/revdb.c b/rpython/translator/revdb/rdb-src/revdb.c
--- a/rpython/translator/revdb/rdb-src/revdb.c
+++ b/rpython/translator/revdb/rdb-src/revdb.c
@@ -8,8 +8,9 @@
#include <ctype.h>
#include <setjmp.h>
+#include "structdef.h"
+#include "forwarddecl.h"
#include "preimpl.h"
-#include "structdef.h"
#include "src/rtyper.h"
#include "rdb-src/revdb_include.h"
@@ -367,8 +368,22 @@
memcpy(_RPyString_AsString(s), arguments, length);
disable_io(&dinfo);
- if (setjmp(jmp_buf_cancel_execution) == 0)
+ if (setjmp(jmp_buf_cancel_execution) == 0) {
+ void *saved_t = pypy_g_ExcData.ed_exc_type;
+ void *saved_v = pypy_g_ExcData.ed_exc_value;
+ pypy_g_ExcData.ed_exc_type = NULL;
+ pypy_g_ExcData.ed_exc_value = NULL;
+
rpy_revdb_command_funcs[index](s);
+
+ if (pypy_g_ExcData.ed_exc_type != NULL) {
+ printf("Command crashed with %.*s\n",
+ (int)(pypy_g_ExcData.ed_exc_type->ov_name->rs_chars.length),
+ pypy_g_ExcData.ed_exc_type->ov_name->rs_chars.items);
+ }
+ pypy_g_ExcData.ed_exc_type = saved_t;
+ pypy_g_ExcData.ed_exc_value = saved_v;
+ }
enable_io(&dinfo);
}
diff --git a/rpython/translator/revdb/test/test_basic.py b/rpython/translator/revdb/test/test_basic.py
--- a/rpython/translator/revdb/test/test_basic.py
+++ b/rpython/translator/revdb/test/test_basic.py
@@ -251,11 +251,23 @@
def setup_class(cls):
#
+ def g(cmdline):
+ if len(cmdline) > 5:
+ raise ValueError
+ g._dont_inline_ = True
+ #
def blip(cmdline):
revdb.send_output('<<<' + cmdline + '>>>\n')
if cmdline == 'oops':
for i in range(1000):
print 42 # I/O not permitted
+ if cmdline == 'raise-and-catch':
+ try:
+ g(cmdline)
+ except ValueError:
+ pass
+ if cmdline == 'crash':
+ raise ValueError
revdb.send_output('blipped\n')
lambda_blip = lambda: blip
#
@@ -279,7 +291,8 @@
child = self.replay()
child.expectx('(3)$ ')
child.sendline('r oops')
- child.expectx('<<<oops>>>\r\nAttempted to do I/O or access raw memory')
+ child.expectx('<<<oops>>>\r\n')
+ child.expectx('Attempted to do I/O or access raw memory')
child.expectx('(3)$ ')
def test_interaction_with_forward(self):
@@ -288,8 +301,23 @@
child.sendline('go 1')
child.expectx('(1)$ ')
child.sendline('r oops')
- child.expectx('<<<oops>>>\r\nAttempted to do I/O or access raw memory')
+ child.expectx('<<<oops>>>\r\n')
+ child.expectx('Attempted to do I/O or access raw memory')
child.expectx('(1)$ ')
child.sendline('forward 50')
child.expectx('At end.\r\n')
child.expectx('(3)$ ')
+
+ def test_raise_and_catch(self):
+ child = self.replay()
+ child.expectx('(3)$ ')
+ child.sendline('r raise-and-catch')
+ child.expectx('<<<raise-and-catch>>>\r\nblipped\r\n')
+ child.expectx('(3)$ ')
+
+ def test_crash(self):
+ child = self.replay()
+ child.expectx('(3)$ ')
+ child.sendline('r crash')
+ child.expectx('<<<crash>>>\r\nCommand crashed with ValueError')
+ child.expectx('(3)$ ')
More information about the pypy-commit
mailing list