aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/beam_bp.c
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2014-03-07 10:41:32 +0100
committerBjörn Gustavsson <[email protected]>2014-03-20 13:10:36 +0100
commit9327904dcbf2708823c05baa7532783fb0214792 (patch)
treed5f157e885b0ccdbe63f95173df72425f1a9d468 /erts/emulator/beam/beam_bp.c
parent544fb141916d8676bc763318074e4d0783414af1 (diff)
downloadotp-9327904dcbf2708823c05baa7532783fb0214792.tar.gz
otp-9327904dcbf2708823c05baa7532783fb0214792.tar.bz2
otp-9327904dcbf2708823c05baa7532783fb0214792.zip
Teach the call_time trace to notice when the trace dies (non-SMP system)
The call_time trace is a special kind of tracing that requires a tracer process just like ordinary call trace, but it never actually sends anything to the tracer. It merely use the existence of a trace process (and call trace flags) as an indication that call_time tracing is active for the process. If the tracer dies in a non-SMP run-time system, processes with call_time tracing would not notice that the tracer had died. Furthermore, if the set_on_spawn flag was active, the dead tracer could be propagaged to newly spawned processes. Before accumulating trace information in a non-SMP system, always validate the tracer process. (In an SMP system, a reference to a dead tracer will be cleared away each time a process is scheduled.) While we could put all of the new code beam_bp.c, we have chosen to make a function call from beam_bp.c to a function in erl_trace.c for clarity's sake and to ease further maintenance. In the future, we might want to handle tracing in more similar ways in the SMP and non-SMP system.
Diffstat (limited to 'erts/emulator/beam/beam_bp.c')
-rw-r--r--erts/emulator/beam/beam_bp.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/erts/emulator/beam/beam_bp.c b/erts/emulator/beam/beam_bp.c
index 49a34ab4ad..4e711c89e0 100644
--- a/erts/emulator/beam/beam_bp.c
+++ b/erts/emulator/beam/beam_bp.c
@@ -642,7 +642,7 @@ erts_generic_breakpoint(Process* c_p, BeamInstr* I, Eterm* reg)
erts_smp_atomic_inc_nob(&bp->count->acount);
}
- if (bp_flags & ERTS_BPF_TIME_TRACE_ACTIVE) {
+ if (bp_flags & ERTS_BPF_TIME_TRACE_ACTIVE && erts_is_tracer_proc_valid(c_p)) {
Eterm w;
erts_trace_time_call(c_p, I, bp->time);
w = (BeamInstr) *c_p->cp;
@@ -730,7 +730,8 @@ erts_bif_trace(int bif_index, Process* p, Eterm* args, BeamInstr* I)
}
}
if (bp_flags & ERTS_BPF_TIME_TRACE_ACTIVE &&
- IS_TRACED_FL(p, F_TRACE_CALLS)) {
+ IS_TRACED_FL(p, F_TRACE_CALLS) &&
+ erts_is_tracer_proc_valid(p)) {
BeamInstr *pc = (BeamInstr *)ep->code+3;
erts_trace_time_call(p, pc, bp->time);
}