Commit 1d29fbd18e for perl
commit 1d29fbd18e8f041082a1257634c12c961b60b3c9
Author: David Mitchell <davem@iabyn.nospamdeletethisbit.com>
Date: Sun Sep 13 14:56:40 2026 +0100
regex: improve cur_eval debugging output
Standardise the debugging output which is emitted when cur_eval is
updated. Use the same message format in all instances, and include an
extra location which sets cur_eval but didn't emit debugging info.
Also correct the state name in a few debugging messages, e.g.
"EVAL_AB_fail" => "EVAL_postponed_A/B_fail".
diff --git a/regexec.c b/regexec.c
index 2160788c32..8b124a4067 100644
--- a/regexec.c
+++ b/regexec.c
@@ -8756,6 +8756,10 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
ST.B = next;
ST.prev_eval = cur_eval;
cur_eval = st;
+ DEBUG_STACK_r({
+ re_exec_indentf("EVAL/GOSUB: set cur_eval = %p; was %p\n",
+ depth, cur_eval, ST.prev_eval);
+ });
/* now continue from first node in postoned RE */
PUSH_YES_STATE_GOTO(EVAL_postponed_A, startpoint, locinput,
loceol, script_run_begin);
@@ -8767,10 +8771,6 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
case EVAL_postponed_B: /* cleanup the B part after a
successful (??{A})B */
/* note: this is called twice; first after popping B, then A */
- DEBUG_STACK_r({
- re_exec_indentf("EVAL_postponed_A/B cur_eval = %p prev_eval = %p\n",
- depth, cur_eval, ST.prev_eval);
- });
#define SET_RECURSE_LOCINPUT(STR,VAL) \
if ( cur_eval && CUR_EVAL.close_paren ) { \
@@ -8792,6 +8792,10 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
S_set_reg_curpm(aTHX_ rex_sv, reginfo);
rex = ReANY(rex_sv);
rexi = RXi_GET(rex);
+ DEBUG_STACK_r({
+ re_exec_indentf("EVAL_postponed_A/B set cur_eval = %p; was %p\n",
+ depth, ST.prev_eval, cur_eval);
+ });
cur_eval = ST.prev_eval;
cur_curlyx = ST.prev_curlyx;
@@ -8812,12 +8816,9 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
case EVAL_postponed_A_fail: /* unsuccessfully ran A in (??{A})B */
case EVAL_postponed_B_fail: /* unsuccessfully ran B in (??{A})B */
/* note: this is called twice; first after popping B, then A */
- DEBUG_STACK_r({
- re_exec_indentf("EVAL_AB_fail cur_eval = %p prev_eval = %p\n",
- depth, cur_eval, ST.prev_eval);
- });
- SET_RECURSE_LOCINPUT("EVAL_AB_fail[before]", CUR_EVAL.prev_recurse_locinput);
+ SET_RECURSE_LOCINPUT("EVAL_postponed_A/B_fail[before]",
+ CUR_EVAL.prev_recurse_locinput);
rex_sv = ST.prev_rex;
is_utf8_pat = reginfo->is_utf8_pat = cBOOL(RX_UTF8(rex_sv));
@@ -8827,6 +8828,10 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
REGCP_UNWIND(ST.lastcp);
regcppop(rex, &maxopenparen);
+ DEBUG_STACK_r({
+ re_exec_indentf("EVAL_postponed_A/B_fail set cur_eval = %p; was %p\n",
+ depth, ST.prev_eval, cur_eval);
+ });
cur_eval = ST.prev_eval;
cur_curlyx = ST.prev_curlyx;
@@ -8835,7 +8840,8 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
if ( nochange_depth )
nochange_depth--;
- SET_RECURSE_LOCINPUT("EVAL_AB_fail[after]", cur_eval->locinput);
+ SET_RECURSE_LOCINPUT("EVAL_postponed_A/B_fail[after]",
+ cur_eval->locinput);
sayNO_SILENT;
#undef ST
@@ -9953,8 +9959,8 @@ NULL
st->u.eval.prev_eval = cur_eval;
cur_eval = CUR_EVAL.prev_eval;
DEBUG_EXECUTE_r(
- re_exec_indentf("END: EVAL trying tail ... (cur_eval = %p)\n",
- depth, cur_eval););
+ re_exec_indentf("END: EVAL trying tail ... set cur_eval = %p; was %p\n",
+ depth, cur_eval, st->u.eval.prev_eval););
if ( nochange_depth )
nochange_depth--;