1. 进入debug模式
# perl -d ./perl_debugger.pl
it prompts,
DB<1>
 
2. 查看从第10行开始的代码。 查看函数get_pattern的代码
DB<1> l 10
10: my $pattern;
DB<2> l get_pattern
11 {
12:    my $pattern;
13:    print “Enter search string: “;
14:    chomp ($pattern = );
15:    return $pattern;
16 }
 
3. 在函数find_files上设置断点
DB<3> b find_files
 
4. 在指定的44行设置断点
DB<4> b 44
 
5. 查看所有的断点
DB<5> L
./perl_debugger.pl:
22:    my $pattern = shift;
break if (1)
44:    print join “\n”,@list;
break if (1)
 
6. 单步调试,s 进入调用函数,n直接下一语句不进入调用函数
DB<5> s
main::(./perl_debugger.pl:39):    $pattern = get_pattern();
DB<5> s
main::get_pattern(./perl_debugger.pl:12):
12:    my $pattern;
Option s and n does step by step execution of each statements. Option s steps into the subroutine. Option n executes the subroutine in a single step (stepping over it).
The s option does stepping into the subroutine but while n option which would execute the subroutine(stepping over it).
 
7. 继续直到下一个断点
DB<5> c
Enter search string: perl
main::find_files(./perl_debugger.pl:22):
22:    my $pattern = shift;
 
8. 继续直到指定的行
DB<5> c 36
main::find_files(./perl_debugger.pl:36):
36:    return @list;
 
9. 打印变量的值
DB<6> p $pattern
perl
DB<7> c
main::(./perl_debugger.pl:44):    print join “\n”,@list;
DB<7> c
./perl_debugger.pl
Debugged program terminated. Use q to quit or R to restart,
use o inhibit_exit to avoid stopping after program termination,
h q, h R or h o to get additional info.
After the last continue operation, the output gets printed on the stdout as “./perl_debugger.pl” since it matches the pattern “perl”.
 
10. 从文件获得debug的命令和断点信息
Perl debugger can get the debug command from the file and execute it. For example, create the file called “debug_cmds” with the perl debug commands as,
c
p $pattern
q
Note that R is used to restart the operation(no need quit and start debugger again).
DB<7> R
DB<7> source debug_cmds
>> c
Enter search string: perl
./perl_debugger.pl
Debugged program terminated. Use q to quit or R to restart,
use o inhibit_exit to avoid stopping after program termination,
h q, h R or h o to get additional info.
>> p $pattern
perl
>> q
 
perl debug命令的总结
Following options can be used once you enter the perl debugger.
h or h h – for help page
c – to continue down from current execution till the breakpoint otherwise till the subroutine name or line number,
p – to show the values of variables,
b – to place the breakpoints,
L – to see the breakpoints set,
d – to delete the breakpoints,
s – to step into the next line execution.
n – to step over the next line execution, so if next line is subroutine call, it would execute subroutine but not descend into it for inspection.
source file – to take the debug commands from the file.
l subname – to see the execution statements available in a subroutine.
q – to quit from the debugger mode.
 
perl debug的高级用法
对调用的module中的函数设置断点:
b foo::bar::test::subname
 
可以设置永久的断点,在需要设置断点的行,加入:
$DB::single =1;
 
设置断点到调用的文件中的函数或行:
b  line_number file_path_name
b  function_name file_path_name
b file_path_name:function_name
 
f file_path_name
b line_number or function_name
 
监视变量的变化,当值被修改的时候,程序停下:
w $varialename

perl debug的更多相关文章

  1. Perl Debug error: SetConsoleMode failed, LastError=|6|

    Windows Strawberry Perl. 解决办法: 1. 设置环境变量 TERM = dumb 2. 重启 CMD 参考资料: http://padre.perlide.org/trac/t ...

  2. Perl的调试方法

    来源: http://my.oschina.net/alphajay/blog/52172 http://www.cnblogs.com/baiyanhuang/archive/2009/11/09/ ...

  3. C代码工具--自动生成enum值和名字映射代码

    这年头好像继续做C语言的人不多了,年轻人大多去互联网和移动应用.确实,那两个领域现在来钱快,且总是供不应求.就说刚刚在一个旧同事的微信群里,有人刚放出自己有团队可以做App几分钟,哇塞,好几个人说有项 ...

  4. jmeter sampler maven项目排错记

    eclipse 创建的maven项目,引入jar包之后出现红色叹号,一直找不到原因,连main方法都无法运行,提示找不到类: 错误: 找不到或无法加载主类 soapsampler.SoapSample ...

  5. Debug of bash , perl and python

    1.bash -x   script 2.perl -d  script 3. python -m pdb script n: execute the next line s: execute the ...

  6. Perl的debug小技巧

    进入Perl的调试环境的命令:  Perl  -d  perl_file 设置断点:b + perl代码中的行号. 执行到断点:c 表示continue until breakpoint. 执行下一条 ...

  7. How to DEBUG a trigger or procedure

    DEBUGGING STORED PROCEDURES Over the past several weeks, we’ve been working on debugging a stored pr ...

  8. perl小记

    perl是一种运行式脚本,所以在debug的时候,多用print,在后台看有没有输出相关的结果,来判断相应的错误. 部分perl正则表达式: $gene =~/^LOC/  以“LOC”开头的字符串 ...

  9. [转载]两个半小时学会Perl

    Learn Perl in about 2 hours 30 minutes By Sam Hughes Perl is a dynamic, dynamically-typed, high-leve ...

随机推荐

  1. Ex 5_28 Alice想要举办一个舞会..._第十次作业

    根据总人数建立顶点数量为总人数的无向图,顶点之间有边相连表示两个人相互认识,没有边则表示不认识.对于每一个顶点v,设d(v)表示顶点的度,若d(v)<5,即v认识的人数少于5,则不邀请v,若d( ...

  2. citySelect省市区jQuery联动插件

    参考地址:http://blog.csdn.net/qq_33556185/article/details/50704446 参考地址:http://www.lanrenzhijia.com/jque ...

  3. SQL数据库基础知识

  4. 如何通过编译Linux内核打开IPVS(LVS)的debug模式

    前言 为了定位keepalived VIP的问题, 一步一步定位到IPVS, IPVS默认是没有打开Debug模式的, 若需要打开Debug模式需要重新编译IPVS模块加载后才行, 最好的方式当然是仅 ...

  5. GuzzleHttp 请求设置超时时间

    之前调用一个三方的 WEB API,大量的请求超时,导致 PHP 进程被占用完.整个网站一直报 504. 其中一个优化措施就是对三方 API 调用设置超时时间. use GuzzleHttp\Clie ...

  6. (七)dubbo服务集群实现负载均衡

    当某个服务并发量特别大的时候,一个服务延迟太高,我们就需要进行服务集群,例如某个项目一天注册量10万,这个注册功能就必须要进行集群了,否则一个服务无法应付这么大的并发量: dubbo的服务集群很简单, ...

  7. python 全栈开发,Day102(支付宝支付)

    昨日内容回顾 1. django请求生命周期? - 当用户在浏览器中输入url时,浏览器会生成请求头和请求体发给服务端 请求头和请求体中会包含浏览器的动作(action),这个动作通常为get或者po ...

  8. myeclipse启动错误:org.eclipse.swt.SWTError: No more handles

    myeclipse启动错误,生成日志: !SESSION 2014-11-06 09:13:16.296 ----------------------------------------------- ...

  9. 基于jsp+servlet图书管理系统之后台用户信息插入操作

    前奏: 刚开始接触博客园写博客,就是写写平时学的基础知识,慢慢发现大神写的博客思路很清晰,知识很丰富,非常又价值,反思自己写的,顿时感觉非常low,有相当长一段时间没有分享自己的知识.于是静下心来钻研 ...

  10. OPENJDK 源码编译

    一.整体编译 我的环境: Ubuntu 16.04 LTS apache-ant-1.8.0-bin.zip 环境变量: export LANG=C export ALT_BOOTDIR=/home/ ...