@@ -544,13 +544,9 @@ access_range::dump_to_pp (pretty_printer *pp, bool simple) const
DEBUG_FUNCTION void
access_range::dump (bool simple) const
{
- pretty_printer pp;
- pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
- pp.set_output_stream (stderr);
+ tree_dump_pretty_printer pp (stderr);
dump_to_pp (&pp, simple);
pp_newline (&pp);
- pp_flush (&pp);
}
void
@@ -363,12 +363,8 @@ call_details::dump_to_pp (pretty_printer *pp, bool simple) const
DEBUG_FUNCTION void
call_details::dump (bool simple) const
{
- pretty_printer pp;
- pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
- pp.set_output_stream (stderr);
+ tree_dump_pretty_printer pp (stderr);
dump_to_pp (&pp, simple);
- pp_flush (&pp);
}
/* Get a conjured_svalue for this call for REG,
@@ -146,12 +146,8 @@ call_summary::dump (const extrinsic_state &ext_state,
FILE *fp,
bool simple) const
{
- pretty_printer pp;
- pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
- pp.set_output_stream (fp);
+ tree_dump_pretty_printer pp (fp);
dump_to_pp (ext_state, &pp, simple);
- pp_flush (&pp);
}
/* Dump a multiline representation of this object to stderr. */
@@ -885,12 +881,8 @@ call_summary_replay::dump_to_pp (pretty_printer *pp, bool simple) const
void
call_summary_replay::dump (FILE *fp, bool simple) const
{
- pretty_printer pp;
- pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
- pp.set_output_stream (fp);
+ tree_dump_pretty_printer pp (fp);
dump_to_pp (&pp, simple);
- pp_flush (&pp);
}
/* Dump a multiline representation of this object to stderr. */
@@ -197,13 +197,9 @@ checker_event::dump (pretty_printer *pp) const
DEBUG_FUNCTION void
checker_event::debug () const
{
- pretty_printer pp;
- pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
- pp.set_output_stream (stderr);
+ tree_dump_pretty_printer pp (stderr);
dump (&pp);
pp_newline (&pp);
- pp_flush (&pp);
}
/* Hook for being notified when this event has its final id EMISSION_ID
@@ -182,13 +182,9 @@ range::dump_to_pp (pretty_printer *pp) const
DEBUG_FUNCTION void
range::dump () const
{
- pretty_printer pp;
- pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
- pp.set_output_stream (stderr);
+ tree_dump_pretty_printer pp (stderr);
dump_to_pp (&pp);
pp_newline (&pp);
- pp_flush (&pp);
}
/* Determine if there is only one possible value for this range.
@@ -445,13 +441,9 @@ bounded_range::dump_to_pp (pretty_printer *pp, bool show_types) const
void
bounded_range::dump (bool show_types) const
{
- pretty_printer pp;
- pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
- pp.set_output_stream (stderr);
+ tree_dump_pretty_printer pp (stderr);
dump_to_pp (&pp, show_types);
pp_newline (&pp);
- pp_flush (&pp);
}
json::object *
@@ -718,13 +710,9 @@ bounded_ranges::dump_to_pp (pretty_printer *pp, bool show_types) const
DEBUG_FUNCTION void
bounded_ranges::dump (bool show_types) const
{
- pretty_printer pp;
- pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
- pp.set_output_stream (stderr);
+ tree_dump_pretty_printer pp (stderr);
dump_to_pp (&pp, show_types);
pp_newline (&pp);
- pp_flush (&pp);
}
json::value *
@@ -1769,12 +1757,8 @@ constraint_manager::dump_to_pp (pretty_printer *pp, bool multiline) const
void
constraint_manager::dump (FILE *fp) const
{
- pretty_printer pp;
- pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
- pp.set_output_stream (fp);
+ tree_dump_pretty_printer pp (fp);
dump_to_pp (&pp, true);
- pp_flush (&pp);
}
/* Dump a multiline representation of this constraint_manager to stderr. */
@@ -1419,12 +1419,8 @@ void
exploded_node::dump (FILE *fp,
const extrinsic_state &ext_state) const
{
- pretty_printer pp;
- pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
- pp.set_output_stream (fp);
+ tree_dump_pretty_printer pp (fp);
dump_to_pp (&pp, ext_state);
- pp_flush (&pp);
}
/* Dump a multiline representation of this node to stderr. */
@@ -4828,12 +4824,8 @@ exploded_path::dump_to_pp (pretty_printer *pp,
void
exploded_path::dump (FILE *fp, const extrinsic_state *ext_state) const
{
- pretty_printer pp;
- pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
- pp.set_output_stream (fp);
+ tree_dump_pretty_printer pp (fp);
dump_to_pp (&pp, ext_state);
- pp_flush (&pp);
}
/* Dump this path in multiline form to stderr. */
@@ -300,11 +300,8 @@ program_point::print (pretty_printer *pp, const format &f) const
DEBUG_FUNCTION void
program_point::dump () const
{
- pretty_printer pp;
- pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
- pp.set_output_stream (stderr);
+ tree_dump_pretty_printer pp (stderr);
print (&pp, format (true));
- pp_flush (&pp);
}
/* Return a new json::object of the form
@@ -83,12 +83,8 @@ extrinsic_state::dump_to_pp (pretty_printer *pp) const
void
extrinsic_state::dump_to_file (FILE *outf) const
{
- pretty_printer pp;
- if (outf == stderr)
- pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
- pp.set_output_stream (outf);
+ tree_dump_pretty_printer pp (outf);
dump_to_pp (&pp);
- pp_flush (&pp);
}
/* Dump a multiline representation of this state to stderr. */
@@ -271,13 +267,9 @@ sm_state_map::print (const region_model *model,
DEBUG_FUNCTION void
sm_state_map::dump (bool simple) const
{
- pretty_printer pp;
- pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
- pp.set_output_stream (stderr);
+ tree_dump_pretty_printer pp (stderr);
print (NULL, simple, true, &pp);
pp_newline (&pp);
- pp_flush (&pp);
}
/* Return a new json::object of the form
@@ -1165,13 +1157,8 @@ program_state::dump_to_file (const extrinsic_state &ext_state,
bool summarize, bool multiline,
FILE *outf) const
{
- pretty_printer pp;
- pp_format_decoder (&pp) = default_tree_printer;
- if (outf == stderr)
- pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
- pp.set_output_stream (outf);
+ tree_dump_pretty_printer pp (outf);
dump_to_pp (ext_state, summarize, multiline, &pp);
- pp_flush (&pp);
}
/* Dump a multiline representation of this state to stderr. */
@@ -95,13 +95,9 @@ symbolic_byte_offset::dump_to_pp (pretty_printer *pp, bool simple) const
void
symbolic_byte_offset::dump (bool simple) const
{
- pretty_printer pp;
- pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
- pp.set_output_stream (stderr);
+ tree_dump_pretty_printer pp (stderr);
dump_to_pp (&pp, simple);
pp_newline (&pp);
- pp_flush (&pp);
}
json::value *
@@ -154,13 +150,9 @@ symbolic_byte_range::dump_to_pp (pretty_printer *pp,
void
symbolic_byte_range::dump (bool simple, region_model_manager &mgr) const
{
- pretty_printer pp;
- pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
- pp.set_output_stream (stderr);
+ tree_dump_pretty_printer pp (stderr);
dump_to_pp (&pp, simple, mgr);
pp_newline (&pp);
- pp_flush (&pp);
}
json::value *
@@ -83,11 +83,8 @@ record_layout::dump_to_pp (pretty_printer *pp) const
void
record_layout::dump () const
{
- pretty_printer pp;
- pp_format_decoder (&pp) = default_tree_printer;
- pp.set_output_stream (stderr);
+ tree_dump_pretty_printer pp (stderr);
dump_to_pp (&pp);
- pp_flush (&pp);
}
const record_layout::item *
@@ -347,12 +347,8 @@ reachable_regions::dump_to_pp (pretty_printer *pp) const
DEBUG_FUNCTION void
reachable_regions::dump () const
{
- pretty_printer pp;
- pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
- pp.set_output_stream (stderr);
+ tree_dump_pretty_printer pp (stderr);
dump_to_pp (&pp);
- pp_flush (&pp);
}
} // namespace ana
@@ -223,13 +223,9 @@ region_to_value_map::dump_to_pp (pretty_printer *pp, bool simple,
DEBUG_FUNCTION void
region_to_value_map::dump (bool simple) const
{
- pretty_printer pp;
- pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
- pp.set_output_stream (stderr);
+ tree_dump_pretty_printer pp (stderr);
dump_to_pp (&pp, simple, true);
pp_newline (&pp);
- pp_flush (&pp);
}
/* Generate a JSON value for this region_to_value_map.
@@ -483,13 +479,9 @@ region_model::dump_to_pp (pretty_printer *pp, bool simple,
void
region_model::dump (FILE *fp, bool simple, bool multiline) const
{
- pretty_printer pp;
- pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
- pp.set_output_stream (fp);
+ tree_dump_pretty_printer pp (fp);
dump_to_pp (&pp, simple, multiline);
pp_newline (&pp);
- pp_flush (&pp);
}
/* Dump a multiline representation of this model to stderr. */
@@ -7397,12 +7389,8 @@ model_merger::dump_to_pp (pretty_printer *pp, bool simple) const
void
model_merger::dump (FILE *fp, bool simple) const
{
- pretty_printer pp;
- pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
- pp.set_output_stream (fp);
+ tree_dump_pretty_printer pp (fp);
dump_to_pp (&pp, simple);
- pp_flush (&pp);
}
/* Dump a multiline representation of this merger to stderr. */
@@ -138,13 +138,9 @@ region_offset::dump_to_pp (pretty_printer *pp, bool simple) const
DEBUG_FUNCTION void
region_offset::dump (bool simple) const
{
- pretty_printer pp;
- pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
- pp.set_output_stream (stderr);
+ tree_dump_pretty_printer pp (stderr);
dump_to_pp (&pp, simple);
pp_newline (&pp);
- pp_flush (&pp);
}
/* An svalue that matches the pattern (BASE * FACTOR) + OFFSET
@@ -1015,13 +1011,9 @@ region::get_relative_concrete_byte_range (byte_range *out) const
DEBUG_FUNCTION void
region::dump (bool simple) const
{
- pretty_printer pp;
- pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
- pp.set_output_stream (stderr);
+ tree_dump_pretty_printer pp (stderr);
dump_to_pp (&pp, simple);
pp_newline (&pp);
- pp_flush (&pp);
}
/* Dump a tree-like representation of this region and its constituent symbols
@@ -584,12 +584,9 @@ deallocator_set::deallocator_set (malloc_state_machine *sm,
DEBUG_FUNCTION void
deallocator_set::dump () const
{
- pretty_printer pp;
- pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
- pp.set_output_stream (stderr);
+ tree_dump_pretty_printer pp (stderr);
dump_to_pp (&pp);
pp_newline (&pp);
- pp_flush (&pp);
}
/* struct custom_deallocator_set : public deallocator_set. */
@@ -107,13 +107,9 @@ uncertainty_t::dump_to_pp (pretty_printer *pp, bool simple) const
DEBUG_FUNCTION void
uncertainty_t::dump (bool simple) const
{
- pretty_printer pp;
- pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
- pp.set_output_stream (stderr);
+ tree_dump_pretty_printer pp (stderr);
dump_to_pp (&pp, simple);
pp_newline (&pp);
- pp_flush (&pp);
}
/* class binding_key. */
@@ -144,13 +140,9 @@ binding_key::make (store_manager *mgr, const region *r)
DEBUG_FUNCTION void
binding_key::dump (bool simple) const
{
- pretty_printer pp;
- pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
- pp.set_output_stream (stderr);
+ tree_dump_pretty_printer pp (stderr);
dump_to_pp (&pp, simple);
pp_newline (&pp);
- pp_flush (&pp);
}
/* Get a description of this binding_key. */
@@ -230,11 +222,9 @@ bit_range::dump_to_pp (pretty_printer *pp) const
DEBUG_FUNCTION void
bit_range::dump () const
{
- pretty_printer pp;
- pp.set_output_stream (stderr);
+ tree_dump_pretty_printer pp (stderr);
dump_to_pp (&pp);
pp_newline (&pp);
- pp_flush (&pp);
}
/* Generate a JSON value for this bit_range.
@@ -506,11 +496,9 @@ byte_range::dump_to_pp (pretty_printer *pp) const
DEBUG_FUNCTION void
byte_range::dump () const
{
- pretty_printer pp;
- pp.set_output_stream (stderr);
+ tree_dump_pretty_printer pp (stderr);
dump_to_pp (&pp);
pp_newline (&pp);
- pp_flush (&pp);
}
/* Generate a JSON value for this byte_range.
@@ -773,13 +761,9 @@ binding_map::dump_to_pp (pretty_printer *pp, bool simple,
DEBUG_FUNCTION void
binding_map::dump (bool simple) const
{
- pretty_printer pp;
- pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
- pp.set_output_stream (stderr);
+ tree_dump_pretty_printer pp (stderr);
dump_to_pp (&pp, simple, true);
pp_newline (&pp);
- pp_flush (&pp);
}
/* Return a new json::object of the form
@@ -1400,17 +1384,13 @@ binding_cluster::dump_to_pp (pretty_printer *pp, bool simple,
DEBUG_FUNCTION void
binding_cluster::dump (bool simple) const
{
- pretty_printer pp;
- pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
- pp.set_output_stream (stderr);
+ tree_dump_pretty_printer pp (stderr);
pp_string (&pp, " cluster for: ");
m_base_region->dump_to_pp (&pp, simple);
pp_string (&pp, ": ");
pp_newline (&pp);
dump_to_pp (&pp, simple, true);
pp_newline (&pp);
- pp_flush (&pp);
}
/* Assert that this object is valid. */
@@ -2636,13 +2616,9 @@ store::dump_to_pp (pretty_printer *pp, bool simple, bool multiline,
DEBUG_FUNCTION void
store::dump (bool simple) const
{
- pretty_printer pp;
- pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
- pp.set_output_stream (stderr);
+ tree_dump_pretty_printer pp (stderr);
dump_to_pp (&pp, simple, true, NULL);
pp_newline (&pp);
- pp_flush (&pp);
}
/* Assert that this object is valid. */
@@ -898,13 +898,9 @@ superedge::dump (pretty_printer *pp) const
DEBUG_FUNCTION void
superedge::dump () const
{
- pretty_printer pp;
- pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
- pp.set_output_stream (stderr);
+ tree_dump_pretty_printer pp (stderr);
dump (&pp);
pp_newline (&pp);
- pp_flush (&pp);
}
/* Implementation of dedge::dump_dot for superedges.
@@ -86,13 +86,9 @@ svalue::dump () const
DEBUG_FUNCTION void
svalue::dump (bool simple) const
{
- pretty_printer pp;
- pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
- pp.set_output_stream (stderr);
+ tree_dump_pretty_printer pp (stderr);
dump_to_pp (&pp, simple);
pp_newline (&pp);
- pp_flush (&pp);
}
/* Generate a textual representation of this svalue for debugging purposes. */
@@ -59,15 +59,9 @@ void dump_to_pp (const T &obj, text_art::theme *theme, pretty_printer *pp)
template <typename T>
void dump_to_file (const T &obj, FILE *outf)
{
- pretty_printer pp;
- pp_format_decoder (&pp) = default_tree_printer;
- if (outf == stderr)
- pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
- pp.set_output_stream (outf);
-
+ tree_dump_pretty_printer pp (outf);
text_art::theme *theme = global_dc->get_diagram_theme ();
dump_to_pp (obj, theme, &pp);
- pp_flush (&pp);
}
/* Dump OBJ to stderr, using OBJ's make_dump_widget member function. */
@@ -55,4 +55,24 @@ void tree_diagnostics_defaults (diagnostic_context *context);
bool default_tree_printer (pretty_printer *, text_info *, const char *,
int, bool, bool, bool, bool *, pp_token_list &);
+/* A subclass of pretty_printer for writing "dump" functions.
+ Wires itself up to a FILE *, and colorizes if it's stderr and
+ the user requested colorization. */
+
+class tree_dump_pretty_printer : public pretty_printer
+{
+public:
+ tree_dump_pretty_printer (FILE *outf)
+ {
+ pp_format_decoder (this) = default_tree_printer;
+ if (outf == stderr)
+ pp_show_color (this) = pp_show_color (global_dc->m_printer);
+ set_output_stream (outf);
+ }
+ ~tree_dump_pretty_printer ()
+ {
+ pp_flush (this);
+ }
+};
+
#endif /* ! GCC_TREE_DIAGNOSTIC_H */