From: Petr Machata Date: Thu, 30 Sep 2010 14:53:47 +0000 (+0200) Subject: dwarflint: Check for CUs that miss arange table X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e8532915d832c6747c44ee562d69d0f4098df62b;p=thirdparty%2Felfutils.git dwarflint: Check for CUs that miss arange table +testcase --- diff --git a/dwarflint/Makefile.am b/dwarflint/Makefile.am index fff6906d9..3f1680bab 100644 --- a/dwarflint/Makefile.am +++ b/dwarflint/Makefile.am @@ -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 index 000000000..0a698133d --- /dev/null +++ b/dwarflint/check_debug_aranges.ii @@ -0,0 +1 @@ +class check_debug_aranges; diff --git a/dwarflint/check_debug_info.cc b/dwarflint/check_debug_info.cc index a69a90765..3b4942a65 100644 --- a/dwarflint/check_debug_info.cc +++ b/dwarflint/check_debug_info.cc @@ -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 () .prereq () .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::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 reg_debug_info_refs; diff --git a/dwarflint/check_debug_info.hh b/dwarflint/check_debug_info.hh index 01189d144..714b6499a 100644 --- a/dwarflint/check_debug_info.hh +++ b/dwarflint/check_debug_info.hh @@ -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 (); diff --git a/dwarflint/lowlevel_checks.cc b/dwarflint/lowlevel_checks.cc index 2b4abc1ed..c767a0a72 100644 --- a/dwarflint/lowlevel_checks.cc +++ b/dwarflint/lowlevel_checks.cc @@ -45,6 +45,7 @@ lowlevel_checks::descriptor () .prereq () .prereq () .prereq () + .prereq () .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 index 000000000..6fe30488f 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 index 000000000..25fa2dc61 --- /dev/null +++ b/dwarflint/tests/run-check_debug_info_refs.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_debug_info_refs-1 + +testrun_compare ./dwarflint --strict --check=check_debug_info_refs check_debug_info_refs-1 <