aboutsummaryrefslogtreecommitdiff
path: root/py/nlr.h
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-04-05 18:32:08 +0100
committerDamien George <damien.p.george@gmail.com>2014-04-05 18:32:08 +0100
commitea13f407a392593e7746131952a57bad222ee882 (patch)
tree240fb586f678808bb5039a22e06a6214408adfc3 /py/nlr.h
parent2a037408af77d4c9e9cc98f5f12ea77fab93cc0e (diff)
py: Change nlr_jump to nlr_raise, to aid in debugging.
This does not affect code size or performance when debugging turned off. To address issue #420.
Diffstat (limited to 'py/nlr.h')
-rw-r--r--py/nlr.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/py/nlr.h b/py/nlr.h
index b94ca7d3f..ce62334fd 100644
--- a/py/nlr.h
+++ b/py/nlr.h
@@ -26,3 +26,16 @@ struct _nlr_buf_t {
unsigned int nlr_push(nlr_buf_t *);
void nlr_pop(void);
void nlr_jump(void *val) __attribute__((noreturn));
+
+// use nlr_raise instead of nlr_jump so that debugging is easier
+#ifndef DEBUG
+#define nlr_raise(val) nlr_jump(val)
+#else
+#define nlr_raise(val) \
+ do { \
+ void *_val = val; \
+ assert(_val != NULL); \
+ assert(mp_obj_is_exception_instance(_val)); \
+ nlr_jump(_val); \
+ } while (0)
+#endif