Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

I noticed the following problem in using the perl debugger, Devel::Trepan, with code that uses the SelfLoader perl module.

SelfLoader uses eval() to install subroutines at run time. The perl debugger would like to have access to the text of the eval string. With this, when one is debugging into one of those procedures the debugger can show you were you are. The two things that defeat this in SelfLoader is the use of lexically-scoped (or my) hash %Cache of such added text which it deletes just before running the code.

The general outline of the SelfLoader is:

package SelfLoader; ... my %Cache; # private cache for all SelfLoader's client packages ... AUTOLOAD { our $AUTOLOAD; # $AUTOLOAD is fully-qualified function name, e.g. MyPackage::fn ... # set $Cache{$AUTOLOAD} to file text from __DATA__ to __END__ ... delete $Cache{$AUTOLOAD}; goto &$AUTOLOAD; }

So basically, when debugging I'd like to rewrite the above to change my %Cache to our %Cache and remove the delete $Cache{$AUTOLOAD};

Alternatively, the routine that updates %Cache is called SelfLoader::_add_to_cache() so that could be augmented to save to another hash somewhere. But the problem here is that it still needs to update the lexically-scoped %Cached hash.

The two techniques that come to mind are monkey-patching and the Decorator pattern. Alas, because of the specifics of how SelfLoader works which I won't go into here (and am not totally positive I understand), I don't see how to do either.

Thoughts on how to address? Thanks.


In reply to Modifying SelfLoader to save eval() text by rockyb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others surveying the Monastery: (9)
    As of 2014-12-19 22:43 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (94 votes), past polls