Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

perldb: Howto trace only "my" modules?

by The Perlman (Beadle)
on Jan 29, 2012 at 18:36 UTC ( #950617=perlquestion: print w/ replies, xml ) Need Help??
The Perlman has asked for the wisdom of the Perl Monks concerning the following question:

investigating the perldebugger shows some nice features like producing stack traces of every call
tst.pl:
sub a { b(@_) } sub b { return map { $_ +1 } @_; } print a (1,2,3)
interactive example (could be fully automated)
perl -d tst.pl Loading DB routines from perl5db.pl version 1.3 Editor support enabled. Enter h or `h h' for help, or `man perldebug' for more help. Package /tmp/tst.pl. DB<3> o f=31 frame = '31' DB<4> c in @=main::a(1, 2, 3) from /tmp/tst.pl:9 in @=main::b(1, 2, 3) from /tmp/tst.pl:2 out @=main::b(1, 2, 3) from /tmp/tst.pl:2 list context return from main::b: 0 2 1 3 2 4 out @=main::a(1, 2, 3) from /tmp/tst.pl:9 list context return from main::a: 0 2 1 3 2 4

my only problem is how to avoid in deep tracing of third-party modules I use.

is there any option where I can provide a pattern which modules/subs/file-pathes to trace and which to ignore?

Could also be useful for automatic distinction between step-in /step-over when single-stepping...

Comment on perldb: Howto trace only "my" modules?
Select or Download Code
Re: perldb: Howto trace only "my" modules?
by Anonymous Monk on Jan 29, 2012 at 19:38 UTC
      Sorry, this question has nothing to do with breakpoints.
Re: perldb: Howto trace only "my" modules?
by Kanji (Parson) on Jan 29, 2012 at 19:43 UTC

    There's a The Effective Perler article on custom tracing entitled Trace your Perl programs that you might find useful, particularly the last example.

    To summarize...

    • Under the -d switch, perl calls &DB::DB before each statement
    • You can write your own tracer (e.g., Devel::Foo) to define your own &DB::DB that excludes third-party modules, and run it via -d:Foo
    • .
      Thanks for the links.

      I was aware that I can overload internal DB:: functions, (sorry for not mentioning)

      I just had the hope that I could solve this with an *option* (CLI or .perldb).

      Actually in this case I think I have to overload DB::sub like demonstrated in perldebguts

      { package DB; sub DB {} sub sub {print ++$i, " $sub\n"; &$sub} }
      Thanks anyway! :)
Re: perldb: Howto trace only "my" modules?
by Khen1950fx (Canon) on Jan 30, 2012 at 02:21 UTC
    Aspect::Library::Trace might be what you're looking for.
    package Foo; use strict; use warnings; use Aspect; use Aspect::Library::Trace; use Data::Dumper::Concise; aspect Trace => call qr/^Foo::/; sub a { my($var) = @_; b(@_); } sub b { my($var) = @_; return map( {$_ + 1;} @_ ); } print Dumper( a(qw[1 2 3]) );

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://950617]
Approved by LanX
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2014-07-31 01:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (242 votes), past polls