]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
json: add dump overload for easier debugging
authorDavid Malcolm <dmalcolm@redhat.com>
Wed, 24 Jul 2024 22:07:51 +0000 (18:07 -0400)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Sun, 28 Jul 2024 17:05:53 +0000 (19:05 +0200)
This has saved me a lot of typing in the debugger.

gcc/ChangeLog:
* json.cc (value::dump): New overload, taking no params.
* json.h (value::dump): New decl.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/json.cc
gcc/json.h

index b3106f39cedf011f51b9f5e32f0d79f37e7d0cc6..53edca5205567c3528874938147316d95ab56868 100644 (file)
@@ -90,6 +90,16 @@ value::dump (FILE *outf, bool formatted) const
   pp_flush (&pp);
 }
 
+/* A convenience function for debugging.
+   Dump to stderr with formatting, and a trailing newline. */
+
+void
+value::dump () const
+{
+  dump (stderr, true);
+  fprintf (stderr, "\n");
+}
+
 /* class json::object, a subclass of json::value, representing
    an ordered collection of key/value pairs.  */
 
index 97c68116b32928cf9ddab69978b8013f95fd1a88..ad4f8c448f8c1db72ef09b6231140d9b3d8d442b 100644 (file)
@@ -83,6 +83,7 @@ class value
   virtual void print (pretty_printer *pp, bool formatted) const = 0;
 
   void dump (FILE *, bool formatted) const;
+  void DEBUG_FUNCTION dump () const;
 };
 
 /* Subclass of value for objects: a collection of key/value pairs