Commit 42f36563 by David Malcolm

analyzer: add extrinsic_state::dump

gcc/analyzer/ChangeLog:
	* 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.
parent ebe9174e
2020-01-30 David Malcolm <dmalcolm@redhat.com> 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 * diagnostic-manager.cc (for_each_state_change): Use
extrinsic_state::get_num_checkers rather than accessing m_checkers extrinsic_state::get_num_checkers rather than accessing m_checkers
directly. directly.
......
...@@ -59,6 +59,44 @@ along with GCC; see the file COPYING3. If not see ...@@ -59,6 +59,44 @@ along with GCC; see the file COPYING3. If not see
namespace ana { 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. */ /* class sm_state_map. */
/* sm_state_map's ctor. */ /* sm_state_map's ctor. */
......
...@@ -45,6 +45,10 @@ public: ...@@ -45,6 +45,10 @@ public:
unsigned get_num_checkers () const { return m_checkers.length (); } 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: private:
/* The state machines. */ /* The state machines. */
auto_delete_vec <state_machine> &m_checkers; auto_delete_vec <state_machine> &m_checkers;
......
...@@ -28,6 +28,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -28,6 +28,7 @@ along with GCC; see the file COPYING3. If not see
#include "options.h" #include "options.h"
#include "function.h" #include "function.h"
#include "diagnostic-core.h" #include "diagnostic-core.h"
#include "pretty-print.h"
#include "analyzer/analyzer.h" #include "analyzer/analyzer.h"
#include "analyzer/analyzer-logging.h" #include "analyzer/analyzer-logging.h"
#include "analyzer/sm.h" #include "analyzer/sm.h"
...@@ -91,6 +92,17 @@ state_machine::validate (state_t s) const ...@@ -91,6 +92,17 @@ state_machine::validate (state_t s) const
gcc_assert (s < m_state_names.length ()); 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, /* Create instances of the various state machines, each using LOGGER,
and populate OUT with them. */ and populate OUT with them. */
......
...@@ -80,6 +80,8 @@ public: ...@@ -80,6 +80,8 @@ public:
void validate (state_t s) const; void validate (state_t s) const;
void dump_to_pp (pretty_printer *pp) const;
protected: protected:
state_t add_state (const char *name); state_t add_state (const char *name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment