4
%% Copyright Ericsson AB 1996-2009. All Rights Reserved.
4
%% Copyright Ericsson AB 1996-2010. All Rights Reserved.
6
6
%% The contents of this file are subject to the Erlang Public License,
7
7
%% Version 1.1, (the "License"); you may not use this file except in
8
8
%% compliance with the License. You should have received a copy of the
9
9
%% Erlang Public License along with this software. If not, it can be
10
10
%% retrieved online at http://www.erlang.org/.
12
12
%% Software distributed under the License is distributed on an "AS IS"
13
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
14
%% the License for the specific language governing rights and limitations
15
15
%% under the License.
376
376
_Msg when Debug =:= [] ->
377
377
handle_msg(Msg, Parent, Name, StateName, StateData, Mod, Time);
379
Debug1 = sys:handle_debug(Debug, {?MODULE, print_event},
379
Debug1 = sys:handle_debug(Debug, fun print_event/3,
380
380
{Name, StateName}, {in, Msg}),
381
381
handle_msg(Msg, Parent, Name, StateName, StateData,
382
382
Mod, Time, Debug1)
466
466
From = from(Msg),
467
467
case catch dispatch(Msg, Mod, StateName, StateData) of
468
468
{next_state, NStateName, NStateData} ->
469
Debug1 = sys:handle_debug(Debug, {?MODULE, print_event},
469
Debug1 = sys:handle_debug(Debug, fun print_event/3,
470
470
{Name, NStateName}, return),
471
471
loop(Parent, Name, NStateName, NStateData, Mod, infinity, Debug1);
472
472
{next_state, NStateName, NStateData, Time1} ->
473
Debug1 = sys:handle_debug(Debug, {?MODULE, print_event},
473
Debug1 = sys:handle_debug(Debug, fun print_event/3,
474
474
{Name, NStateName}, return),
475
475
loop(Parent, Name, NStateName, NStateData, Mod, Time1, Debug1);
476
476
{reply, Reply, NStateName, NStateData} when From =/= undefined ->
520
520
reply(Name, {To, Tag}, Reply, Debug, StateName) ->
521
521
reply({To, Tag}, Reply),
522
sys:handle_debug(Debug, {?MODULE, print_event}, Name,
522
sys:handle_debug(Debug, fun print_event/3, Name,
523
523
{out, Reply, To, StateName}).
525
525
%%% ---------------------------------------------------
542
542
{shutdown,_}=Shutdown ->
545
error_info(Reason, Name, Msg, StateName, StateData, Debug),
546
case erlang:function_exported(Mod, format_status, 2) of
548
Args = [get(), StateData],
549
case catch Mod:format_status(terminate, Args) of
550
{'EXIT', _} -> StateData;
556
error_info(Reason,Name,Msg,StateName,FmtStateData,Debug),
603
614
format_status(Opt, StatusData) ->
604
615
[PDict, SysState, Parent, Debug, [Name, StateName, StateData, Mod, _Time]] =
606
Header = lists:concat(["Status for state machine ", Name]),
617
StatusHdr = "Status for state machine",
620
lists:concat([StatusHdr, " ", pid_to_list(Name)]);
621
is_atom(Name); is_list(Name) ->
622
lists:concat([StatusHdr, " ", Name]);
607
626
Log = sys:get_debug(log, Debug, []),
627
DefaultStatus = [{data, [{"StateData", StateData}]}],
609
629
case erlang:function_exported(Mod, format_status, 2) of
611
631
case catch Mod:format_status(Opt,[PDict,StateData]) of
612
{'EXIT', _} -> [{data, [{"StateData", StateData}]}];
632
{'EXIT', _} -> DefaultStatus;
633
StatusList when is_list(StatusList) -> StatusList;
616
[{data, [{"StateData", StateData}]}]
618
639
[{header, Header},
619
640
{data, [{"Status", SysState},