From e8532915d832c6747c44ee562d69d0f4098df62b Mon Sep 17 00:00:00 2001 From: Petr Machata Date: Thu, 30 Sep 2010 16:53:47 +0200 Subject: [PATCH] dwarflint: Check for CUs that miss arange table +testcase --- dwarflint/Makefile.am | 8 +++-- dwarflint/check_debug_aranges.ii | 1 + dwarflint/check_debug_info.cc | 30 +++++++++++----- dwarflint/check_debug_info.hh | 4 ++- dwarflint/lowlevel_checks.cc | 1 + dwarflint/tests/check_debug_info_refs-1.bz2 | Bin 0 -> 2704 bytes dwarflint/tests/run-check_debug_info_refs.sh | 35 +++++++++++++++++++ 7 files changed, 66 insertions(+), 13 deletions(-) create mode 100644 dwarflint/check_debug_aranges.ii create mode 100755 dwarflint/tests/check_debug_info_refs-1.bz2 create mode 100755 dwarflint/tests/run-check_debug_info_refs.sh 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 0000000000000000000000000000000000000000..6fe30488f0f2e0dea1d3343e11dc5f6146297999 GIT binary patch literal 2704 zc-jGw3UBp7T4*^jL0KkKSr3jHGyn<+fB*mg|Nrj)|NsC0|84*O-*o@)8?h2AT##Muva}fN7w_42FOMKmamm02u&e(<4n88Vvvd8USJ% zG}8&8f&xT{My8rfCXEx)Y^IuNrYEFhQ1n32>M}Y;Ae@185N0rdyZj&oTv80_gYnwl;?hF>tjG_748R_R zx-MjjK0T)1vs}XfX(NVcLeaiAI^Gu^%;THg?xSU`G$%8zv{k~ zM|o3YNktf6bfQ5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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 <