diff options
| author | Petr Machata <[email protected]> | 2010-09-30 16:53:47 +0200 |
|---|---|---|
| committer | Petr Machata <[email protected]> | 2010-09-30 16:53:47 +0200 |
| commit | e8532915d832c6747c44ee562d69d0f4098df62b (patch) | |
| tree | da31f5456bef4930b52c4f6c0076978ddfa487d1 | |
| parent | 25770c356d9b856858230c4e09f819cfa3525ef8 (diff) | |
dwarflint: Check for CUs that miss arange table
+testcase
| -rw-r--r-- | dwarflint/Makefile.am | 8 | ||||
| -rw-r--r-- | dwarflint/check_debug_aranges.ii | 1 | ||||
| -rw-r--r-- | dwarflint/check_debug_info.cc | 30 | ||||
| -rw-r--r-- | dwarflint/check_debug_info.hh | 4 | ||||
| -rw-r--r-- | dwarflint/lowlevel_checks.cc | 1 | ||||
| -rwxr-xr-x | dwarflint/tests/check_debug_info_refs-1.bz2 | bin | 0 -> 2704 bytes | |||
| -rwxr-xr-x | dwarflint/tests/run-check_debug_info_refs.sh | 35 |
7 files changed, 66 insertions, 13 deletions
diff --git a/dwarflint/Makefile.am b/dwarflint/Makefile.am index fff6906d..3f1680ba 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 00000000..0a698133 --- /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 a69a9076..3b4942a6 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<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; diff --git a/dwarflint/check_debug_info.hh b/dwarflint/check_debug_info.hh index 01189d14..714b6499 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 2b4abc1e..c767a0a7 100644 --- a/dwarflint/lowlevel_checks.cc +++ b/dwarflint/lowlevel_checks.cc @@ -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 Binary files differnew file mode 100755 index 00000000..6fe30488 --- /dev/null +++ b/dwarflint/tests/check_debug_info_refs-1.bz2 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 00000000..25fa2dc6 --- /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 +# <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 |
