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 <dmalcolm@redhat.com>
This commit is contained in:
David Malcolm 2025-09-18 16:07:09 -04:00
parent 21fe45f111
commit 423d7b24e7
8 changed files with 49 additions and 0 deletions

View 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;

View 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

View 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

View 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
{

View 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;

View 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))

View 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
{

View 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;