yes, $DB::line was the one I was looking for originally. Thanks.
The perl5db.pl documentation was most helpful to me, but actually the in-place comments more than the POD, at least for what I wanted right now. perldebguts is also interesting.
I've also begun to use the explicit debugger invocation from the source in a few interesting places.
My current state is this (to give everyone some feedback):
I'm working on a Mac and I have employed BBEdit as debugging output viewer.
I have made just some minor modifications to perl5db.pl to the following effects:
• whenever the debugger detects a switch between sources (notably including evals as well!), it writes out the current source to the file ~/t/Perl/thesource.pl
• The debugger pushes a cursor position update on every tracing step to the BBEdit window named thesource.pl via AppleScript (called osascript on the command-line gateway):
system("osascript", "-e",
"tell application \"BBEdit\"
tell the text of the window \"thesource.pl\"
select insertion point before line $line
end tell
end tell");
• I have augmented the debugger command "|" with an optional parameter which is appended to the pager option string before execution. I'm using it like this:
o pager=cat>~/t/Perl/
{|(vars.pl)y
{{|(stack.txt)T
{{|(package_vars.pl)X
|(vars.pl)y actually executes the y command and pipes it to the effective "pager" cat>~/t/Perl/vars.pl, writing it to that file on every prompt.
So the pre-prompt auto commands keep updating the following files in ~/t/Perl/:
vars.pl: dump of local variables
stack.txt: stack backtrace
package_vars.pl: package variables (I keep this off much of the time because in my project the amount can be huge)
In the GUI editor BBEdit I keep these three files and thesource.pl open besides my working sources and data files. BBEdit automatically detects any files being updated and reloads them transparently while preserving their scrolled positions. And perl5db.pl also keeps updating the cursor in thesource.pl.
This is so fast that it is an actually usable replacement for a regular GUI debugger.
And when I occasionally want to display additional information, I can just push it to additional windows as needed like this:
|(more.pl)x %mhash
For me it's quite nice that syntax colouring and all the GUI niceties of my regular source editor are just seamlessly available and I have large, independent windows for debugger output. That the debugger still needs to be operated on the command line in a Terminal window is not an issue in this context since BBEdit in the background keeps updating its windows while I keep going.
And this is what it looks like while debugging Perl code:
<img src="http://i.imgur.com/zSWB3wO.png" title="Hosted by imgur.com" />
I'm aware that this is kind of freaky (which is half the fun of it!), but it works quite well and is much more practical than the command-line-only debugger on its own. I'm aware that there are some other GUI wrappers around, but they come with their own quirks again, so I actually prefer it this way for the moment.
The same principle could certainly be applied to other environments than OS X and BBEdit as well, so maybe it helps anyone else along as well.
If anyone is interested, I can of course provide the (pretty raw) modifications I've made to perl5db.pl.
I've just needed to get ahead with the actual debugging in some relatively complex code, so right now functionality goes before beauty for me.
One known TODO would be to run the tracing cursor in the actual source files and switching between those as needed instead of using the saved thesource.pl for everything (except for evals where that's the only way), but I may get around to that some time later. |