Commit 884d9141 by David Malcolm

analyzer: make summarized dumps more comprehensive

The previous implementation of summarized dumps within
region_model::dump_to_pp showed only the "top-level" keys within the
current frame and for globals, and thus didn't e.g. show the values
of fields of structs, or elements of arrays.

This patch rewrites it to gather a vec of representative path_vars
for all regions, using this to generate the dump, so that all expressible
lvalues ought to make it to the summarized dump.

gcc/analyzer/ChangeLog:
	* region-model.cc: Include "stor-layout.h".
	(region_model::dump_to_pp): Rather than calling
	dump_summary_of_map on each of the current frame and the globals,
	instead get a vec of representative path_vars for all regions,
	and then dump a summary of all of them.
	(region_model::dump_summary_of_map): Delete, rewriting into...
	(region_model::dump_summary_of_rep_path_vars): ...this new
	function, working on a vec of path_vars.
	(region_model::set_value): New overload.
	(region_model::get_representative_path_var): Rename
	"parent_region" local to "parent_reg" and consolidate with other
	local.  Guard test for grandparent being stack on parent_reg being
	non-NULL.  Move handling for parent being an array_region to
	within guard for parent_reg being non-NULL.
	(selftest::make_test_compound_type): New function.
	(selftest::test_dump_2): New selftest.
	(selftest::test_dump_3): New selftest.
	(selftest::test_stack_frames): Update expected output from
	simplified dump to show "a" and "b" from parent frame and "y" in
	child frame.
	(selftest::analyzer_region_model_cc_tests): Call test_dump_2 and
	test_dump_3.
	* region-model.h (region_model::set_value): New overload decl.
	(region_model::dump_summary_of_map): Delete.
	(region_model::dump_summary_of_rep_path_vars): New.
parent f665beeb
2020-03-18 David Malcolm <dmalcolm@redhat.com> 2020-03-18 David Malcolm <dmalcolm@redhat.com>
* region-model.cc: Include "stor-layout.h".
(region_model::dump_to_pp): Rather than calling
dump_summary_of_map on each of the current frame and the globals,
instead get a vec of representative path_vars for all regions,
and then dump a summary of all of them.
(region_model::dump_summary_of_map): Delete, rewriting into...
(region_model::dump_summary_of_rep_path_vars): ...this new
function, working on a vec of path_vars.
(region_model::set_value): New overload.
(region_model::get_representative_path_var): Rename
"parent_region" local to "parent_reg" and consolidate with other
local. Guard test for grandparent being stack on parent_reg being
non-NULL. Move handling for parent being an array_region to
within guard for parent_reg being non-NULL.
(selftest::make_test_compound_type): New function.
(selftest::test_dump_2): New selftest.
(selftest::test_dump_3): New selftest.
(selftest::test_stack_frames): Update expected output from
simplified dump to show "a" and "b" from parent frame and "y" in
child frame.
(selftest::analyzer_region_model_cc_tests): Call test_dump_2 and
test_dump_3.
* region-model.h (region_model::set_value): New overload decl.
(region_model::dump_summary_of_map): Delete.
(region_model::dump_summary_of_rep_path_vars): New.
2020-03-18 David Malcolm <dmalcolm@redhat.com>
* region-model.h (class noop_region_model_context): New subclass * region-model.h (class noop_region_model_context): New subclass
of region_model_context. of region_model_context.
(class tentative_region_model_context): Inherit from (class tentative_region_model_context): Inherit from
......
...@@ -1771,6 +1771,7 @@ class region_model ...@@ -1771,6 +1771,7 @@ class region_model
void set_value (region_id lhs_rid, svalue_id rhs_sid, void set_value (region_id lhs_rid, svalue_id rhs_sid,
region_model_context *ctxt); region_model_context *ctxt);
void set_value (tree lhs, tree rhs, region_model_context *ctxt);
svalue_id set_to_new_unknown_value (region_id dst_rid, tree type, svalue_id set_to_new_unknown_value (region_id dst_rid, tree type,
region_model_context *ctxt); region_model_context *ctxt);
...@@ -1884,8 +1885,9 @@ class region_model ...@@ -1884,8 +1885,9 @@ class region_model
void poison_any_pointers_to_bad_regions (const region_id_set &bad_regions, void poison_any_pointers_to_bad_regions (const region_id_set &bad_regions,
enum poison_kind pkind); enum poison_kind pkind);
void dump_summary_of_map (pretty_printer *pp, map_region *map_region, void dump_summary_of_rep_path_vars (pretty_printer *pp,
bool *is_first) const; auto_vec<path_var> *rep_path_vars,
bool *is_first);
auto_delete_vec<svalue> m_svalues; auto_delete_vec<svalue> m_svalues;
auto_delete_vec<region> m_regions; auto_delete_vec<region> m_regions;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment