Skip to content

Commit

Permalink
Added some firings of the percept-trace D probe (spawn, exit, active/…
Browse files Browse the repository at this point in the history
…inactive, link, getting unlinked).
  • Loading branch information
k4t3r1n4 committed Oct 3, 2012
1 parent 993c627 commit a112f0d
Show file tree
Hide file tree
Showing 8 changed files with 252 additions and 1 deletion.
30 changes: 30 additions & 0 deletions erts/emulator/beam/bif.c
Expand Up @@ -121,6 +121,9 @@ static int insert_internal_link(Process* p, Eterm rpid)
} }
if (IS_TRACED_FL(rp, F_TRACE_PROCS)) if (IS_TRACED_FL(rp, F_TRACE_PROCS))
trace_proc(p, rp, am_getting_linked, p->id); trace_proc(p, rp, am_getting_linked, p->id);
if (DTRACE_ENABLED(percept_trace)) {
d_trace_proc(p, rp, am_getting_linked, p->id);
}


if (p == rp) if (p == rp)
erts_smp_proc_unlock(p, rp_locks & ~ERTS_PROC_LOCK_MAIN); erts_smp_proc_unlock(p, rp_locks & ~ERTS_PROC_LOCK_MAIN);
Expand All @@ -141,6 +144,9 @@ BIF_RETTYPE link_1(BIF_ALIST_1)
if (IS_TRACED_FL(BIF_P, F_TRACE_PROCS)) { if (IS_TRACED_FL(BIF_P, F_TRACE_PROCS)) {
trace_proc(BIF_P, BIF_P, am_link, BIF_ARG_1); trace_proc(BIF_P, BIF_P, am_link, BIF_ARG_1);
} }
if (DTRACE_ENABLED(percept_trace)) {
d_trace_proc(BIF_P, BIF_P, am_link, BIF_ARG_1);
}
/* check that the pid or port which is our argument is OK */ /* check that the pid or port which is our argument is OK */


if (is_internal_pid(BIF_ARG_1)) { if (is_internal_pid(BIF_ARG_1)) {
Expand Down Expand Up @@ -937,6 +943,9 @@ BIF_RETTYPE unlink_1(BIF_ALIST_1)
if (IS_TRACED_FL(BIF_P, F_TRACE_PROCS)) { if (IS_TRACED_FL(BIF_P, F_TRACE_PROCS)) {
trace_proc(BIF_P, BIF_P, am_unlink, BIF_ARG_1); trace_proc(BIF_P, BIF_P, am_unlink, BIF_ARG_1);
} }
if (DTRACE_ENABLED(percept_trace)) {
d_trace_proc(BIF_P, BIF_P, am_unlink, BIF_ARG_1);
}


if (is_internal_port(BIF_ARG_1)) { if (is_internal_port(BIF_ARG_1)) {
Port *pt = erts_id2port_sflgs(BIF_ARG_1, Port *pt = erts_id2port_sflgs(BIF_ARG_1,
Expand Down Expand Up @@ -1072,6 +1081,9 @@ BIF_RETTYPE unlink_1(BIF_ALIST_1)
if (IS_TRACED_FL(rp, F_TRACE_PROCS) && rl != NULL) { if (IS_TRACED_FL(rp, F_TRACE_PROCS) && rl != NULL) {
trace_proc(BIF_P, rp, am_getting_unlinked, BIF_P->id); trace_proc(BIF_P, rp, am_getting_unlinked, BIF_P->id);
} }
if (DTRACE_ENABLED(percept_trace)) {
d_trace_proc(BIF_P, rp, am_getting_unlinked, BIF_P->id);
}


if (rp != BIF_P) if (rp != BIF_P)
erts_smp_proc_unlock(rp, ERTS_PROC_LOCK_LINK); erts_smp_proc_unlock(rp, ERTS_PROC_LOCK_LINK);
Expand Down Expand Up @@ -1863,6 +1875,9 @@ do_send(Process *p, Eterm to, Eterm msg, int suspend) {
if (erts_system_profile_flags.runnable_procs && erts_system_profile_flags.exclusive) { if (erts_system_profile_flags.runnable_procs && erts_system_profile_flags.exclusive) {
profile_runnable_proc(p, am_inactive); profile_runnable_proc(p, am_inactive);
} }
if (DTRACE_ENABLED(percept_trace)) {
d_profile_runnable_proc(p, am_inactive);
}
erts_whereis_name(p, ERTS_PROC_LOCK_MAIN, erts_whereis_name(p, ERTS_PROC_LOCK_MAIN,
to, to,
&rp, 0, ERTS_P2P_FLG_SMP_INC_REFC, &rp, 0, ERTS_P2P_FLG_SMP_INC_REFC,
Expand All @@ -1880,6 +1895,9 @@ do_send(Process *p, Eterm to, Eterm msg, int suspend) {
if (erts_system_profile_flags.runnable_procs && erts_system_profile_flags.exclusive) { if (erts_system_profile_flags.runnable_procs && erts_system_profile_flags.exclusive) {
profile_runnable_proc(p, am_active); profile_runnable_proc(p, am_active);
} }
if (DTRACE_ENABLED(percept_trace)) {
d_profile_runnable_proc(p, am_active);
}


if (IS_TRACED(p)) if (IS_TRACED(p))
trace_send(p, to, msg); trace_send(p, to, msg);
Expand Down Expand Up @@ -1912,6 +1930,9 @@ do_send(Process *p, Eterm to, Eterm msg, int suspend) {
if (erts_system_profile_flags.runnable_procs && erts_system_profile_flags.exclusive) { if (erts_system_profile_flags.runnable_procs && erts_system_profile_flags.exclusive) {
profile_runnable_proc(p, am_inactive); profile_runnable_proc(p, am_inactive);
} }
if (DTRACE_ENABLED(percept_trace)) {
d_profile_runnable_proc(p, am_inactive);
}
pt = erts_id2port(to, p, ERTS_PROC_LOCK_MAIN); pt = erts_id2port(to, p, ERTS_PROC_LOCK_MAIN);
port_common: port_common:
ERTS_SMP_LC_ASSERT(!pt || erts_lc_is_port_locked(pt)); ERTS_SMP_LC_ASSERT(!pt || erts_lc_is_port_locked(pt));
Expand Down Expand Up @@ -1977,6 +1998,9 @@ do_send(Process *p, Eterm to, Eterm msg, int suspend) {
if (erts_system_profile_flags.runnable_procs && erts_system_profile_flags.exclusive) { if (erts_system_profile_flags.runnable_procs && erts_system_profile_flags.exclusive) {
profile_runnable_proc(p, am_active); profile_runnable_proc(p, am_active);
} }
if (DTRACE_ENABLED(percept_trace)) {
d_profile_runnable_proc(p, am_active);
}
if (ERTS_PROC_IS_EXITING(p)) { if (ERTS_PROC_IS_EXITING(p)) {
KILL_CATCHES(p); /* Must exit */ KILL_CATCHES(p); /* Must exit */
return SEND_USER_ERROR; return SEND_USER_ERROR;
Expand Down Expand Up @@ -2014,6 +2038,9 @@ do_send(Process *p, Eterm to, Eterm msg, int suspend) {
if (erts_system_profile_flags.runnable_procs && erts_system_profile_flags.exclusive) { if (erts_system_profile_flags.runnable_procs && erts_system_profile_flags.exclusive) {
profile_runnable_proc(p, am_inactive); profile_runnable_proc(p, am_inactive);
} }
if (DTRACE_ENABLED(percept_trace)) {
d_profile_runnable_proc(p, am_inactive);
}


erts_whereis_name(p, ERTS_PROC_LOCK_MAIN, erts_whereis_name(p, ERTS_PROC_LOCK_MAIN,
tp[1], tp[1],
Expand All @@ -2033,6 +2060,9 @@ do_send(Process *p, Eterm to, Eterm msg, int suspend) {
if (erts_system_profile_flags.runnable_procs && erts_system_profile_flags.exclusive) { if (erts_system_profile_flags.runnable_procs && erts_system_profile_flags.exclusive) {
profile_runnable_proc(p, am_active); profile_runnable_proc(p, am_active);
} }
if (DTRACE_ENABLED(percept_trace)) {
d_profile_runnable_proc(p, am_active);
}


if (!rp) { if (!rp) {
return 0; return 0;
Expand Down
12 changes: 12 additions & 0 deletions erts/emulator/beam/dist.c
Expand Up @@ -327,6 +327,9 @@ static void doit_link_net_exits_sub(ErtsLink *sublnk, void *vlnecp)
/* We didn't exit the process and it is traced */ /* We didn't exit the process and it is traced */
trace_proc(NULL, rp, am_getting_unlinked, sublnk->pid); trace_proc(NULL, rp, am_getting_unlinked, sublnk->pid);
} }
if (xres >= 0 && DTRACE_ENABLED(percept_trace)) {
d_trace_proc(NULL, rp, am_getting_unlinked, sublnk->pid);
}
} }
erts_smp_proc_unlock(rp, rp_locks); erts_smp_proc_unlock(rp, rp_locks);
} }
Expand Down Expand Up @@ -1155,6 +1158,9 @@ int erts_net_message(Port *prt,


if (IS_TRACED_FL(rp, F_TRACE_PROCS)) if (IS_TRACED_FL(rp, F_TRACE_PROCS))
trace_proc(NULL, rp, am_getting_linked, from); trace_proc(NULL, rp, am_getting_linked, from);
if (DTRACE_ENABLED(percept_trace)) {
d_trace_proc(NULL, rp, am_getting_linked, from);
}


erts_smp_proc_unlock(rp, ERTS_PROC_LOCK_LINK); erts_smp_proc_unlock(rp, ERTS_PROC_LOCK_LINK);
break; break;
Expand All @@ -1181,6 +1187,9 @@ int erts_net_message(Port *prt,
if (IS_TRACED_FL(rp, F_TRACE_PROCS) && lnk != NULL) { if (IS_TRACED_FL(rp, F_TRACE_PROCS) && lnk != NULL) {
trace_proc(NULL, rp, am_getting_unlinked, from); trace_proc(NULL, rp, am_getting_unlinked, from);
} }
if (DTRACE_ENABLED(percept_trace) && lnk != NULL) {
d_trace_proc(NULL, rp, am_getting_unlinked, from);
}


erts_smp_proc_unlock(rp, ERTS_PROC_LOCK_LINK); erts_smp_proc_unlock(rp, ERTS_PROC_LOCK_LINK);


Expand Down Expand Up @@ -1511,6 +1520,9 @@ int erts_net_message(Port *prt,
/* We didn't exit the process and it is traced */ /* We didn't exit the process and it is traced */
trace_proc(NULL, rp, am_getting_unlinked, from); trace_proc(NULL, rp, am_getting_unlinked, from);
} }
if (xres >= 0 && DTRACE_ENABLED(percept_trace)) {
d_trace_proc(NULL, rp, am_getting_unlinked, from);
}
} }
erts_smp_proc_unlock(rp, rp_locks); erts_smp_proc_unlock(rp, rp_locks);
} }
Expand Down
29 changes: 28 additions & 1 deletion erts/emulator/beam/erl_bif_port.c
Expand Up @@ -136,6 +136,9 @@ do_port_command(Process *BIF_P, Eterm arg1, Eterm arg2, Eterm arg3,
if (erts_system_profile_flags.runnable_procs && erts_system_profile_flags.exclusive) { if (erts_system_profile_flags.runnable_procs && erts_system_profile_flags.exclusive) {
profile_runnable_proc(BIF_P, am_inactive); profile_runnable_proc(BIF_P, am_inactive);
} }
if (DTRACE_ENABLED(percept_trace)) {
d_profile_runnable_proc(BIF_P, am_inactive);
}


p = id_or_name2port(BIF_P, arg1); p = id_or_name2port(BIF_P, arg1);
if (!p) { if (!p) {
Expand All @@ -145,6 +148,9 @@ do_port_command(Process *BIF_P, Eterm arg1, Eterm arg2, Eterm arg3,
if (erts_system_profile_flags.runnable_procs && erts_system_profile_flags.exclusive) { if (erts_system_profile_flags.runnable_procs && erts_system_profile_flags.exclusive) {
profile_runnable_proc(BIF_P, am_active); profile_runnable_proc(BIF_P, am_active);
} }
if (DTRACE_ENABLED(percept_trace)) {
d_profile_runnable_proc(BIF_P, am_active);
}
BIF_ERROR(BIF_P, BADARG); BIF_ERROR(BIF_P, BADARG);
} }


Expand Down Expand Up @@ -202,6 +208,9 @@ do_port_command(Process *BIF_P, Eterm arg1, Eterm arg2, Eterm arg3,
if (erts_system_profile_flags.runnable_procs && erts_system_profile_flags.exclusive) { if (erts_system_profile_flags.runnable_procs && erts_system_profile_flags.exclusive) {
profile_runnable_proc(BIF_P, am_active); profile_runnable_proc(BIF_P, am_active);
} }
if (DTRACE_ENABLED(percept_trace)) {
d_profile_runnable_proc(BIF_P, am_active);
}


if (ERTS_PROC_IS_EXITING(BIF_P)) { if (ERTS_PROC_IS_EXITING(BIF_P)) {
KILL_CATCHES(BIF_P); /* Must exit */ KILL_CATCHES(BIF_P); /* Must exit */
Expand Down Expand Up @@ -281,6 +290,9 @@ port_call(Process* c_p, Eterm arg1, Eterm arg2, Eterm arg3)
if (erts_system_profile_flags.runnable_procs && erts_system_profile_flags.exclusive) { if (erts_system_profile_flags.runnable_procs && erts_system_profile_flags.exclusive) {
profile_runnable_proc(c_p, am_inactive); profile_runnable_proc(c_p, am_inactive);
} }
if (DTRACE_ENABLED(percept_trace)) {
d_profile_runnable_proc(c_p, am_inactive);
}


p = id_or_name2port(c_p, arg1); p = id_or_name2port(c_p, arg1);
if (!p) { if (!p) {
Expand All @@ -301,6 +313,9 @@ port_call(Process* c_p, Eterm arg1, Eterm arg2, Eterm arg3)
if (erts_system_profile_flags.runnable_procs && erts_system_profile_flags.exclusive) { if (erts_system_profile_flags.runnable_procs && erts_system_profile_flags.exclusive) {
profile_runnable_proc(c_p, am_active); profile_runnable_proc(c_p, am_active);
} }
if (DTRACE_ENABLED(percept_trace)) {
d_profile_runnable_proc(c_p, am_active);
}


if (p) if (p)
erts_port_release(p); erts_port_release(p);
Expand Down Expand Up @@ -427,7 +442,10 @@ port_call(Process* c_p, Eterm arg1, Eterm arg2, Eterm arg3)
if (erts_system_profile_flags.runnable_procs && erts_system_profile_flags.exclusive) { if (erts_system_profile_flags.runnable_procs && erts_system_profile_flags.exclusive) {
profile_runnable_proc(c_p, am_active); profile_runnable_proc(c_p, am_active);
} }

if (DTRACE_ENABLED(percept_trace)) {
d_profile_runnable_proc(c_p, am_active);
}

return res; return res;
} }


Expand All @@ -445,6 +463,9 @@ BIF_RETTYPE port_control_3(BIF_ALIST_3)
if (erts_system_profile_flags.runnable_procs && erts_system_profile_flags.exclusive) { if (erts_system_profile_flags.runnable_procs && erts_system_profile_flags.exclusive) {
profile_runnable_proc(BIF_P, am_inactive); profile_runnable_proc(BIF_P, am_inactive);
} }
if (DTRACE_ENABLED(percept_trace)) {
d_profile_runnable_proc(BIF_P, am_inactive);
}


p = id_or_name2port(BIF_P, BIF_ARG_1); p = id_or_name2port(BIF_P, BIF_ARG_1);
if (!p) { if (!p) {
Expand All @@ -456,6 +477,9 @@ BIF_RETTYPE port_control_3(BIF_ALIST_3)
if (erts_system_profile_flags.runnable_procs && erts_system_profile_flags.exclusive) { if (erts_system_profile_flags.runnable_procs && erts_system_profile_flags.exclusive) {
profile_runnable_proc(BIF_P, am_active); profile_runnable_proc(BIF_P, am_active);
} }
if (DTRACE_ENABLED(percept_trace)) {
d_profile_runnable_proc(BIF_P, am_active);
}


BIF_ERROR(BIF_P, BADARG); BIF_ERROR(BIF_P, BADARG);
} }
Expand Down Expand Up @@ -495,6 +519,9 @@ BIF_RETTYPE port_control_3(BIF_ALIST_3)
if (erts_system_profile_flags.runnable_procs && erts_system_profile_flags.exclusive) { if (erts_system_profile_flags.runnable_procs && erts_system_profile_flags.exclusive) {
profile_runnable_proc(BIF_P, am_active); profile_runnable_proc(BIF_P, am_active);
} }
if (DTRACE_ENABLED(percept_trace)) {
d_profile_runnable_proc(BIF_P, am_active);
}


if (is_non_value(res)) { if (is_non_value(res)) {
BIF_ERROR(BIF_P, BADARG); BIF_ERROR(BIF_P, BADARG);
Expand Down
30 changes: 30 additions & 0 deletions erts/emulator/beam/erl_process.c
Expand Up @@ -4271,6 +4271,9 @@ suspend_process(ErtsRunQueue *rq, Process *p)
if ((erts_system_profile_flags.runnable_procs) && (p->rcount == 1) && (p->status != P_WAITING)) { if ((erts_system_profile_flags.runnable_procs) && (p->rcount == 1) && (p->status != P_WAITING)) {
profile_runnable_proc(p, am_inactive); profile_runnable_proc(p, am_inactive);
} }
if (DTRACE_ENABLED(percept_trace) && (p->rcount == 1) && (p->status != P_WAITING)) {
d_profile_runnable_proc(p, am_inactive);
}


p->status = P_SUSPENDED; p->status = P_SUSPENDED;


Expand Down Expand Up @@ -6190,6 +6193,11 @@ internal_add_to_runq(ErtsRunQueue *runq, Process *p)
|| prev_status == P_SUSPENDED)) { || prev_status == P_SUSPENDED)) {
profile_runnable_proc(p, am_active); profile_runnable_proc(p, am_active);
} }
if ((DTRACE_ENABLED(percept_trace))
&& (prev_status == P_WAITING
|| prev_status == P_SUSPENDED)) {
d_profile_runnable_proc(p, am_active);
}


if (add_runq != runq) if (add_runq != runq)
erts_smp_runq_unlock(add_runq); erts_smp_runq_unlock(add_runq);
Expand Down Expand Up @@ -6231,6 +6239,9 @@ remove_proc_from_runq(ErtsRunQueue *rq, Process *p, int to_inactive)


if (res && erts_system_profile_flags.runnable_procs && to_inactive) if (res && erts_system_profile_flags.runnable_procs && to_inactive)
profile_runnable_proc(p, am_inactive); profile_runnable_proc(p, am_inactive);
if (res && DTRACE_ENABLED(percept_trace) && to_inactive) {
d_profile_runnable_proc(p, am_active);
}


#ifdef ERTS_SMP #ifdef ERTS_SMP
ASSERT(!(p->status_flags & ERTS_PROC_SFLG_INRUNQ)); ASSERT(!(p->status_flags & ERTS_PROC_SFLG_INRUNQ));
Expand Down Expand Up @@ -6627,6 +6638,10 @@ Process *schedule(Process *p, int calls)
&& (p->status == P_WAITING)) { && (p->status == P_WAITING)) {
profile_runnable_proc(p, am_inactive); profile_runnable_proc(p, am_inactive);
} }
if (DTRACE_ENABLED(percept_trace)
&& (p->status == P_WAITING)) {
d_profile_runnable_proc(p, am_inactive);
}


if (IS_TRACED(p)) { if (IS_TRACED(p)) {
if (IS_TRACED_FL(p, F_TRACE_CALLS) && p->status != P_FREE) { if (IS_TRACED_FL(p, F_TRACE_CALLS) && p->status != P_FREE) {
Expand Down Expand Up @@ -7606,6 +7621,9 @@ erl_create_process(Process* parent, /* Parent of process (default group leader).
if (IS_TRACED_FL(parent, F_TRACE_PROCS)) { if (IS_TRACED_FL(parent, F_TRACE_PROCS)) {
trace_proc(parent, parent, am_link, p->id); trace_proc(parent, parent, am_link, p->id);
} }
if (DTRACE_ENABLED(percept_trace)) {
d_trace_proc(parent, parent, am_link, p->id);
}


#ifdef DEBUG #ifdef DEBUG
ret = erts_add_link(&(parent->nlinks), LINK_PID, p->id); ret = erts_add_link(&(parent->nlinks), LINK_PID, p->id);
Expand Down Expand Up @@ -7696,6 +7714,9 @@ erl_create_process(Process* parent, /* Parent of process (default group leader).
dtrace_fun_decode(p, mod, func, arity, process_name, mfa); dtrace_fun_decode(p, mod, func, arity, process_name, mfa);
DTRACE2(process_spawn, process_name, mfa); DTRACE2(process_spawn, process_name, mfa);
} }
if (DTRACE_ENABLED(percept_trace)) {
d_trace_proc_spawn(parent, p->id, mod, func, args);
}
#endif #endif


error: error:
Expand Down Expand Up @@ -8612,6 +8633,9 @@ static void doit_exit_link(ErtsLink *lnk, void *vpcontext)
if (IS_TRACED_FL(rp, F_TRACE_PROCS)) { if (IS_TRACED_FL(rp, F_TRACE_PROCS)) {
trace_proc(p, rp, am_getting_unlinked, p->id); trace_proc(p, rp, am_getting_unlinked, p->id);
} }
if (DTRACE_ENABLED(percept_trace)) {
d_trace_proc(p, rp, am_getting_unlinked, p->id);
}
} }
} }
ASSERT(rp != p); ASSERT(rp != p);
Expand Down Expand Up @@ -8714,6 +8738,9 @@ erts_do_exit_process(Process* p, Eterm reason)
if (erts_system_profile_flags.runnable_procs && (p->status != P_WAITING)) { if (erts_system_profile_flags.runnable_procs && (p->status != P_WAITING)) {
profile_runnable_proc(p, am_inactive); profile_runnable_proc(p, am_inactive);
} }
if (DTRACE_ENABLED(percept_trace) && (p->status != P_WAITING)) {
d_profile_runnable_proc(p, am_inactive);
}


#ifdef ERTS_SMP #ifdef ERTS_SMP
erts_pix_lock(pix_lock); erts_pix_lock(pix_lock);
Expand Down Expand Up @@ -8746,6 +8773,9 @@ erts_do_exit_process(Process* p, Eterm reason)
if (IS_TRACED_FL(p,F_TRACE_PROCS)) if (IS_TRACED_FL(p,F_TRACE_PROCS))
trace_proc(p, p, am_exit, reason); trace_proc(p, p, am_exit, reason);
} }
if (DTRACE_ENABLED(percept_trace)) {
d_trace_proc(p, p, am_exit, reason);
}


erts_trace_check_exiting(p->id); erts_trace_check_exiting(p->id);


Expand Down

0 comments on commit a112f0d

Please sign in to comment.