]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Fix iteration over low-level attributes
authorPetr Machata <pmachata@redhat.com>
Tue, 8 Mar 2011 17:53:22 +0000 (18:53 +0100)
committerPetr Machata <pmachata@redhat.com>
Tue, 8 Mar 2011 17:53:22 +0000 (18:53 +0100)
- this to allow (certainly bogus, but anyway) attribute name == 0
- test case that triggers this

dwarflint/check_debug_info.cc
dwarflint/tests/garbage-3.bz2 [new file with mode: 0644]
dwarflint/tests/run-bad.sh

index 6672c8c8dcb0f19ee986eba31ecd7dee5fac0444..348dad0d27d136bcf44d998617e2ff3dd334ffcf 100644 (file)
@@ -642,7 +642,7 @@ namespace
 
        /* Attribute values.  */
        for (struct abbrev_attrib *it = abbrev->attribs;
-            it->name != 0; ++it)
+            it->name != 0 || it->form != 0; ++it)
          {
            where.ref = &it->where;
 
@@ -1097,7 +1097,7 @@ check_debug_info::check_debug_info (checkstack &stack, dwarflint &lint)
            if (!it->second.abbr[i].used)
              wr_message (it->second.abbr[i].where,
                          cat (mc_impact_3, mc_acc_bloat, mc_abbrevs))
-               << "abbreviation is never used." << std::endl;
+               << "abbreviation is never used." << std::endl;
     }
 
   // re-link CUs so that they form a chain again.  This is to
diff --git a/dwarflint/tests/garbage-3.bz2 b/dwarflint/tests/garbage-3.bz2
new file mode 100644 (file)
index 0000000..ad66a41
Binary files /dev/null and b/dwarflint/tests/garbage-3.bz2 differ
index 871fe551c88a0ff954102b7a93fe0481588390ff..38b9be1a3294ddb7801f0348249c0e1c0521725c 100755 (executable)
@@ -27,7 +27,7 @@
 
 srcdir=$srcdir/tests
 
-testfiles hello.bad-1 hello.bad-3 garbage-1 garbage-2
+testfiles hello.bad-1 hello.bad-3 garbage-1 garbage-2 garbage-3
 
 testrun_compare ./dwarflint hello.bad-1 <<EOF
 error: .debug_info: DIE 0x83: abbrev section at 0x0 doesn't contain code 83.
@@ -50,3 +50,7 @@ EOF
 testrun_compare ./dwarflint garbage-2 <<EOF
 error: .debug_info: CU 0: toplevel DIE must be either compile_unit or partial_unit.
 EOF
+
+testrun_compare ./dwarflint --check=@low garbage-3 <<EOF
+error: .debug_abbrev: abbr. attribute 0xc: invalid or unknown name 0x0.
+EOF