If the maxdepth is included, it must be a numeral N the value is dumped only N levels deep, as if the dumpDepth option had been temporarily set to N. The output format is governed by multiple options described under "Configurable Options". See Dumpvalue if you'd like to do this yourself. When dumping hashes, you'll probably prefer 'x \%h' rather than 'x %h'. Nested data structures are printed out recursively, unlike the real print function in Perl. # x exprĮvaluates its expression in list context and dumps out the result in a pretty-printed fashion. ![]() The DB::OUT filehandle is opened to /dev/tty, regardless of where STDOUT may be redirected to. In particular, because this is just Perl's own print function, this means that nested data structures and objects are not dumped, unlike with the x command. This is useful if you need to know if your code is running under the debugger: if ( $^P ) expr in the current package. If Perl is called with the -d switch, the variable $^P will hold a true value. # perl -dt threaded_program_nameĭebug a given program using threads (experimental). # perl -d:ptkdb program_nameĭebug a given program via the Devel::ptkdb GUI. Interactively supply an arbitrary expression using -e. On the given program identified by program_name. There are several ways to call the debugger: # perl -d program_name If a debugger command coincides with some function in your own program, merely precede the function with something that doesn't look like a debugger command, such as a leading or perhaps a +, or by wrapping it with parentheses or braces. The debugger is a nice environment to learn Perl, but if you interactively experiment using material which should be in the same scope, stuff it in one line.įor any text entered at the debugger prompt, leading and trailing whitespace is first stripped before further processing. As a result any newly introduced lexical variable or any modified capture buffer content is lost after the eval. Note that the said eval is bound by an implicit scope. (The debugger uses the DB package for keeping its own state information.) Contrary to popular expectations, whenever the debugger halts and shows you a line of code, it always displays the line it's about to execute, rather than the one it has just executed.Īny command not recognized by the debugger is directly executed ( eval'd) as Perl code in the current package. The program will halt right before the first run-time executable statement (but see below regarding compile-time statements) and ask you to enter a debugger command. Then when the interpreter starts up, it preloads a special Perl library file containing the debugger. That means your code must first compile correctly for the debugger to work on it. Instead, the -d flag tells the compiler to insert source information into the parse trees it's about to hand off to the interpreter. ![]() In Perl, the debugger is not a separate program the way it usually is in the typical compiled environment. ![]() This is so convenient that you often fire up the debugger all by itself just to test out Perl constructs interactively to see what they do. This works like an interactive Perl environment, prompting for debugger commands that let you examine source code, set breakpoints, get stack backtraces, change the values of variables, etc. If you invoke Perl with the -d switch, your script runs under the Perl source debugger. If you're looking for the nitty gritty details of how the debugger is implemented, you may prefer to read perldebguts.įor in-depth technical usage details, see, the documentation of the debugger itself. If you're new to the Perl debugger, you may prefer to read perldebtut, which is a tutorial introduction to the debugger.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |