You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some OPs, such as OP_CONST, OP_GVSV and OP_METHOD_NAMED, point to an SV
or GV. In threaded builds, these SVs are moved to the pad and an index is
stored in the OP instead (typically op_targ or op_padix).
When op_dump() is called upon to display an OP (typically during
debugging or via perl -Dx), then currently, information about the linked
SV (e.g. the glob's name) is displayed only on non-threaded builds,
since op_dump() can't assume that PL_curpad[] is associated with this
particular op. Thus you get things like an OP_CONST being dumped that
doesn't display the const's value. This is annoying during debugging.
This commit makes it so that when dumping common OPs which have an SV in
the pad, it tries to find the CV, if any, associated with that op, and
if so, uses that CV's pad to lookup the value. If unsuccessful, it
falls back to not displaying the SV. This commit uses two main
techniques to find the CV. Both rely on first following the op_parent
chain from the current op to find the root op of the optree which this
op is embedded in. Then, if compiling, it compares this with the roots
of the optrees currently on the parse stack, and so, uses the associated
CV which is is pointed to from that slot on the parse stack. Or, if
runtime, looks for a SUB or EVAL context on the context stack and sees
if that sub or eval's CvROOT() / PL_eval_root matches the root of the
op's tree.
The next two commits will extend this to handle 'perl -Dx' too.
This commit also tries to show the state of the fields on CONST and
METHOD_FOO ops which can hold an SV or index, in addition to showing the SV
that is retrieved from them.
Here are examples of some op dumps on threaded builds before and after
this commit:
--------------------------------------------------------------
const SVOP(0x2a051578) ===> 6 [gvsv 0x2a0515e8]
TARG = 2
FLAGS = (SCALAR,SLABBED,MORESIB)
gvsv PADOP(0x2a0515e8) ===> 5 [sassign 0x2a051538]
FLAGS = (SCALAR,SLABBED)
PADIX = 1
method_redir METHOP(0x13dd4318) ===> 5 [entersub 0x13dd4358]
TARG = 4
FLAGS = (UNKNOWN,SLABBED)
--------------------------------------------------------------
const SVOP(0x22f655b8) ===> 6 [gvsv 0x22f65628]
TARG = 2
FLAGS = (SCALAR,SLABBED,MORESIB)
OP_SV = 0x0
SV = PV("abc"\0) (0x22f65768)
gvsv PADOP(0x22f65628) ===> 5 [sassign 0x22f65578]
FLAGS = (SCALAR,SLABBED)
PADIX = 1
GV = main::x (0x22f58f20)
method_redir METHOP(0x1d83f318) ===> 5 [entersub 0x1d83f358]
TARG = 4
FLAGS = (UNKNOWN,SLABBED)
OP_METH_SV = 0x0
METH = PV("foo") (0x1d833010)
RCLASS_TARG = 2
RCLASS = PV("BAR") (0x1d83f638)
--------------------------------------------------------------
0 commit comments