Skip to content

Commit 2a90c22

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 f1170a0 commit 2a90c22

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
@@ -3515,15 +3515,40 @@ Perl_debop(pTHX_ const OP *o)
35153515
break;
35163516
case OP_GVSV:
35173517
case OP_GV:
3518+
case OP_AELEMFAST:
3519+
case OP_RCATLINE:
35183520
PerlIO_printf(Perl_debug_log, "(%" SVf ")",
35193521
SVfARG(S_gv_display(aTHX_ cGVOPo_gv)));
3522+
if (o->op_type == OP_AELEMFAST)
3523+
do_fast_ix:
3524+
PerlIO_printf(Perl_debug_log, "[%" IVdf "]",
3525+
(IV)(I8)o->op_private);
3526+
break;
3527+
3528+
case OP_METHOD_NAMED: /* $obj->foo */
3529+
case OP_METHOD_SUPER: /* $obj->SUPER::foo */
3530+
case OP_METHOD_REDIR: /* $obj->BAR::foo */
3531+
case OP_METHOD_REDIR_SUPER: /* $obj->BAR::SUPER::foo */
3532+
PerlIO_printf(Perl_debug_log, "(%s)",
3533+
SvPEEK(cMETHOPo_meth));
3534+
if ( o->op_type == OP_METHOD_REDIR
3535+
|| o->op_type == OP_METHOD_REDIR_SUPER)
3536+
{
3537+
PerlIO_printf(Perl_debug_log, "(%s)",
3538+
SvPEEK(cMETHOPo_rclass));
3539+
}
35203540
break;
35213541

35223542
case OP_PADSV:
35233543
case OP_PADAV:
35243544
case OP_PADHV:
35253545
case OP_ARGELEM:
3546+
case OP_PADSV_STORE:
3547+
case OP_AELEMFAST_LEX:
3548+
do_lex:
35263549
S_deb_padvar(aTHX_ o->op_targ, 1, 1);
3550+
if (o->op_type == OP_AELEMFAST_LEX)
3551+
goto do_fast_ix;
35273552
break;
35283553

35293554
case OP_PADRANGE:
@@ -3542,6 +3567,10 @@ Perl_debop(pTHX_ const OP *o)
35423567
break;
35433568

35443569
default:
3570+
if ( (PL_opargs[o->op_type] & OA_TARGLEX)
3571+
&& (o->op_private & OPpTARGET_MY))
3572+
goto do_lex;
3573+
35453574
break;
35463575
}
35473576
PerlIO_printf(Perl_debug_log, "\n");

0 commit comments

Comments
 (0)