aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2016-03-14 12:49:53 +0100
committerBjörn Gustavsson <[email protected]>2016-03-16 10:11:12 +0100
commit577125cc69feb5c14fa7e13edd3c3157f9c4a0ec (patch)
treeb5d355bb122708b5d787584b1d9373bb775aeeeb
parent4e0c08b7b7658531af6151702372e2b9bdd8d8fd (diff)
downloadotp-577125cc69feb5c14fa7e13edd3c3157f9c4a0ec.tar.gz
otp-577125cc69feb5c14fa7e13edd3c3157f9c4a0ec.tar.bz2
otp-577125cc69feb5c14fa7e13edd3c3157f9c4a0ec.zip
code_server: Normalize the pathnames for all loaded modules
On Windows, the pathnames for modules that are loaded early are returned with mixed backslashes and slashes: 1> code:which(lists). "C:\\Program Files\\erl8.0/lib/stdlib-2.7/ebin/lists.beam" 2> Modules loaded later are fully normalized. When starting the code_server, normalize the pathnames for all modules that have been loaded so far.
-rw-r--r--lib/kernel/src/code_server.erl4
-rw-r--r--lib/kernel/test/code_SUITE.erl21
2 files changed, 22 insertions, 3 deletions
diff --git a/lib/kernel/src/code_server.erl b/lib/kernel/src/code_server.erl
index 6262407354..fb08b4c22b 100644
--- a/lib/kernel/src/code_server.erl
+++ b/lib/kernel/src/code_server.erl
@@ -67,7 +67,9 @@ init(Ref, Parent, [Root,Mode]) ->
%% Pre-loaded modules are always sticky.
ets:insert(Db, [{M,preloaded},{{sticky,M},true}])
end, erlang:pre_loaded()),
- ets:insert(Db, init:fetch_loaded()),
+ Loaded0 = init:fetch_loaded(),
+ Loaded = [{M,filename:join([P])} || {M,P} <- Loaded0], %Normalize.
+ ets:insert(Db, Loaded),
IPath =
case Mode of
diff --git a/lib/kernel/test/code_SUITE.erl b/lib/kernel/test/code_SUITE.erl
index 298c1f7d6b..abea23e854 100644
--- a/lib/kernel/test/code_SUITE.erl
+++ b/lib/kernel/test/code_SUITE.erl
@@ -34,7 +34,8 @@
purge_stacktrace/1, mult_lib_roots/1, bad_erl_libs/1,
code_archive/1, code_archive2/1, on_load/1, on_load_binary/1,
on_load_embedded/1, on_load_errors/1, big_boot_embedded/1,
- native_early_modules/1, get_mode/1]).
+ native_early_modules/1, get_mode/1,
+ normalized_paths/1]).
-export([init_per_testcase/2, end_per_testcase/2,
init_per_suite/1, end_per_suite/1]).
@@ -61,7 +62,7 @@ all() ->
purge_stacktrace, mult_lib_roots,
bad_erl_libs, code_archive, code_archive2, on_load,
on_load_binary, on_load_embedded, on_load_errors,
- big_boot_embedded, native_early_modules, get_mode].
+ big_boot_embedded, native_early_modules, get_mode, normalized_paths].
groups() ->
[].
@@ -1451,6 +1452,22 @@ native_early_modules_1(Architecture) ->
get_mode(Config) when is_list(Config) ->
interactive = code:get_mode().
+%% Make sure that the paths for all loaded modules have been normalized.
+normalized_paths(_Config) ->
+ do_normalized_paths(erlang:loaded()).
+
+do_normalized_paths([M|Ms]) ->
+ case code:which(M) of
+ Special when is_atom(Special) ->
+ do_normalized_paths(Ms);
+ File when is_list(File) ->
+ File = filename:join([File]),
+ do_normalized_paths(Ms)
+ end;
+do_normalized_paths([]) ->
+ ok.
+
+
%%-----------------------------------------------------------------
%% error_logger handler.
%% (Copied from stdlib/test/proc_lib_SUITE.erl.)