[09/11,analyzer] Add checker_path::debug
diff mbox series

Message ID 1574284430-8776-10-git-send-email-dmalcolm@redhat.com
State New
Headers show
Series
  • Static analysis v2
Related show

Commit Message

David Malcolm Nov. 20, 2019, 9:13 p.m. UTC
This patch adds a new debugging function.

gcc/ChangeLog:
	* analyzer/checker-path.cc (checker_path::debug): New member
	function.
	* analyzer/checker-path.h (checker_path::debug): New decl.
---
 gcc/analyzer/checker-path.cc | 19 +++++++++++++++++++
 gcc/analyzer/checker-path.h  |  2 +-
 2 files changed, 20 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/gcc/analyzer/checker-path.cc b/gcc/analyzer/checker-path.cc
index 5302504..0a18406 100644
--- a/gcc/analyzer/checker-path.cc
+++ b/gcc/analyzer/checker-path.cc
@@ -883,6 +883,25 @@  checker_path::maybe_log (logger *logger, const char *desc) const
     }
 }
 
+/* Print a multiline form of this path to STDERR.  */
+
+DEBUG_FUNCTION void
+checker_path::debug () const
+{
+  checker_event *e;
+  int i;
+  FOR_EACH_VEC_ELT (m_events, i, e)
+    {
+      label_text event_desc (e->get_desc (false));
+      fprintf (stderr,
+	       "[%i]: %s \"%s\"\n",
+	       i,
+	       event_kind_to_string (m_events[i]->m_kind),
+	       event_desc.m_buffer);
+      event_desc.maybe_free ();
+    }
+}
+
 /* Add a warning_event to the end of this path.  */
 
 void
diff --git a/gcc/analyzer/checker-path.h b/gcc/analyzer/checker-path.h
index f042f47..916e5a7 100644
--- a/gcc/analyzer/checker-path.h
+++ b/gcc/analyzer/checker-path.h
@@ -499,8 +499,8 @@  public:
     return *m_events[idx];
   }
 
-
   void dump (pretty_printer *pp) const;
+  void debug () const;
 
   void maybe_log (logger *logger, const char *desc) const;