]> gcc.gnu.org Git - gcc.git/commitdiff
analyzer: add extrinsic_state::dump
authorDavid Malcolm <dmalcolm@redhat.com>
Thu, 30 Jan 2020 21:59:15 +0000 (16:59 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Fri, 31 Jan 2020 00:28:43 +0000 (19:28 -0500)
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.

gcc/analyzer/ChangeLog
gcc/analyzer/program-state.cc
gcc/analyzer/program-state.h
gcc/analyzer/sm.cc
gcc/analyzer/sm.h

index 9f2420624c0bb0b9bd3d94f7c2ed573139889394..709d1cb913f7ffbe0191a167d9eb6609e3ab5e12 100644 (file)
@@ -1,3 +1,15 @@
+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
index ead62a5d423813d24099016970e6c57963e66ef2..4c0b9a8bfa05754f720d838dd5a0ffb6e2baaa80 100644 (file)
@@ -59,6 +59,44 @@ along with GCC; see the file COPYING3.  If not see
 
 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.  */
index a052c6e80266acbf2c978ab3da9ef26a642f63da..d2badb1a2ed07cd9e7a577166691676eb5b48a18 100644 (file)
@@ -45,6 +45,10 @@ public:
 
   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;
index 74fd17033ff38804821e6cbda65e49ac3e9bc970..e94c691c16cd48a3853b7d78628ad20b985402f1 100644 (file)
@@ -28,6 +28,7 @@ along with GCC; see the file COPYING3.  If not see
 #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"
@@ -91,6 +92,17 @@ state_machine::validate (state_t s) const
   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.  */
 
index 25163d7a7b1bcd056e4a0f7cefa68d96fd830c59..3e8f4b6891d56b32a653309d4cd4f4858c5fbe04 100644 (file)
@@ -80,6 +80,8 @@ public:
 
   void validate (state_t s) const;
 
+  void dump_to_pp (pretty_printer *pp) const;
+
 protected:
   state_t add_state (const char *name);
 
This page took 0.072341 seconds and 5 git commands to generate.