]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Be lazy when looking into CU headers for check_debug_abbrev
authorPetr Machata <pmachata@redhat.com>
Thu, 3 Mar 2011 16:02:47 +0000 (17:02 +0100)
committerPetr Machata <pmachata@redhat.com>
Thu, 3 Mar 2011 16:02:47 +0000 (17:02 +0100)
- And so don't complain that we have no headers in cases where we have
  no abbrevs either.
- Also consider no abbrevs a message, not an error
- Add a test case for the same

dwarflint/check_debug_abbrev.cc
dwarflint/tests/null.o.bz2 [new file with mode: 0644]
dwarflint/tests/run-nodebug.sh

index 8d413fc6040a55590e8fbcd58f157d7e9b8c1972..f2383319fe9745739c497b2ef1247ef80fadd5ff 100644 (file)
@@ -125,10 +125,15 @@ namespace
   check_no_abbreviations (check_debug_abbrev::abbrev_map const &abbrevs)
   {
     bool ret = abbrevs.begin () == abbrevs.end ();
+
+    // It's not an error when the abbrev table contains no abbrevs.
+    // But since we got here, apparently there was a .debug_abbrev
+    // section with size of more than 0 bytes, which is wasteful.
     if (ret)
       {
        where wh = WHERE (sec_abbrev, NULL);
-       wr_error (&wh, ": no abbreviations.\n");
+       wr_message (wh, cat (mc_abbrevs, mc_impact_1, mc_acc_bloat))
+         << "no abbreviations." << std::endl;
       }
     return ret;
   }
@@ -148,13 +153,6 @@ namespace
 
     // Tolerate failure here.
     dwarf_version const *ver = NULL;
-    if (cu_headers == NULL)
-      {
-       wr_error (where)
-         << "couldn't load CU headers; assuming CUs are of latest DWARF flavor."
-         << std::endl;
-       ver = dwarf_version::get_latest ();
-      }
     where.addr1 = 0;
 
     bool failed = false;
@@ -277,6 +275,14 @@ namespace
                    ver = dwarf_version::get_latest ();
                  }
              }
+           else if (ver == NULL)
+             {
+               wr_error (where)
+                 << "couldn't load CU headers; assuming CUs are of latest DWARF flavor."
+                 << std::endl;
+               ver = dwarf_version::get_latest ();
+             }
+
            assert (ver != NULL);
          }
 
diff --git a/dwarflint/tests/null.o.bz2 b/dwarflint/tests/null.o.bz2
new file mode 100644 (file)
index 0000000..f272d5a
Binary files /dev/null and b/dwarflint/tests/null.o.bz2 differ
index 5bfc2c552cc46510339bd18a4a2f3125d3a536f6..049bf5708be21cf0684f3c3a728c2795f76fc392 100755 (executable)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2010 Red Hat, Inc.
+# Copyright (C) 2010, 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
@@ -27,7 +27,7 @@
 
 srcdir=$srcdir/tests
 
-testfiles nodebug
+testfiles nodebug null.o
 
 testrun_compare ./dwarflint nodebug <<EOF
 error: .debug_abbrev: data not found.
@@ -69,3 +69,11 @@ nodebug:
 nodebug:
 warning: the rule \`oentuh' never matched.
 EOF
+
+testrun_compare ./dwarflint null.o <<EOF
+error: .debug_info: data not found.
+EOF
+
+testrun_compare ./dwarflint --nodebug:ignore null.o <<EOF
+No errors
+EOF