aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tools
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2016-04-15 15:10:55 +0200
committerLukas Larsson <[email protected]>2016-04-15 15:10:55 +0200
commitbe7f01689e71cbc1896ea5c11fb0ebc6f7f6dd8a (patch)
treee7db1292fe6aa167408b7a7c93289fe2cca7e5c1 /lib/tools
parent67df3b3792857a2b4885c0acbeaa7f32f3594b0c (diff)
parentcff38617986001e0a5f3f48de20acbeccceea978 (diff)
downloadotp-be7f01689e71cbc1896ea5c11fb0ebc6f7f6dd8a.tar.gz
otp-be7f01689e71cbc1896ea5c11fb0ebc6f7f6dd8a.tar.bz2
otp-be7f01689e71cbc1896ea5c11fb0ebc6f7f6dd8a.zip
Merge branch 'lukas/erts/tracer-module-and-more/PR-1009/OTP-10268'
* lukas/erts/tracer-module-and-more/PR-1009/OTP-10268: (26 commits) erts: Don't trace on link events when port is dead erts: more logging in trace_bif_SUITE trace_bif_return erts: Make trace_delivered go via sys msg dispatcher again erts: Add comment about future trace optimizations erts: Optimize tracer reload test erts: Document erlang:match_spec_test/3 runtime_tools: Make dbg work with erl_tracer modules runtime_rools: Allow new timestamp trace flags runtime_tools: Lots of dbg docs updates erts: Deallocate heap fragments from trace nif calls eprof: Fix tests after tracer module incompatabilities fprof: update to work with new spawned trace event erts: Add 'spawned' trace event to 'procs' trace flag erts: send and receive no longer need status lock erts: Do 'unregister' as "self-tracing" erts: Silence harmless valgrind warning in dec_term erts: Fix end_per_testcase crash in local_trace_SUITE observer: Update ttb to work with tracing on ports runtime_tools: Update dbg to work with tracing on ports erts: Add tracing examples in match spec docs ...
Diffstat (limited to 'lib/tools')
-rw-r--r--lib/tools/src/fprof.erl15
-rw-r--r--lib/tools/test/eprof_SUITE.erl3
-rw-r--r--lib/tools/test/fprof_SUITE.erl27
3 files changed, 35 insertions, 10 deletions
diff --git a/lib/tools/src/fprof.erl b/lib/tools/src/fprof.erl
index c5c24c8eb3..f9da748fef 100644
--- a/lib/tools/src/fprof.erl
+++ b/lib/tools/src/fprof.erl
@@ -1567,13 +1567,20 @@ trace_handler({trace_ts, Pid, return_to, {_M, _F, Args} = MFArgs, TS} = Trace,
trace_return_to(Table, Pid, Func, TS),
TS;
%%
-%% spawn
+%% spawn, only needed (and reliable) prior to 19.0
trace_handler({trace_ts, Pid, spawn, Child, MFArgs, TS} = Trace,
Table, _, Dump) ->
dump_stack(Dump, get(Pid), Trace),
trace_spawn(Table, Child, MFArgs, TS, Pid),
TS;
%%
+%% spawned, added in 19.0
+trace_handler({trace_ts, Pid, spawned, Parent, MFArgs, TS} = Trace,
+ Table, _, Dump) ->
+ dump_stack(Dump, get(Pid), Trace),
+ trace_spawn(Table, Pid, MFArgs, TS, Parent),
+ TS;
+%%
%% exit
trace_handler({trace_ts, Pid, exit, _Reason, TS} = Trace,
Table, _, Dump) ->
@@ -2014,8 +2021,10 @@ trace_spawn(Table, Pid, MFArgs, TS, Parent) ->
ets:insert(Table, #proc{id = Pid, parent = Parent,
spawned_as = MFArgs});
_ ->
- throw({inconsistent_trace_data, ?MODULE, ?LINE,
- [Pid, MFArgs, TS, Parent, Stack]})
+ %% In 19.0 we get both a spawn and spawned event,
+ %% however we do not know the order so we just ignore
+ %% the second event that comes
+ ok
end.
diff --git a/lib/tools/test/eprof_SUITE.erl b/lib/tools/test/eprof_SUITE.erl
index ba3b71cc1f..e908413315 100644
--- a/lib/tools/test/eprof_SUITE.erl
+++ b/lib/tools/test/eprof_SUITE.erl
@@ -81,9 +81,6 @@ basic(Config) when is_list(Config) ->
%% error case
- error = eprof:profile([Pid], fun() -> eprof_test:go(10) end),
- Pid = whereis(eprof),
- error = eprof:profile([Pid], fun() -> eprof_test:go(10) end),
A = spawn(fun() -> receive _ -> ok end end),
profiling = eprof:profile([A]),
true = exit(A, kill_it),
diff --git a/lib/tools/test/fprof_SUITE.erl b/lib/tools/test/fprof_SUITE.erl
index 244bdaaf0e..e18d384b52 100644
--- a/lib/tools/test/fprof_SUITE.erl
+++ b/lib/tools/test/fprof_SUITE.erl
@@ -985,10 +985,15 @@ handle_trace({trace_ts,Pid,spawn,NewPid,{M,F,Args},TS},P) ->
MFA = {M,F,length(Args)},
?dbg("~p",[{{spawn,Pid,NewPid,MFA},get(Pid)}]),
T = ts_sub(TS,get({Pid,last_ts})),
- put({NewPid,last_ts},TS),
- put(NewPid,[suspend,MFA]),
- insert(NewPid,suspend),
- insert(NewPid,MFA),
+ case get(NewPid) of
+ undefined ->
+ put({NewPid,last_ts},TS),
+ put(NewPid,[suspend,MFA]),
+ insert(NewPid,suspend),
+ insert(NewPid,MFA);
+ _Else ->
+ ok
+ end,
case get(Pid) of
[SpawningMFA|_] = Stack ->
update_own(Pid,SpawningMFA,T),
@@ -996,6 +1001,19 @@ handle_trace({trace_ts,Pid,spawn,NewPid,{M,F,Args},TS},P) ->
end,
put({Pid,last_ts},TS),
P;
+handle_trace({trace_ts,NewPid,spawned,Pid,{M,F,Args},TS},P) ->
+ MFA = {M,F,length(Args)},
+ ?dbg("~p",[{{spawned,NewPid,Pid,MFA},get(NewPid)}]),
+ case get(NewPid) of
+ undefined ->
+ put({NewPid,last_ts},TS),
+ put(NewPid,[suspend,MFA]),
+ insert(NewPid,suspend),
+ insert(NewPid,MFA);
+ _Else ->
+ ok
+ end,
+ P;
handle_trace({trace_ts,Pid,exit,_Reason,TS},P) ->
?dbg("~p",[{{exit,Pid,_Reason},get(Pid)}]),
T = ts_sub(TS,get({Pid,last_ts})),
@@ -1023,6 +1041,7 @@ handle_trace(end_of_trace,P) ->
P ! {result,[{totals,TotAcc,TotOwn}|ProcOwns]++Result},
P;
handle_trace(Other,_P) ->
+ ct:log("Got unexpected trace message: ~p",[Other]),
exit({unexpected,Other}).
find_return_to(MFA,[MFA|_]=Stack) ->