analyzer: add .fpath.txt dumps to -fdump-analyzer-feasibility
I found this extension to -fdump-analyzer-feasibility very helpful when debugging PR analyzer/105285. gcc/analyzer/ChangeLog: * diagnostic-manager.cc (epath_finder::process_worklist_item): Call dump_feasible_path when a path that reaches the the target enode is found. (epath_finder::dump_feasible_path): New. * engine.cc (feasibility_state::dump_to_pp): New. * exploded-graph.h (feasibility_state::dump_to_pp): New decl. * feasible-graph.cc (feasible_graph::dump_feasible_path): New. * feasible-graph.h (feasible_graph::dump_feasible_path): New decls. * program-point.cc (function_point::print): Fix missing trailing newlines. * program-point.h (program_point::print_source_line): Remove unimplemented decl. gcc/ChangeLog: * doc/invoke.texi (-fdump-analyzer-feasibility): Mention the fpath.txt output. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
This commit is contained in:
parent
509fd16da8
commit
d8586b00dd
@ -112,6 +112,10 @@ private:
|
||||
void dump_feasible_graph (const exploded_node *target_enode,
|
||||
const char *desc, unsigned diag_idx,
|
||||
const feasible_graph &fg);
|
||||
void dump_feasible_path (const exploded_node *target_enode,
|
||||
unsigned diag_idx,
|
||||
const feasible_graph &fg,
|
||||
const feasible_node &fnode) const;
|
||||
|
||||
const exploded_graph &m_eg;
|
||||
shortest_exploded_paths *m_sep;
|
||||
@ -510,6 +514,9 @@ epath_finder::process_worklist_item (feasible_worklist *worklist,
|
||||
target_enode->m_index, diag_idx,
|
||||
succ_fnode->get_path_length ());
|
||||
*out_best_path = fg->make_epath (succ_fnode);
|
||||
if (flag_dump_analyzer_feasibility)
|
||||
dump_feasible_path (target_enode, diag_idx, *fg, *succ_fnode);
|
||||
|
||||
/* Success: stop the worklist iteration. */
|
||||
return false;
|
||||
}
|
||||
@ -608,6 +615,23 @@ epath_finder::dump_feasible_graph (const exploded_node *target_enode,
|
||||
free (filename);
|
||||
}
|
||||
|
||||
/* Dump the path to FNODE to "BASE_NAME.DIAG_IDX.to-enN.fpath.txt". */
|
||||
|
||||
void
|
||||
epath_finder::dump_feasible_path (const exploded_node *target_enode,
|
||||
unsigned diag_idx,
|
||||
const feasible_graph &fg,
|
||||
const feasible_node &fnode) const
|
||||
{
|
||||
auto_timevar tv (TV_ANALYZER_DUMP);
|
||||
pretty_printer pp;
|
||||
pp_printf (&pp, "%s.%i.to-en%i.fpath.txt",
|
||||
dump_base_name, diag_idx, target_enode->m_index);
|
||||
char *filename = xstrdup (pp_formatted_text (&pp));
|
||||
fg.dump_feasible_path (fnode, filename);
|
||||
free (filename);
|
||||
}
|
||||
|
||||
/* class saved_diagnostic. */
|
||||
|
||||
/* saved_diagnostic's ctor.
|
||||
|
@ -4605,6 +4605,15 @@ feasibility_state::maybe_update_for_edge (logger *logger,
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Dump this object to PP. */
|
||||
|
||||
void
|
||||
feasibility_state::dump_to_pp (pretty_printer *pp,
|
||||
bool simple, bool multiline) const
|
||||
{
|
||||
m_model.dump_to_pp (pp, simple, multiline);
|
||||
}
|
||||
|
||||
/* A family of cluster subclasses for use when generating .dot output for
|
||||
exploded graphs (-fdump-analyzer-exploded-graph), for grouping the
|
||||
enodes into hierarchical boxes.
|
||||
|
@ -1001,6 +1001,8 @@ public:
|
||||
const region_model &get_model () const { return m_model; }
|
||||
const auto_sbitmap &get_snodes_visited () const { return m_snodes_visited; }
|
||||
|
||||
void dump_to_pp (pretty_printer *pp, bool simple, bool multiline) const;
|
||||
|
||||
private:
|
||||
region_model m_model;
|
||||
auto_sbitmap m_snodes_visited;
|
||||
|
@ -218,6 +218,71 @@ feasible_graph::make_epath (feasible_node *fnode) const
|
||||
return epath;
|
||||
}
|
||||
|
||||
/* Dump the path to DST_FNODE in textual form to PP. */
|
||||
|
||||
void
|
||||
feasible_graph::dump_feasible_path (const feasible_node &dst_fnode,
|
||||
pretty_printer *pp) const
|
||||
{
|
||||
const feasible_node *fnode = &dst_fnode;
|
||||
|
||||
auto_vec<const feasible_edge *> fpath;
|
||||
|
||||
/* FG is actually a tree. Built the path backwards, by walking
|
||||
backwards from FNODE until we reach the origin. */
|
||||
while (fnode->get_inner_node ()->m_index != 0)
|
||||
{
|
||||
gcc_assert (fnode->m_preds.length () == 1);
|
||||
feasible_edge *pred_fedge
|
||||
= static_cast <feasible_edge *> (fnode->m_preds[0]);
|
||||
fpath.safe_push (pred_fedge);
|
||||
fnode = static_cast <const feasible_node *> (pred_fedge->m_src);
|
||||
}
|
||||
|
||||
/* Now reverse it. */
|
||||
fpath.reverse ();
|
||||
|
||||
for (unsigned i = 0; i < fpath.length (); i++)
|
||||
{
|
||||
const feasible_edge *fedge = fpath[i];
|
||||
const feasible_node *src_fnode
|
||||
= static_cast <const feasible_node *> (fedge->m_src);
|
||||
const feasible_node *dest_fnode
|
||||
= static_cast <const feasible_node *> (fedge->m_dest);
|
||||
|
||||
pp_printf (pp, "fpath[%i]: FN %i (EN %i) -> FN %i (EN %i)",
|
||||
i,
|
||||
src_fnode->get_index (),
|
||||
src_fnode->get_inner_node ()->m_index,
|
||||
dest_fnode->get_index (),
|
||||
dest_fnode->get_inner_node ()->m_index);
|
||||
pp_newline (pp);
|
||||
pp_printf (pp, " FN %i (EN %i):",
|
||||
dest_fnode->get_index (),
|
||||
dest_fnode->get_inner_node ()->m_index);
|
||||
pp_newline (pp);
|
||||
const program_point &point = dest_fnode->get_inner_node ()->get_point ();
|
||||
point.print (pp, format (true));
|
||||
dest_fnode->get_state ().dump_to_pp (pp, true, true);
|
||||
pp_newline (pp);
|
||||
}
|
||||
}
|
||||
|
||||
/* Dump the path to DST_FNODE in textual form to FILENAME. */
|
||||
|
||||
void
|
||||
feasible_graph::dump_feasible_path (const feasible_node &dst_fnode,
|
||||
const char *filename) const
|
||||
{
|
||||
FILE *fp = fopen (filename, "w");
|
||||
pretty_printer pp;
|
||||
pp_format_decoder (&pp) = default_tree_printer;
|
||||
pp.buffer->stream = fp;
|
||||
dump_feasible_path (dst_fnode, &pp);
|
||||
pp_flush (&pp);
|
||||
fclose (fp);
|
||||
}
|
||||
|
||||
/* Dump stats about this graph to LOGGER. */
|
||||
|
||||
void
|
||||
|
@ -197,11 +197,17 @@ class feasible_graph : public digraph <fg_traits>
|
||||
|
||||
exploded_path *make_epath (feasible_node *fnode) const;
|
||||
|
||||
void dump_feasible_path (const feasible_node &dst_fnode,
|
||||
const char *filename) const;
|
||||
|
||||
unsigned get_num_infeasible () const { return m_num_infeasible; }
|
||||
|
||||
void log_stats (logger *logger) const;
|
||||
|
||||
private:
|
||||
void dump_feasible_path (const feasible_node &dst_fnode,
|
||||
pretty_printer *pp) const;
|
||||
|
||||
unsigned m_num_infeasible;
|
||||
};
|
||||
|
||||
|
@ -114,6 +114,8 @@ function_point::print (pretty_printer *pp, const format &f) const
|
||||
|
||||
case PK_ORIGIN:
|
||||
pp_printf (pp, "origin");
|
||||
if (f.m_newlines)
|
||||
pp_newline (pp);
|
||||
break;
|
||||
|
||||
case PK_BEFORE_SUPERNODE:
|
||||
@ -156,6 +158,8 @@ function_point::print (pretty_printer *pp, const format &f) const
|
||||
|
||||
case PK_AFTER_SUPERNODE:
|
||||
pp_printf (pp, "after SN: %i", m_supernode->m_index);
|
||||
if (f.m_newlines)
|
||||
pp_newline (pp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -179,7 +179,6 @@ public:
|
||||
}
|
||||
|
||||
void print (pretty_printer *pp, const format &f) const;
|
||||
void print_source_line (pretty_printer *pp) const;
|
||||
void dump () const;
|
||||
|
||||
json::object *to_json () const;
|
||||
|
@ -10198,8 +10198,8 @@ diagnostic to @file{@var{file}.@var{idx}.@var{kind}.epath.txt}.
|
||||
@opindex dump-analyzer-feasibility
|
||||
Dump internal details about the analyzer's search for feasible paths.
|
||||
The details are written in a form suitable for viewing with GraphViz
|
||||
to filenames of the form @file{@var{file}.*.fg.dot} and
|
||||
@file{@var{file}.*.tg.dot}.
|
||||
to filenames of the form @file{@var{file}.*.fg.dot},
|
||||
@file{@var{file}.*.tg.dot}, and @file{@var{file}.*.fpath.txt}.
|
||||
|
||||
@item -fdump-analyzer-json
|
||||
@opindex fdump-analyzer-json
|
||||
|
Loading…
Reference in New Issue
Block a user