{
    "content": [
        {
            "type": "text",
            "text": "# perldebguts (man)\n\n## NAME\n\nperldebguts - Guts of Perl debugging\n\n## DESCRIPTION\n\nThis is not perldebug, which tells you how to use the debugger.  This manpage describes low-\nlevel details concerning the debugger's internals, which range from difficult to impossible\nto understand for anyone who isn't incredibly intimate with Perl's guts.  Caveat lector.\n\n## Sections\n\n- **NAME**\n- **DESCRIPTION** (8 subsections)\n- **SEE ALSO**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "perldebguts",
        "section": "",
        "mode": "man",
        "summary": "perldebguts - Guts of Perl debugging",
        "synopsis": null,
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 4,
                "subsections": [
                    {
                        "name": "Debugger Internals",
                        "lines": 77
                    },
                    {
                        "name": "Writing Your Own Debugger",
                        "lines": 78
                    },
                    {
                        "name": "Frame Listing Output Examples",
                        "lines": 166
                    },
                    {
                        "name": "Debugging Regular Expressions",
                        "lines": 8
                    },
                    {
                        "name": "Compile-time Output",
                        "lines": 100
                    },
                    {
                        "name": "Types of Nodes",
                        "lines": 323
                    },
                    {
                        "name": "Run-time Output",
                        "lines": 40
                    },
                    {
                        "name": "Debugging Perl Memory Usage",
                        "lines": 113
                    }
                ]
            },
            {
                "name": "SEE ALSO",
                "lines": 5,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "perldebguts - Guts of Perl debugging\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "This is not perldebug, which tells you how to use the debugger.  This manpage describes low-\nlevel details concerning the debugger's internals, which range from difficult to impossible\nto understand for anyone who isn't incredibly intimate with Perl's guts.  Caveat lector.\n",
                "subsections": [
                    {
                        "name": "Debugger Internals",
                        "content": "Perl has special debugging hooks at compile-time and run-time used to create debugging\nenvironments.  These hooks are not to be confused with the perl -Dxxx command described in\nperlrun, which is usable only if a special Perl is built per the instructions in the INSTALL\npodpage in the Perl source tree.\n\nFor example, whenever you call Perl's built-in \"caller\" function from the package \"DB\", the\narguments that the corresponding stack frame was called with are copied to the @DB::args\narray.  These mechanisms are enabled by calling Perl with the -d switch.  Specifically, the\nfollowing additional features are enabled (cf. \"$^P\" in perlvar):\n\n•   Perl inserts the contents of $ENV{PERL5DB} (or \"BEGIN {require 'perl5db.pl'}\" if not\npresent) before the first line of your program.\n\n•   Each array \"@{\"<$filename\"}\" holds the lines of $filename for a file compiled by Perl.\nThe same is also true for \"eval\"ed strings that contain subroutines, or which are\ncurrently being executed.  The $filename for \"eval\"ed strings looks like \"(eval 34)\".\n\nValues in this array are magical in numeric context: they compare equal to zero only if\nthe line is not breakable.\n\n•   Each hash \"%{\"<$filename\"}\" contains breakpoints and actions keyed by line number.\nIndividual entries (as opposed to the whole hash) are settable.  Perl only cares about\nBoolean true here, although the values used by perl5db.pl have the form\n\"$breakcondition\\0$action\".\n\nThe same holds for evaluated strings that contain subroutines, or which are currently\nbeing executed.  The $filename for \"eval\"ed strings looks like \"(eval 34)\".\n\n•   Each scalar \"${\"<$filename\"}\" contains $filename.  This is also the case for evaluated\nstrings that contain subroutines, or which are currently being executed.  The $filename\nfor \"eval\"ed strings looks like \"(eval 34)\".\n\n•   After each \"require\"d file is compiled, but before it is executed,\n\"DB::postponed(*{\"<$filename\"})\" is called if the subroutine \"DB::postponed\" exists.\nHere, the $filename is the expanded name of the \"require\"d file, as found in the values\nof %INC.\n\n•   After each subroutine \"subname\" is compiled, the existence of $DB::postponed{subname} is\nchecked.  If this key exists, \"DB::postponed(subname)\" is called if the \"DB::postponed\"\nsubroutine also exists.\n\n•   A hash %DB::sub is maintained, whose keys are subroutine names and whose values have the\nform \"filename:startline-endline\".  \"filename\" has the form \"(eval 34)\" for subroutines\ndefined inside \"eval\"s.\n\n•   When the execution of your program reaches a point that can hold a breakpoint, the\n\"DB::DB()\" subroutine is called if any of the variables $DB::trace, $DB::single, or\n$DB::signal is true.  These variables are not \"local\"izable.  This feature is disabled\nwhen executing inside \"DB::DB()\", including functions called from it unless \"$^D &\n(1<<30)\" is true.\n\n•   When execution of the program reaches a subroutine call, a call to &DB::sub(args) is made\ninstead, with $DB::sub set to identify the called subroutine.  (This doesn't happen if\nthe calling subroutine was compiled in the \"DB\" package.)  $DB::sub normally holds the\nname of the called subroutine, if it has a name by which it can be looked up.  Failing\nthat, $DB::sub will hold a reference to the called subroutine.  Either way, the &DB::sub\nsubroutine can use $DB::sub as a reference by which to call the called subroutine, which\nit will normally want to do.\n\nIf the call is to an lvalue subroutine, and &DB::lsub is defined &DB::lsub(args) is\ncalled instead, otherwise falling back to &DB::sub(args).\n\n•   When execution of the program uses \"goto\" to enter a non-XS subroutine and the 0x80 bit\nis set in $^P, a call to &DB::goto is made, with $DB::sub set to identify the subroutine\nbeing entered.  The call to &DB::goto does not replace the \"goto\"; the requested\nsubroutine will still be entered once &DB::goto has returned.  $DB::sub normally holds\nthe name of the subroutine being entered, if it has one.  Failing that, $DB::sub will\nhold a reference to the subroutine being entered.  Unlike when &DB::sub is called, it is\nnot guaranteed that $DB::sub can be used as a reference to operate on the subroutine\nbeing entered.\n\nNote that if &DB::sub needs external data for it to work, no subroutine call is possible\nwithout it. As an example, the standard debugger's &DB::sub depends on the $DB::deep variable\n(it defines how many levels of recursion deep into the debugger you can go before a mandatory\nbreak).  If $DB::deep is not defined, subroutine calls are not possible, even though &DB::sub\nexists.\n"
                    },
                    {
                        "name": "Writing Your Own Debugger",
                        "content": "Environment Variables\n\nThe \"PERL5DB\" environment variable can be used to define a debugger.  For example, the\nminimal \"working\" debugger (it actually doesn't do anything) consists of one line:\n\nsub DB::DB {}\n\nIt can easily be defined like this:\n\n$ PERL5DB=\"sub DB::DB {}\" perl -d your-script\n\nAnother brief debugger, slightly more useful, can be created with only the line:\n\nsub DB::DB {print ++$i; scalar <STDIN>}\n\nThis debugger prints a number which increments for each statement encountered and waits for\nyou to hit a newline before continuing to the next statement.\n\nThe following debugger is actually useful:\n\n{\npackage DB;\nsub DB  {}\nsub sub {print ++$i, \" $sub\\n\"; &$sub}\n}\n\nIt prints the sequence number of each subroutine call and the name of the called subroutine.\nNote that &DB::sub is being compiled into the package \"DB\" through the use of the \"package\"\ndirective.\n\nWhen it starts, the debugger reads your rc file (./.perldb or ~/.perldb under Unix), which\ncan set important options.  (A subroutine (&afterinit) can be defined here as well; it is\nexecuted after the debugger completes its own initialization.)\n\nAfter the rc file is read, the debugger reads the PERLDBOPTS environment variable and uses\nit to set debugger options. The contents of this variable are treated as if they were the\nargument of an \"o ...\" debugger command (q.v. in \"Configurable Options\" in perldebug).\n\nDebugger Internal Variables\n\nIn addition to the file and subroutine-related variables mentioned above, the debugger also\nmaintains various magical internal variables.\n\n•   @DB::dbline is an alias for \"@{\"::<currentfile\"}\", which holds the lines of the\ncurrently-selected file (compiled by Perl), either explicitly chosen with the debugger's\n\"f\" command, or implicitly by flow of execution.\n\nValues in this array are magical in numeric context: they compare equal to zero only if\nthe line is not breakable.\n\n•   %DB::dbline is an alias for \"%{\"::<currentfile\"}\", which contains breakpoints and\nactions keyed by line number in the currently-selected file, either explicitly chosen\nwith the debugger's \"f\" command, or implicitly by flow of execution.\n\nAs previously noted, individual entries (as opposed to the whole hash) are settable.\nPerl only cares about Boolean true here, although the values used by perl5db.pl have the\nform \"$breakcondition\\0$action\".\n\nDebugger Customization Functions\n\nSome functions are provided to simplify customization.\n\n•   See \"Configurable Options\" in perldebug for a description of options parsed by\n\"DB::parseoptions(string)\".\n\n•   \"DB::dumptrace(skip[,count])\" skips the specified number of frames and returns a list\ncontaining information about the calling frames (all of them, if \"count\" is missing).\nEach entry is reference to a hash with keys \"context\" (either \".\", \"$\", or \"@\"), \"sub\"\n(subroutine name, or info about \"eval\"), \"args\" (\"undef\" or a reference to an array),\n\"file\", and \"line\".\n\n•   \"DB::printtrace(FH, skip[, count[, short]])\" prints formatted info about caller frames.\nThe last two functions may be convenient as arguments to \"<\", \"<<\" commands.\n\nNote that any variables and functions that are not documented in this manpages (or in\nperldebug) are considered for internal use only, and as such are subject to change without\nnotice.\n"
                    },
                    {
                        "name": "Frame Listing Output Examples",
                        "content": "The \"frame\" option can be used to control the output of frame information.  For example,\ncontrast this expression trace:\n\n$ perl -de 42\nStack dump during die enabled outside of evals.\n\nLoading DB routines from perl5db.pl patch level 0.94\nEmacs support available.\n\nEnter h or 'h h' for help.\n\nmain::(-e:1):   0\nDB<1> sub foo { 14 }\n\nDB<2> sub bar { 3 }\n\nDB<3> t print foo() * bar()\nmain::((eval 172):3):   print foo() + bar();\nmain::foo((eval 168):2):\nmain::bar((eval 170):2):\n42\n\nwith this one, once the \"o\"ption \"frame=2\" has been set:\n\nDB<4> o f=2\nframe = '2'\nDB<5> t print foo() * bar()\n3:      foo() * bar()\nentering main::foo\n2:     sub foo { 14 };\nexited main::foo\nentering main::bar\n2:     sub bar { 3 };\nexited main::bar\n42\n\nBy way of demonstration, we present below a laborious listing resulting from setting your\n\"PERLDBOPTS\" environment variable to the value \"f=n N\", and running perl -d -V from the\ncommand line.  Examples using various values of \"n\" are shown to give you a feel for the\ndifference between settings.  Long though it may be, this is not a complete listing, but only\nexcerpts.\n\n1.\nentering main::BEGIN\nentering Config::BEGIN\nPackage lib/Exporter.pm.\nPackage lib/Carp.pm.\nPackage lib/Config.pm.\nentering Config::TIEHASH\nentering Exporter::import\nentering Exporter::export\nentering Config::myconfig\nentering Config::FETCH\nentering Config::FETCH\nentering Config::FETCH\nentering Config::FETCH\n\n2.\nentering main::BEGIN\nentering Config::BEGIN\nPackage lib/Exporter.pm.\nPackage lib/Carp.pm.\nexited Config::BEGIN\nPackage lib/Config.pm.\nentering Config::TIEHASH\nexited Config::TIEHASH\nentering Exporter::import\nentering Exporter::export\nexited Exporter::export\nexited Exporter::import\nexited main::BEGIN\nentering Config::myconfig\nentering Config::FETCH\nexited Config::FETCH\nentering Config::FETCH\nexited Config::FETCH\nentering Config::FETCH\n\n3.\nin  $=main::BEGIN() from /dev/null:0\nin  $=Config::BEGIN() from lib/Config.pm:2\nPackage lib/Exporter.pm.\nPackage lib/Carp.pm.\nPackage lib/Config.pm.\nin  $=Config::TIEHASH('Config') from lib/Config.pm:644\nin  $=Exporter::import('Config', 'myconfig', 'configvars') from /dev/null:0\nin  $=Exporter::export('Config', 'main', 'myconfig', 'configvars') from li\nin  @=Config::myconfig() from /dev/null:0\nin  $=Config::FETCH(ref(Config), 'package') from lib/Config.pm:574\nin  $=Config::FETCH(ref(Config), 'baserev') from lib/Config.pm:574\nin  $=Config::FETCH(ref(Config), 'PERLVERSION') from lib/Config.pm:574\nin  $=Config::FETCH(ref(Config), 'PERLSUBVERSION') from lib/Config.pm:574\nin  $=Config::FETCH(ref(Config), 'osname') from lib/Config.pm:574\nin  $=Config::FETCH(ref(Config), 'osvers') from lib/Config.pm:574\n\n4.\nin  $=main::BEGIN() from /dev/null:0\nin  $=Config::BEGIN() from lib/Config.pm:2\nPackage lib/Exporter.pm.\nPackage lib/Carp.pm.\nout $=Config::BEGIN() from lib/Config.pm:0\nPackage lib/Config.pm.\nin  $=Config::TIEHASH('Config') from lib/Config.pm:644\nout $=Config::TIEHASH('Config') from lib/Config.pm:644\nin  $=Exporter::import('Config', 'myconfig', 'configvars') from /dev/null:0\nin  $=Exporter::export('Config', 'main', 'myconfig', 'configvars') from lib/\nout $=Exporter::export('Config', 'main', 'myconfig', 'configvars') from lib/\nout $=Exporter::import('Config', 'myconfig', 'configvars') from /dev/null:0\nout $=main::BEGIN() from /dev/null:0\nin  @=Config::myconfig() from /dev/null:0\nin  $=Config::FETCH(ref(Config), 'package') from lib/Config.pm:574\nout $=Config::FETCH(ref(Config), 'package') from lib/Config.pm:574\nin  $=Config::FETCH(ref(Config), 'baserev') from lib/Config.pm:574\nout $=Config::FETCH(ref(Config), 'baserev') from lib/Config.pm:574\nin  $=Config::FETCH(ref(Config), 'PERLVERSION') from lib/Config.pm:574\nout $=Config::FETCH(ref(Config), 'PERLVERSION') from lib/Config.pm:574\nin  $=Config::FETCH(ref(Config), 'PERLSUBVERSION') from lib/Config.pm:574\n\n5.\nin  $=main::BEGIN() from /dev/null:0\nin  $=Config::BEGIN() from lib/Config.pm:2\nPackage lib/Exporter.pm.\nPackage lib/Carp.pm.\nout $=Config::BEGIN() from lib/Config.pm:0\nPackage lib/Config.pm.\nin  $=Config::TIEHASH('Config') from lib/Config.pm:644\nout $=Config::TIEHASH('Config') from lib/Config.pm:644\nin  $=Exporter::import('Config', 'myconfig', 'configvars') from /dev/null:0\nin  $=Exporter::export('Config', 'main', 'myconfig', 'configvars') from lib/E\nout $=Exporter::export('Config', 'main', 'myconfig', 'configvars') from lib/E\nout $=Exporter::import('Config', 'myconfig', 'configvars') from /dev/null:0\nout $=main::BEGIN() from /dev/null:0\nin  @=Config::myconfig() from /dev/null:0\nin  $=Config::FETCH('Config=HASH(0x1aa444)', 'package') from lib/Config.pm:574\nout $=Config::FETCH('Config=HASH(0x1aa444)', 'package') from lib/Config.pm:574\nin  $=Config::FETCH('Config=HASH(0x1aa444)', 'baserev') from lib/Config.pm:574\nout $=Config::FETCH('Config=HASH(0x1aa444)', 'baserev') from lib/Config.pm:574\n\n6.\nin  $=CODE(0x15eca4)() from /dev/null:0\nin  $=CODE(0x182528)() from lib/Config.pm:2\nPackage lib/Exporter.pm.\nout $=CODE(0x182528)() from lib/Config.pm:0\nscalar context return from CODE(0x182528): undef\nPackage lib/Config.pm.\nin  $=Config::TIEHASH('Config') from lib/Config.pm:628\nout $=Config::TIEHASH('Config') from lib/Config.pm:628\nscalar context return from Config::TIEHASH:   empty hash\nin  $=Exporter::import('Config', 'myconfig', 'configvars') from /dev/null:0\nin  $=Exporter::export('Config', 'main', 'myconfig', 'configvars') from lib/Exporter.pm:171\nout $=Exporter::export('Config', 'main', 'myconfig', 'configvars') from lib/Exporter.pm:171\nscalar context return from Exporter::export: ''\nout $=Exporter::import('Config', 'myconfig', 'configvars') from /dev/null:0\nscalar context return from Exporter::import: ''\n\nIn all cases shown above, the line indentation shows the call tree.  If bit 2 of \"frame\" is\nset, a line is printed on exit from a subroutine as well.  If bit 4 is set, the arguments are\nprinted along with the caller info.  If bit 8 is set, the arguments are printed even if they\nare tied or references.  If bit 16 is set, the return value is printed, too.\n\nWhen a package is compiled, a line like this\n\nPackage lib/Carp.pm.\n\nis printed with proper indentation.\n"
                    },
                    {
                        "name": "Debugging Regular Expressions",
                        "content": "There are two ways to enable debugging output for regular expressions.\n\nIf your perl is compiled with \"-DDEBUGGING\", you may use the -Dr flag on the command line,\nand \"-Drv\" for more verbose information.\n\nOtherwise, one can \"use re 'debug'\", which has effects at both compile time and run time.\nSince Perl 5.9.5, this pragma is lexically scoped.\n"
                    },
                    {
                        "name": "Compile-time Output",
                        "content": "The debugging output at compile time looks like this:\n\nCompiling REx '[bc]d(ef*g)+h[ij]k$'\nsize 45 Got 364 bytes for offset annotations.\nfirst at 1\nrarest char g at 0\nrarest char d at 0\n1: ANYOF[bc](12)\n12: EXACT <d>(14)\n14: CURLYX[0] {1,32767}(28)\n16:   OPEN1(18)\n18:     EXACT <e>(20)\n20:     STAR(23)\n21:       EXACT <f>(0)\n23:     EXACT <g>(25)\n25:   CLOSE1(27)\n27:   WHILEM[1/1](0)\n28: NOTHING(29)\n29: EXACT <h>(31)\n31: ANYOF[ij](42)\n42: EXACT <k>(44)\n44: EOL(45)\n45: END(0)\nanchored 'de' at 1 floating 'gh' at 3..2147483647 (checking floating)\nstclass 'ANYOF[bc]' minlen 7\nOffsets: [45]\n1[4] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 5[1]\n0[0] 12[1] 0[0] 6[1] 0[0] 7[1] 0[0] 9[1] 8[1] 0[0] 10[1] 0[0]\n11[1] 0[0] 12[0] 12[0] 13[1] 0[0] 14[4] 0[0] 0[0] 0[0] 0[0]\n0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 18[1] 0[0] 19[1] 20[0]\nOmitting $` $& $' support.\n\nThe first line shows the pre-compiled form of the regex.  The second shows the size of the\ncompiled form (in arbitrary units, usually 4-byte words) and the total number of bytes\nallocated for the offset/length table, usually 4+\"size\"*8.  The next line shows the label id\nof the first node that does a match.\n\nThe\n\nanchored 'de' at 1 floating 'gh' at 3..2147483647 (checking floating)\nstclass 'ANYOF[bc]' minlen 7\n\nline (split into two lines above) contains optimizer information.  In the example shown, the\noptimizer found that the match should contain a substring \"de\" at offset 1, plus substring\n\"gh\" at some offset between 3 and infinity.  Moreover, when checking for these substrings (to\nabandon impossible matches quickly), Perl will check for the substring \"gh\" before checking\nfor the substring \"de\".  The optimizer may also use the knowledge that the match starts (at\nthe \"first\" id) with a character class, and no string shorter than 7 characters can possibly\nmatch.\n\nThe fields of interest which may appear in this line are\n\n\"anchored\" STRING \"at\" POS\n\"floating\" STRING \"at\" POS1..POS2\nSee above.\n\n\"matching floating/anchored\"\nWhich substring to check first.\n\n\"minlen\"\nThe minimal length of the match.\n\n\"stclass\" TYPE\nType of first matching node.\n\n\"noscan\"\nDon't scan for the found substrings.\n\n\"isall\"\nMeans that the optimizer information is all that the regular expression contains, and\nthus one does not need to enter the regex engine at all.\n\n\"GPOS\"\nSet if the pattern contains \"\\G\".\n\n\"plus\"\nSet if the pattern starts with a repeated char (as in \"x+y\").\n\n\"implicit\"\nSet if the pattern starts with \".*\".\n\n\"with eval\"\nSet if the pattern contain eval-groups, such as \"(?{ code })\" and \"(??{ code })\".\n\n\"anchored(TYPE)\"\nIf the pattern may match only at a handful of places, with \"TYPE\" being \"SBOL\", \"MBOL\",\nor \"GPOS\".  See the table below.\n\nIf a substring is known to match at end-of-line only, it may be followed by \"$\", as in\n\"floating 'k'$\".\n\nThe optimizer-specific information is used to avoid entering (a slow) regex engine on strings\nthat will not definitely match.  If the \"isall\" flag is set, a call to the regex engine may\nbe avoided even when the optimizer found an appropriate place for the match.\n\nAbove the optimizer section is the list of nodes of the compiled form of the regex.  Each\nline has format\n\n\"   \"id: TYPE OPTIONAL-INFO (next-id)\n"
                    },
                    {
                        "name": "Types of Nodes",
                        "content": "Here are the current possible types, with short descriptions:\n\n# TYPE arg-description [regnode-struct-suffix] [longjump-len] DESCRIPTION\n\n# Exit points\n\nEND              no         End of program.\nSUCCEED          no         Return from a subroutine, basically.\n\n# Line Start Anchors:\nSBOL             no         Match \"\" at beginning of line: /^/, /\\A/\nMBOL             no         Same, assuming multiline: /^/m\n\n# Line End Anchors:\nSEOL             no         Match \"\" at end of line: /$/\nMEOL             no         Same, assuming multiline: /$/m\nEOS              no         Match \"\" at end of string: /\\z/\n\n# Match Start Anchors:\nGPOS             no         Matches where last m//g left off.\n\n# Word Boundary Opcodes:\nBOUND            no         Like BOUNDA for non-utf8, otherwise like\nBOUNDU\nBOUNDL           no         Like BOUND/BOUNDU, but \\w and \\W are\ndefined by current locale\nBOUNDU           no         Match \"\" at any boundary of a given type\nusing /u rules.\nBOUNDA           no         Match \"\" at any boundary between \\w\\W or\n\\W\\w, where \\w is [a-zA-Z0-9]\nNBOUND           no         Like NBOUNDA for non-utf8, otherwise like\nBOUNDU\nNBOUNDL          no         Like NBOUND/NBOUNDU, but \\w and \\W are\ndefined by current locale\nNBOUNDU          no         Match \"\" at any non-boundary of a given\ntype using using /u rules.\nNBOUNDA          no         Match \"\" betweeen any \\w\\w or \\W\\W, where\n\\w is [a-zA-Z0-9]\n\n# [Special] alternatives:\nREGANY          no         Match any one character (except newline).\nSANY             no         Match any one character.\nANYOF            sv         Match character in (or not in) this class,\ncharclass  single char match only\nANYOFD           sv         Like ANYOF, but /d is in effect\ncharclass\nANYOFL           sv         Like ANYOF, but /l is in effect\ncharclass\nANYOFPOSIXL      sv         Like ANYOFL, but matches [[:posix:]]\ncharclass classes\nposixl\n\nANYOFH           sv 1       Like ANYOF, but only has \"High\" matches,\nnone in the bitmap; the flags field\ncontains the lowest matchable UTF-8 start\nbyte\nANYOFHb          sv 1       Like ANYOFH, but all matches share the same\nUTF-8 start byte, given in the flags field\nANYOFHr          sv 1       Like ANYOFH, but the flags field contains\npacked bounds for all matchable UTF-8 start\nbytes.\nANYOFHs          sv 1       Like ANYOFHb, but has a string field that\ngives the leading matchable UTF-8 bytes;\nflags field is len\nANYOFR           packed 1   Matches any character in the range given by\nits packed args: upper 12 bits is the max\ndelta from the base lower 20; the flags\nfield contains the lowest matchable UTF-8\nstart byte\nANYOFRb          packed 1   Like ANYOFR, but all matches share the same\nUTF-8 start byte, given in the flags field\n\nANYOFM           byte 1     Like ANYOF, but matches an invariant byte\nas determined by the mask and arg\nNANYOFM          byte 1     complement of ANYOFM\n\n# POSIX Character Classes:\nPOSIXD           none       Some [[:class:]] under /d; the FLAGS field\ngives which one\nPOSIXL           none       Some [[:class:]] under /l; the FLAGS field\ngives which one\nPOSIXU           none       Some [[:class:]] under /u; the FLAGS field\ngives which one\nPOSIXA           none       Some [[:class:]] under /a; the FLAGS field\ngives which one\nNPOSIXD          none       complement of POSIXD, [[:^class:]]\nNPOSIXL          none       complement of POSIXL, [[:^class:]]\nNPOSIXU          none       complement of POSIXU, [[:^class:]]\nNPOSIXA          none       complement of POSIXA, [[:^class:]]\n\nCLUMP            no         Match any extended grapheme cluster\nsequence\n\n# Alternation\n\n# BRANCH        The set of branches constituting a single choice are\n#               hooked together with their \"next\" pointers, since\n#               precedence prevents anything being concatenated to\n#               any individual branch.  The \"next\" pointer of the last\n#               BRANCH in a choice points to the thing following the\n#               whole choice.  This is also where the final \"next\"\n#               pointer of each individual branch points; each branch\n#               starts with the operand node of a BRANCH node.\n#\nBRANCH           node       Match this alternative, or the next...\n\n# Literals\n\nEXACT            str        Match this string (flags field is the\nlength).\n\n# In a long string node, the U32 argument is the length, and is\n# immediately followed by the string.\nLEXACT           len:str 1  Match this long string (preceded by length;\nflags unused).\nEXACTL           str        Like EXACT, but /l is in effect (used so\nlocale-related warnings can be checked for)\nEXACTF           str        Like EXACT, but match using /id rules;\n(string not UTF-8, ASCII folded; non-ASCII\nnot)\nEXACTFL          str        Like EXACT, but match using /il rules;\n(string not likely to be folded)\nEXACTFU          str        Like EXACT, but match using /iu rules;\n(string folded)\n\nEXACTFAA         str        Like EXACT, but match using /iaa rules;\n(string folded except MICRO in non-UTF8\npatterns; doesn't contain SHARP S unless\nUTF-8; folded length <= unfolded)\nEXACTFAANOTRIE str        Like EXACTFAA, (string not UTF-8, folded\nexcept: MICRO, SHARP S; folded length <=\nunfolded, not currently trie-able)\n\nEXACTFUP         str        Like EXACT, but match using /iu rules;\n(string not UTF-8, folded except MICRO:\nhence Problematic)\n\nEXACTFLU8        str        Like EXACTFU, but use /il, UTF-8, (string\nis folded, and everything in it is above\n255\nEXACTREQ8       str        Like EXACT, but only UTF-8 encoded targets\ncan match\nLEXACTREQ8      len:str 1  Like LEXACT, but only UTF-8 encoded targets\ncan match\nEXACTFUREQ8     str        Like EXACTFU, but only UTF-8 encoded\ntargets can match\n\nEXACTFUSEDGE   str        /di rules, but nothing in it precludes /ui,\nexcept begins and/or ends with [Ss];\n(string not UTF-8; compile-time only)\n\n# New charclass like patterns\nLNBREAK          none       generic newline pattern\n\n# Trie Related\n\n# Behave the same as A|LIST|OF|WORDS would. The '..C' variants\n# have inline charclass data (ascii only), the 'C' store it in the\n# structure.\n\nTRIE             trie 1     Match many EXACT(F[ALU]?)? at once.\nflags==type\nTRIEC            trie       Same as TRIE, but with embedded charclass\ncharclass  data\n\nAHOCORASICK      trie 1     Aho Corasick stclass. flags==type\nAHOCORASICKC     trie       Same as AHOCORASICK, but with embedded\ncharclass  charclass data\n\n# Do nothing types\n\nNOTHING          no         Match empty string.\n# A variant of above which delimits a group, thus stops optimizations\nTAIL             no         Match empty string. Can jump here from\noutside.\n\n# Loops\n\n# STAR,PLUS    '?', and complex '*' and '+', are implemented as\n#               circular BRANCH structures.  Simple cases\n#               (one character per match) are implemented with STAR\n#               and PLUS for speed and to minimize recursive plunges.\n#\nSTAR             node       Match this (simple) thing 0 or more times.\nPLUS             node       Match this (simple) thing 1 or more times.\n\nCURLY            sv 2       Match this simple thing {n,m} times.\nCURLYN           no 2       Capture next-after-this simple thing\nCURLYM           no 2       Capture this medium-complex thing {n,m}\ntimes.\nCURLYX           sv 2       Match this complex thing {n,m} times.\n\n# This terminator creates a loop structure for CURLYX\nWHILEM           no         Do curly processing and see if rest\nmatches.\n\n# Buffer related\n\n# OPEN,CLOSE,GROUPP     ...are numbered at compile time.\nOPEN             num 1      Mark this point in input as start of #n.\nCLOSE            num 1      Close corresponding OPEN of #n.\nSROPEN           none       Same as OPEN, but for script run\nSRCLOSE          none       Close preceding SROPEN\n\nREF              num 1      Match some already matched string\nREFF             num 1      Match already matched string, using /di\nrules.\nREFFL            num 1      Match already matched string, using /li\nrules.\nREFFU            num 1      Match already matched string, usng /ui.\nREFFA            num 1      Match already matched string, using /aai\nrules.\n\n# Named references.  Code in regcomp.c assumes that these all are after\n# the numbered references\nREFN             no-sv 1    Match some already matched string\nREFFN            no-sv 1    Match already matched string, using /di\nrules.\nREFFLN           no-sv 1    Match already matched string, using /li\nrules.\nREFFUN           num 1      Match already matched string, using /ui\nrules.\nREFFAN           num 1      Match already matched string, using /aai\nrules.\n\n# Support for long RE\nLONGJMP          off 1 1    Jump far away.\nBRANCHJ          off 1 1    BRANCH with long offset.\n\n# Special Case Regops\nIFMATCH          off 1 1    Succeeds if the following matches; non-zero\nflags \"f\", nextoff \"o\" means lookbehind\nassertion starting \"f..(f-o)\" characters\nbefore current\nUNLESSM          off 1 1    Fails if the following matches; non-zero\nflags \"f\", nextoff \"o\" means lookbehind\nassertion starting \"f..(f-o)\" characters\nbefore current\nSUSPEND          off 1 1    \"Independent\" sub-RE.\nIFTHEN           off 1 1    Switch, should be preceded by switcher.\nGROUPP           num 1      Whether the group matched.\n\n# The heavy worker\n\nEVAL             evl/flags  Execute some Perl code.\n2L\n\n# Modifiers\n\nMINMOD           no         Next operator is not greedy.\nLOGICAL          no         Next opcode should set the flag only.\n\n# This is not used yet\nRENUM            off 1 1    Group with independently numbered parens.\n\n# Regex Subroutines\nGOSUB            num/ofs 2L recurse to paren arg1 at (signed) ofs arg2\n\n# Special conditionals\nGROUPPN          no-sv 1    Whether the group matched.\nINSUBP           num 1      Whether we are in a specific recurse.\nDEFINEP          none 1     Never execute directly.\n\n# Backtracking Verbs\nENDLIKE          none       Used only for the type field of verbs\nOPFAIL           no-sv 1    Same as (?!), but with verb arg\nACCEPT           no-sv/num  Accepts the current matched string, with\n2L         verbar\n\n# Verbs With Arguments\nVERB             no-sv 1    Used only for the type field of verbs\nPRUNE            no-sv 1    Pattern fails at this startpoint if no-\nbacktracking through this\nMARKPOINT        no-sv 1    Push the current location for rollback by\ncut.\nSKIP             no-sv 1    On failure skip forward (to the mark)\nbefore retrying\nCOMMIT           no-sv 1    Pattern fails outright if backtracking\nthrough this\nCUTGROUP         no-sv 1    On failure go to the next alternation in\nthe group\n\n# Control what to keep in $&.\nKEEPS            no         $& begins here.\n\n# SPECIAL  REGOPS\n\n# This is not really a node, but an optimized away piece of a \"long\"\n# node.  To simplify debugging output, we mark it as if it were a node\nOPTIMIZED        off        Placeholder for dump.\n\n# Special opcode with the property that no opcode in a compiled program\n# will ever be of this type. Thus it can be used as a flag value that\n# no other opcode has been seen. END is used similarly, in that an END\n# node cant be optimized. So END implies \"unoptimizable\" and PSEUDO\n# mean \"not seen anything to optimize yet\".\nPSEUDO           off        Pseudo opcode for internal use.\n\nREGEXSET        depth p    Regex set, temporary node used in pre-\noptimization compilation\n\nFollowing the optimizer information is a dump of the offset/length table, here split across\nseveral lines:\n\nOffsets: [45]\n1[4] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 5[1]\n0[0] 12[1] 0[0] 6[1] 0[0] 7[1] 0[0] 9[1] 8[1] 0[0] 10[1] 0[0]\n11[1] 0[0] 12[0] 12[0] 13[1] 0[0] 14[4] 0[0] 0[0] 0[0] 0[0]\n0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 18[1] 0[0] 19[1] 20[0]\n\nThe first line here indicates that the offset/length table contains 45 entries.  Each entry\nis a pair of integers, denoted by \"offset[length]\".  Entries are numbered starting with 1, so\nentry #1 here is \"1[4]\" and entry #12 is \"5[1]\".  \"1[4]\" indicates that the node labeled \"1:\"\n(the \"1: ANYOF[bc]\") begins at character position 1 in the pre-compiled form of the regex,\nand has a length of 4 characters.  \"5[1]\" in position 12 indicates that the node labeled\n\"12:\" (the \"12: EXACT <d>\") begins at character position 5 in the pre-compiled form of the\nregex, and has a length of 1 character.  \"12[1]\" in position 14 indicates that the node\nlabeled \"14:\" (the \"14: CURLYX[0] {1,32767}\") begins at character position 12 in the pre-\ncompiled form of the regex, and has a length of 1 character---that is, it corresponds to the\n\"+\" symbol in the precompiled regex.\n\n\"0[0]\" items indicate that there is no corresponding node.\n"
                    },
                    {
                        "name": "Run-time Output",
                        "content": "First of all, when doing a match, one may get no run-time output even if debugging is\nenabled.  This means that the regex engine was never entered and that all of the job was\ntherefore done by the optimizer.\n\nIf the regex engine was entered, the output may look like this:\n\nMatching '[bc]d(ef*g)+h[ij]k$' against 'abcdefggh'\nSetting an EVAL scope, savestack=3\n2 <ab> <cdefggh>    |  1: ANYOF\n3 <abc> <defggh>    | 11: EXACT <d>\n4 <abcd> <efggh>    | 13: CURLYX {1,32767}\n4 <abcd> <efggh>    | 26:   WHILEM\n0 out of 1..32767  cc=effff31c\n4 <abcd> <efggh>    | 15:     OPEN1\n4 <abcd> <efggh>    | 17:     EXACT <e>\n5 <abcde> <fggh>    | 19:     STAR\nEXACT <f> can match 1 times out of 32767...\nSetting an EVAL scope, savestack=3\n6 <bcdef> <ggh>    | 22:       EXACT <g>\n7 <bcdefg> <gh>    | 24:       CLOSE1\n7 <bcdefg> <gh>    | 26:       WHILEM\n1 out of 1..32767  cc=effff31c\nSetting an EVAL scope, savestack=12\n7 <bcdefg> <gh>    | 15:         OPEN1\n7 <bcdefg> <gh>    | 17:         EXACT <e>\nrestoring \\1 to 4(4)..7\nfailed, try continuation...\n7 <bcdefg> <gh>    | 27:         NOTHING\n7 <bcdefg> <gh>    | 28:         EXACT <h>\nfailed...\nfailed...\n\nThe most significant information in the output is about the particular node of the compiled\nregex that is currently being tested against the target string.  The format of these lines is\n\n\"    \"STRING-OFFSET <PRE-STRING> <POST-STRING>   |ID:  TYPE\n\nThe TYPE info is indented with respect to the backtracking level.  Other incidental\ninformation appears interspersed within.\n"
                    },
                    {
                        "name": "Debugging Perl Memory Usage",
                        "content": "Perl is a profligate wastrel when it comes to memory use.  There is a saying that to estimate\nmemory usage of Perl, assume a reasonable algorithm for memory allocation, multiply that\nestimate by 10, and while you still may miss the mark, at least you won't be quite so\nastonished.  This is not absolutely true, but may provide a good grasp of what happens.\n\nAssume that an integer cannot take less than 20 bytes of memory, a float cannot take less\nthan 24 bytes, a string cannot take less than 32 bytes (all these examples assume 32-bit\narchitectures, the result are quite a bit worse on 64-bit architectures).  If a variable is\naccessed in two of three different ways (which require an integer, a float, or a string), the\nmemory footprint may increase yet another 20 bytes.  A sloppy malloc(3) implementation can\ninflate these numbers dramatically.\n\nOn the opposite end of the scale, a declaration like\n\nsub foo;\n\nmay take up to 500 bytes of memory, depending on which release of Perl you're running.\n\nAnecdotal estimates of source-to-compiled code bloat suggest an eightfold increase.  This\nmeans that the compiled form of reasonable (normally commented, properly indented etc.) code\nwill take about eight times more space in memory than the code took on disk.\n\nThe -DL command-line switch is obsolete since circa Perl 5.6.0 (it was available only if Perl\nwas built with \"-DDEBUGGING\").  The switch was used to track Perl's memory allocations and\npossible memory leaks.  These days the use of malloc debugging tools like Purify or valgrind\nis suggested instead.  See also \"PERLMEMLOG\" in perlhacktips.\n\nOne way to find out how much memory is being used by Perl data structures is to install the\nDevel::Size module from CPAN: it gives you the minimum number of bytes required to store a\nparticular data structure.  Please be mindful of the difference between the size() and\ntotalsize().\n\nIf Perl has been compiled using Perl's malloc you can analyze Perl memory usage by setting\n$ENV{PERLDEBUGMSTATS}.\n\nUsing $ENV{PERLDEBUGMSTATS}\nIf your perl is using Perl's malloc() and was compiled with the necessary switches (this is\nthe default), then it will print memory usage statistics after compiling your code when\n\"$ENV{PERLDEBUGMSTATS} > 1\", and before termination of the program when\n\"$ENV{PERLDEBUGMSTATS} >= 1\".  The report format is similar to the following example:\n\n$ PERLDEBUGMSTATS=2 perl -e \"require Carp\"\nMemory allocation statistics after compilation: (buckets 4(4)..8188(8192)\n14216 free:   130   117    28     7     9   0   2     2   1 0 0\n437    61    36     0     5\n60924 used:   125   137   161    55     7   8   6    16   2 0 1\n74   109   304    84    20\nTotal sbrk(): 77824/21:119. Odd ends: pad+heads+chain+tail: 0+636+0+2048.\nMemory allocation statistics after execution:   (buckets 4(4)..8188(8192)\n30888 free:   245    78    85    13     6   2   1     3   2 0 1\n315   162    39    42    11\n175816 used:   265   176  1112   111    26  22  11    27   2 1 1\n196   178  1066   798    39\nTotal sbrk(): 215040/47:145. Odd ends: pad+heads+chain+tail: 0+2192+0+6144.\n\nIt is possible to ask for such a statistic at arbitrary points in your execution using the\nmstat() function out of the standard Devel::Peek module.\n\nHere is some explanation of that format:\n\n\"buckets SMALLEST(APPROX)..GREATEST(APPROX)\"\nPerl's malloc() uses bucketed allocations.  Every request is rounded up to the closest\nbucket size available, and a bucket is taken from the pool of buckets of that size.\n\nThe line above describes the limits of buckets currently in use.  Each bucket has two\nsizes: memory footprint and the maximal size of user data that can fit into this bucket.\nSuppose in the above example that the smallest bucket were size 4.  The biggest bucket\nwould have usable size 8188, and the memory footprint would be 8192.\n\nIn a Perl built for debugging, some buckets may have negative usable size.  This means\nthat these buckets cannot (and will not) be used.  For larger buckets, the memory\nfootprint may be one page greater than a power of 2.  If so, the corresponding power of\ntwo is printed in the \"APPROX\" field above.\n\nFree/Used\nThe 1 or 2 rows of numbers following that correspond to the number of buckets of each\nsize between \"SMALLEST\" and \"GREATEST\".  In the first row, the sizes (memory footprints)\nof buckets are powers of two--or possibly one page greater.  In the second row, if\npresent, the memory footprints of the buckets are between the memory footprints of two\nbuckets \"above\".\n\nFor example, suppose under the previous example, the memory footprints were\n\nfree:    8     16    32    64    128  256 512 1024 2048 4096 8192\n4     12    24    48    80\n\nWith a non-\"DEBUGGING\" perl, the buckets starting from 128 have a 4-byte overhead, and\nthus an 8192-long bucket may take up to 8188-byte allocations.\n\n\"Total sbrk(): SBRKed/SBRKs:CONTINUOUS\"\nThe first two fields give the total amount of memory perl sbrk(2)ed (ess-broken? :-) and\nnumber of sbrk(2)s used.  The third number is what perl thinks about continuity of\nreturned chunks.  So long as this number is positive, malloc() will assume that it is\nprobable that sbrk(2) will provide continuous memory.\n\nMemory allocated by external libraries is not counted.\n\n\"pad: 0\"\nThe amount of sbrk(2)ed memory needed to keep buckets aligned.\n\n\"heads: 2192\"\nAlthough memory overhead of bigger buckets is kept inside the bucket, for smaller\nbuckets, it is kept in separate areas.  This field gives the total size of these areas.\n\n\"chain: 0\"\nmalloc() may want to subdivide a bigger bucket into smaller buckets.  If only a part of\nthe deceased bucket is left unsubdivided, the rest is kept as an element of a linked\nlist.  This field gives the total size of these chunks.\n\n\"tail: 6144\"\nTo minimize the number of sbrk(2)s, malloc() asks for more memory.  This field gives the\nsize of the yet unused part, which is sbrk(2)ed, but never touched.\n"
                    }
                ]
            },
            "SEE ALSO": {
                "content": "perldebug, perl5db.pl, perlguts, perlrun, re, and Devel::DProf.\n\n\n\nperl v5.34.0                                 2026-06-23                               PERLDEBGUTS(1)",
                "subsections": []
            }
        }
    }
}