This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
dwarlint: check_range_out_of_scope only check location of pc_contained_dies
- From: Mark Wielaard <mjw at redhat dot com>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Thu, 31 Mar 2011 23:49:04 +0200
- Subject: dwarlint: check_range_out_of_scope only check location of pc_contained_dies
Hi,
I was seeing lots of warnings from dwarflint saying a location attribute
was outside containing scope. This was for things like the
DW_AT_location of a DW_TAG_formal_parameter. I think these shouldn't be
checked. In fact the first check in recursively_validate () already only
looked at code describing dies. So I made the second check for the
location address ranges use the same logic. Does this look OK, or is it
more subtle than that?
diff -w attached, full patch on mjw/location-range branch (since it is
mostly whitespace).
Thanks,
Mark
diff --git a/dwarflint/check_range_out_of_scope.cc b/dwarflint/check_range_out_of_scope.cc
index daa2bc3..873118d 100644
--- a/dwarflint/check_range_out_of_scope.cc
+++ b/dwarflint/check_range_out_of_scope.cc
@@ -89,6 +89,25 @@ check_range_out_of_scope::check_range_out_of_scope (checkstack &stack, dwarflint
}
}
+/* These PC-ful DIEs should be wholly contained by PC-ful parental DIE. */
+bool
+is_pc_contained_die (dwarf::debug_info_entry const &die)
+{
+ switch (die.tag ())
+ {
+ case DW_TAG_inlined_subroutine:
+ case DW_TAG_lexical_block:
+ case DW_TAG_entry_point:
+ case DW_TAG_label:
+ case DW_TAG_with_stmt:
+ case DW_TAG_try_block:
+ case DW_TAG_catch_block:
+ return true;
+ default:
+ return false;
+ }
+}
+
void
check_range_out_of_scope::recursively_validate
(dwarf::compile_unit const &cu,
@@ -147,20 +166,7 @@ check_range_out_of_scope::recursively_validate
// If my_ranges is non-empty, check that it's a subset of
// ranges.
- if (my_ranges.size () != 0)
- {
- // xxx Extract this logic to some table.
- switch (die.tag ())
- {
- /* These PC-ful DIEs should be wholly contained by
- PC-ful parental DIE. */
- case DW_TAG_inlined_subroutine:
- case DW_TAG_lexical_block:
- case DW_TAG_entry_point:
- case DW_TAG_label:
- case DW_TAG_with_stmt:
- case DW_TAG_try_block:
- case DW_TAG_catch_block:
+ if (is_pc_contained_die (die) && my_ranges.size () != 0)
{
coverage cov1;
for (ranges_t::const_iterator it = my_ranges.begin ();
@@ -186,8 +192,6 @@ check_range_out_of_scope::recursively_validate
<< std::endl;
}
}
- }
- }
// xxx building the coverage for each die is a waste of time
ranges_t const &use_ranges
@@ -200,6 +204,8 @@ check_range_out_of_scope::recursively_validate
// Now finally look for location attributes and check that
// _their_ PCs form a subset of ranges of this DIE.
+ if (is_pc_contained_die (die))
+ {
for (dwarf::debug_info_entry::attributes_type::const_iterator
at = die.attributes ().begin ();
at != die.attributes ().end (); ++at)
@@ -237,6 +243,7 @@ check_range_out_of_scope::recursively_validate
}
}
}
+ }
// Check children recursively.
for (dwarf::debug_info_entry::children_type::const_iterator