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 \
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) \
--- /dev/null
+class check_debug_aranges;
#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 *
.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;
}
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;
#include "checks.hh"
#include "check_debug_abbrev.ii"
#include "check_debug_line.ii"
+#include "check_debug_aranges.ii"
#include "sections.ii"
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.
{
check_debug_info *_m_info;
check_debug_line *_m_line;
+ check_debug_aranges *_m_aranges;
public:
static checkdescriptor const *descriptor ();
.prereq<check_debug_line> ()
.prereq<check_debug_loc> ()
.prereq<check_debug_ranges> ()
+ .prereq<check_debug_info_refs> ()
.hidden ()
);
return &cd;
--- /dev/null
+#! /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