Just another Perl shrine | |
PerlMonks |
debugging eval'd code with source (SOLVED)by sharkey (Scribe) |
on Jul 09, 2008 at 05:53 UTC ( [id://696388]=perlquestion: print w/replies, xml ) | Need Help?? |
sharkey has asked for the wisdom of the Perl Monks concerning the following question:
I've been debugging code which has eval'd subs in it. Normally when inside these subs, the debugger just shows something line "(eval 20)" for the current subroutine with no code from the current line.
But once, mysteriously, the debugger actually showed me the code which had been eval'd as I stepped through it. I figured if it can happen once, it can happen again, so I started investigating how it could happen. perldebguts documents the @{"_<(eval 20)"} variables where the code for eval'd stuff should be stored. The trouble is, most of the time, there is no code there for my evals. I can look in the symbol table and see lots of other (eval ##) entries which do have code in them. For example, like this: So my question for the perl debug gurus out there is, Why do some eval's get their code stored and others do not? Is there anything I can do to encourage my eval'd code to get stored? EUREKA! It is the presence of a named sub, or even a named sub stub, which convinces perl to keep the eval'd code in memory. So for my anonymous subs, I can do this: The debugger can now show me the code for the anonymous sub, even if I use the same stub name in all of the evals.
Back to
Seekers of Perl Wisdom
|
|