Beispiel #1
0
/**Function********************************************************************

  Synopsis    [Action method associated with TraceCompact class.]

  Description [ The action associated with TraceCompact is to print the trace
  in the specified file in compact format.]

  SideEffects []

  SeeAlso     []

******************************************************************************/
int trace_compact_action(const TracePlugin_ptr plugin)

{
    Trace_ptr trace = plugin->trace;
    TraceIter start_iter;
    TraceIter stop_iter;
    TraceIter step;

    TraceIteratorType input_iter_type;
    TraceIteratorType state_iter_type;
    TraceIteratorType combo_iter_type;
    TraceSymbolsIter sym_iter;

    int i;
    node_ptr sym;

    FILE* out = TraceOpt_output_stream(plugin->opt);

    start_iter = (0 != TraceOpt_from_here(plugin->opt))
                 ? trace_ith_iter(trace, TraceOpt_from_here(plugin->opt))
                 : trace_first_iter(trace);

    stop_iter = (0 != TraceOpt_to_here(plugin->opt))
                ? trace_ith_iter(trace, 1 + TraceOpt_to_here(plugin->opt))
                : TRACE_END_ITER;

    input_iter_type = TraceOpt_show_defines(plugin->opt)
                      ? TRACE_ITER_I_SYMBOLS : TRACE_ITER_I_VARS;

    state_iter_type = TraceOpt_show_defines(plugin->opt)
                      ? TRACE_ITER_SF_SYMBOLS : TRACE_ITER_SF_VARS;

    combo_iter_type = TraceOpt_show_defines(plugin->opt)
                      ? TRACE_ITER_SI_DEFINES : TRACE_ITER_NONE;

    {   /* ----- prints the header: first inputs, then states and comb ----- */
        fprintf(out, "Steps\\Vars\t");

        TRACE_SYMBOLS_FOREACH(trace, input_iter_type, sym_iter, sym) {
            /* skip non-visible symbols */
            if (!trace_plugin_is_visible_symbol(plugin, sym)) continue;

            TracePlugin_print_symbol(plugin, sym);
            fprintf(out, "\t");
        }
        TRACE_SYMBOLS_FOREACH(trace, state_iter_type, sym_iter, sym) {
            /* skip non-visible symbols */
            if (!trace_plugin_is_visible_symbol(plugin, sym)) continue;

            TracePlugin_print_symbol(plugin, sym);
            fprintf(out, "\t");
        }
        TRACE_SYMBOLS_FOREACH(trace, combo_iter_type, sym_iter, sym) {
            /* skip non-visible symbols */
            if (!trace_plugin_is_visible_symbol(plugin, sym)) continue;

            TracePlugin_print_symbol(plugin, sym);
            fprintf(out, "\t");
        }
        fprintf(out,"\n");
    } /* header */

    i = MAX(1, TraceOpt_from_here(plugin->opt));
    step = start_iter;
    while (stop_iter != step) {

        fprintf(out, "Step%d\t", i);

        /* lazy defines evaluation */
        if (TraceOpt_show_defines(plugin->opt)) {
            trace_step_evaluate_defines(trace, step);
        }

        TRACE_SYMBOLS_FOREACH (trace, input_iter_type, sym_iter, sym) {
            node_ptr val = Trace_step_get_value(trace, step, sym);

            if (Nil != val) {
                TracePlugin_print_symbol(plugin, val);
            }
            else {
                fprintf(out, "-");
            }

            fprintf(out, "\t");
        }

        TRACE_SYMBOLS_FOREACH(trace, state_iter_type, sym_iter, sym) {
            node_ptr val = Trace_step_get_value(trace, step, sym);

            if (Nil != val) {
                TracePlugin_print_symbol(plugin, val);
            }
            else {
                fprintf(out, "-");
            }

            fprintf(out, "\t");
        }
Beispiel #2
0
int trace_explainer_action(const TracePlugin_ptr self)
{
  const Trace_ptr trace = self->trace;
  const SymbTable_ptr symb_table = Trace_get_symb_table(trace);
  const NuSMVEnv_ptr env = EnvObject_get_environment(ENV_OBJECT(symb_table));

  TraceIter start_iter;
  TraceIter stop_iter;
  TraceIter step;
  TraceIteratorType input_iter_type;
  TraceIteratorType state_iter_type;
  TraceIteratorType combo_iter_type;
  hash_ptr changed_states;
  int i;

  OStream_ptr out = TraceOpt_output_stream(self->opt);

  start_iter = (0 != TraceOpt_from_here(self->opt))
    ? trace_ith_iter(trace, TraceOpt_from_here(self->opt))
    : trace_first_iter(trace);

  stop_iter = (0 != TraceOpt_to_here(self->opt))
    ? trace_ith_iter(trace, 1 + TraceOpt_to_here(self->opt))
    : TRACE_END_ITER;

  input_iter_type = TraceOpt_show_defines(self->opt)
    ? TRACE_ITER_I_SYMBOLS : TRACE_ITER_I_VARS;

  state_iter_type = TraceOpt_show_defines(self->opt)
    ? TRACE_ITER_SF_SYMBOLS : TRACE_ITER_SF_VARS;

  combo_iter_type = TraceOpt_show_defines(self->opt)
    ? (TraceOpt_show_defines_with_next(self->opt)
       ? TRACE_ITER_COMBINATORIAL
       : TRACE_ITER_SI_DEFINES)
    : TRACE_ITER_NONE;

  OStream_printf(out, "Trace Description: %s \n", Trace_get_desc(trace));
  OStream_printf(out, "Trace Type: %s \n", TraceType_to_string(env, Trace_get_type(trace)));

  /* indent */
  OStream_inc_indent_size(out);

  changed_states = new_assoc();
  nusmv_assert(changed_states != (hash_ptr)NULL);

  i = MAX(1, TraceOpt_from_here(self->opt)); step = start_iter;
  while (stop_iter != step) {
    TraceStepIter iter;
    node_ptr symb;
    node_ptr val;

    boolean input_header = false;

    /* lazy defines evaluation */
    if (TraceOpt_show_defines(self->opt)) {
      trace_step_evaluate_defines(trace, step);
    }

    /* COMBINATORIAL SECTION (optional) */
    TRACE_STEP_FOREACH(trace, step, combo_iter_type, iter, symb, val) {
      /* skip non-visible symbols */
      if (!trace_plugin_is_visible_symbol(self, symb)) continue;

      /* if required, print only symbols with changed values */
      if (TRACE_EXPLAINER(self)->changes_only) {
        if (val == find_assoc(changed_states, symb)) { continue; }
        insert_assoc(changed_states, symb, val);
      }

      TracePlugin_print_assignment(self, symb, val);
    } /* foreach SI_DEFINES */

    /* INPUT SECTION (optional) */
    TRACE_STEP_FOREACH(trace, step, input_iter_type, iter, symb, val) {
      if (false == input_header) {
        OStream_printf(out, "-> Input: %d.%d <-\n", Trace_get_id(trace), i);
        input_header = true;
      }
      /* skip non-visible symbols */
      if (!trace_plugin_is_visible_symbol(self, symb)) continue;

      /* if required, print only symbols with changed values */
      if (TRACE_EXPLAINER(self)->changes_only) {
        if (val == find_assoc(changed_states, symb)) { continue; }
        insert_assoc(changed_states, symb, val);
      }

      TracePlugin_print_assignment(self, symb, val);
    } /* foreach I_SYMBOLS */

    if (Trace_step_is_loopback(trace, step)) {
      OStream_printf(out, "-- Loop starts here\n");
    }

    /* STATE SECTION (mandatory) */
    OStream_printf(out, "-> State: %d.%d <-\n", Trace_get_id(trace), i);
    TRACE_STEP_FOREACH(trace, step, state_iter_type, iter, symb, val) {
      /* skip non-visible symbols */
      if (!trace_plugin_is_visible_symbol(self, symb)) continue;

      /* if required, print only symbols with changed values */
      if (TRACE_EXPLAINER(self)->changes_only) {
        if (val == find_assoc(changed_states, symb)) { continue; }
        insert_assoc(changed_states, symb, val);
      }

      TracePlugin_print_assignment(self, symb, val);
    } /* foreach SF_SYMBOLS */

    ++ i; step = TraceIter_get_next(step);
  } /* while */

  free_assoc(changed_states);

  /* deindent */
  OStream_dec_indent_size(out);

  return 0;
}