X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/8bbe2fa886e5d6b4040c8d1485d5b8fbd53d8e71..1bb1a3d6d354f67d1158693a799cb49037d27475:/dump.c diff --git a/dump.c b/dump.c index 30743ae..bc2776a 100644 --- a/dump.c +++ b/dump.c @@ -94,43 +94,43 @@ S_append_flags(pTHX_ SV *sv, U32 flags, const struct flag_to_name *start, /* =for apidoc pv_escape -Escapes at most the first "count" chars of pv and puts the results into -dsv such that the size of the escaped string will not exceed "max" chars +Escapes at most the first C chars of C and puts the results into +C such that the size of the escaped string will not exceed C chars and will not contain any incomplete escape sequences. The number of bytes -escaped will be returned in the STRLEN *escaped parameter if it is not null. -When the dsv parameter is null no escaping actually occurs, but the number +escaped will be returned in the C parameter if it is not null. +When the C parameter is null no escaping actually occurs, but the number of bytes that would be escaped were it not null will be calculated. -If flags contains PERL_PV_ESCAPE_QUOTE then any double quotes in the string +If flags contains C then any double quotes in the string will also be escaped. Normally the SV will be cleared before the escaped string is prepared, -but when PERL_PV_ESCAPE_NOCLEAR is set this will not occur. +but when C is set this will not occur. -If PERL_PV_ESCAPE_UNI is set then the input string is treated as UTF-8 -if PERL_PV_ESCAPE_UNI_DETECT is set then the input string is scanned +If C is set then the input string is treated as UTF-8 +if C is set then the input string is scanned using C to determine if it is UTF-8. -If PERL_PV_ESCAPE_ALL is set then all input chars will be output -using C<\x01F1> style escapes, otherwise if PERL_PV_ESCAPE_NONASCII is set, only +If C is set then all input chars will be output +using C<\x01F1> style escapes, otherwise if C is set, only non-ASCII chars will be escaped using this style; otherwise, only chars above 255 will be so escaped; other non printable chars will use octal or common escaped patterns like C<\n>. -Otherwise, if PERL_PV_ESCAPE_NOBACKSLASH +Otherwise, if C then all chars below 255 will be treated as printable and will be output as literals. -If PERL_PV_ESCAPE_FIRSTCHAR is set then only the first char of the +If C is set then only the first char of the string will be escaped, regardless of max. If the output is to be in hex, then it will be returned as a plain hex sequence. Thus the output will either be a single char, an octal escape sequence, a special escape like C<\n> or a hex value. -If PERL_PV_ESCAPE_RE is set then the escape char used will be a '%' and -not a '\\'. This is because regexes very often contain backslashed -sequences, whereas '%' is not a particularly common character in patterns. +If C is set then the escape char used will be a C<"%"> and +not a C<"\\">. This is because regexes very often contain backslashed +sequences, whereas C<"%"> is not a particularly common character in patterns. -Returns a pointer to the escaped text as held by dsv. +Returns a pointer to the escaped text as held by C. =cut */ @@ -249,23 +249,23 @@ Perl_pv_escape( pTHX_ SV *dsv, char const * const str, =for apidoc pv_pretty Converts a string into something presentable, handling escaping via -pv_escape() and supporting quoting and ellipses. +C and supporting quoting and ellipses. -If the PERL_PV_PRETTY_QUOTE flag is set then the result will be +If the C flag is set then the result will be double quoted with any double quotes in the string escaped. Otherwise -if the PERL_PV_PRETTY_LTGT flag is set then the result be wrapped in +if the C flag is set then the result be wrapped in angle brackets. -If the PERL_PV_PRETTY_ELLIPSES flag is set and not all characters in +If the C flag is set and not all characters in string were output then an ellipsis C<...> will be appended to the string. Note that this happens AFTER it has been quoted. -If start_color is non-null then it will be inserted after the opening -quote (if there is one) but before the escaped text. If end_color +If C is non-null then it will be inserted after the opening +quote (if there is one) but before the escaped text. If C is non-null then it will be inserted after the escaped text but before any quotes or ellipses. -Returns a pointer to the prettified text as held by dsv. +Returns a pointer to the prettified text as held by C. =cut */ @@ -477,9 +477,9 @@ Perl_sv_peek(pTHX_ SV *sv) } } else if (SvNOKp(sv)) { - STORE_NUMERIC_LOCAL_SET_STANDARD(); + STORE_LC_NUMERIC_UNDERLYING_SET_STANDARD(); Perl_sv_catpvf(aTHX_ t, "(%"NVgf")",SvNVX(sv)); - RESTORE_NUMERIC_LOCAL(); + RESTORE_LC_NUMERIC_UNDERLYING(); } else if (SvIOKp(sv)) { if (SvIsUV(sv)) @@ -572,7 +572,10 @@ Perl_dump_packsubs_perl(pTHX_ const HV *stash, bool justperl) for (i = 0; i <= (I32) HvMAX(stash); i++) { const HE *entry; for (entry = HvARRAY(stash)[i]; entry; entry = HeNEXT(entry)) { - const GV * const gv = (const GV *)HeVAL(entry); + GV * gv = (GV *)HeVAL(entry); + if (SvROK(gv) && SvTYPE(SvRV(gv)) == SVt_PVCV) + /* unfake a fake GV */ + (void)CvGV(SvRV(gv)); if (SvTYPE(gv) != SVt_PVGV || !GvGP(gv)) continue; if (GvCVu(gv)) @@ -841,7 +844,7 @@ Perl_do_op_dump(pTHX_ I32 level, PerlIO *file, const OP *o) if (o->op_savefree) sv_catpvs(tmpsv, ",SAVEFREE"); if (o->op_static) sv_catpvs(tmpsv, ",STATIC"); if (o->op_folded) sv_catpvs(tmpsv, ",FOLDED"); - if (o->op_lastsib) sv_catpvs(tmpsv, ",LASTSIB"); + if (o->op_moresib) sv_catpvs(tmpsv, ",MORESIB"); Perl_dump_indent(aTHX_ level, file, "FLAGS = (%s)\n", SvCUR(tmpsv) ? SvPVX_const(tmpsv) + 1 : ""); } @@ -902,7 +905,10 @@ Perl_do_op_dump(pTHX_ I32 level, PerlIO *file, const OP *o) sv_catpv(tmpsv, &PL_op_private_labels[label]); sv_catpv(tmpsv, "="); } - sv_catpv(tmpsv, &PL_op_private_labels[enum_label]); + if (enum_label == -1) + Perl_sv_catpvf(aTHX_ tmpsv, "0x%"UVxf, (UV)val); + else + sv_catpv(tmpsv, &PL_op_private_labels[enum_label]); } else { @@ -962,6 +968,7 @@ Perl_do_op_dump(pTHX_ I32 level, PerlIO *file, const OP *o) for (i=0; i < count; i++) Perl_dump_indent(aTHX_ level+1, file, "%"UVuf" => 0x%"UVxf"\n", i, items[i].uv); + break; } case OP_CONST: @@ -1084,9 +1091,6 @@ Perl_gv_dump(pTHX_ GV *gv) const char* name; SV *sv, *tmp = newSVpvs_flags("", SVs_TEMP); - - PERL_ARGS_ASSERT_GV_DUMP; - if (!gv) { PerlIO_printf(Perl_debug_log, "{}\n"); return; @@ -1103,7 +1107,7 @@ Perl_gv_dump(pTHX_ GV *gv) Perl_dump_indent(aTHX_ 1, Perl_debug_log, "-> %s", generic_pv_escape( tmp, name, len, SvUTF8(sv) )); } - PerlIO_putc(Perl_debug_log, '\n'); + (void)PerlIO_putc(Perl_debug_log, '\n'); Perl_dump_indent(aTHX_ 0, Perl_debug_log, "}\n"); } @@ -1113,7 +1117,7 @@ Perl_gv_dump(pTHX_ GV *gv) */ static const struct { const char type; const char *name; } magic_names[] = { -#include "mg_names.c" +#include "mg_names.inc" /* this null string terminates the list */ { 0, NULL }, }; @@ -1224,7 +1228,7 @@ Perl_do_magic_dump(pTHX_ I32 level, PerlIO *file, const MAGIC *mg, I32 nest, I32 " ???? - " __FILE__ " does not know how to handle this MG_LEN" ); - PerlIO_putc(file, '\n'); + (void)PerlIO_putc(file, '\n'); } if (mg->mg_type == PERL_MAGIC_utf8) { const STRLEN * const cache = (STRLEN *) mg->mg_ptr; @@ -1267,7 +1271,7 @@ Perl_do_hv_dump(pTHX_ I32 level, PerlIO *file, const char *name, HV *sv) HvNAMELEN(sv), HvNAMEUTF8(sv))); } else - PerlIO_putc(file, '\n'); + (void)PerlIO_putc(file, '\n'); } void @@ -1282,7 +1286,7 @@ Perl_do_gv_dump(pTHX_ I32 level, PerlIO *file, const char *name, GV *sv) generic_pv_escape( tmpsv, GvNAME(sv), GvNAMELEN(sv), GvNAMEUTF8(sv) )); } else - PerlIO_putc(file, '\n'); + (void)PerlIO_putc(file, '\n'); } void @@ -1306,7 +1310,7 @@ Perl_do_gvgv_dump(pTHX_ I32 level, PerlIO *file, const char *name, GV *sv) generic_pv_escape( tmp, GvNAME(sv), GvNAMELEN(sv), GvNAMEUTF8(sv))); } else - PerlIO_putc(file, '\n'); + (void)PerlIO_putc(file, '\n'); } const struct flag_to_name first_sv_flags_names[] = { @@ -1382,6 +1386,7 @@ const struct flag_to_name regexp_extflags_names[] = { {RXf_PMf_EXTENDED, "PMf_EXTENDED,"}, {RXf_PMf_EXTENDED_MORE, "PMf_EXTENDED_MORE,"}, {RXf_PMf_KEEPCOPY, "PMf_KEEPCOPY,"}, + {RXf_PMf_NOCAPTURE, "PMf_NOCAPURE,"}, {RXf_IS_ANCHORED, "IS_ANCHORED,"}, {RXf_NO_INPLACE_SUBST, "NO_INPLACE_SUBST,"}, {RXf_EVAL_SEEN, "EVAL_SEEN,"}, @@ -1411,7 +1416,6 @@ const struct flag_to_name regexp_core_intflags_names[] = { {PREGf_CUTGROUP_SEEN, "CUTGROUP_SEEN,"}, {PREGf_USE_RE_EVAL, "USE_RE_EVAL,"}, {PREGf_NOSCAN, "NOSCAN,"}, - {PREGf_CANY_SEEN, "CANY_SEEN,"}, {PREGf_GPOS_SEEN, "GPOS_SEEN,"}, {PREGf_GPOS_FLOAT, "GPOS_FLOAT,"}, {PREGf_ANCH_MBOL, "ANCH_MBOL,"}, @@ -1551,29 +1555,20 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo && type != SVt_REGEXP && !isGV_with_GP(sv) && !SvVALID(sv)) || (type == SVt_IV && !SvROK(sv))) { if (SvIsUV(sv) -#ifdef PERL_OLD_COPY_ON_WRITE - || SvIsCOW(sv) -#endif ) Perl_dump_indent(aTHX_ level, file, " UV = %"UVuf, (UV)SvUVX(sv)); else Perl_dump_indent(aTHX_ level, file, " IV = %"IVdf, (IV)SvIVX(sv)); -#ifdef PERL_OLD_COPY_ON_WRITE - if (SvIsCOW_shared_hash(sv)) - PerlIO_printf(file, " (HASH)"); - else if (SvIsCOW_normal(sv)) - PerlIO_printf(file, " (COW from 0x%"UVxf")", (UV)SvUVX(sv)); -#endif - PerlIO_putc(file, '\n'); + (void)PerlIO_putc(file, '\n'); } if ((type >= SVt_PVNV && type != SVt_PVAV && type != SVt_PVHV && type != SVt_PVCV && type != SVt_PVFM && type != SVt_REGEXP && type != SVt_PVIO && !isGV_with_GP(sv) && !SvVALID(sv)) || type == SVt_NV) { - STORE_NUMERIC_LOCAL_SET_STANDARD(); + STORE_LC_NUMERIC_UNDERLYING_SET_STANDARD(); Perl_dump_indent(aTHX_ level, file, " NV = %.*" NVgf "\n", NV_DIG, SvNVX(sv)); - RESTORE_NUMERIC_LOCAL(); + RESTORE_LC_NUMERIC_UNDERLYING(); } if (SvROK(sv)) { @@ -1626,7 +1621,7 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo if (!re) Perl_dump_indent(aTHX_ level, file, " LEN = %"IVdf"\n", (IV)SvLEN(sv)); -#ifdef PERL_NEW_COPY_ON_WRITE +#ifdef PERL_COPY_ON_WRITE if (SvIsCOW(sv) && SvLEN(sv)) Perl_dump_indent(aTHX_ level, file, " COW_REFCNT = %d\n", CowREFCNT(sv)); @@ -1657,7 +1652,7 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo Perl_dump_indent(aTHX_ level, file, " ALLOC = 0x%"UVxf"\n", PTR2UV(AvALLOC(sv))); } else - PerlIO_putc(file, '\n'); + (void)PerlIO_putc(file, '\n'); Perl_dump_indent(aTHX_ level, file, " FILL = %"IVdf"\n", (IV)AvFILLp(sv)); Perl_dump_indent(aTHX_ level, file, " MAX = %"IVdf"\n", (IV)AvMAX(sv)); Perl_dump_indent(aTHX_ level, file, " ARYLEN = 0x%"UVxf"\n", @@ -1718,7 +1713,7 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo PerlIO_printf(file, ", "); } } - PerlIO_putc(file, ')'); + (void)PerlIO_putc(file, ')'); /* The "quality" of a hash is defined as the total number of comparisons needed to access every element once, relative to the expected number needed for a random hash. @@ -1737,10 +1732,10 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo pow2 = pow2 << 1; theoret = usedkeys; theoret += theoret * (theoret-1)/pow2; - PerlIO_putc(file, '\n'); + (void)PerlIO_putc(file, '\n'); Perl_dump_indent(aTHX_ level, file, " hash quality = %.1"NVff"%%", theoret/sum*100); } - PerlIO_putc(file, '\n'); + (void)PerlIO_putc(file, '\n'); Perl_dump_indent(aTHX_ level, file, " KEYS = %"IVdf"\n", (IV)usedkeys); { STRLEN count = 0; @@ -1776,7 +1771,7 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo PerlIO_printf(file, " (LAST = 0x%"UVxf")", (UV)HvLASTRAND_get(sv)); } #endif - PerlIO_putc(file, '\n'); + (void)PerlIO_putc(file, '\n'); } { MAGIC * const mg = mg_find(sv, PERL_MAGIC_symtab); @@ -2038,7 +2033,7 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo Perl_dump_indent(aTHX_ level, file, " GPFLAGS = 0x%"UVxf " (%s)\n", (UV)GvGPFLAGS(sv), - GvALIASED_SV(sv) ? "ALIASED_SV" : ""); + ""); Perl_dump_indent(aTHX_ level, file, " LINE = %"IVdf"\n", (IV)GvLINE(sv)); Perl_dump_indent(aTHX_ level, file, " FILE = \"%s\"\n", GvFILE(sv)); do_gv_dump (level, file, " EGV", GvEGV(sv)); @@ -2207,6 +2202,8 @@ Perl_runops_debug(pTHX) ++PL_op_exec_cnt[PL_op->op_type]; #endif if (PL_debug) { + ENTER; + SAVETMPS; if (PL_watchaddr && (*PL_watchaddr != PL_watchok)) PerlIO_printf(Perl_debug_log, "WARNING: %"UVxf" changed from %"UVxf" to %"UVxf"\n", @@ -2224,6 +2221,8 @@ Perl_runops_debug(pTHX) if (DEBUG_t_TEST_) debop(PL_op); if (DEBUG_P_TEST_) debprof(PL_op); + FREETMPS; + LEAVE; } OP_ENTRY_PROBE(OP_NAME(PL_op)); @@ -2238,7 +2237,7 @@ Perl_runops_debug(pTHX) /* print the names of the n lexical vars starting at pad offset off */ -void +STATIC void S_deb_padvar(pTHX_ PADOFFSET off, int n, bool paren) { PADNAME *sv; @@ -2269,7 +2268,7 @@ S_deb_padvar(pTHX_ PADOFFSET off, int n, bool paren) /* append to the out SV, the name of the lexical at offset off in the CV * cv */ -void +static void S_append_padvar(pTHX_ PADOFFSET off, CV *cv, SV *out, int n, bool paren, bool is_scalar) { @@ -2288,7 +2287,9 @@ S_append_padvar(pTHX_ PADOFFSET off, CV *cv, SV *out, int n, if (namepad && (sv = padnamelist_fetch(namepad, off + i))) { STRLEN cur = SvCUR(out); - Perl_sv_catpvf(aTHX_ out, "[%"PNf, PNfARG(sv)); + Perl_sv_catpvf(aTHX_ out, "[%"UTF8f, + UTF8fARG(1, PadnameLEN(sv) - 1, + PadnamePV(sv) + 1)); if (is_scalar) SvPVX(out)[cur] = '$'; } @@ -2302,7 +2303,7 @@ S_append_padvar(pTHX_ PADOFFSET off, CV *cv, SV *out, int n, } -void +static void S_append_gv_name(pTHX_ GV *gv, SV *out) { SV *sv; @@ -2312,23 +2313,24 @@ S_append_gv_name(pTHX_ GV *gv, SV *out) } sv = newSV(0); gv_fullname4(sv, gv, NULL, FALSE); - Perl_sv_catpvf(aTHX_ out, "%c%-p", '$', sv); + Perl_sv_catpvf(aTHX_ out, "$%"SVf, SVfARG(sv)); SvREFCNT_dec_NN(sv); } #ifdef USE_ITHREADS -# define ITEM_SV(item) *av_fetch(comppad, (item)->pad_offset, FALSE); +# define ITEM_SV(item) (comppad ? \ + *av_fetch(comppad, (item)->pad_offset, FALSE) : NULL); #else # define ITEM_SV(item) UNOP_AUX_item_sv(item) #endif /* return a temporary SV containing a stringified representation of - * the op_aux field of a UNOP_AUX op, associated with CV cv + * the op_aux field of a MULTIDEREF op, associated with CV cv */ SV* -Perl_unop_aux_stringify(pTHX_ const OP *o, CV *cv) +Perl_multideref_stringify(pTHX_ const OP *o, CV *cv) { UNOP_AUX_item *items = cUNOP_AUXo->op_aux; UV actions = items->uv; @@ -2336,13 +2338,19 @@ Perl_unop_aux_stringify(pTHX_ const OP *o, CV *cv) bool last = 0; bool is_hash = FALSE; int derefs = 0; - SV *out = sv_2mortal(newSVpv("",0)); + SV *out = newSVpvn_flags("",0,SVs_TEMP); #ifdef USE_ITHREADS - PADLIST * const padlist = CvPADLIST(cv); - PAD *comppad = PadlistARRAY(padlist)[1]; + PAD *comppad; + + if (cv) { + PADLIST *padlist = CvPADLIST(cv); + comppad = PadlistARRAY(padlist)[1]; + } + else + comppad = NULL; #endif - PERL_ARGS_ASSERT_UNOP_AUX_STRINGIFY; + PERL_ARGS_ASSERT_MULTIDEREF_STRINGIFY; while (!last) { switch (actions & MDEREF_ACTION_MASK) { @@ -2350,38 +2358,50 @@ Perl_unop_aux_stringify(pTHX_ const OP *o, CV *cv) case MDEREF_reload: actions = (++items)->uv; continue; + NOT_REACHED; /* NOTREACHED */ case MDEREF_HV_padhv_helem: is_hash = TRUE; + /* FALLTHROUGH */ case MDEREF_AV_padav_aelem: derefs = 1; S_append_padvar(aTHX_ (++items)->pad_offset, cv, out, 1, 0, 1); goto do_elem; + NOT_REACHED; /* NOTREACHED */ case MDEREF_HV_gvhv_helem: is_hash = TRUE; + /* FALLTHROUGH */ case MDEREF_AV_gvav_aelem: derefs = 1; - sv = ITEM_SV(++items); + items++; + sv = ITEM_SV(items); S_append_gv_name(aTHX_ (GV*)sv, out); goto do_elem; + NOT_REACHED; /* NOTREACHED */ case MDEREF_HV_gvsv_vivify_rv2hv_helem: is_hash = TRUE; + /* FALLTHROUGH */ case MDEREF_AV_gvsv_vivify_rv2av_aelem: - sv = ITEM_SV(++items); + items++; + sv = ITEM_SV(items); S_append_gv_name(aTHX_ (GV*)sv, out); goto do_vivify_rv2xv_elem; + NOT_REACHED; /* NOTREACHED */ case MDEREF_HV_padsv_vivify_rv2hv_helem: is_hash = TRUE; + /* FALLTHROUGH */ case MDEREF_AV_padsv_vivify_rv2av_aelem: S_append_padvar(aTHX_ (++items)->pad_offset, cv, out, 1, 0, 1); goto do_vivify_rv2xv_elem; + NOT_REACHED; /* NOTREACHED */ case MDEREF_HV_pop_rv2hv_helem: case MDEREF_HV_vivify_rv2hv_helem: is_hash = TRUE; + /* FALLTHROUGH */ do_vivify_rv2xv_elem: case MDEREF_AV_pop_rv2av_aelem: case MDEREF_AV_vivify_rv2av_aelem: @@ -2398,15 +2418,20 @@ Perl_unop_aux_stringify(pTHX_ const OP *o, CV *cv) switch (actions & MDEREF_INDEX_MASK) { case MDEREF_INDEX_const: if (is_hash) { - STRLEN cur; - char *s; - sv = ITEM_SV(++items); - s = SvPV(sv, cur); - pv_pretty(out, s, cur, 30, - NULL, NULL, - (PERL_PV_PRETTY_NOCLEAR - |PERL_PV_PRETTY_QUOTE - |PERL_PV_PRETTY_ELLIPSES)); + items++; + sv = ITEM_SV(items); + if (!sv) + sv_catpvs_nomg(out, "???"); + else { + STRLEN cur; + char *s; + s = SvPV(sv, cur); + pv_pretty(out, s, cur, 30, + NULL, NULL, + (PERL_PV_PRETTY_NOCLEAR + |PERL_PV_PRETTY_QUOTE + |PERL_PV_PRETTY_ELLIPSES)); + } } else Perl_sv_catpvf(aTHX_ out, "%"IVdf, (++items)->iv); @@ -2415,7 +2440,8 @@ Perl_unop_aux_stringify(pTHX_ const OP *o, CV *cv) S_append_padvar(aTHX_ (++items)->pad_offset, cv, out, 1, 0, 1); break; case MDEREF_INDEX_gvsv: - sv = ITEM_SV(++items); + items++; + sv = ITEM_SV(items); S_append_gv_name(aTHX_ (GV*)sv, out); break; } @@ -2494,8 +2520,8 @@ Perl_debop(pTHX_ const OP *o) break; case OP_MULTIDEREF: - PerlIO_printf(Perl_debug_log, "(%-p)", - unop_aux_stringify(o, deb_curcv(cxstack_ix))); + PerlIO_printf(Perl_debug_log, "(%"SVf")", + SVfARG(multideref_stringify(o, deb_curcv(cxstack_ix)))); break; default: @@ -2506,19 +2532,27 @@ Perl_debop(pTHX_ const OP *o) } STATIC CV* -S_deb_curcv(pTHX_ const I32 ix) +S_deb_curcv(pTHX_ I32 ix) { - const PERL_CONTEXT * const cx = &cxstack[ix]; - if (CxTYPE(cx) == CXt_SUB || CxTYPE(cx) == CXt_FORMAT) - return cx->blk_sub.cv; - else if (CxTYPE(cx) == CXt_EVAL && !CxTRYBLOCK(cx)) - return cx->blk_eval.cv; - else if (ix == 0 && PL_curstackinfo->si_type == PERLSI_MAIN) - return PL_main_cv; - else if (ix <= 0) - return NULL; - else - return deb_curcv(ix - 1); + PERL_SI *si = PL_curstackinfo; + for (; ix >=0; ix--) { + const PERL_CONTEXT * const cx = &(si->si_cxstack)[ix]; + + if (CxTYPE(cx) == CXt_SUB || CxTYPE(cx) == CXt_FORMAT) + return cx->blk_sub.cv; + else if (CxTYPE(cx) == CXt_EVAL && !CxTRYBLOCK(cx)) + return cx->blk_eval.cv; + else if (ix == 0 && si->si_type == PERLSI_MAIN) + return PL_main_cv; + else if (ix == 0 && CxTYPE(cx) == CXt_NULL + && si->si_type == PERLSI_SORT) + { + /* fake sort sub; use CV of caller */ + si = si->si_prev; + ix = si->si_cxix + 1; + } + } + return NULL; } void @@ -2560,11 +2594,5 @@ Perl_debprofdump(pTHX) /* - * Local variables: - * c-indentation-style: bsd - * c-basic-offset: 4 - * indent-tabs-mode: nil - * End: - * * ex: set ts=8 sts=4 sw=4 et: */