FSM step by step

Vance Shipley <>
Mon Aug 16 20:38:06 CEST 2004


On Mon, Aug 16, 2004 at 02:55:38PM -0300, Eduardo Figoli wrote:
}  
}  Is there a way to execute an FSM (OTP module FSM behaviour)
}  step by step without modifying the existing FSM implementation code?

You want the debugger!

http://www.erlang.org/doc/r9c/lib/debugger-2.2/doc/html/debugger_chapter.html#1.3

It's well worth the time to learn.

At a lower level you can use stdlib's sys module.  This is what the 
debugger does.  You can supply debug options (dbg_opt()) in the gen_fsm
start function:

  gen_fsm:start_link(Module, Args, [{debug, Dbgs}])

One of these options can be {install, {Func, FuncState}}}.  This debug
function will be called for every system event.  You would have this
function wait for a "step" message before continuing.  You can install
a debug function in a running process with sys:remove/2.

I have found the debug options to be a handy way of debugging in the
field applications.  I install a handler which formats just the
information I'm interested in and presents it in an application specific
way.  It's easy to turn it on and off and the distibuted code is
unchanged.

	-Vance






More information about the erlang-questions mailing list