aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tools/src/cover.erl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tools/src/cover.erl')
-rw-r--r--lib/tools/src/cover.erl36
1 files changed, 26 insertions, 10 deletions
diff --git a/lib/tools/src/cover.erl b/lib/tools/src/cover.erl
index 71e17e0ba1..9ec5e809bc 100644
--- a/lib/tools/src/cover.erl
+++ b/lib/tools/src/cover.erl
@@ -782,7 +782,7 @@ main_process_loop(State) ->
{From, {{analyse_to_file, Opts},Module}} ->
S = try
Loaded = is_loaded(Module, State),
- spawn(fun() ->
+ spawn_link(fun() ->
?SPAWN_DBG(analyse_to_file,{Module,Opts}),
do_parallel_analysis_to_file(
Module, Opts, Loaded, From, State)
@@ -1017,14 +1017,24 @@ load_compiled([{Module,File,Binary,InitialTable}|Compiled],Acc) ->
%% Make sure the #bump{} records are available *before* the
%% module is loaded.
insert_initial_data(InitialTable),
- NewAcc =
- case code:load_binary(Module, ?TAG, Binary) of
- {module,Module} ->
- add_compiled(Module, File, Acc);
- _ ->
- do_clear(Module),
- Acc
- end,
+ Sticky = case code:is_sticky(Module) of
+ true ->
+ code:unstick_mod(Module),
+ true;
+ false ->
+ false
+ end,
+ NewAcc = case code:load_binary(Module, ?TAG, Binary) of
+ {module,Module} ->
+ add_compiled(Module, File, Acc);
+ _ ->
+ do_clear(Module),
+ Acc
+ end,
+ case Sticky of
+ true -> code:stick_mod(Module);
+ false -> ok
+ end,
load_compiled(Compiled,NewAcc);
load_compiled([],Acc) ->
Acc.
@@ -2143,7 +2153,13 @@ find_source(Module, File0) ->
throw_file(filename:join([BeamDir, "..", "src", Base])),
%% Not in ../src: look for source path in compile info, but
%% first look relative the beam directory.
- Info = lists:keyfind(source, 1, Module:module_info(compile)),
+ Info =
+ try lists:keyfind(source, 1, Module:module_info(compile))
+ catch error:undef ->
+ %% The module might have been imported
+ %% and the beam not available
+ throw({beam, File0})
+ end,
false == Info andalso throw({beam, File0}), %% stripped
{source, SrcFile} = Info,
throw_file(splice(BeamDir, SrcFile)), %% below ../src