Permalink
Browse files

add some diagnostics to sanity check failures

  • Loading branch information...
1 parent 3de80cd commit c675e49a32b033dcdc9a4fab5e3b9cb7ccd31f27 @demerphq demerphq committed Oct 29, 2012
Showing with 10 additions and 0 deletions.
  1. +10 −0 Perl/Encoder/srl_buffer.h
View
@@ -37,7 +37,17 @@
#define DEBUG_ASSERT_BUF_SPACE(enc, len) ((void)0)
#endif
+#ifndef NDEBUG
+#define DEBUG_ASSERT_BUF_SANE(enc) STMT_START { \
+ if(!(((enc)->buf_start <= (enc)->pos) && ((enc)->pos <= (enc)->buf_end))){\
+ warn("failed sanity assertion check - pos: %ld [%p %p %p] %ld", \
+ (long)BUF_POS_OFS(enc), (enc)->buf_start, (enc)->pos, (enc)->buf_end, (long)BUF_SPACE(enc)); \
+ } \
+ assert(((enc)->buf_start <= (enc)->pos) && ((enc)->pos <= (enc)->buf_end));\
+} STMT_END
+#else
#define DEBUG_ASSERT_BUF_SANE(enc) assert(((enc)->buf_start <= (enc)->pos) && ((enc)->pos <= (enc)->buf_end))
+#endif
static SRL_INLINE void
srl_buf_grow_nocheck(pTHX_ srl_encoder_t *enc, size_t minlen)

0 comments on commit c675e49

Please sign in to comment.