Skip to content

Commit 16efb1a

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 14b937f commit 16efb1a

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
@@ -3519,15 +3519,40 @@ Perl_debop(pTHX_ const OP *o)
35193519
break;
35203520
case OP_GVSV:
35213521
case OP_GV:
3522+
case OP_AELEMFAST:
3523+
case OP_RCATLINE:
35223524
PerlIO_printf(Perl_debug_log, "(%" SVf ")",
35233525
SVfARG(S_gv_display(aTHX_ cGVOPo_gv)));
3526+
if (o->op_type == OP_AELEMFAST)
3527+
do_fast_ix:
3528+
PerlIO_printf(Perl_debug_log, "[%" IVdf "]",
3529+
(IV)(I8)o->op_private);
3530+
break;
3531+
3532+
case OP_METHOD_NAMED: /* $obj->foo */
3533+
case OP_METHOD_SUPER: /* $obj->SUPER::foo */
3534+
case OP_METHOD_REDIR: /* $obj->BAR::foo */
3535+
case OP_METHOD_REDIR_SUPER: /* $obj->BAR::SUPER::foo */
3536+
PerlIO_printf(Perl_debug_log, "(%s)",
3537+
SvPEEK(cMETHOPo_meth));
3538+
if ( o->op_type == OP_METHOD_REDIR
3539+
|| o->op_type == OP_METHOD_REDIR_SUPER)
3540+
{
3541+
PerlIO_printf(Perl_debug_log, "(%s)",
3542+
SvPEEK(cMETHOPo_rclass));
3543+
}
35243544
break;
35253545

35263546
case OP_PADSV:
35273547
case OP_PADAV:
35283548
case OP_PADHV:
35293549
case OP_ARGELEM:
3550+
case OP_PADSV_STORE:
3551+
case OP_AELEMFAST_LEX:
3552+
do_lex:
35303553
S_deb_padvar(aTHX_ o->op_targ, 1, 1);
3554+
if (o->op_type == OP_AELEMFAST_LEX)
3555+
goto do_fast_ix;
35313556
break;
35323557

35333558
case OP_PADRANGE:
@@ -3546,6 +3571,10 @@ Perl_debop(pTHX_ const OP *o)
35463571
break;
35473572

35483573
default:
3574+
if ( (PL_opargs[o->op_type] & OA_TARGLEX)
3575+
&& (o->op_private & OPpTARGET_MY))
3576+
goto do_lex;
3577+
35493578
break;
35503579
}
35513580
PerlIO_printf(Perl_debug_log, "\n");

0 commit comments

Comments
 (0)