如何在 Perl 程序中的特定文件上设置断点? [英] How to set breakpoint on a particular file in Perl program?
问题描述
我的 Perl 程序如下所示:
My Perl program looks like:
foo/
foo/bar/
for/bar/test.pm
foo.pm
foo/bar.pm
test.pl
并使用 perl test.pl
启动程序.我想在 foo/bar/test.pm 中调试一个子程序.如何在该子程序上设置断点?
and use perl test.pl
to start the program.
I want to debug a sub in foo/bar/test.pm. How to set a breakpoint on that sub?
我该怎么做?
谢谢.
推荐答案
要调试 perl 脚本,请使用 -d
开关来调用调试器.
To debug a perl script, use the -d
switch to invoke the debugger.
perl -d test.pl
在调试器中,您可以使用 b
在当前文件中设置断点.有时候在一个还没有加载或者很久以前加载的文件中设置断点很麻烦,所以你也可以把行
Within the debugger you can use b <line no>
to set a breakpoint in the current file. Sometimes it is a hassle to set a breakpoint in a file that hasn't been loaded yet or that was loaded a long time ago, so you can also put the line
$DB::single = 1;
在任何 perl 程序中的任何地方,调试器将在执行该行后立即中断.这也是在编译时运行的代码中设置断点的好方法(唯一方法?).
anywhere in any perl program, and the debugger will break immediately after it executes that line. This is also a good way (the only way?) to set a breakpoint in code that will be run at compile time.
这篇关于如何在 Perl 程序中的特定文件上设置断点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!