2020-01-30 David Malcolm <dmalcolm@redhat.com>
+ * program-state.cc (extrinsic_state::dump_to_pp): New.
+ (extrinsic_state::dump_to_file): New.
+ (extrinsic_state::dump): New.
+ * program-state.h (extrinsic_state::dump_to_pp): New decl.
+ (extrinsic_state::dump_to_file): New decl.
+ (extrinsic_state::dump): New decl.
+ * sm.cc: Include "pretty-print.h".
+ (state_machine::dump_to_pp): New.
+ * sm.h (state_machine::dump_to_pp): New decl.
+
+2020-01-30 David Malcolm <dmalcolm@redhat.com>
+
* diagnostic-manager.cc (for_each_state_change): Use
extrinsic_state::get_num_checkers rather than accessing m_checkers
directly.
namespace ana {
+/* class extrinsic_state. */
+
+/* Dump a multiline representation of this state to PP. */
+
+void
+extrinsic_state::dump_to_pp (pretty_printer *pp) const
+{
+ pp_printf (pp, "extrinsic_state: %i checker(s)\n", get_num_checkers ());
+ unsigned i;
+ state_machine *checker;
+ FOR_EACH_VEC_ELT (m_checkers, i, checker)
+ {
+ pp_printf (pp, "m_checkers[%i]: %qs\n", i, checker->get_name ());
+ checker->dump_to_pp (pp);
+ }
+}
+
+/* Dump a multiline representation of this state to OUTF. */
+
+void
+extrinsic_state::dump_to_file (FILE *outf) const
+{
+ pretty_printer pp;
+ if (outf == stderr)
+ pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp.buffer->stream = outf;
+ dump_to_pp (&pp);
+ pp_flush (&pp);
+}
+
+/* Dump a multiline representation of this state to stderr. */
+
+DEBUG_FUNCTION void
+extrinsic_state::dump () const
+{
+ dump_to_file (stderr);
+}
+
/* class sm_state_map. */
/* sm_state_map's ctor. */
unsigned get_num_checkers () const { return m_checkers.length (); }
+ void dump_to_pp (pretty_printer *pp) const;
+ void dump_to_file (FILE *outf) const;
+ void dump () const;
+
private:
/* The state machines. */
auto_delete_vec <state_machine> &m_checkers;
#include "options.h"
#include "function.h"
#include "diagnostic-core.h"
+#include "pretty-print.h"
#include "analyzer/analyzer.h"
#include "analyzer/analyzer-logging.h"
#include "analyzer/sm.h"
gcc_assert (s < m_state_names.length ());
}
+/* Dump a multiline representation of this state machine to PP. */
+
+void
+state_machine::dump_to_pp (pretty_printer *pp) const
+{
+ unsigned i;
+ const char *name;
+ FOR_EACH_VEC_ELT (m_state_names, i, name)
+ pp_printf (pp, " state %i: %qs\n", i, name);
+}
+
/* Create instances of the various state machines, each using LOGGER,
and populate OUT with them. */
void validate (state_t s) const;
+ void dump_to_pp (pretty_printer *pp) const;
+
protected:
state_t add_state (const char *name);