Argus.Extractors.GenStatem (Panoptes v0.13.0)

Copy Markdown View Source

gen_statem extractor.

Detects gen_statem modules and extracts their state machine structure: states, transitions, and timeouts. Supports state_functions callback mode (function names = states) and handle_event_function mode (state passed as argument).

Approach

For state_functions mode, each exported function whose name isn't a standard gen_statem callback is treated as a state handler. Transitions are detected by scanning return tuples for {:next_state, target, ...} patterns.

For handle_event_function mode, the handle_event/4 function is analyzed for state argument patterns.

Emitted facts

  • statem_event_clause(mod, func, event_type) — a clause head matches this event type
  • statem_call_unreplied(mod, func, site) — a {:call, from} clause returns at site without replying, postponing, or keeping from
  • statem_info_catchall(mod, func) — some clause accepts :info with any content
  • statem_event_catchall(mod, func) — some clause accepts any event

The clause-head walk behind the last three lives in Argus.Extractors.GenStatem.EventClauses.

  • statem_module(mod, callback_mode) — gen_statem module identification
  • statem_state(mod, state) — state in the machine
  • statem_transition(mod, from, event, to) — state transition
  • statem_timeout(mod, state, type, value) — timeout set per state