diff options
Diffstat (limited to 'lib/kernel/src/error_handler.erl')
-rw-r--r-- | lib/kernel/src/error_handler.erl | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/lib/kernel/src/error_handler.erl b/lib/kernel/src/error_handler.erl index 5f2507fc08..e1f99bf417 100644 --- a/lib/kernel/src/error_handler.erl +++ b/lib/kernel/src/error_handler.erl @@ -1,30 +1,38 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1996-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1996-2011. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(error_handler). +%% FIXME: remove no_native directive after HiPE has been changed to make +%% remote calls link to the target's Export* like BEAM does. +%% For a detailed explanation see the commit titled +%% "error_handler: add no_native compiler directive" +-compile(no_native). %% A simple error handler. -export([undefined_function/3, undefined_lambda/3, stub_function/3, breakpoint/3]). --spec undefined_function(Module :: atom(), Function :: atom(), Args :: [_]) -> - any(). +-spec undefined_function(Module, Function, Args) -> + any() when + Module :: atom(), + Function :: atom(), + Args :: list(). undefined_function(Module, Func, Args) -> case ensure_loaded(Module) of @@ -46,8 +54,10 @@ undefined_function(Module, Func, Args) -> crash(Module, Func, Args) end. --spec undefined_lambda(Module :: atom(), Function :: fun(), Args :: [_]) -> - any(). +-spec undefined_lambda(Module, Fun, Args) -> term() when + Module :: atom(), + Fun :: fun(), + Args :: list(). undefined_lambda(Module, Fun, Args) -> case ensure_loaded(Module) of @@ -75,9 +85,13 @@ int() -> int. %% %% Crash providing a beautiful stack backtrace. %% +-spec crash(atom(), [term()]) -> no_return(). + crash(Fun, Args) -> crash({Fun,Args}). +-spec crash(atom(), atom(), arity()) -> no_return(). + crash(M, F, A) -> crash({M,F,A}). @@ -117,13 +131,13 @@ stub_function(Mod, Func, Args) -> check_inheritance(Module, Args) -> Attrs = erlang:get_module_info(Module, attributes), - case lists:keysearch(extends, 1, Attrs) of - {value,{extends,[Base]}} when is_atom(Base), Base =/= Module -> + case lists:keyfind(extends, 1, Attrs) of + {extends, [Base]} when is_atom(Base), Base =/= Module -> %% This is just a heuristic for detecting abstract modules %% with inheritance so they can be handled; it would be %% much better to do it in the emulator runtime - case lists:keysearch(abstract, 1, Attrs) of - {value,{abstract,[true]}} -> + case lists:keyfind(abstract, 1, Attrs) of + {abstract, [true]} -> case lists:reverse(Args) of [M|Rs] when tuple_size(M) > 1, element(1,M) =:= Module, |