Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

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
sub a { b(@_) } sub b { return map { $_ +1 } @_; } print a (1,2,3)
interactive example (could be fully automated)
perl -d Loading DB routines from version 1.3 Editor support enabled. Enter h or `h h' for help, or `man perldebug' for more help. Package /tmp/ DB<3> o f=31 frame = '31' DB<4> c in @=main::a(1, 2, 3) from /tmp/ in @=main::b(1, 2, 3) from /tmp/ out @=main::b(1, 2, 3) from /tmp/ list context return from main::b: 0 2 1 3 2 4 out @=main::a(1, 2, 3) from /tmp/ 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...

Replies are listed 'Best First'.
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]) );
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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://950617]
Approved by LanX
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2018-06-25 10:16 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.