[erlang-questions] Extracting detailed information from TypEr/Dialyzer

Tomas Abrahamsson tomas.abrahamsson@REDACTED
Sun Oct 31 19:58:35 CET 2010


On Tue, Oct 12, 2010 at 09:00, Torben Hoffmann <torben.lehoff@REDACTED> wrote:
> Hi,
>
> I want to extract the following information from a gen_fsm:
>
>   - all the states
>   - the incoming events
>   - possible next states
>
> but I want to do it per function clause and not only on the function level
> as TypEr and Dialyzer does it.

One way to do that is to copy each function clause into a
separate function.  Then one can run TypEr on the expanded
code.  Attached is an escript that does such an expansion
of exported functions of arity 2 and 3, and also of
handle_event, handle_sync_event and handle_info. The script
accepts -I and -D options for include paths and macro
definitions, just like erlc,and prints the expanded program
on stdout.

I've tried plotting state machines from the output of TypEr
when run on the expanded results, and it seems to do reasonably
well. I haven't done any thorough verification.

It doesn't solve all of your problems: it doesn't find any
outgoing messages, and it has the same limitations you
already indicated when returning from a function clause in
different ways, so I guess the results are roughly what
you already seems to have, or what Vance's drawing tool
already produces.

Somehow being able to make more use of TypEr's
knowledge about a file would be really interesting,
for example to be able to query it for type information
given various execution paths through the program,
if it would be possible.

BRs
Tomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fsm_clause_separator.es
Type: application/ecmascript
Size: 6080 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20101031/a55e36f6/attachment.bin>


More information about the erlang-questions mailing list