Skip to content
Snippets Groups Projects
Commit 2ca19d43 authored by David Malcolm's avatar David Malcolm
Browse files

diagnostics: add debug dump functions


This commit expands on r15-3973-g4c7a58ac2617e2, which added
debug "dump" member functiosn to pretty_printer and output_buffer.

This followup adds "dump" member functions to diagnostic_context and
diagnostic_format, extends the existing dump functions and adds
indentation to make it much easier to see the various relationships
between context, format, printer, etc.

Hence you can now do:

(gdb) call global_dc->dump ()

and get a useful summary of what the diagnostic subsystem is doing;
for example:

(gdb) call global_dc->dump()
diagnostic_context:
  counts:
  output format:
    sarif_output_format
  printer:
    m_show_color: false
    m_url_format: bel
    m_buffer:
      m_formatted_obstack current object: length 0:
      m_chunk_obstack current object: length 0:
      pp_formatted_chunks: depth 0
        0: TEXT("Function ")]
        1: BEGIN_QUOTE, TEXT("program"), END_QUOTE]
        2: TEXT(" requires an argument list at ")]
        3: TEXT("(1)")]

showing the counts of all diagnostic kind that are non-zero (none yet),
that we have a sarif output format, and the printer is part-way through
formatting a string.

gcc/ChangeLog:
	* diagnostic-format-json.cc (json_output_format::dump): New.
	* diagnostic-format-sarif.cc (sarif_output_format::dump): New.
	(sarif_file_output_format::dump): New.
	* diagnostic-format-text.cc (diagnostic_text_output_format::dump):
	New.
	* diagnostic-format-text.h (diagnostic_text_output_format::dump):
	New decl.
	* diagnostic-format.h (diagnostic_output_format::dump): New decls.
	* diagnostic.cc (diagnostic_context::dump): New.
	(diagnostic_output_format::dump): New.
	* diagnostic.h (diagnostic_context::dump): New decls.
	* pretty-print-format-impl.h (pp_formatted_chunks::dump): Add
	"indent" param.
	* pretty-print.cc (bytes_per_hexdump_line): New constant.
	(print_hexdump_line): New.
	(print_hexdump): New.
	(output_buffer::dump): Add "indent" param and use it.  Add
	hexdump of current object in m_formatted_obstack and
	m_chunk_obstack.
	(pp_formatted_chunks::dump): Add "indent" param and use it.
	(pretty_printer::dump): Likewise.  Add dumping of m_show_color
	and m_url_format.
	* pretty-print.h (output_buffer::dump): Add "indent" param.
	(pretty_printer::dump): Likewise.

gcc/testsuite/ChangeLog:
	* gcc.dg/plugin/diagnostic_plugin_xhtml_format.c
	(xhtml_output_format::dump): New.

Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
parent d277ded2
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment