analyzer: better logging of event creation
gcc/analyzer/ChangeLog: * checker-path.cc (checker_event::debug): New. (checker_path::add_event): Move here from checker-path.h. Add logging. * checker-path.h (checker_event::debug): New decl. (checker_path::checker_path): Add logger param. (checker_path::add_event): Move definition from here to checker-path.cc. (checker_path::m_logger): New field. * diagnostic-manager.cc (diagnostic_manager::emit_saved_diagnostic): Pass logger to checker_path ctor. (diagnostic_manager::add_events_for_eedge): Log scope when processing a run of stmts. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
This commit is contained in:
parent
d8c1058102
commit
965ce1ba39
3 changed files with 36 additions and 6 deletions
|
@ -204,6 +204,20 @@ checker_event::dump (pretty_printer *pp) const
|
|||
get_location ());
|
||||
}
|
||||
|
||||
/* Dump this event to stderr (for debugging/logging purposes). */
|
||||
|
||||
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->printer);
|
||||
pp.buffer->stream = stderr;
|
||||
dump (&pp);
|
||||
pp_newline (&pp);
|
||||
pp_flush (&pp);
|
||||
}
|
||||
|
||||
/* Hook for being notified when this event has its final id EMISSION_ID
|
||||
and is about to emitted for PD.
|
||||
|
||||
|
@ -1228,6 +1242,21 @@ checker_path::maybe_log (logger *logger, const char *desc) const
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
checker_path::add_event (std::unique_ptr<checker_event> event)
|
||||
{
|
||||
if (m_logger)
|
||||
{
|
||||
m_logger->start_log_line ();
|
||||
m_logger->log_partial ("added event[%i]: %s ",
|
||||
m_events.length (),
|
||||
event_kind_to_string (event.get ()->m_kind));
|
||||
event.get ()->dump (m_logger->get_printer ());
|
||||
m_logger->end_log_line ();
|
||||
}
|
||||
m_events.safe_push (event.release ());
|
||||
}
|
||||
|
||||
/* Print a multiline form of this path to STDERR. */
|
||||
|
||||
DEBUG_FUNCTION void
|
||||
|
|
|
@ -118,6 +118,7 @@ public:
|
|||
}
|
||||
|
||||
void dump (pretty_printer *pp) const;
|
||||
void debug () const;
|
||||
|
||||
void set_location (location_t loc) { m_loc = loc; }
|
||||
|
||||
|
@ -607,7 +608,7 @@ private:
|
|||
class checker_path : public diagnostic_path
|
||||
{
|
||||
public:
|
||||
checker_path () : diagnostic_path () {}
|
||||
checker_path (logger *logger) : diagnostic_path (), m_logger (logger) {}
|
||||
|
||||
/* Implementation of diagnostic_path vfuncs. */
|
||||
|
||||
|
@ -631,10 +632,7 @@ public:
|
|||
|
||||
void maybe_log (logger *logger, const char *desc) const;
|
||||
|
||||
void add_event (std::unique_ptr<checker_event> event)
|
||||
{
|
||||
m_events.safe_push (event.release ());
|
||||
}
|
||||
void add_event (std::unique_ptr<checker_event> event);
|
||||
|
||||
void delete_event (int idx)
|
||||
{
|
||||
|
@ -711,6 +709,8 @@ private:
|
|||
exploded_node *, so that rewind events can refer to them in their
|
||||
descriptions. */
|
||||
hash_map <const exploded_node *, diagnostic_event_id_t> m_setjmp_event_ids;
|
||||
|
||||
logger *m_logger;
|
||||
};
|
||||
|
||||
} // namespace ana
|
||||
|
|
|
@ -1356,7 +1356,7 @@ diagnostic_manager::emit_saved_diagnostic (const exploded_graph &eg,
|
|||
|
||||
/* This is the diagnostic_path subclass that will be built for
|
||||
the diagnostic. */
|
||||
checker_path emission_path;
|
||||
checker_path emission_path (get_logger ());
|
||||
|
||||
/* Populate emission_path with a full description of EPATH. */
|
||||
build_emission_path (pb, *epath, &emission_path);
|
||||
|
@ -1963,6 +1963,7 @@ diagnostic_manager::add_events_for_eedge (const path_builder &pb,
|
|||
events for them. */
|
||||
if (dst_state.m_region_model)
|
||||
{
|
||||
log_scope s (get_logger (), "processing run of stmts");
|
||||
program_state iter_state (dst_state);
|
||||
program_point iter_point (dst_point);
|
||||
while (1)
|
||||
|
|
Loading…
Add table
Reference in a new issue