Perl -d 調試perl程式

來源:互聯網
上載者:User

在控制台輸入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.

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.