How can I debug a custom debugger?

Viewed 244

I wrote a custom debugger as described in 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.

I suppose I can do this by setting $^D to 1<<30, since the documentation says:

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. 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.

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. (This doesn't happen if the subroutine was compiled in the DB package.)

(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.

How can I trace the execution of my DB::DB() and DB::sub() subroutines step-by-step?

UPD According to the answer below. 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?

1 Answers
Related