]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
diagnostics: add dump methods to client_data_hooks and logical_location_manager
authorDavid Malcolm <dmalcolm@redhat.com>
Thu, 18 Sep 2025 20:07:09 +0000 (16:07 -0400)
committerDavid Malcolm <dmalcolm@redhat.com>
Thu, 18 Sep 2025 20:07:09 +0000 (16:07 -0400)
gcc/ChangeLog:
* diagnostics/client-data-hooks.h (client_data_hooks::dump): New.
* diagnostics/context.cc (context::dump): Dump
m_client_data_hooks.
(client_data_hooks::dump): New.
* diagnostics/logical-locations.h
(logical_locations::manager::dump): New.
* diagnostics/selftest-logical-locations.cc: Include
"diagnostics/dumping.h".
(test_manager::dump): New.
* diagnostics/selftest-logical-locations.h (test_manager::dump):
New decl.
* libgdiagnostics.cc: Include "diagnostics/dumping.h".
(impl_logical_location_manager::dump): New.
* tree-logical-location.cc: Include "diagnostics/dumping.h".
(tree_logical_location_manager::dump): New.
* tree-logical-location.h (tree_logical_location_manager::dump):
New decl.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/diagnostics/client-data-hooks.h
gcc/diagnostics/context.cc
gcc/diagnostics/logical-locations.h
gcc/diagnostics/selftest-logical-locations.cc
gcc/diagnostics/selftest-logical-locations.h
gcc/libgdiagnostics.cc
gcc/tree-logical-location.cc
gcc/tree-logical-location.h

index 94c51b28190a003a4dda25d38c320dceccf5e4b0..2926e94de05f1df64aba0ad33db30384f987643a 100644 (file)
@@ -36,6 +36,9 @@ class client_data_hooks
  public:
   virtual ~client_data_hooks () {}
 
+  void dump (FILE *out, int indent) const;
+  void DEBUG_FUNCTION dump () const { dump (stderr, 0); }
+
   /* Get version info for this client, or NULL.  */
   virtual const client_version_info *get_any_version_info () const = 0;
 
index 139c022a6027ad7fc2c0d2abc5587a2edd3739d7..cd14977d542558053bb975d8f5ccb093305ea8bc 100644 (file)
@@ -455,6 +455,11 @@ context::dump (FILE *outfile, int indent) const
     m_file_cache->dump (outfile, indent + 4);
   else
     dumping::emit_none (outfile, indent + 4);
+  dumping::emit_heading (outfile, indent + 2, "client data hooks");
+  if (m_client_data_hooks)
+    m_client_data_hooks->dump (outfile, indent + 4);
+  else
+    dumping::emit_none (outfile, indent + 4);
 }
 
 /* Return true if sufficiently severe diagnostics have been seen that
@@ -654,6 +659,18 @@ context::initialize_fixits_change_set ()
   m_fixits_change_set = new changes::change_set (*m_file_cache);
 }
 
+// class client_data_hooks
+
+void
+client_data_hooks::dump (FILE *outfile, int indent) const
+{
+  dumping::emit_heading (outfile, indent, "logical location manager");
+  if (auto mgr = get_logical_location_manager ())
+    mgr->dump (outfile, indent + 2);
+  else
+    dumping::emit_none (outfile, indent + 2);
+}
+
 } // namespace diagnostics
 
 /* Initialize DIAGNOSTIC, where the message MSG has already been
index b52a9b4f3b9874aeb5ad6c4989285e9841d77342..ba787bd3e3e114f395243f47268072ed69a01c74 100644 (file)
@@ -148,6 +148,9 @@ class manager
 public:
   virtual ~manager () {}
 
+  virtual void dump (FILE *out, int indent) const = 0;
+  void DEBUG_FUNCTION dump () const { dump (stderr, 0); }
+
   /* vfuncs for interpreting keys.  */
 
   /* Get a string (or NULL) for K suitable for use by the SARIF logicalLocation
index 8ba423389f20b7c0abd2b85eae0078eeb4280306..f8d5b75f747826e925be7c09a0ed98ba62cb2127 100644 (file)
@@ -23,6 +23,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "coretypes.h"
 #include "selftest.h"
 #include "diagnostics/selftest-logical-locations.h"
+#include "diagnostics/dumping.h"
 
 #if CHECKING_P
 
@@ -38,6 +39,12 @@ test_manager::~test_manager ()
     delete iter.second;
 }
 
+void
+test_manager::dump (FILE *outfile, int indent) const
+{
+  dumping::emit_heading (outfile, indent, "test_manager");
+}
+
 const char *
 test_manager::get_short_name (key k) const
 {
index c14a28282dabe3fd88791d5c867f6c4cc8e79e93..e630382d38ef891342c60679f1f8db2699c4cc7f 100644 (file)
@@ -39,6 +39,8 @@ class test_manager : public manager
 public:
   ~test_manager ();
 
+  void dump (FILE *out, int indent) const final override;
+
   const char *get_short_name (key) const final override;
   const char *get_name_with_scope (key) const final override;
   const char *get_internal_name (key) const final override;
index d87dd46cb5c19d64651ca47e0ab9805f9fe2e31c..cceddff9d690675426d97e9c5baa731cfae964a2 100644 (file)
@@ -37,6 +37,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "diagnostics/digraphs.h"
 #include "diagnostics/state-graphs.h"
 #include "diagnostics/logical-locations.h"
+#include "diagnostics/dumping.h"
 #include "diagnostics/changes.h"
 #include "libgdiagnostics.h"
 #include "libgdiagnostics-private.h"
@@ -478,6 +479,12 @@ public:
     return key::from_ptr (ptr);
   }
 
+  void dump (FILE *outfile, int indent) const final override
+  {
+    diagnostics::dumping::emit_heading
+      (outfile, indent, "impl_logical_location_manager");
+  }
+
   const char *get_short_name (key k) const final override
   {
     if (auto loc = ptr_from_key (k))
index 19bccd1a70609fe957891d98f0ae24a2da3313c6..b39327feca5ea4d64105c1ab0344def3c662245a 100644 (file)
@@ -26,6 +26,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-logical-location.h"
 #include "langhooks.h"
 #include "intl.h"
+#include "diagnostics/dumping.h"
 
 using namespace diagnostics::logical_locations;
 
@@ -40,6 +41,13 @@ assert_valid_tree (const_tree node)
 /* class tree_logical_location_manager
    : public diagnostics::logical_locations::manager.  */
 
+void
+tree_logical_location_manager::dump (FILE *outfile, int indent) const
+{
+  diagnostics::dumping::emit_heading (outfile, indent,
+                                     "tree_logical_location_manager");
+}
+
 const char *
 tree_logical_location_manager::get_short_name (key k) const
 {
index 2a7de37ade785de6fca5c1c1ec372d4e8a600b3e..b7e0da8d6ff136bd7088f53c450450c8de0bee4b 100644 (file)
@@ -34,6 +34,8 @@ public:
   using key = diagnostics::logical_locations::key;
   using kind = diagnostics::logical_locations::kind;
 
+  void dump (FILE *out, int indent) const final override;
+
   const char *get_short_name (key) const final override;
   const char *get_name_with_scope (key) const final override;
   const char *get_internal_name (key) const final override;