简体   繁体   English

如何调试自定义调试器?

[英]How can I debug a custom debugger?

I wrote a custom debugger as described in perldebguts . 我编写了一个自定义调试器,如perldebguts中所述 There's something wrong with my debugger code, though, so I want to step through my DB::DB() and DB::sub() routines line-by-line to isolate the problem. 但是我的调试器代码有问题,所以我想逐行遍历我的DB::DB()DB::sub()例程来隔离问题。

I suppose I can do this by setting $^D to 1<<30 , since the documentation says: 我想我可以通过将$^D设置$^D 1<<30来实现这一点,因为文档说:

When the execution of your program reaches a point that can hold a breakpoint, the DB::DB() subroutine is called if any of the variables $DB::trace , $DB::single , or $DB::signal is true. 当程序的执行到达可以保存断点的点时,如果任何变量$DB::trace$DB::single$DB::signal为true,则调用DB::DB()子例程。 These variables are not localizable. 这些变量不可本地化。 This feature is disabled when executing inside DB::DB() , including functions called from it unless $^D & (1<<30) is true. DB::DB()内执行时禁用此功能,包括从中调用的函数, 除非$^D & (1<<30)为真。

When execution of the program reaches a subroutine call, a call to &DB::sub (args) is made instead, with $DB::sub holding the name of the called subroutine. 当程序执行到达子程序调用时,调用&DB::sub (args)代替, $DB::sub保存被调用子程序的名称。 (This doesn't happen if the subroutine was compiled in the DB package.) (如果子程序是在DB包中编译的,则不会发生这种情况。)

(emphasis added) (重点补充)

People on the IRC #perl-help channel said that with $^D & (1<<30) I may be able to debug my debugger but they didn't know any details beyond that. IRC#perl-help频道的人说用$^D & (1<<30)我可以调试我的调试器,但除此之外他们不知道任何细节。

How can I trace the execution of my DB::DB() and DB::sub() subroutines step-by-step? 如何逐步跟踪DB::DB()DB::sub()子例程的执行情况?

UPD According to the answer below. UPD根据下面的答案。 When set $^D |= (1<<30) flag this allows me to debug debugger commands which is defined outside of DB namespace, but that is not an answer for question: How to disable that feature when executing inside DB::DB? 当设置$^D |= (1<<30)标志时,这允许我调试在DB命名空间之外定义的调试器命令,但这不是问题的答案: 如何在DB :: DB内执行时禁用该功能?

This is my custom debugger Devel::DebugHooks which I want to debug. 这是我想要调试的自定义调试器Devel :: DebugHooks

When I run this expression from debugger $^D|=(1<<30) and after that run debugger command, like vars 2 $x , this will allow me to debug code which is called from DB:: namespace. 当我从调试器$^D|=(1<<30)运行这个表达式,之后运行调试器命令,比如vars 2 $x ,这将允许我调试从DB :: namespace调用的代码。

This feature is disabled when executing inside DB::DB(), including functions called from it unless $^D & (1<<30) is true 在DB :: DB()内部执行时禁用此功能,包括从中调用的函数,除非$^D & (1<<30)为真

This sentence from DOC just makes confusion. 来自DOC的这句话只会令人困惑。
The feature is NOT disabled when executing inside DB::DB() unless $^D & (1<<30) is true. 除非$^D & (1<<30)为真,否则在DB::DB()内执行时不会禁用该功能。
This feature is disabled only for functions called from DB::DB() when $^D & (1<<30) is true $^D & (1<<30)为真时,仅对从DB::DB()调用的函数禁用此功能

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM