summaryrefslogtreecommitdiff
path: root/gcc/analyzer/diagnostic-manager.cc
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2022-07-27 17:38:53 -0400
committerDavid Malcolm <dmalcolm@redhat.com>2022-07-27 17:53:54 -0400
commit1321183a13540b5c3503586b94c758198471c7b3 (patch)
treed8d116832a6693f6404421cc4d5766482bba0dcb /gcc/analyzer/diagnostic-manager.cc
parent4c1c38ba9535435b04ee22cda33042b7d48ca183 (diff)
analyzer: add .fpath.txt dumps to -fdump-analyzer-feasibility
(cherry picked from r13-6-gd8586b00dd00a1783862da5f0c8811a740400074) 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>
Diffstat (limited to 'gcc/analyzer/diagnostic-manager.cc')
-rw-r--r--gcc/analyzer/diagnostic-manager.cc24
1 files changed, 24 insertions, 0 deletions
diff --git a/gcc/analyzer/diagnostic-manager.cc b/gcc/analyzer/diagnostic-manager.cc
index bf7c8fc5147..5bd4cd49cac 100644
--- a/gcc/analyzer/diagnostic-manager.cc
+++ b/gcc/analyzer/diagnostic-manager.cc
@@ -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.