- the actual fix is removing the forced lint.check <check_debug_loc>.
The lowlevel_checks pass takes care of validating any present sections.
In this case .debug_loc isn't there, yet the check needs to run.
- and add a test case for this.
TESTS = tests/run-debug_abbrev-duplicate-attribute.sh \
tests/run-check_duplicate_DW_tag_variable.sh \
tests/run-location-leaks.sh \
- tests/run-nodebug.sh
+ tests/run-nodebug.sh \
+ tests/run-check_range_out_of_scope.sh
-EXTRA_DIST = tests/run-debug_abbrev-duplicate-attribute.sh tests/debug_abbrev-duplicate-attribute.bz2 \
- tests/run-check_duplicate_DW_tag_variable.sh tests/crc7.ko.debug.bz2 \
- tests/run-location-leaks.sh tests/location-leaks.bz2 \
- tests/run-nodebug.sh tests/nodebug.bz2
+EXTRA_DIST = $(TESTS) \
+ tests/debug_abbrev-duplicate-attribute.bz2 \
+ tests/crc7.ko.debug.bz2 \
+ tests/location-leaks.bz2 \
+ tests/nodebug.bz2 \
+ tests/check_range_out_of_scope-1.bz2
installed_TESTS_ENVIRONMENT = libdir=$(DESTDIR)$(libdir) \
bindir=$(DESTDIR)$(bindir) \
// Register the check.
reg<check_range_out_of_scope> reg_range_out_of_scope;
+ const ::Dwarf_Addr noaddr = -1;
}
check_range_out_of_scope::check_range_out_of_scope (checkstack &stack, dwarflint &lint)
: highlevel_check<check_range_out_of_scope> (stack, lint)
{
- lint.check <check_debug_loc> (stack);
-
try
{
class dwarf::compile_units const &cus = dw.compile_units ();
where_reset_2 (&wh, die.offset ());
::Dwarf_Addr low_pc = 0;
- ::Dwarf_Addr high_pc = -1;
+ ::Dwarf_Addr high_pc = ::noaddr;
ranges_t my_ranges;
for (dwarf::debug_info_entry::attributes_type::const_iterator
at = die.attributes ().begin ();
my_ranges.push_back (*it);
}
- if (low_pc != 0 || high_pc != (::Dwarf_Addr)-1)
+ if (low_pc != 0 || high_pc != ::noaddr)
{
// Simultaneous appearance of both low_pc/high_pc pair
// and rangelist pointer is forbidden by 3.1.1 #1.
// purpose as low_pc/high_pc pair that covers one
// address point.
- if (high_pc == (::Dwarf_Addr)-1
+ if (high_pc == ::noaddr
&& die.tag () != DW_TAG_compile_unit
&& die.tag () != DW_TAG_partial_unit)
high_pc = low_pc + 1;
- if (high_pc != (::Dwarf_Addr)-1)
+ if (high_pc != ::noaddr)
{
if (my_ranges.size () != 0)
wr_message (wh, cat (mc_impact_4, mc_info, mc_error))
--- /dev/null
+#! /bin/sh
+# Copyright (C) 2010 Red Hat, Inc.
+# This file is part of Red Hat elfutils.
+#
+# Red Hat elfutils is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by the
+# Free Software Foundation; version 2 of the License.
+#
+# Red Hat elfutils is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with Red Hat elfutils; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
+#
+# Red Hat elfutils is an included package of the Open Invention Network.
+# An included package of the Open Invention Network is a package for which
+# Open Invention Network licensees cross-license their patents. No patent
+# license is granted, either expressly or impliedly, by designation as an
+# included package. Should you wish to participate in the Open Invention
+# Network licensing program, please visit www.openinventionnetwork.com
+# <http://www.openinventionnetwork.com>.
+
+. $srcdir/../tests/test-subr.sh
+
+srcdir=$srcdir/tests
+
+testfiles check_range_out_of_scope-1
+
+testrun_compare ./dwarflint --check=check_range_out_of_scope check_range_out_of_scope-1 <<EOF
+error: .debug_info: DIE 0x8b: PC range [0x4004d0, 0x4004d1) is not a sub-range of containing scope.
+error: .debug_info: DIE 0x7a: in this context: [0x4004d4, 0x4004db)
+EOF