diff options
-rw-r--r-- | embed.fnc | 2 | ||||
-rw-r--r-- | perl.h | 18 | ||||
-rw-r--r-- | pod/perldelta.pod | 5 | ||||
-rw-r--r-- | proto.h | 2 |
4 files changed, 24 insertions, 3 deletions
@@ -3724,4 +3724,6 @@ XEop |STRLEN*|dup_warnings |NULLOK STRLEN* warnings Amd |void |CopFILEGV_set |NN COP * c|NN GV * gv #endif +Amd|char *const|phase_name|enum perl_phase + : ex: set ts=8 sts=4 sw=4 noet: @@ -5423,6 +5423,24 @@ EXTCONST char *const PL_phase_names[] = { EXTCONST char *const PL_phase_names[]; #endif +/* +=for apidoc_section $utility + +=for apidoc Amd|char *const|phase_name|enum perl_phase + +Returns the given phase's name as a NUL-terminated string. + +For example, to print a stack trace that includes the current +interpreter phase you might do: + + const char* phase_name = phase_name(PL_phase); + mess("This is weird. (Perl phase: %s)", phase_name); + +=cut +*/ + +#define phase_name(phase) (PL_phase_names[phase]) + #ifndef PERL_CORE /* Do not use this macro. It only exists for extensions that rely on PL_dirty * instead of using the newer PL_phase, which provides everything PL_dirty diff --git a/pod/perldelta.pod b/pod/perldelta.pod index c30c628ddd..bde13eee7c 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -346,9 +346,8 @@ well. =over 4 -=item * - -XXX +=item * A new phase_name() interface provides access to the name +for each interpreter phase (i.e., PL_phase value). =back @@ -2808,6 +2808,8 @@ PERL_CALLCONV int perl_run(PerlInterpreter *my_perl); assert(my_perl) PERL_CALLCONV Signal_t Perl_perly_sighandler(int sig, Siginfo_t *info, void *uap, bool safe); #define PERL_ARGS_ASSERT_PERLY_SIGHANDLER +/* PERL_CALLCONV char *const phase_name(pTHX_ enum perl_phase); */ +#define PERL_ARGS_ASSERT_PHASE_NAME PERL_CALLCONV void Perl_pmop_dump(pTHX_ PMOP* pm); #define PERL_ARGS_ASSERT_PMOP_DUMP PERL_CALLCONV OP* Perl_pmruntime(pTHX_ OP *o, OP *expr, OP *repl, UV flags, I32 floor); |