summaryrefslogtreecommitdiff
path: root/dump.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2018-03-06 15:24:38 +0000
committerDavid Mitchell <davem@iabyn.com>2018-03-06 15:30:28 +0000
commit49ea76a70e8a4984b7d555bfbac872c0624b858c (patch)
tree1f0d77017f3bca3bff931ca121c2470b3a3c7ec4 /dump.c
parent3f515a2edaad4fe95e69a30dcc8823e4d7353d43 (diff)
downloadperl-49ea76a70e8a4984b7d555bfbac872c0624b858c.tar.gz
op_dump(): display op_next to self as [SELF]
Normally op_next (and similar) fields of an op are displayed with the address and basic details of the op they point to, e.g. 5 gvsv PADOP(0x1b7ac48) ===> 5 [sassign 0x1b7ab80] This commit enhances that so that if the field points back to the op containing the field (as is often the case during the early phases of building an op tree), instead display it as just: 5 gvsv PADOP(0x1b7ac48) ===> [SELF]
Diffstat (limited to 'dump.c')
-rw-r--r--dump.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/dump.c b/dump.c
index 41b5f377b5..aeb9955688 100644
--- a/dump.c
+++ b/dump.c
@@ -610,10 +610,12 @@ S_opdump_indent(pTHX_ const OP *o, I32 level, UV bar, PerlIO *file,
*/
static void
-S_opdump_link(pTHX_ const OP *o, PerlIO *file)
+S_opdump_link(pTHX_ const OP *base, const OP *o, PerlIO *file)
{
PerlIO_puts(file, " ===> ");
- if (o)
+ if (o == base)
+ PerlIO_puts(file, "[SELF]\n");
+ else if (o)
PerlIO_printf(file, "%" UVuf " [%s 0x%" UVxf "]\n",
sequence_num(o), OP_NAME(o), PTR2UV(o));
else
@@ -994,7 +996,7 @@ S_do_op_dump_bar(pTHX_ I32 level, UV bar, PerlIO *file, const OP *o)
PerlIO_printf(file, " %s(0x%" UVxf ")",
op_class_names[op_class(o)], PTR2UV(o));
- S_opdump_link(aTHX_ o->op_next, file);
+ S_opdump_link(aTHX_ o, o->op_next, file);
/* print op common fields */
@@ -1202,11 +1204,11 @@ S_do_op_dump_bar(pTHX_ I32 level, UV bar, PerlIO *file, const OP *o)
case OP_ENTERITER:
case OP_ENTERLOOP:
S_opdump_indent(aTHX_ o, level, bar, file, "REDO");
- S_opdump_link(aTHX_ cLOOPo->op_redoop, file);
+ S_opdump_link(aTHX_ o, cLOOPo->op_redoop, file);
S_opdump_indent(aTHX_ o, level, bar, file, "NEXT");
- S_opdump_link(aTHX_ cLOOPo->op_nextop, file);
+ S_opdump_link(aTHX_ o, cLOOPo->op_nextop, file);
S_opdump_indent(aTHX_ o, level, bar, file, "LAST");
- S_opdump_link(aTHX_ cLOOPo->op_lastop, file);
+ S_opdump_link(aTHX_ o, cLOOPo->op_lastop, file);
break;
case OP_REGCOMP:
@@ -1227,7 +1229,7 @@ S_do_op_dump_bar(pTHX_ I32 level, UV bar, PerlIO *file, const OP *o)
case OP_ENTERTRY:
case OP_ONCE:
S_opdump_indent(aTHX_ o, level, bar, file, "OTHER");
- S_opdump_link(aTHX_ cLOGOPo->op_other, file);
+ S_opdump_link(aTHX_ o, cLOGOPo->op_other, file);
break;
case OP_SPLIT:
case OP_MATCH: