]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: check_range_out_of_scope should run even on absent .debug_loc
authorPetr Machata <pmachata@redhat.com>
Thu, 30 Sep 2010 12:23:55 +0000 (14:23 +0200)
committerPetr Machata <pmachata@redhat.com>
Thu, 30 Sep 2010 12:23:55 +0000 (14:23 +0200)
- 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.

dwarflint/Makefile.am
dwarflint/check_range_out_of_scope.cc
dwarflint/tests/check_range_out_of_scope-1.bz2 [new file with mode: 0755]
dwarflint/tests/run-check_range_out_of_scope.sh [new file with mode: 0755]

index e69324b6011bfad21e939c73b5f14b24adcf2164..fff6906d913a9d27aa1bf6eae812b39f4b7f12b1 100644 (file)
@@ -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) \
index db774998ba158f000343be7d61042c43e457a5fe..7a17559884bbec0e4b6d88f7cc5140adfad87bfb 100644 (file)
@@ -63,13 +63,12 @@ namespace
 
   // 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 ();
@@ -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 (executable)
index 0000000..1ef81cb
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 (executable)
index 0000000..6745efa
--- /dev/null
@@ -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
+# <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