aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'lib/kernel')
-rw-r--r--lib/kernel/doc/src/code.xml13
-rw-r--r--lib/kernel/src/code.erl6
-rw-r--r--lib/kernel/src/code_server.erl3
-rw-r--r--lib/kernel/test/code_SUITE.erl9
4 files changed, 28 insertions, 3 deletions
diff --git a/lib/kernel/doc/src/code.xml b/lib/kernel/doc/src/code.xml
index 279c7558bc..dbcf376487 100644
--- a/lib/kernel/doc/src/code.xml
+++ b/lib/kernel/doc/src/code.xml
@@ -738,6 +738,19 @@ rpc:call(Node, code, load_binary, [Module, Filename, Binary]),
<c>undefined</c>.</p>
</desc>
</func>
+
+ <func>
+ <name name="get_mode" arity="0"/>
+ <fsummary>The code_server's mode.</fsummary>
+ <desc>
+ <p>This function returns an atom describing the code_server's mode:
+ <c>interactive</c> or <c>embedded</c>. </p>
+ <p>This information is useful when an external entity (for example,
+ an IDE) provides additional code for a running node. If in interactive
+ mode, it only needs to add to the code path. If in embedded mode,
+ the code has to be loaded with <c>load_binary/3</c></p>
+ </desc>
+ </func>
</funcs>
</erlref>
diff --git a/lib/kernel/src/code.erl b/lib/kernel/src/code.erl
index 8a543abd6f..03fba96d4b 100644
--- a/lib/kernel/src/code.erl
+++ b/lib/kernel/src/code.erl
@@ -64,7 +64,8 @@
where_is_file/1,
where_is_file/2,
set_primary_archive/4,
- clash/0]).
+ clash/0,
+ get_mode/0]).
-export_type([load_error_rsn/0, load_ret/0]).
@@ -293,6 +294,9 @@ replace_path(Name, Dir) when (is_atom(Name) orelse is_list(Name)),
-spec rehash() -> 'ok'.
rehash() -> call(rehash).
+-spec get_mode() -> 'embedded' | 'interactive'.
+get_mode() -> call(get_mode).
+
%%-----------------------------------------------------------------
call(Req) ->
diff --git a/lib/kernel/src/code_server.erl b/lib/kernel/src/code_server.erl
index b770fce887..5d74e8620b 100644
--- a/lib/kernel/src/code_server.erl
+++ b/lib/kernel/src/code_server.erl
@@ -422,6 +422,9 @@ handle_call({is_cached,File}, {_From,_Tag}, S=#state{cache=Cache}) ->
end
end;
+handle_call(get_mode, {_From,_Tag}, S=#state{mode=Mode}) ->
+ {reply, Mode, S};
+
handle_call(Other,{_From,_Tag}, S) ->
error_msg(" ** Codeserver*** ignoring ~w~n ",[Other]),
{noreply,S}.
diff --git a/lib/kernel/test/code_SUITE.erl b/lib/kernel/test/code_SUITE.erl
index d7424c0c9a..4c040f0a0e 100644
--- a/lib/kernel/test/code_SUITE.erl
+++ b/lib/kernel/test/code_SUITE.erl
@@ -33,7 +33,7 @@
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]).
+ native_early_modules/1, get_mode/1]).
-export([init_per_testcase/2, end_per_testcase/2,
init_per_suite/1, end_per_suite/1,
@@ -60,7 +60,7 @@ all() ->
where_is_file_cached, 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].
+ big_boot_embedded, native_early_modules, get_mode].
groups() ->
[].
@@ -1594,6 +1594,11 @@ native_early_modules_1(Architecture) ->
ok
end.
+get_mode(suite) -> [];
+get_mode(doc) -> ["Test that the mode of the code server is properly retrieved"];
+get_mode(Config) when is_list(Config) ->
+ interactive = code:get_mode().
+
%%-----------------------------------------------------------------
%% error_logger handler.
%% (Copied from stdlib/test/proc_lib_SUITE.erl.)