From 37092dab15448ef6a078800e3ff0cc41880ea765 Mon Sep 17 00:00:00 2001
From: Lukas Larsson
Date: Thu, 10 Dec 2015 11:10:46 +0100
Subject: erts: Implement tracer modules
Add the possibility to use modules as trace data receivers. The functions
in the module have to be nifs as otherwise complex trace probes will be
very hard to handle (complex means trace probes for ports for example).
This commit changes the way that the ptab->tracer field works from always
being an immediate, to now be NIL if no tracer is present or else be
the tuple {TracerModule, TracerState} where TracerModule is an atom that
is later used to lookup the appropriate tracer callbacks to call and
TracerState is just passed to the tracer callback. The default process and
port tracers have been rewritten to use the new API.
This commit also changes the order which trace messages are delivered to the
potential tracer process. Any enif_send done in a tracer module may be delayed
indefinitely because of lock order issues. If a message is delayed any other
trace message send from that process is also delayed so that order is preserved
for each traced entity. This means that for some trace events (i.e. send/receive)
the events may come in an unintuitive order (receive before send) to the
trace receiver. Timestamps are taken when the trace message is generated so
trace messages from differented processes may arrive with the timestamp
out of order.
Both the erlang:trace and seq_trace:set_system_tracer accept the new tracer
module tracers and also the backwards compatible arguments.
OTP-10267
---
lib/kernel/doc/src/seq_trace.xml | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
(limited to 'lib/kernel/doc/src/seq_trace.xml')
diff --git a/lib/kernel/doc/src/seq_trace.xml b/lib/kernel/doc/src/seq_trace.xml
index 1feb3fcb07..5ac199b6a7 100644
--- a/lib/kernel/doc/src/seq_trace.xml
+++ b/lib/kernel/doc/src/seq_trace.xml
@@ -213,9 +213,10 @@ seq_trace:set_token(OldToken), % activate the trace token again
Sets the system tracer. The system tracer can be either a
- process or port denoted by Tracer. Returns the previous
- value (which can be false if no system tracer is
- active).
+ process, port or tracer module
+ denoted by Tracer.
+ Returns the previous value (which can be false if no system
+ tracer is active).
Failure: {badarg, Info}} if Pid is not an
existing local pid.
@@ -225,7 +226,7 @@ seq_trace:set_token(OldToken), % activate the trace token again
Return the pid() or port() of the current system tracer.
- Returns the pid or port identifier of the current system
+
Returns the pid, port identifier or tracer module of the current system
tracer or false if no system tracer is activated.
@@ -298,7 +299,7 @@ TimeStamp = {Seconds, Milliseconds, Microseconds}
matches a message in a receive statement, according to the trace
token carried by the received message, empty or not.
On each Erlang node, a process can be set as the system tracer.
- This process receives trace messages each time
+ This process will receive trace messages each time
a message with a trace token is sent or received (if the trace
token flag send or 'receive' is set). The system
tracer can then print each trace event, write it to a file, or
--
cgit v1.2.3