Skip to content

Conversation

@iabyn
Copy link
Contributor

@iabyn iabyn commented Nov 12, 2025

This commit, and its two precursors, makes the output of perl -Dx, a.k.a op_dump(), display the names of pad variables as well as the target number on pad ops.

  • This set of changes does not require a perldelta entry.

Make S_deb_padvar() a thin wrapper over a new S_deb_padvar_cv() function,
which does the same thing (display a pad variable name), but does it for
a specified CV rather than only for the currently executing CV. This
function will be used shorty.
The existing S_get_sv_from_pad() function does two things: it finds the
CV associated with the specified op, and then extracts something from
that CV's pad.

This commit splits the 'find the associated CV' part of the code out
into a separate function, which will be used elsewhere shortly.
Make op_dump(), as used by 'perl -Dx', display the names of pad
variables when dumping pad ops.

The runtime perl -Dt already does this (note the $x, $y etc appearing in
the op name displays):

    $ perl -Dt -e'my ($x, $y); $y = 1+$x'

    (-e:0)	enter
    (-e:0)	nextstate
    (-e:1)	padrange($x,$y)
    (-e:1)	nextstate
    (-e:1)	const(IV(1))
    (-e:1)	padsv($x)
    (-e:1)	add($y)
    (-e:1)	leave

While the (typically compile-time) -Dx detailed optree dumping didn't.
Here are some 'before this commit' and 'after' examples of how some of
those ops were/are now displayed. Note the changes in the 'TARG = N'
lines for the following code:

    $  perl -Dx -e'my ($x, $y); $y = 1+$x'

Before:

    4    |   +--padrange OP(0x31b08960) ===> 6 [nextstate 0x31b09fc0]
         |   |   TARG = 1
         |   |   FLAGS = (VOID,MOD,SLABBED,MORESIB)
         |   |   PRIVATE = (LVINTRO,range=0x2)

    10   +--add BINOP(0x31b0a060) ===> 1 [leave 0x31b08880]
             TARG = 2
             FLAGS = (VOID,KIDS,SLABBED)
             PRIVATE = (TARGMY,0x2)

    11       +--padsv OP(0x31b0a0a0) ===> 10 [add 0x31b0a060]
                 TARG = 1
                 FLAGS = (SCALAR,SLABBED)

After:

    4    |   +--padrange OP(0x18ffe920) ===> 6 [nextstate 0x18ffff80]
         |   |   TARG = 1 ($x,$y)
         |   |   FLAGS = (VOID,MOD,SLABBED,MORESIB)
         |   |   PRIVATE = (LVINTRO,range=0x2)

    10   +--add BINOP(0x19000020) ===> 1 [leave 0x18ffe840]
             TARG = 2 ($y)
             FLAGS = (VOID,KIDS,SLABBED)
             PRIVATE = (TARGMY,0x2)

    11       +--padsv OP(0x19000060) ===> 10 [add 0x19000020]
                 TARG = 1 ($x)
                 FLAGS = (SCALAR,SLABBED)
@iabyn iabyn merged commit 067d8a6 into blead Nov 13, 2025
68 checks passed
@iabyn iabyn deleted the davem/Dx_varname branch November 13, 2025 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants