]> git.ipfire.org Git - thirdparty/gcc.git/commit
diagnostics: revamp of dumping of "diagnostics" internal state
authorDavid Malcolm <dmalcolm@redhat.com>
Fri, 8 Aug 2025 20:55:45 +0000 (16:55 -0400)
committerDavid Malcolm <dmalcolm@redhat.com>
Fri, 8 Aug 2025 20:55:45 +0000 (16:55 -0400)
commitac4e7455a3323750d7f07a3f652b090a1bc2b498
tree17240c8eb9d5d61253af268d091b81b6e2f63801
parentf14fee14d440cffa1eedaf5681602b446e263100
diagnostics: revamp of dumping of "diagnostics" internal state

The diagnostics subsystem has a handy dump feature, usable
during debugging via

  (gdb) call global_dc->dump ()

which prints copious amounts of information about the state
of the diagnostics subsystem to stderr.

This patch consolidates the implementation and extends it, adding
various per-sink data (generation options specific to each of text,
SARIF, and HTML).

No functional difference intended outside of the debugger.

gcc/ChangeLog:
* Makefile.in (OBJS-libcommon): Add diagnostics/dumping.o.
* diagnostics/buffering.cc: Include "diagnostics/dumping.h".
(buffer::dump): Reimplement using diagnostics::dumping.
* diagnostics/context.cc: Include "diagnostics/dumping.h".
(context::dump): Reimplement using diagnostics::dumping.
Use sink::dump_kind when listing the sinks.
(sink::dump): Reimplement using diagnostics::dumping.
(counters::dump): Likewise.
* diagnostics/dumping.cc: New file.
* diagnostics/dumping.h: New file.
* diagnostics/file-cache.cc: Include "diagnostics/dumping.h".
(file_cache::dump): Reimplement using diagnostics::dumping.
(file_cache_slot::dump): Likewise.
* diagnostics/html-sink.cc: Include "diagnostics/dumping.h".
(html_generation_options::dump): New.
(html_sink_buffer::dump): Reimplement using diagnostics::dumping.
(html_builder::dump): New.
(html_sink::dump): Reimplement using diagnostics::dumping.
Add dump of the html_builder.
(html_file_sink::dump): Replace with...
(html_file_sink::dump_kind): ...this.
(html_buffered_sink::dump_kind): New.
* diagnostics/html-sink.h (html_generation_options::dump): New
decl.
* diagnostics/sarif-sink.cc: Include "diagnostics/dumping.h".
(sarif_serialization_format_json::dump): New.
(sarif_builder::dump): New.
(sarif_sink_buffer::dump): Reimplement using diagnostics::dumping.
(sarif_sink::dump): Likewise.  Add dump of the sarif_builder.
(sarif_stream_sink::dump_kind): New.
(sarif_file_sink::dump): Replace with...
(sarif_file_sink::dump_kind): ...this.
(get_dump_string_for_sarif_version): New.
(sarif_generation_options::dump): New.
(class buffered_sink): Rename to...
(class sarif_buffered_sink): ...this.
(sarif_buffered_sink::dump_kind): New.
* diagnostics/sarif-sink.h (sarif_serialization_format::dump):
New.
(sarif_serialization_format_json::dump): New decl.
(sarif_generation_options::dump): New decl.
* diagnostics/sink.h (sink::dump_kind): New.
* diagnostics/text-sink.cc: Include "diagnostics/dumping.h".
(text_sink_buffer::dump): Reimplement using diagnostics::dumping.
(text_sink::dump): Likewise.  Emit fields m_show_nesting,
m_show_locations_in_nesting, and m_show_nesting_levels.
* diagnostics/text-sink.h (text_sink::dump_kind): New.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
13 files changed:
gcc/Makefile.in
gcc/diagnostics/buffering.cc
gcc/diagnostics/context.cc
gcc/diagnostics/dumping.cc [new file with mode: 0644]
gcc/diagnostics/dumping.h [new file with mode: 0644]
gcc/diagnostics/file-cache.cc
gcc/diagnostics/html-sink.cc
gcc/diagnostics/html-sink.h
gcc/diagnostics/sarif-sink.cc
gcc/diagnostics/sarif-sink.h
gcc/diagnostics/sink.h
gcc/diagnostics/text-sink.cc
gcc/diagnostics/text-sink.h