diff options
author | Lukas Larsson <[email protected]> | 2016-05-19 10:54:43 +0200 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2016-05-24 10:42:16 +0200 |
commit | 115f0ba77ad7d01ab95fd9f9bbeca53f04f12284 (patch) | |
tree | c7134ee895b23d8160440cec7dd1598b1f689de3 /lib/runtime_tools | |
parent | 0bc0e3e51a4229245c4111667eec9133a1a8984c (diff) | |
download | otp-115f0ba77ad7d01ab95fd9f9bbeca53f04f12284.tar.gz otp-115f0ba77ad7d01ab95fd9f9bbeca53f04f12284.tar.bz2 otp-115f0ba77ad7d01ab95fd9f9bbeca53f04f12284.zip |
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.
Diffstat (limited to 'lib/runtime_tools')
-rw-r--r-- | lib/runtime_tools/c_src/dyntrace.c | 43 | ||||
-rw-r--r-- | lib/runtime_tools/src/dyntrace.erl | 38 |
2 files changed, 44 insertions, 37 deletions
diff --git a/lib/runtime_tools/c_src/dyntrace.c b/lib/runtime_tools/c_src/dyntrace.c index e7a4a73373..3d2de9c21c 100644 --- a/lib/runtime_tools/c_src/dyntrace.c +++ b/lib/runtime_tools/c_src/dyntrace.c @@ -96,14 +96,14 @@ static ErlNifFunc nif_funcs[] = { {"user_trace_i4s4", 9, user_trace_i4s4}, {"user_trace_n", 10, user_trace_n}, #ifdef HAVE_USE_LTTNG - {"trace_procs", 6, trace_procs}, - {"trace_ports", 6, trace_ports}, - {"trace_running_procs", 6, trace_running_procs}, - {"trace_running_ports", 6, trace_running_ports}, - {"trace_call", 6, trace_call}, - {"trace_send", 6, trace_send}, - {"trace_receive", 6, trace_receive}, - {"trace_garbage_collection", 6, trace_garbage_collection}, + {"trace_procs", 5, trace_procs}, + {"trace_ports", 5, trace_ports}, + {"trace_running_procs", 5, trace_running_procs}, + {"trace_running_ports", 5, trace_running_ports}, + {"trace_call", 5, trace_call}, + {"trace_send", 5, trace_send}, + {"trace_receive", 5, trace_receive}, + {"trace_garbage_collection", 5, trace_garbage_collection}, {"enabled_procs", 3, enabled_procs}, {"enabled_ports", 3, enabled_ports}, {"enabled_running_procs", 3, enabled_running_procs}, @@ -114,8 +114,7 @@ static ErlNifFunc nif_funcs[] = { {"enabled_garbage_collection", 3, enabled_garbage_collection}, #endif {"enabled", 3, enabled}, - {"trace", 5, trace}, - {"trace", 6, trace} + {"trace", 5, trace} }; ERL_NIF_INIT(dyntrace, nif_funcs, load, NULL, NULL, NULL) @@ -123,6 +122,7 @@ ERL_NIF_INIT(dyntrace, nif_funcs, load, NULL, NULL, NULL) static ERL_NIF_TERM atom_true; static ERL_NIF_TERM atom_false; static ERL_NIF_TERM atom_error; +static ERL_NIF_TERM atom_extra; static ERL_NIF_TERM atom_not_available; static ERL_NIF_TERM atom_badarg; static ERL_NIF_TERM atom_ok; @@ -187,6 +187,7 @@ static int load(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM load_info) atom_true = enif_make_atom(env,"true"); atom_false = enif_make_atom(env,"false"); atom_error = enif_make_atom(env,"error"); + atom_extra = enif_make_atom(env,"extra"); atom_not_available = enif_make_atom(env,"not_available"); atom_badarg = enif_make_atom(env,"badarg"); atom_ok = enif_make_atom(env,"ok"); @@ -325,7 +326,7 @@ static ERL_NIF_TERM trace_garbage_collection(ErlNifEnv* env, int argc, const ERL int arity; unsigned long ohbsz, nhbsz, size; - ASSERT(argc == 6); + ASSERT(argc == 5); /* Assume gc info order does not change */ gci = argv[3]; @@ -428,11 +429,13 @@ static ERL_NIF_TERM trace_call(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv } } else if (argv[0] == atom_exception_from) { const ERL_NIF_TERM* tuple; + ERL_NIF_TERM extra; int arity; lttng_decl_mfabuf(mfa); char class[LTTNG_BUFFER_SZ]; - enif_get_tuple(env, argv[4], &arity, &tuple); + enif_get_map_value(env, argv[4], atom_extra, &extra); + enif_get_tuple(env, extra, &arity, &tuple); enif_snprintf(class, LTTNG_BUFFER_SZ, "%T", tuple[0]); if (enif_get_tuple(env, argv[3], &arity, &tuple)) { @@ -457,14 +460,17 @@ static ERL_NIF_TERM enabled_send(ErlNifEnv *env, int argc, const ERL_NIF_TERM ar static ERL_NIF_TERM trace_send(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { + ERL_NIF_TERM extra; lttng_decl_procbuf(pid); lttng_pid_to_str(argv[2], pid); + enif_get_map_value(env, argv[4], atom_extra, &extra); + if (argv[0] == atom_send) { lttng_decl_procbuf(to); char msg[LTTNG_BUFFER_SZ]; - lttng_pid_to_str(argv[4], to); + lttng_pid_to_str(extra, to); enif_snprintf(msg, LTTNG_BUFFER_SZ, "%T", argv[3]); LTTNG3(message_send, pid, to, msg); @@ -472,7 +478,7 @@ static ERL_NIF_TERM trace_send(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv lttng_decl_procbuf(to); char msg[LTTNG_BUFFER_SZ]; - lttng_pid_to_str(argv[4], to); + lttng_pid_to_str(extra, to); enif_snprintf(msg, LTTNG_BUFFER_SZ, "%T", argv[3]); /* mark it as non existing ? */ @@ -537,6 +543,7 @@ static ERL_NIF_TERM trace_procs(ErlNifEnv* env, int argc, const ERL_NIF_TERM arg /* spawn */ if (argv[0] == atom_spawn) { + ERL_NIF_TERM extra; char undef[] = "undefined"; const ERL_NIF_TERM* tuple; int arity; @@ -545,7 +552,9 @@ static ERL_NIF_TERM trace_procs(ErlNifEnv* env, int argc, const ERL_NIF_TERM arg lttng_pid_to_str(argv[3], to); - if (enif_get_tuple(env, argv[4], &arity, &tuple)) { + enif_get_map_value(env, argv[4], atom_extra, &extra); + + if (enif_get_tuple(env, extra, &arity, &tuple)) { if (enif_is_list(env, tuple[2])) { enif_get_list_length(env, tuple[2], &len); } else { @@ -618,11 +627,13 @@ static ERL_NIF_TERM trace_ports(ErlNifEnv* env, int argc, const ERL_NIF_TERM arg /* open and closed */ if (argv[0] == atom_open) { + ERL_NIF_TERM extra; char driver[LTTNG_BUFFER_SZ]; lttng_decl_procbuf(pid); lttng_pid_to_str(argv[3], pid); + enif_get_map_value(env, argv[4], atom_extra, &extra); - enif_snprintf(driver, LTTNG_BUFFER_SZ, "%T", argv[4]); + enif_snprintf(driver, LTTNG_BUFFER_SZ, "%T", extra); LTTNG3(port_open, pid, driver, port); } else if (argv[0] == atom_closed) { char reason[LTTNG_BUFFER_SZ]; diff --git a/lib/runtime_tools/src/dyntrace.erl b/lib/runtime_tools/src/dyntrace.erl index 28e6d67d96..58c5a773c3 100644 --- a/lib/runtime_tools/src/dyntrace.erl +++ b/lib/runtime_tools/src/dyntrace.erl @@ -42,15 +42,14 @@ -export([put_tag/1, get_tag/0, get_tag_data/0, spread_tag/1, restore_tag/1]). -export([trace/5, - trace/6, - trace_procs/6, - trace_ports/6, - trace_running_procs/6, - trace_running_ports/6, - trace_call/6, - trace_send/6, - trace_receive/6, - trace_garbage_collection/6]). + trace_procs/5, + trace_ports/5, + trace_running_procs/5, + trace_running_ports/5, + trace_call/5, + trace_send/5, + trace_receive/5, + trace_garbage_collection/5]). -export([enabled_procs/3, enabled_ports/3, @@ -147,34 +146,31 @@ user_trace_i4s4(_, _, _, _, _, _, _, _, _) -> user_trace_n(_, _, _, _, _, _, _, _, _, _) -> erlang:nif_error(nif_not_loaded). -trace(_TracerState, _Label, _SeqTraceInfo, _, _Opts) -> +trace(_TraceTag, _TracerState, _Tracee, _TraceTerm, _Opts) -> erlang:nif_error(nif_not_loaded). -trace(_TraceTag, _TracerState, _Tracee, _FirstTraceTerm, _SecondTraceTerm, _Opts) -> +trace_procs(_TraceTag, _TracerState, _Tracee, _TraceTerm, _Opts) -> erlang:nif_error(nif_not_loaded). -trace_procs(_TraceTag, _TracerState, _Tracee, _FirstTraceTerm, _SecondTraceTerm, _Opts) -> +trace_ports(_TraceTag, _TracerState, _Tracee, _TraceTerm, _Opts) -> erlang:nif_error(nif_not_loaded). -trace_ports(_TraceTag, _TracerState, _Tracee, _FirstTraceTerm, _SecondTraceTerm, _Opts) -> +trace_running_procs(_TraceTag, _TracerState, _Tracee, _TraceTerm, _Opts) -> erlang:nif_error(nif_not_loaded). -trace_running_procs(_TraceTag, _TracerState, _Tracee, _FirstTraceTerm, _SecondTraceTerm, _Opts) -> +trace_running_ports(_TraceTag, _TracerState, _Tracee, _TraceTerm, _Opts) -> erlang:nif_error(nif_not_loaded). -trace_running_ports(_TraceTag, _TracerState, _Tracee, _FirstTraceTerm, _SecondTraceTerm, _Opts) -> +trace_call(_TraceTag, _TracerState, _Tracee, _TraceTerm, _Opts) -> erlang:nif_error(nif_not_loaded). -trace_call(_TraceTag, _TracerState, _Tracee, _FirstTraceTerm, _SecondTraceTerm, _Opts) -> +trace_send(_TraceTag, _TracerState, _Tracee, _TraceTerm, _Opts) -> erlang:nif_error(nif_not_loaded). -trace_send(_TraceTag, _TracerState, _Tracee, _FirstTraceTerm, _SecondTraceTerm, _Opts) -> +trace_receive(_TraceTag, _TracerState, _Tracee, _TraceTerm, _Opts) -> erlang:nif_error(nif_not_loaded). -trace_receive(_TraceTag, _TracerState, _Tracee, _FirstTraceTerm, _SecondTraceTerm, _Opts) -> - erlang:nif_error(nif_not_loaded). - -trace_garbage_collection(_TraceTag, _TracerState, _Tracee, _FirstTraceTerm, _SecondTraceTerm, _Opts) -> +trace_garbage_collection(_TraceTag, _TracerState, _Tracee, _TraceTerm, _Opts) -> erlang:nif_error(nif_not_loaded). enabled(_TraceTag, _TracerState, _Tracee) -> |