From 115f0ba77ad7d01ab95fd9f9bbeca53f04f12284 Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Thu, 19 May 2016 10:54:43 +0200 Subject: erts: Move tracer SecondTraceTerm to Opts map The extra trace data has been moved to the opts map in order for the tracer to be able to distinguish inbetween extra trace data 'undefined' and no extra trace data. In the same commit all opts associations have been changed so that if the tracer should not use them, the key is left unassicated instead of being sent to undefined. This should be give a small performance gain and also makes the API easier to work with. --- erts/doc/src/erl_tracer.xml | 96 +++++++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 51 deletions(-) (limited to 'erts/doc') diff --git a/erts/doc/src/erl_tracer.xml b/erts/doc/src/erl_tracer.xml index d4c8bbad31..7841fdfd63 100644 --- a/erts/doc/src/erl_tracer.xml +++ b/erts/doc/src/erl_tracer.xml @@ -67,7 +67,7 @@

The different trace tags that the tracer will be called with. Each trace tag is described in greater detail in - Module:trace/6 + Module:trace/5

@@ -84,14 +84,18 @@

The options for the tracee.

timestamp - If not set to undefined, the tracer has been requested to - include a timestamp. + If set the tracer has been requested to include a timestamp. + extra + If set the tracepoint has included additonal data about + the trace event. What the additional data is depends on which + TraceTag has been triggered. The extra trace data + corresponds to the fifth elemnt in the trace tuples described in + erlang:trace/3. match_spec_result - If not set to true, the tracer has been requested to - include the output of a match specification that was run. + If set the tracer has been requested to include the output + of a match specification that was run. scheduler_id - Set to a number if the scheduler id is to be included by the tracer. - Otherwise it is set to undefined. + Set the scheduler id is to be included by the tracer. @@ -115,23 +119,23 @@ Module:enabled/3 Mandatory - Module:trace/6 + Module:trace/5 Mandatory Module:enabled_procs/3 Optional - Module:trace_procs/6 + Module:trace_procs/5 Optional Module:enabled_ports/3 Optional - Module:trace_ports/6 + Module:trace_ports/5 Optional Module:enabled_running_ports/3 Optional - Module:trace_running_ports/6 + Module:trace_running_ports/5 Optional Module:enabled_running_procs/3 Optional - Module:trace_running_procs/6 + Module:trace_running_procs/5 Optional @@ -166,14 +170,13 @@ - Module:trace(TraceTag, TracerState, Tracee, FirstTraceTerm, SecondTraceTerm, Opts) -> Result + Module:trace(TraceTag, TracerState, Tracee, TraceTerm, Opts) -> Result Check if a trace event should be generated. TraceTag = trace_tag() TracerState = term() Tracee = tracee() FirstTraceTerm = term() - SecondTraceTerm = term() | undefined Opts = trace_opts() Result = ok @@ -182,17 +185,17 @@ the Module:enabled/3 callback returned trace. In it any side effects needed by the tracer should be done. The tracepoint payload is located in - the FirstTraceTerm and SecondTraceTerm. The content - of the TraceTerms depends on which TraceTag has been triggered. - The FirstTraceTerm and SecondTraceTerm correspond to the - fourth and fifth slot in the trace tuples described in + the TraceTerm. The content of the TraceTerm depends on which + TraceTag has been triggered. + The TraceTerm corresponds to the + fourth element in the trace tuples described in erlang:trace/3. - If the tuple only has four elements, SecondTraceTerm will be - undefined.

+ If the trace tuple has five elements, the fifth element will be sent as + the extra value in the Opts maps.

- Module:trace(seq_trace, TracerState, Label, SeqTraceInfo, undefined, Opts) -> Result + Module:trace(seq_trace, TracerState, Label, SeqTraceInfo, Opts) -> Result Check if a sequence trace event should be generated. TracerState = term() @@ -228,14 +231,13 @@ - Module:trace_procs(TraceTag, TracerState, Tracee, FirstTraceTerm, SecondTraceTerm, Opts) -> Result + Module:trace_procs(TraceTag, TracerState, Tracee, TraceTerm, Opts) -> Result Check if a trace event should be generated. TraceTag = trace_tag() TracerState = term() Tracee = tracee() FirstTraceTerm = term() - SecondTraceTerm = term() | undefined Opts = trace_opts() Result = ok @@ -243,7 +245,7 @@

This callback will be called when a tracepoint is triggered and the Module:enabled_procs/3 callback returned trace.

-

If trace_procs/6 is not defined trace/6 will be called instead.

+

If trace_procs/5 is not defined trace/5 will be called instead.

@@ -265,14 +267,13 @@ - Module:trace_ports(TraceTag, TracerState, Tracee, FirstTraceTerm, SecondTraceTerm, Opts) -> Result + Module:trace_ports(TraceTag, TracerState, Tracee, TraceTerm, Opts) -> Result Check if a trace event should be generated. TraceTag = trace_tag() TracerState = term() Tracee = tracee() FirstTraceTerm = term() - SecondTraceTerm = term() | undefined Opts = trace_opts() Result = ok @@ -280,7 +281,7 @@

This callback will be called when a tracepoint is triggered and the Module:enabled_ports/3 callback returned trace.

-

If trace_ports/6 is not defined trace/6 will be called instead.

+

If trace_ports/5 is not defined trace/5 will be called instead.

@@ -302,14 +303,13 @@ - Module:trace_running_procs(TraceTag, TracerState, Tracee, FirstTraceTerm, SecondTraceTerm, Opts) -> Result + Module:trace_running_procs(TraceTag, TracerState, Tracee, TraceTerm, Opts) -> Result Check if a trace event should be generated. TraceTag = trace_tag_running_procs() TracerState = term() Tracee = tracee() FirstTraceTerm = term() - SecondTraceTerm = term() | undefined Opts = trace_opts() Result = ok @@ -317,7 +317,7 @@

This callback will be called when a tracepoint is triggered and the Module:enabled_running_procs/3 callback returned trace.

-

If trace_running_procs/6 is not defined trace/6 will be called instead.

+

If trace_running_procs/5 is not defined trace/5 will be called instead.

@@ -339,14 +339,13 @@ - Module:trace_running_ports(TraceTag, TracerState, Tracee, FirstTraceTerm, SecondTraceTerm, Opts) -> Result + Module:trace_running_ports(TraceTag, TracerState, Tracee, TraceTerm, Opts) -> Result Check if a trace event should be generated. TraceTag = trace_tag_running_ports() TracerState = term() Tracee = tracee() FirstTraceTerm = term() - SecondTraceTerm = term() | undefined Opts = trace_opts() Result = ok @@ -354,7 +353,7 @@

This callback will be called when a tracepoint is triggered and the Module:enabled_running_ports/3 callback returned trace.

-

If trace_running_ports/6 is not defined trace/6 will be called instead.

+

If trace_running_ports/5 is not defined trace/5 will be called instead.

@@ -376,14 +375,13 @@ - Module:trace_call(TraceTag, TracerState, Tracee, FirstTraceTerm, SecondTraceTerm, Opts) -> Result + Module:trace_call(TraceTag, TracerState, Tracee, TraceTerm, Opts) -> Result Check if a trace event should be generated. TraceTag = trace_tag_call() TracerState = term() Tracee = tracee() FirstTraceTerm = term() - SecondTraceTerm = term() | undefined Opts = trace_opts() Result = ok @@ -391,7 +389,7 @@

This callback will be called when a tracepoint is triggered and the Module:enabled_call/3 callback returned trace.

-

If trace_call/6 is not defined trace/6 will be called instead.

+

If trace_call/5 is not defined trace/5 will be called instead.

@@ -413,14 +411,13 @@ - Module:trace_send(TraceTag, TracerState, Tracee, FirstTraceTerm, SecondTraceTerm, Opts) -> Result + Module:trace_send(TraceTag, TracerState, Tracee, TraceTerm, Opts) -> Result Check if a trace event should be generated. TraceTag = trace_tag_send() TracerState = term() Tracee = tracee() FirstTraceTerm = term() - SecondTraceTerm = term() | undefined Opts = trace_opts() Result = ok @@ -428,7 +425,7 @@

This callback will be called when a tracepoint is triggered and the Module:enabled_send/3 callback returned trace.

-

If trace_send/6 is not defined trace/6 will be called instead.

+

If trace_send/5 is not defined trace/5 will be called instead.

@@ -450,14 +447,13 @@ - Module:trace_receive(TraceTag, TracerState, Tracee, FirstTraceTerm, SecondTraceTerm, Opts) -> Result + Module:trace_receive(TraceTag, TracerState, Tracee, TraceTerm, Opts) -> Result Check if a trace event should be generated. TraceTag = trace_tag_receive() TracerState = term() Tracee = tracee() FirstTraceTerm = term() - SecondTraceTerm = term() | undefined Opts = trace_opts() Result = ok @@ -465,7 +461,7 @@

This callback will be called when a tracepoint is triggered and the Module:enabled_receive/3 callback returned trace.

-

If trace_receive/6 is not defined trace/6 will be called instead.

+

If trace_receive/5 is not defined trace/5 will be called instead.

@@ -487,14 +483,13 @@ - Module:trace_garbage_collection(TraceTag, TracerState, Tracee, FirstTraceTerm, SecondTraceTerm, Opts) -> Result + Module:trace_garbage_collection(TraceTag, TracerState, Tracee, TraceTerm, Opts) -> Result Check if a trace event should be generated. TraceTag = trace_tag_gc() TracerState = term() Tracee = tracee() FirstTraceTerm = term() - SecondTraceTerm = term() | undefined Opts = trace_opts() Result = ok @@ -502,7 +497,7 @@

This callback will be called when a tracepoint is triggered and the Module:enabled_garbage_collection/3 callback returned trace.

-

If trace_garbage_collection/6 is not defined trace/6 will be called instead.

+

If trace_garbage_collection/5 is not defined trace/5 will be called instead.

@@ -543,7 +538,7 @@ ok
 -module(erl_msg_tracer).
 
--export([enabled/3, trace/6, load/0]).
+-export([enabled/3, trace/5, load/0]).
 
 load() ->
     erlang:load_nif("erl_msg_tracer", []).
@@ -551,7 +546,7 @@ load() ->
 enabled(_, _, _) ->
     error.
 
-trace(_, _, _,_, _, _) ->
+trace(_, _, _,_, _) ->
     error.
     

erl_msg_tracer.c

@@ -569,7 +564,7 @@ static ERL_NIF_TERM trace(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]); static ErlNifFunc nif_funcs[] = { {"enabled", 3, enabled}, - {"trace", 6, trace} + {"trace", 5, trace} }; ERL_NIF_INIT(erl_msg_tracer, nif_funcs, load, NULL, upgrade, unload) @@ -632,9 +627,8 @@ static ERL_NIF_TERM enabled(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) * argv[0]: TraceTag, should only be 'send' * argv[1]: TracerState, process to send {argv[2], argv[4]} to * argv[2]: Tracee - * argv[3]: Message, ignored - * argv[4]: Recipient - * argv[5]: Options, ignored + * argv[3]: Recipient + * argv[4]: Options, ignored */ static ERL_NIF_TERM trace(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { -- cgit v1.2.3