1Data::Dump::Trace(3) User Contributed Perl Documentation Data::Dump::Trace(3)
2
3
4
6 Data::Dump::Trace - Helpers to trace function and method calls
7
9 use Data::Dump::Trace qw(autowrap mcall);
10
11 autowrap("LWP::UserAgent" => "ua", "HTTP::Response" => "res");
12
13 use LWP::UserAgent;
14 $ua = mcall(LWP::UserAgent => "new"); # instead of LWP::UserAgent->new;
15 $ua->get("http://www.example.com")->dump;
16
18 The following functions are provided:
19
20 autowrap( $class )
21 autowrap( $class => $prefix )
22 autowrap( $class1 => $prefix1, $class2 => $prefix2, ... )
23 autowrap( $class1 => \%info1, $class2 => \%info2, ... )
24 Register classes whose objects are automatically wrapped when
25 returned by one of the call functions below. If $prefix is
26 provided it will be used as to name the objects.
27
28 Alternative is to pass an %info hash for each class. The
29 recognized keys are:
30
31 prefix => $string
32 The prefix string used to name objects of this type.
33
34 proto => \%hash
35 A hash of prototypes to use for the methods when an object is
36 wrapped.
37
38 wrap( name => $str, func => \&func, proto => $proto )
39 wrap( name => $str, obj => $obj, proto => \%hash )
40 Returns a wrapped function or object. When a wrapped function is
41 invoked then a trace is printed after the underlying function has
42 returned. When a method on a wrapped object is invoked then a
43 trace is printed after the methods on the underlying objects has
44 returned.
45
46 See "Prototypes" for description of the "proto" argument.
47
48 call( $name, \&func, $proto, @ARGS )
49 Calls the given function with the given arguments. The trace will
50 use $name as the name of the function.
51
52 See "Prototypes" for description of the $proto argument.
53
54 mcall( $class, $method, $proto, @ARGS )
55 mcall( $object, $method, $proto, @ARGS )
56 Calls the given method with the given arguments.
57
58 See "Prototypes" for description of the $proto argument.
59
60 trace( $symbol, $prototype )
61 Replaces the function given by $symbol with a wrapped function.
62
63 Prototypes
64 Note: The prototype string syntax described here is experimental and
65 likely to change in revisions of this interface.
66
67 The $proto argument to call() and mcall() can optionally provide a
68 prototype for the function call. This give the tracer hints about how
69 to best format the argument lists and if there are in/out or out
70 arguments. The general form for the prototype string is:
71
72 <arguments> = <return_value>
73
74 The default prototype is "@ = @"; list of values as input and list of
75 values as output.
76
77 The value '%' can be used for both arguments and return value to say
78 that key/value pair style lists are used.
79
80 Alternatively, individual positional arguments can be listed each
81 represented by a letter:
82
83 "i" input argument
84
85 "o" output argument
86
87 "O" both input and output argument
88
89 If the return value prototype has "!" appended, then it signals that
90 this function sets errno ($!) when it returns a false value. The trace
91 will display the current value of errno in that case.
92
93 If the return value prototype looks like a variable name (with "$"
94 prefix), and the function returns a blessed object, then the variable
95 name will be used as prefix and the returned object automatically
96 traced.
97
99 Data::Dump
100
102 Copyright 2009 Gisle Aas.
103
104 This library is free software; you can redistribute it and/or modify it
105 under the same terms as Perl itself.
106
107
108
109perl v5.30.1 2020-01-29 Data::Dump::Trace(3)