From f4197b8e1d1f984eb6635ea41ce14394432b96b1 Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Tue, 14 Feb 2017 13:32:16 +0000 Subject: [PATCH] -Mre=Debug,ALL: indicate regex state stack pushes At this maximal level of debugging output, it displays the top 3 state stack entries each time it pushes, but with no obvious indication that a push is occurring. This commit changes this output: | 1| Setting an EVAL scope, savestack=9, | 2| #4 WHILEM_A_max | 2| #3 WHILEM_A_max | 2| #2 CURLYX_end yes 0 | 2| 4:POSIXD[\w](5) to be this (which includes the word "push" and extra indentation for the stack dump): | 1| Setting an EVAL scope, savestack=9, | 2| push #4 WHILEM_A_max | 2| #3 WHILEM_A_max | 2| #2 CURLYX_end yes 0 | 2| 4:POSIXD[\w](5) Also, replace curd (current depth) var with a positive integer offset (i) var, to avoid signed/unsigned mixing problems. --- regexec.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/regexec.c b/regexec.c index 2d5bf0b..bf9809a 100644 --- a/regexec.c +++ b/regexec.c @@ -8520,16 +8520,17 @@ NULL DEBUG_STACK_r({ regmatch_state *cur = st; regmatch_state *curyes = yes_state; - int curd = depth; + U32 i; regmatch_slab *slab = PL_regmatch_slab; - for (;curd > -1 && (depth-curd < 3);cur--,curd--) { + for (i = 0; i < 3 && i <= depth; cur--,i++) { if (cur < SLAB_FIRST(slab)) { slab = slab->prev; cur = SLAB_LAST(slab); } - Perl_re_exec_indentf( aTHX_ "#%-3d %-10s %s\n", + Perl_re_exec_indentf( aTHX_ "%4s #%-3d %-10s %s\n", depth, - curd, PL_reg_name[cur->resume_state], + i ? " " : "push", + depth - i, PL_reg_name[cur->resume_state], (curyes == cur) ? "yes" : "" ); if (curyes == cur) -- 1.8.3.1