diff options
author | Björn-Egil Dahlberg <[email protected]> | 2016-04-20 11:47:16 +0200 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2016-04-29 18:31:36 +0200 |
commit | a80b7eeb9927309cdbc68296ca9892486a3a8707 (patch) | |
tree | 6373054b1d5a283f8ea76204938b948d6b147c2d | |
parent | 4e2a61519f022a85e7774d9be65067d33256cb01 (diff) | |
download | otp-a80b7eeb9927309cdbc68296ca9892486a3a8707.tar.gz otp-a80b7eeb9927309cdbc68296ca9892486a3a8707.tar.bz2 otp-a80b7eeb9927309cdbc68296ca9892486a3a8707.zip |
runtime_tools: Extend 'trace' and 'enabled' tracer callbacks
Adds the following capabilities to dyntrace
* enabled_running_ports/3
* enabled_running_procs/3 changed from enabled_running/3
* trace_running_ports/6
* trace_running_procs/6 changed from trace_running/6
-rw-r--r-- | lib/runtime_tools/c_src/dyntrace.c | 56 | ||||
-rw-r--r-- | lib/runtime_tools/c_src/dyntrace_lttng.h | 15 | ||||
-rw-r--r-- | lib/runtime_tools/src/dyntrace.erl | 16 |
3 files changed, 74 insertions, 13 deletions
diff --git a/lib/runtime_tools/c_src/dyntrace.c b/lib/runtime_tools/c_src/dyntrace.c index 58a20691f7..773a5f67ec 100644 --- a/lib/runtime_tools/c_src/dyntrace.c +++ b/lib/runtime_tools/c_src/dyntrace.c @@ -72,7 +72,8 @@ static ERL_NIF_TERM trace(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]); #ifdef HAVE_USE_LTTNG static ERL_NIF_TERM trace_procs(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]); static ERL_NIF_TERM trace_ports(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]); -static ERL_NIF_TERM trace_running(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]); +static ERL_NIF_TERM trace_running_procs(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]); +static ERL_NIF_TERM trace_running_ports(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]); static ERL_NIF_TERM trace_call(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]); static ERL_NIF_TERM trace_send(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]); static ERL_NIF_TERM trace_receive(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]); @@ -80,7 +81,8 @@ static ERL_NIF_TERM trace_garbage_collection(ErlNifEnv* env, int argc, const ERL static ERL_NIF_TERM enabled_procs(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]); static ERL_NIF_TERM enabled_ports(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]); -static ERL_NIF_TERM enabled_running(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]); +static ERL_NIF_TERM enabled_running_procs(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]); +static ERL_NIF_TERM enabled_running_ports(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]); static ERL_NIF_TERM enabled_call(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]); static ERL_NIF_TERM enabled_send(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]); static ERL_NIF_TERM enabled_receive(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]); @@ -96,14 +98,16 @@ static ErlNifFunc nif_funcs[] = { #ifdef HAVE_USE_LTTNG {"trace_procs", 6, trace_procs}, {"trace_ports", 6, trace_ports}, - {"trace_running", 6, trace_running}, + {"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}, {"enabled_procs", 3, enabled_procs}, {"enabled_ports", 3, enabled_ports}, - {"enabled_running", 3, enabled_running}, + {"enabled_running_procs", 3, enabled_running_procs}, + {"enabled_running_ports", 3, enabled_running_ports}, {"enabled_call", 3, enabled_call}, {"enabled_send", 3, enabled_send}, {"enabled_receive", 3, enabled_receive}, @@ -677,7 +681,7 @@ static ERL_NIF_TERM trace_ports(ErlNifEnv* env, int argc, const ERL_NIF_TERM arg return atom_ok; } -static ERL_NIF_TERM enabled_running(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[]) +static ERL_NIF_TERM enabled_running_procs(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[]) { ASSERT(argc == 3); @@ -687,15 +691,15 @@ static ERL_NIF_TERM enabled_running(ErlNifEnv *env, int argc, const ERL_NIF_TERM return atom_discard; } -static ERL_NIF_TERM trace_running(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) +static ERL_NIF_TERM trace_running_procs(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { lttng_decl_procbuf(pid); const ERL_NIF_TERM* tuple; char *mfastr = "undefined"; int arity; + lttng_decl_mfabuf(mfa); lttng_pid_to_str(argv[2], pid); - lttng_decl_mfabuf(mfa); if (enif_get_tuple(env, argv[3], &arity, &tuple)) { int val; @@ -703,8 +707,7 @@ static ERL_NIF_TERM trace_running(ErlNifEnv* env, int argc, const ERL_NIF_TERM a lttng_mfa_to_str(tuple[0], tuple[1], val, mfa); mfastr = mfa; } - - /* running */ + /* running processes */ if (argv[0] == atom_in) { LTTNG3(process_scheduled, pid, mfastr, "in"); } else if (argv[0] == atom_out) { @@ -717,6 +720,41 @@ static ERL_NIF_TERM trace_running(ErlNifEnv* env, int argc, const ERL_NIF_TERM a } else if (argv[0] == atom_out_exited) { LTTNG3(process_scheduled, pid, mfastr, "out_exited"); } + + return atom_ok; +} + +static ERL_NIF_TERM enabled_running_ports(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[]) +{ + ASSERT(argc == 3); + + if (LTTNG_ENABLED(port_scheduled)) + return atom_trace; + + return atom_discard; +} + +static ERL_NIF_TERM trace_running_ports(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) +{ + lttng_decl_procbuf(pid); + lttng_decl_mfabuf(where); + + lttng_portid_to_str(argv[2], pid); + erts_snprintf(where, LTTNG_BUFFER_SZ, "%T", argv[3]); + + /* running ports */ + if (argv[0] == atom_in) { + LTTNG3(port_scheduled, pid, where, "in"); + } else if (argv[0] == atom_out) { + LTTNG3(port_scheduled, pid, where, "out"); + /* exiting */ + } else if (argv[0] == atom_in_exiting) { + LTTNG3(port_scheduled, pid, where, "in_exiting"); + } else if (argv[0] == atom_out_exiting) { + LTTNG3(port_scheduled, pid, where, "out_exiting"); + } else if (argv[0] == atom_out_exited) { + LTTNG3(port_scheduled, pid, where, "out_exited"); + } return atom_ok; } #endif diff --git a/lib/runtime_tools/c_src/dyntrace_lttng.h b/lib/runtime_tools/c_src/dyntrace_lttng.h index 541a6c16e8..3550a1cab5 100644 --- a/lib/runtime_tools/c_src/dyntrace_lttng.h +++ b/lib/runtime_tools/c_src/dyntrace_lttng.h @@ -196,6 +196,21 @@ TRACEPOINT_EVENT( ) ) +TRACEPOINT_EVENT( + com_ericsson_dyntrace, + port_scheduled, + TP_ARGS( + char*, p, + char*, op, + char*, type + ), + TP_FIELDS( + ctf_string(pid, p) + ctf_string(entry, op) + ctf_string(type, type) + ) +) + /* Call tracing */ TRACEPOINT_EVENT( diff --git a/lib/runtime_tools/src/dyntrace.erl b/lib/runtime_tools/src/dyntrace.erl index 8a449e5749..28e6d67d96 100644 --- a/lib/runtime_tools/src/dyntrace.erl +++ b/lib/runtime_tools/src/dyntrace.erl @@ -45,7 +45,8 @@ trace/6, trace_procs/6, trace_ports/6, - trace_running/6, + trace_running_procs/6, + trace_running_ports/6, trace_call/6, trace_send/6, trace_receive/6, @@ -53,7 +54,8 @@ -export([enabled_procs/3, enabled_ports/3, - enabled_running/3, + enabled_running_procs/3, + enabled_running_ports/3, enabled_call/3, enabled_send/3, enabled_receive/3, @@ -157,7 +159,10 @@ trace_procs(_TraceTag, _TracerState, _Tracee, _FirstTraceTerm, _SecondTraceTerm, trace_ports(_TraceTag, _TracerState, _Tracee, _FirstTraceTerm, _SecondTraceTerm, _Opts) -> erlang:nif_error(nif_not_loaded). -trace_running(_TraceTag, _TracerState, _Tracee, _FirstTraceTerm, _SecondTraceTerm, _Opts) -> +trace_running_procs(_TraceTag, _TracerState, _Tracee, _FirstTraceTerm, _SecondTraceTerm, _Opts) -> + erlang:nif_error(nif_not_loaded). + +trace_running_ports(_TraceTag, _TracerState, _Tracee, _FirstTraceTerm, _SecondTraceTerm, _Opts) -> erlang:nif_error(nif_not_loaded). trace_call(_TraceTag, _TracerState, _Tracee, _FirstTraceTerm, _SecondTraceTerm, _Opts) -> @@ -181,7 +186,10 @@ enabled_procs(_TraceTag, _TracerState, _Tracee) -> enabled_ports(_TraceTag, _TracerState, _Tracee) -> erlang:nif_error(nif_not_loaded). -enabled_running(_TraceTag, _TracerState, _Tracee) -> +enabled_running_procs(_TraceTag, _TracerState, _Tracee) -> + erlang:nif_error(nif_not_loaded). + +enabled_running_ports(_TraceTag, _TracerState, _Tracee) -> erlang:nif_error(nif_not_loaded). enabled_call(_TraceTag, _TracerState, _Tracee) -> |