Skip to content

Commit d842683

Browse files
committed
Perl_debop() / -Dt: display some OP args better
Perl_debop() displays an op in a compact one-line form, typically used by 'perl -Dt' to show the next op to be executed. This commit improves the display of some ops slightly: in particular, where the name of a GV argument to the op, or the name of the associated lexical var is displayed, sometimes this wasn't being done, for example for the new op OP_PADSV_STORE, which probably just got missed when being added. It also now displays: * the name of the lexical var for ops which have the OPpTARGET_MY optimisation; * the name of the method and redirect class for method ops; * the index of the aelemfast and aelemfast_lex op For example, with the following code: my ($sum); sub Bar::foo {} my $obj = bless {}, 'Foo'; my @lexary; $^D='t'; $sum = 1; $sum = $ary[-2] + $lexary[3]; $obj->Bar::foo(); $x .= <>; then before, the -Dt output for certain lines was: padsv_store aelemfast aelemfast_lex add method_redir rcatline and is now: padsv_store($sum) aelemfast(main::ary)[-2] aelemfast_lex(@lexary)[3] add($sum) method_redir(PV("foo"))(PV("Bar")) rcatline(main::ARGV)
1 parent 7738c44 commit d842683

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

dump.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3517,15 +3517,40 @@ Perl_debop(pTHX_ const OP *o)
35173517
break;
35183518
case OP_GVSV:
35193519
case OP_GV:
3520+
case OP_AELEMFAST:
3521+
case OP_RCATLINE:
35203522
PerlIO_printf(Perl_debug_log, "(%" SVf ")",
35213523
SVfARG(S_gv_display(aTHX_ cGVOPo_gv)));
3524+
if (o->op_type == OP_AELEMFAST)
3525+
do_fast_ix:
3526+
PerlIO_printf(Perl_debug_log, "[%" IVdf "]",
3527+
(IV)(I8)o->op_private);
3528+
break;
3529+
3530+
case OP_METHOD_NAMED: /* $obj->foo */
3531+
case OP_METHOD_SUPER: /* $obj->SUPER::foo */
3532+
case OP_METHOD_REDIR: /* $obj->BAR::foo */
3533+
case OP_METHOD_REDIR_SUPER: /* $obj->BAR::SUPER::foo */
3534+
PerlIO_printf(Perl_debug_log, "(%s)",
3535+
SvPEEK(cMETHOPo_meth));
3536+
if ( o->op_type == OP_METHOD_REDIR
3537+
|| o->op_type == OP_METHOD_REDIR_SUPER)
3538+
{
3539+
PerlIO_printf(Perl_debug_log, "(%s)",
3540+
SvPEEK(cMETHOPo_rclass));
3541+
}
35223542
break;
35233543

35243544
case OP_PADSV:
35253545
case OP_PADAV:
35263546
case OP_PADHV:
35273547
case OP_ARGELEM:
3548+
case OP_PADSV_STORE:
3549+
case OP_AELEMFAST_LEX:
3550+
do_lex:
35283551
S_deb_padvar(aTHX_ o->op_targ, 1, 1);
3552+
if (o->op_type == OP_AELEMFAST_LEX)
3553+
goto do_fast_ix;
35293554
break;
35303555

35313556
case OP_PADRANGE:
@@ -3544,6 +3569,10 @@ Perl_debop(pTHX_ const OP *o)
35443569
break;
35453570

35463571
default:
3572+
if ( (PL_opargs[o->op_type] & OA_TARGLEX)
3573+
&& (o->op_private & OPpTARGET_MY))
3574+
goto do_lex;
3575+
35473576
break;
35483577
}
35493578
PerlIO_printf(Perl_debug_log, "\n");

0 commit comments

Comments
 (0)