tests/run-bad.sh \
tests/run-check_self_referential_die.sh \
tests/run-DW_AT_high_pc-relative.sh \
- tests/run-DW_AT_high_pc-below.sh
+ tests/run-DW_AT_high_pc-below.sh \
+ tests/run-DW_AT-later-version.sh
TESTS = $(EXTRA_TESTS) \
tests/test-coverage \
tests/garbage-12.bz2 \
tests/check_self_referential_die.bz2 \
tests/DW_AT_high_pc-relative.bz2 \
- tests/DW_AT_high_pc-below.bz2
+ tests/DW_AT_high_pc-below.bz2 \
+ tests/DW_AT-later-version.bz2
installed_TESTS_ENVIRONMENT = libdir=$(DESTDIR)$(libdir) \
bindir=$(DESTDIR)$(bindir) \
// Tolerate failure here.
dwarf_version const *ver = NULL;
+ static dwarf_version const *latest_ver = dwarf_version::get_latest ();
where.addr1 = 0;
bool failed = false;
<< "couldn't load CU headers for processing .debug_abbrev; "
"assuming latest DWARF flavor."
<< std::endl;
- ver = dwarf_version::get_latest ();
+ ver = latest_ver;
}
assert (ver != NULL);
attribute const *attribute = ver->get_attribute (attrib_name);
if (attribute == NULL)
{
- wr_error (where)
- << "invalid or unknown name " << pri::hex (attrib_name)
- << '.' << std::endl;
- // libdw should handle unknown attribute, as long as
- // the form is kosher, so don't fail the check.
+ // GCC commonly emits DWARF 2 with trivial extensions
+ // (such as attribute names) from newer versions. In
+ // GNU mode, don't even mind this. In non-gnu, emit
+ // warning. We explicitly don't do this for forms,
+ // where the consumer wouldn't know how to read or
+ // skip the datum.
+ attribute = latest_ver->get_attribute (attrib_name);
+ if (attribute == NULL)
+ // libdw should handle unknown attribute, as long as
+ // the form is kosher, so don't fail the check.
+ wr_message (where, mc_abbrevs | mc_impact_1)
+ << "invalid or unknown name " << pri::hex (attrib_name)
+ << '.' << std::endl;
+ else if (opt_nognu)
+ wr_message (where, mc_abbrevs | mc_impact_1)
+ << "attribute " << *attribute
+ << " from later DWARF version."
+ << std::endl;
}
form const *form = check_debug_abbrev::check_form
// Error message has been emitted in check_form.
failed = true;
- if (form == NULL || attribute == NULL)
+ if (form == NULL)
continue;
std::pair<std::map<unsigned, uint64_t>::iterator, bool> inserted
if (!inserted.second)
{
wr_error (where)
- << "duplicate attribute " << *attribute
+ << "duplicate attribute "
+ << elfutils::dwarf::attributes::name (attrib_name)
<< " (first was at " << pri::hex (inserted.first->second)
<< ")." << std::endl;
// I think we may allow such files for high-level
#include "dwarf_mips.hh"
#include "check_debug_info.hh"
+global_opt<void_option>
+ opt_nognu ("Don't use GNU extension.", "nognu");
+
dw_class_set::dw_class_set (dw_class a, dw_class b, dw_class c,
dw_class d, dw_class e)
{
std::ostream &
operator << (std::ostream &os, form const &obj)
{
- return os << elfutils::dwarf::forms::name (obj.name ());
+ return os << elfutils::dwarf::forms::identifier (obj.name ());
}
namespace
std::ostream &
operator << (std::ostream &os, attribute const &obj)
{
- return os << elfutils::dwarf::attributes::name (obj.name ());
+ return os << elfutils::dwarf::attributes::identifier (obj.name ());
}
return new dwarf_version_union (source, extension);
}
-global_opt<void_option>
- nognu ("Don't use GNU extension.", "nognu");
-
namespace
{
dwarf_version const *get_ext ()
// need the version to know how to read these attributes in the
// first place.
- if (nognu)
+ if (opt_nognu)
return dwarf_mips_ext ();
else
return dwarf_version::extend (dwarf_mips_ext (), dwarf_gnu_ext ());
#include <iosfwd>
#include "check_debug_info.ii"
#include "dwarf_version.ii"
+#include "option.hh"
+
+extern global_opt<void_option> opt_nognu;
enum dw_class
{
--- /dev/null
+#! /bin/sh
+# Copyright (C) 2011 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 DW_AT-later-version
+
+testrun_compare ./dwarflint --nognu DW_AT-later-version <<EOF
+warning: .debug_abbrev: abbr. attribute 0x15: attribute DW_AT_endianity from later DWARF version.
+warning: .debug_info: DIE 0xb: DW_AT_low_pc value not below DW_AT_high_pc.
+EOF
EOF
testrun_compare ./dwarflint garbage-7 <<EOF
-error: .debug_abbrev: abbr. attribute 0x7e: invalid or unknown name 0x703.
+warning: .debug_abbrev: abbr. attribute 0x7e: invalid or unknown name 0x703.
error: .debug_abbrev: abbr. attribute 0x7e: invalid form 0x0.
error: .debug_abbrev: abbreviation 122: missing zero to mark end-of-table.
EOF
# Here we test that dwarflint can tolerate invalid attribute name.
testrun_compare ./dwarflint --check=@low --nognu --ignore-bloat libdl-2.12.so.debug <<EOF
-error: .debug_abbrev: abbr. attribute 0xbe: invalid or unknown name 0x2107.
-error: .debug_abbrev: abbr. attribute 0x330: invalid or unknown name 0x2107.
-error: .debug_abbrev: abbr. attribute 0xa28: invalid or unknown name 0x2107.
-error: .debug_abbrev: abbr. attribute 0x108e: invalid or unknown name 0x2107.
-error: .debug_abbrev: abbr. attribute 0x1300: invalid or unknown name 0x2107.
+warning: .debug_abbrev: abbr. attribute 0xbe: invalid or unknown name 0x2107.
+warning: .debug_abbrev: abbr. attribute 0x330: invalid or unknown name 0x2107.
+warning: .debug_abbrev: abbr. attribute 0xa28: invalid or unknown name 0x2107.
+warning: .debug_abbrev: abbr. attribute 0x108e: invalid or unknown name 0x2107.
+warning: .debug_abbrev: abbr. attribute 0x1300: invalid or unknown name 0x2107.
warning: .debug_info: DIE 0xd9a8: DW_AT_low_pc value not below DW_AT_high_pc.
warning: .debug_info: DIE 0xdcd7: DW_AT_low_pc value not below DW_AT_high_pc.
warning: .debug_info: CU 55709: no aranges table is associated with this CU.