View Source Matcha.Trace (Matcha v0.1.10)
About tracing.
Link to this section Summary
Functions
Checks if pid
is awaiting trace messages.
Trace function
calls to module
with specified arguments
.
The default formatter for trace messages.
Trace all function
calls to module
.
Trace all calls to a module
.
Builds a new trace.
Builds a Matcha.Spec
for tracing purposes.
Starts the provided trace
.
Stops all tracing at once.
Link to this section Types
@type info_flag() ::
:send
| :receive
| :set_on_spawn
| :call
| :return_to
| :procs
| :set_on_first_spawn
| :set_on_link
| :running
| :garbage_collection
| :timestamp
| :monotonic_timestamp
| :strict_monotonic_timestamp
| :arity
@type info_item() ::
:flags
| :tracer
| :traced
| :match_spec
| :meta
| :meta_match_spec
| :call_count
| :call_time
| :all
@type info_item_result() :: {:traced, :global | :local | false | :undefined} | {:match_spec, Matcha.Source.uncompiled() | false | :undefined} | {:meta, pid() | port() | false | :undefined | []} | {:meta, module(), any()} | {:meta_match_spec, Matcha.Source.uncompiled() | false | :undefined} | {:call_count, non_neg_integer() | boolean() | :undefined} | {:call_time, [{pid(), non_neg_integer(), non_neg_integer(), non_neg_integer()}] | boolean() | :undefined}
@type info_result() :: :undefined | {:flags, [info_flag()]} | {:tracer, pid() | port() | []} | {:tracer, module(), any()} | info_item_result() | {:all, [info_item_result()] | false | :undefined}
@type info_subject() :: pid() | port() | :new | :new_processes | :new_ports | {module(), function :: atom(), arity :: non_neg_integer()} | :on_load | :send | :receive
@type t() :: %Matcha.Trace{ arguments: :any | 0..255 | Matcha.Spec.t(), formatter: term(), function: atom(), limit: pos_integer(), module: atom(), pids: pid() | [pid()] | :new | :existing | :all, recon_opts: Keyword.t() }
@type trace_message() :: binary()
Link to this section Functions
@spec awaiting_messages?(:all | pid(), timeout :: non_neg_integer()) :: boolean()
Checks if pid
is awaiting trace messages.
Waits timeout
milliseconds for the pid
to report that all trace messages
intended for it when awaiting_messages?/2
was called have been delivered.
Returns true
if no response is received within timeout
, and you may assume
that pid
is still working through trace messages it has received.
If it receives confirmation before the timeout
, returns false
.
The pid
must refer to an alive (or previously alive) process
from the same node this function is called from,
or it will raise an ArgumentError
.
If the atom :all
is provided instead of a pid
, this function returns true
if any process on the current node is awaiting trace messages.
This function is best used when shutting down processes (or the current node), to give them a chance to finish any tracing they are handling.
@spec calls(atom(), atom(), non_neg_integer() | Matcha.Spec.t(), keyword()) :: :ok
Trace function
calls to module
with specified arguments
.
arguments
may be:
- an integer arity, only tracing function calls with that number of parameters
- a
Matcha.Spec
, only tracing function calls whose arguments match the provided patterns
If calling with just an arity, all matching calls will print a corresponding trace message.
If calling with a spec, additional operations can be performed, as documented in Matcha.Context.Trace
.
By default, only 1 calls will be traced.
More calls can be traced by providing an integer :limit
in the opts
.
All other opts
are forwarded to
:recon_trace.calls/3
as the third argument.
The default formatter for trace messages.
Trace all function
calls to module
.
By default, only 1 calls will be traced.
More calls can be traced by providing an integer :limit
in the opts
.
All other opts
are forwarded to
:recon_trace.calls/3
as the third argument.
@spec info(info_subject(), info_item()) :: info_result()
Trace all calls to a module
.
By default, only 1 calls will be traced.
More calls can be traced by providing an integer :limit
in the opts
.
All other opts
are forwarded to
:recon_trace.calls/3
as the third argument.
Builds a new trace.
A custom :formatter
function can be provided to opts
.
It should be a 1-arity function that accepts a trace_info/0
tuple,
and returns a message string suitable for consumption by :io.format()
.
Builds a Matcha.Spec
for tracing purposes.
Shorthand for Matcha.spec(:trace, spec)
.
Starts the provided trace
.
Stops all tracing at once.