summaryrefslogtreecommitdiff
path: root/perl.h
diff options
context:
space:
mode:
authorFelipe Gasper <felipe@felipegasper.com>2021-08-05 16:01:44 -0400
committerTony Cook <tony@develop-help.com>2021-11-25 15:07:56 +1100
commiteb87cedb600ef8f1265ce27b13197ca7cbc33297 (patch)
tree6503da176300bc8363ce0d90ec70f7bb35c86bf5 /perl.h
parentcaa9af33e832c2614fd55d0d5a06dc716baf9c17 (diff)
downloadperl-eb87cedb600ef8f1265ce27b13197ca7cbc33297.tar.gz
Add a phase_name() macro.
Diffstat (limited to 'perl.h')
-rw-r--r--perl.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/perl.h b/perl.h
index 53f00b1b7a..4b528ab21f 100644
--- a/perl.h
+++ b/perl.h
@@ -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