P is for Practical | |
PerlMonks |
PadWalker and Safe - getting the lexicalsby shushu (Scribe) |
on Oct 09, 2002 at 15:29 UTC ( [id://203962]=perlquestion: print w/replies, xml ) | Need Help?? |
shushu has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks ! My task is to create a Perl reporting for unknown code. The idea is to execute piece of Perl code in a place it can't harm anything, and create a "simple" report out of it. The report should be a printout of every line, and (the hard work) the values of the variables in tihs line. How do we do all of that ? 1. Before the execution we use "Xref.pm" to get detailed data regarding to every line and the variables in it, global and lexical. 2. Using "Safe.pm" and "Safe::Hole.pm" we create a compartment where we execute the code. 3. While executing we use a modified "Devel::Trace" to get every line executed. - To get the global variables we use "dumpvar.pl", similar to the way perl5db do, giving it the list of the variables we took from Xref before. Up to here (surprise) it all works fine. Here is the hard stuff... - To get the lexical variables we needed something special and we found "PadWalker.pm", peek_my(). The problem is that PadWalker gives proper information up to the minute we try to use it via the Safe compartement. There, it seems it can't "penetrate" the compartement... The new Trace relevant code is this, called from sub DB::DB - The unsafe code is "unsafe.pl": The checking code is "check_code.pl": When executed straight ("perl -d:Trace unsafe.pl") I get: When executed via the checker ("perl -d:Trace_shushu2 check_code.pl") I get: * I tried to play with the level given to the &peek_my, with no good effect. * robin (hopefully reading...) - In your jurnal (http://use.perl.org/~robin/journal) you wrote that PadWalker 0.8 is used in the new debugger to do exactly what I need. Can it be used here ? Any suggestions ? Thanks, shushu
Back to
Seekers of Perl Wisdom
|
|