Perl -d 调试perl程序

前端之家收集整理的这篇文章主要介绍了Perl -d 调试perl程序前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

在控制台输入perldoc perldebug即可如何得到如何调试perl程序的文档。


其中重要的命令如下:


p expr      Same as "print {$DB::OUT} expr" in the current package. 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.

           

x [maxdepth] expr
                Evaluates its expression in list context and dumps out the
                result in a pretty-printed fashion.


T           Produce a stack backtrace. See below for details on its
                output.


s [expr]    Single step. Executes until the beginning of another
                statement,descending into subroutine calls. If an
                expression is supplied that includes function calls,it too
                will be single-stepped.

n [expr]    Next. Executes over subroutine calls,until the beginning of
                the next statement. If an expression is supplied that
                includes function calls,those functions will be executed
                with stops before each statement.

r           Continue until the return from the current subroutine. Dump
                the return value if the "PrintRet" option is set (default).


<CR>        Repeat last "n" or "s" command.


L [abw]     List (default all) actions,breakpoints and watch
                expressions


l           List next window of lines.

l line      List a single line.

    l subname   List first window of lines from subroutine. *subname* may be
                a variable that contains a code reference.


b           Sets breakpoint on current line

b [line] [condition]
                Set a breakpoint before the given line. If a condition is
                specified,it's evaluated each time the statement is
                reached: a breakpoint is taken only if the condition is
                true. Breakpoints may only be set on lines that begin an
                executable statement. Conditions don't use "if":

                    b 237 $x > 30
                    b 237 ++$count237 < 11
                    b 33 /pattern/i

b subname [condition]
                Set a breakpoint before the first line of the named
                subroutine. *subname* may be a variable containing a code
                reference (in this case *condition* is not supported).

c [line|sub]
                Continue,optionally inserting a one-time-only breakpoint at
                the specified line or subroutine.


q or ^D     Quit. ("quit" doesn't work for this,unless you've made an
                alias) This is the only supported way to exit the debugger,
                though typing "exit" twice might work.

                Set the "inhibit_exit" option to 0 if you want to be able to
                step off the end the script. You may also need to set
                $finished to 0 if you want to step through global
                destruction.

R           Restart the debugger by "exec()"ing a new session. We try to
                maintain your history across this,but internal settings and
                command-line options may be lost.

                The following setting are currently preserved: history,
                breakpoints,actions,debugger options,and the Perl
                command-line options -w,-I,and -e.


w expr      Add a global watch-expression. Whenever a watched global                 changes the debugger will stop and display the old and new                 values. W expr      Delete watch-expression W *         Delete all watch-expressions.

猜你在找的Perl相关文章