From: David Malcolm Date: Thu, 18 Sep 2025 20:07:09 +0000 (-0400) Subject: diagnostics: add dump methods to client_data_hooks and logical_location_manager X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=423d7b24e7cff24f25c484a15c08006534ea2734;p=thirdparty%2Fgcc.git diagnostics: add dump methods to client_data_hooks and logical_location_manager 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 --- diff --git a/gcc/diagnostics/client-data-hooks.h b/gcc/diagnostics/client-data-hooks.h index 94c51b28190..2926e94de05 100644 --- a/gcc/diagnostics/client-data-hooks.h +++ b/gcc/diagnostics/client-data-hooks.h @@ -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; diff --git a/gcc/diagnostics/context.cc b/gcc/diagnostics/context.cc index 139c022a602..cd14977d542 100644 --- a/gcc/diagnostics/context.cc +++ b/gcc/diagnostics/context.cc @@ -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 diff --git a/gcc/diagnostics/logical-locations.h b/gcc/diagnostics/logical-locations.h index b52a9b4f3b9..ba787bd3e3e 100644 --- a/gcc/diagnostics/logical-locations.h +++ b/gcc/diagnostics/logical-locations.h @@ -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 diff --git a/gcc/diagnostics/selftest-logical-locations.cc b/gcc/diagnostics/selftest-logical-locations.cc index 8ba423389f2..f8d5b75f747 100644 --- a/gcc/diagnostics/selftest-logical-locations.cc +++ b/gcc/diagnostics/selftest-logical-locations.cc @@ -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 { diff --git a/gcc/diagnostics/selftest-logical-locations.h b/gcc/diagnostics/selftest-logical-locations.h index c14a28282da..e630382d38e 100644 --- a/gcc/diagnostics/selftest-logical-locations.h +++ b/gcc/diagnostics/selftest-logical-locations.h @@ -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; diff --git a/gcc/libgdiagnostics.cc b/gcc/libgdiagnostics.cc index d87dd46cb5c..cceddff9d69 100644 --- a/gcc/libgdiagnostics.cc +++ b/gcc/libgdiagnostics.cc @@ -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)) diff --git a/gcc/tree-logical-location.cc b/gcc/tree-logical-location.cc index 19bccd1a706..b39327feca5 100644 --- a/gcc/tree-logical-location.cc +++ b/gcc/tree-logical-location.cc @@ -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 { diff --git a/gcc/tree-logical-location.h b/gcc/tree-logical-location.h index 2a7de37ade7..b7e0da8d6ff 100644 --- a/gcc/tree-logical-location.h +++ b/gcc/tree-logical-location.h @@ -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;