]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Check for CUs that miss arange table
authorPetr Machata <pmachata@redhat.com>
Thu, 30 Sep 2010 14:53:47 +0000 (16:53 +0200)
committerPetr Machata <pmachata@redhat.com>
Thu, 30 Sep 2010 14:53:47 +0000 (16:53 +0200)
+testcase

dwarflint/Makefile.am
dwarflint/check_debug_aranges.ii [new file with mode: 0644]
dwarflint/check_debug_info.cc
dwarflint/check_debug_info.hh
dwarflint/lowlevel_checks.cc
dwarflint/tests/check_debug_info_refs-1.bz2 [new file with mode: 0755]
dwarflint/tests/run-check_debug_info_refs.sh [new file with mode: 0755]

index fff6906d913a9d27aa1bf6eae812b39f4b7f12b1..3f1680babe0cf9a3068848a9cce95147c38b2973 100644 (file)
@@ -66,7 +66,7 @@ dwarflint_SOURCES = \
        check_debug_line.cc check_debug_line.hh check_debug_line.ii \
        check_debug_pub.cc check_debug_pub.hh \
        check_debug_loc_range.cc check_debug_loc_range.hh check_debug_loc_range.ii \
-       check_debug_aranges.cc check_debug_aranges.hh \
+       check_debug_aranges.cc check_debug_aranges.hh check_debug_aranges.ii \
        lowlevel_checks.cc lowlevel_checks.hh \
        check_matching_ranges.cc \
        check_range_out_of_scope.cc \
@@ -81,14 +81,16 @@ 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-check_range_out_of_scope.sh
+       tests/run-check_range_out_of_scope.sh \
+       tests/run-check_debug_info_refs.sh
 
 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
+       tests/check_range_out_of_scope-1.bz2 \
+       tests/check_debug_info_refs-1.bz2
 
 installed_TESTS_ENVIRONMENT = libdir=$(DESTDIR)$(libdir) \
                              bindir=$(DESTDIR)$(bindir) \
diff --git a/dwarflint/check_debug_aranges.ii b/dwarflint/check_debug_aranges.ii
new file mode 100644 (file)
index 0000000..0a69813
--- /dev/null
@@ -0,0 +1 @@
+class check_debug_aranges;
index a69a9076570999893286da294c920c8b4ad7a8a9..3b4942a65f7b2d3627aa7164d8c5857d2aa2391c 100644 (file)
@@ -42,6 +42,7 @@
 #include "check_debug_abbrev.hh"
 #include "check_debug_info.hh"
 #include "check_debug_line.hh"
+#include "check_debug_aranges.hh"
 #include "misc.hh"
 
 checkdescriptor const *
@@ -1300,9 +1301,10 @@ check_debug_info_refs::descriptor ()
      .prereq<typeof (*_m_info)> ()
      .prereq<typeof (*_m_line)> ()
      .description (
-"This pass checks for outstanding unresolved references from\n"
-".debug_info to .debug_line (and perhaps others as they are\n"
-"identified).\n"));
+"This pass checks:\n"
+" - for outstanding unresolved references from .debug_info to .debug_line\n"
+" - that each CU has an associated aranges entry (that even if there is\n"
+"   no .debug_aranges to begin with).\n"));
   return &cd;
 }
 
@@ -1310,13 +1312,23 @@ check_debug_info_refs::check_debug_info_refs (checkstack &stack,
                                              dwarflint &lint)
   : _m_info (lint.check (stack, _m_info))
   , _m_line (lint.toplev_check (stack, _m_line))
+  , _m_aranges (lint.toplev_check (stack, _m_aranges))
 {
   for (std::vector<cu>::iterator it = _m_info->cus.begin ();
        it != _m_info->cus.end (); ++it)
-    if (it->stmt_list.addr != (uint64_t)-1
-       && (_m_line == NULL
-           || !_m_line->has_line_table (it->stmt_list.addr)))
-      wr_error (it->stmt_list.who)
-       << "unresolved reference to .debug_line table "
-       << pri::hex (it->stmt_list.addr) << '.' << std::endl;
+    {
+      if (it->stmt_list.addr != (uint64_t)-1
+         && (_m_line == NULL
+             || !_m_line->has_line_table (it->stmt_list.addr)))
+       wr_error (it->stmt_list.who)
+         << "unresolved reference to .debug_line table "
+         << pri::hex (it->stmt_list.addr) << '.' << std::endl;
+
+      if (_m_aranges != NULL && !it->has_arange)
+       wr_message (it->head->where,
+                   cat (mc_impact_3, mc_acc_suboptimal, mc_aranges, mc_info))
+         << "no aranges table is associated with this CU." << std::endl;
+    }
 }
+
+static reg<check_debug_info_refs> reg_debug_info_refs;
index 01189d14457cf1fa83b9afa1c25065ece873cb21..714b6499ad0618536592e0d8c4712d3863fd388f 100644 (file)
@@ -33,6 +33,7 @@
 #include "checks.hh"
 #include "check_debug_abbrev.ii"
 #include "check_debug_line.ii"
+#include "check_debug_aranges.ii"
 #include "sections.ii"
 
 struct cu_head
@@ -43,7 +44,7 @@ struct cu_head
   Dwarf_Off total_size;         // size + head_size
 
   int offset_size;               // Offset size in this CU.
-  struct where where;           // Where was this section defined.
+  struct where where;           // Where this section was defined.
   Dwarf_Off abbrev_offset;      // Abbreviation section that this CU uses.
   int version;                  // CU version
   int address_size;             // Address size in bytes on the target machine.
@@ -133,6 +134,7 @@ class check_debug_info_refs
 {
   check_debug_info *_m_info;
   check_debug_line *_m_line;
+  check_debug_aranges *_m_aranges;
 
 public:
   static checkdescriptor const *descriptor ();
index 2b4abc1ed4c1b4bd5857c36c7c2e9db82d5ef894..c767a0a721468b170b7542317edc487e46c00d17 100644 (file)
@@ -45,6 +45,7 @@ lowlevel_checks::descriptor ()
      .prereq<check_debug_line> ()
      .prereq<check_debug_loc> ()
      .prereq<check_debug_ranges> ()
+     .prereq<check_debug_info_refs> ()
      .hidden ()
      );
   return &cd;
diff --git a/dwarflint/tests/check_debug_info_refs-1.bz2 b/dwarflint/tests/check_debug_info_refs-1.bz2
new file mode 100755 (executable)
index 0000000..6fe3048
Binary files /dev/null and b/dwarflint/tests/check_debug_info_refs-1.bz2 differ
diff --git a/dwarflint/tests/run-check_debug_info_refs.sh b/dwarflint/tests/run-check_debug_info_refs.sh
new file mode 100755 (executable)
index 0000000..25fa2dc
--- /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_debug_info_refs-1
+
+testrun_compare ./dwarflint --strict --check=check_debug_info_refs check_debug_info_refs-1 <<EOF
+warning: .debug_aranges: table 48 (CU DIE 95): there has already been arange section for this CU.
+warning: .debug_info: CU 0: no aranges table is associated with this CU.
+EOF