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>