aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2016-03-03 14:03:45 +0100
committerBjörn-Egil Dahlberg <[email protected]>2016-04-29 18:31:34 +0200
commitd4c938686562d3c5ccf6a34aafeef6460b9b88f8 (patch)
tree4e0d9ce43afd6fe10a0e8d04d2d7b6300e31e758
parentb36c6d949916e1d7b0f6bee17004c012e6a36112 (diff)
downloadotp-d4c938686562d3c5ccf6a34aafeef6460b9b88f8.tar.gz
otp-d4c938686562d3c5ccf6a34aafeef6460b9b88f8.tar.bz2
otp-d4c938686562d3c5ccf6a34aafeef6460b9b88f8.zip
runtime_tools: Add lttng 'send' and 'receive' tracing
-rw-r--r--lib/runtime_tools/c_src/dyntrace.c132
-rw-r--r--lib/runtime_tools/c_src/dyntrace_lttng.h30
2 files changed, 79 insertions, 83 deletions
diff --git a/lib/runtime_tools/c_src/dyntrace.c b/lib/runtime_tools/c_src/dyntrace.c
index 4abe4f80ac..0be72848e6 100644
--- a/lib/runtime_tools/c_src/dyntrace.c
+++ b/lib/runtime_tools/c_src/dyntrace.c
@@ -126,6 +126,12 @@ static ERL_NIF_TERM atom_in_exiting;
static ERL_NIF_TERM atom_out_exiting;
static ERL_NIF_TERM atom_out_exited;
+/* process messages 'send' and 'receive' */
+
+static ERL_NIF_TERM atom_send;
+static ERL_NIF_TERM atom_receive;
+static ERL_NIF_TERM atom_send_to_non_existing_process;
+
static int load(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM load_info)
{
@@ -164,6 +170,12 @@ static int load(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM load_info)
atom_out_exiting = enif_make_atom(env,"out_exiting");
atom_out_exited = enif_make_atom(env,"out_exited");
+ /* process messages 'send' and 'receive' */
+
+ atom_send = enif_make_atom(env,"send");
+ atom_receive = enif_make_atom(env,"receive");
+ atom_send_to_non_existing_process = enif_make_atom(env,"send_to_non_existing_process");
+
return 0;
}
@@ -300,106 +312,60 @@ static ERL_NIF_TERM trace_garbage_collection(ErlNifEnv* env, int argc, const ERL
}
-static ERL_NIF_TERM trace_receive(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
+static ERL_NIF_TERM trace_send(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
#ifdef HAVE_USE_DTRACE
-#define BUFF_SIZE 1024
- size_t sz = BUFF_SIZE;
- char buff[BUFF_SIZE];
- ASSERT(argc == 6);
-
- if (argv[0] == atom_seq_trace) {
- if (erlang_trace_seq_enabled()) {
- char *label = buff,
- *seq_info = buff + BUFF_SIZE/4;
- erts_snprintf(label, 1*BUFF_SIZE/4, "%T", argv[2]);
- erts_snprintf(seq_info, 3*BUFF_SIZE/4, "%T", argv[3]);
- erlang_trace_seq(label, seq_info);
- }
- } else {
- char *event, p[DTRACE_TERM_BUF_SIZE], state, arg1, arg2, arg3;
-
- event = buff + BUFF_SIZE - sz;
- sz -= enif_get_atom(env, argv[0], event, sz, ERL_NIF_LATIN1);
-
- state = buff + BUFF_SIZE - sz;
- sz -= erts_snprintf(state, sz, "%T", argv[1]);
+#elif HAVE_USE_LTTNG
+ lttng_decl_procbuf(pid);
+ lttng_pid_to_str(argv[2], pid);
- if (enif_is_pid(argv[2]) || enif_is_port(argv[2]))
- dtrace_pid_str(argv[2], p);
- else
- p = NULL;
+ if (argv[0] == atom_send) {
+ lttng_decl_procbuf(to);
+ char msg[LTTNG_BUFFER_SZ];
- arg1 = buff + BUFF_SIZE - sz;
- sz -= erts_snprintf(arg1, sz, "%T", argv[3]);
+ lttng_pid_to_str(argv[4], to);
+ erts_snprintf(msg, LTTNG_BUFFER_SZ, "%T", argv[3]);
- if (argc == 6) {
- arg2 = buff + BUFF_SIZE - sz;
- sz -= erts_snprintf(arg2, sz, "%T", argv[4]);
- } else
- args2 = NULL;
+ LTTNG3(message_send, pid, to, msg);
+ } else if (argv[0] == atom_send_to_non_existing_process) {
+ lttng_decl_procbuf(to);
+ char msg[LTTNG_BUFFER_SZ];
- erlang_trace(p, event, state, arg1, arg2);
+ lttng_pid_to_str(argv[4], to);
+ erts_snprintf(msg, LTTNG_BUFFER_SZ, "%T", argv[3]);
+ /* mark it as non existing ? */
- }
-#elif HAVE_USE_LTTNG
- int i;
- erts_fprintf(stderr, "receive trace:\r\n");
- for (i = 0; i < argc; i++) {
- erts_fprintf(stderr, " %T\r\n", argv[i]);
+ LTTNG3(message_send, pid, to, msg);
+ } else {
+ int i;
+ erts_fprintf(stderr, "trace send:\r\n");
+ for (i = 0; i < argc; i++) {
+ erts_fprintf(stderr, " %T\r\n", argv[i]);
+ }
}
#endif
return atom_ok;
}
-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[])
{
#ifdef HAVE_USE_DTRACE
-#define BUFF_SIZE 1024
- size_t sz = BUFF_SIZE;
- char buff[BUFF_SIZE];
- ASSERT(argc == 6);
-
- if (argv[0] == atom_seq_trace) {
- if (erlang_trace_seq_enabled()) {
- char *label = buff,
- *seq_info = buff + BUFF_SIZE/4;
- erts_snprintf(label, 1*BUFF_SIZE/4, "%T", argv[2]);
- erts_snprintf(seq_info, 3*BUFF_SIZE/4, "%T", argv[3]);
- erlang_trace_seq(label, seq_info);
- }
- } else {
- char *event, p[DTRACE_TERM_BUF_SIZE], state, arg1, arg2, arg3;
-
- event = buff + BUFF_SIZE - sz;
- sz -= enif_get_atom(env, argv[0], event, sz, ERL_NIF_LATIN1);
-
- state = buff + BUFF_SIZE - sz;
- sz -= erts_snprintf(state, sz, "%T", argv[1]);
-
- if (enif_is_pid(argv[2]) || enif_is_port(argv[2]))
- dtrace_pid_str(argv[2], p);
- else
- p = NULL;
+#elif HAVE_USE_LTTNG
+ if (argv[0] == atom_receive) {
+ lttng_decl_procbuf(pid);
+ char msg[LTTNG_BUFFER_SZ];
- arg1 = buff + BUFF_SIZE - sz;
- sz -= erts_snprintf(arg1, sz, "%T", argv[3]);
+ lttng_pid_to_str(argv[2], pid);
+ erts_snprintf(msg, LTTNG_BUFFER_SZ, "%T", argv[3]);
- if (argc == 6) {
- arg2 = buff + BUFF_SIZE - sz;
- sz -= erts_snprintf(arg2, sz, "%T", argv[4]);
- } else
- args2 = NULL;
-
- erlang_trace(p, event, state, arg1, arg2);
-
- }
-#elif HAVE_USE_LTTNG
- int i;
- erts_fprintf(stderr, "trace:\r\n");
- for (i = 0; i < argc; i++) {
- erts_fprintf(stderr, " %T\r\n", argv[i]);
+ LTTNG2(message_receive, pid, msg);
+ } else {
+ int i;
+ erts_fprintf(stderr, "trace receive:\r\n");
+ for (i = 0; i < argc; i++) {
+ erts_fprintf(stderr, " %T\r\n", argv[i]);
+ }
}
#endif
return atom_ok;
diff --git a/lib/runtime_tools/c_src/dyntrace_lttng.h b/lib/runtime_tools/c_src/dyntrace_lttng.h
index 1271f7516a..03cf8a27c1 100644
--- a/lib/runtime_tools/c_src/dyntrace_lttng.h
+++ b/lib/runtime_tools/c_src/dyntrace_lttng.h
@@ -147,6 +147,36 @@ TRACEPOINT_EVENT(
)
)
+/* Process messages */
+
+TRACEPOINT_EVENT(
+ com_ericsson_dyntrace,
+ message_send,
+ TP_ARGS(
+ char*, sender,
+ char*, receiver,
+ char*, msg
+ ),
+ TP_FIELDS(
+ ctf_string(from, sender)
+ ctf_string(to, receiver)
+ ctf_string(message, msg)
+ )
+)
+
+TRACEPOINT_EVENT(
+ com_ericsson_dyntrace,
+ message_receive,
+ TP_ARGS(
+ char*, receiver,
+ char*, msg
+ ),
+ TP_FIELDS(
+ ctf_string(to, receiver)
+ ctf_string(message, msg)
+ )
+)
+
/* Process Memory */
TRACEPOINT_EVENT(