diff options
author | Reini Urban <rurban@cpanel.net> | 2015-03-16 10:27:37 +0100 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2015-11-10 14:17:23 +1100 |
commit | 6cae08a8be145bcb838b49a6de6051e08d4e25a5 (patch) | |
tree | 1fcd25af1a023a401fc019c3111f3b250094a636 /pp.h | |
parent | aec1aee98641bc6f9ad658677f98ce6915bd139a (diff) | |
download | perl-6cae08a8be145bcb838b49a6de6051e08d4e25a5.tar.gz |
MARK -Ds debugging
display the MARK arity and pointers with MARK macros.
assert on markptr underflow.
Diffstat (limited to 'pp.h')
-rw-r--r-- | pp.h | 53 |
1 files changed, 42 insertions, 11 deletions
@@ -55,16 +55,47 @@ Refetch the stack pointer. Used after a callback. See L<perlcall>. #define MARK mark #define TARG targ -#define PUSHMARK(p) \ - STMT_START { \ - I32 * mark_stack_entry; \ - if (UNLIKELY((mark_stack_entry = ++PL_markstack_ptr) == PL_markstack_max)) \ - mark_stack_entry = markstack_grow(); \ - *mark_stack_entry = (I32)((p) - PL_stack_base); \ - } STMT_END - -#define TOPMARK (*PL_markstack_ptr) -#define POPMARK (*PL_markstack_ptr--) +#if defined(DEBUGGING) && defined(PERL_USE_GCC_BRACE_GROUPS) +#define PUSHMARK(p) \ + STMT_START { \ + I32 * mark_stack_entry; \ + if (UNLIKELY((mark_stack_entry = ++PL_markstack_ptr) == PL_markstack_max)) \ + mark_stack_entry = markstack_grow(); \ + *mark_stack_entry = (I32)((p) - PL_stack_base); \ + DEBUG_s(PerlIO_printf(Perl_debug_log, "MARK push %p %d\n", \ + PL_markstack_ptr, *mark_stack_entry)); \ + } STMT_END +#define TOPMARK \ + ({ \ + DEBUG_s(PerlIO_printf(Perl_debug_log, "MARK top %p %d\n", \ + PL_markstack_ptr, *PL_markstack_ptr)); \ + *PL_markstack_ptr; \ + }) +#define POPMARK \ + ({ \ + DEBUG_s(PerlIO_printf(Perl_debug_log, "MARK pop %p %d\n", \ + (PL_markstack_ptr-1), *(PL_markstack_ptr-1))); \ + assert((PL_markstack_ptr > PL_markstack) || !"MARK underflow");\ + *PL_markstack_ptr--; \ + }) +#define INCMARK \ + ({ \ + DEBUG_s(PerlIO_printf(Perl_debug_log, "MARK inc %p %d\n", \ + (PL_markstack_ptr+1), *(PL_markstack_ptr+1))); \ + *PL_markstack_ptr++; \ + }) +#else +#define PUSHMARK(p) \ + STMT_START { \ + I32 * mark_stack_entry; \ + if (UNLIKELY((mark_stack_entry = ++PL_markstack_ptr) == PL_markstack_max)) \ + mark_stack_entry = markstack_grow(); \ + *mark_stack_entry = (I32)((p) - PL_stack_base); \ + } STMT_END +#define TOPMARK (*PL_markstack_ptr) +#define POPMARK (*PL_markstack_ptr--) +#define INCMARK (*PL_markstack_ptr++) +#endif #define dSP SV **sp = PL_stack_sp #define djSP dSP @@ -506,7 +537,7 @@ Does not use C<TARG>. See also C<L</XPUSHu>>, C<L</mPUSHu>> and C<L</PUSHu>>. while (jump_o->op_type == OP_NULL) \ jump_o = jump_o->op_next; \ assert(jump_o->op_type == OP_ENTERSUB); \ - PL_markstack_ptr--; \ + POPMARK; \ return jump_o->op_next; \ } \ return NORMAL; \ |