From: Petr Machata Date: Thu, 30 Sep 2010 12:23:55 +0000 (+0200) Subject: dwarflint: check_range_out_of_scope should run even on absent .debug_loc X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=25770c356d9b856858230c4e09f819cfa3525ef8;p=thirdparty%2Felfutils.git dwarflint: check_range_out_of_scope should run even on absent .debug_loc - the actual fix is removing the forced lint.check . 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. --- diff --git a/dwarflint/Makefile.am b/dwarflint/Makefile.am index e69324b60..fff6906d9 100644 --- a/dwarflint/Makefile.am +++ b/dwarflint/Makefile.am @@ -80,12 +80,15 @@ dwarflint_SOURCES = \ 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) \ diff --git a/dwarflint/check_range_out_of_scope.cc b/dwarflint/check_range_out_of_scope.cc index db774998b..7a1755988 100644 --- a/dwarflint/check_range_out_of_scope.cc +++ b/dwarflint/check_range_out_of_scope.cc @@ -63,13 +63,12 @@ namespace // Register the check. reg 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 (stack, lint) { - lint.check (stack); - try { class dwarf::compile_units const &cus = dw.compile_units (); @@ -102,7 +101,7 @@ check_range_out_of_scope::recursively_validate 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 (); @@ -121,7 +120,7 @@ check_range_out_of_scope::recursively_validate 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. @@ -130,12 +129,12 @@ check_range_out_of_scope::recursively_validate // 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)) diff --git a/dwarflint/tests/check_range_out_of_scope-1.bz2 b/dwarflint/tests/check_range_out_of_scope-1.bz2 new file mode 100755 index 000000000..1ef81cb85 Binary files /dev/null and b/dwarflint/tests/check_range_out_of_scope-1.bz2 differ diff --git a/dwarflint/tests/run-check_range_out_of_scope.sh b/dwarflint/tests/run-check_range_out_of_scope.sh new file mode 100755 index 000000000..6745efa3d --- /dev/null +++ b/dwarflint/tests/run-check_range_out_of_scope.sh @@ -0,0 +1,35 @@ +#! /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 +# . + +. $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 <