]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Fix how --check handles low-level checks
authorPetr Machata <pmachata@redhat.com>
Fri, 22 Oct 2010 14:25:18 +0000 (16:25 +0200)
committerPetr Machata <pmachata@redhat.com>
Fri, 22 Oct 2010 14:25:18 +0000 (16:25 +0200)
dwarflint/checkrule.cc
dwarflint/lowlevel_checks.cc
dwarflint/tests/run-aranges_terminate_early.sh

index 051d73777ae7c02a79aa9d8fff64d747d6f7b497..0ebefe839a0e1d676a0f0cd40ffd3922c6484a9d 100644 (file)
@@ -61,14 +61,6 @@ namespace
 bool
 checkrules::should_check (checkstack const &stack) const
 {
-#if 0
-  std::cout << "---\nstack" << std::endl;
-  for (checkstack::const_iterator jt = stack.begin ();
-       jt != stack.end (); ++jt)
-    std::cout << (*jt)->name << std::flush << "  ";
-  std::cout << std::endl;
-#endif
-
   // We always allow scheduling hidden checks.  Those are service
   // routines that the user doesn't even see it the list of checks.
   assert (!stack.empty ());
index c767a0a721468b170b7542317edc487e46c00d17..77e6bbbff282573635cf2ee80f0267b33a58ad84 100644 (file)
@@ -55,8 +55,8 @@ static reg<lowlevel_checks> reg_lowlevel_checks;
 namespace
 {
   template<class T> struct do_check {
-    static void check (checkstack &stack, dwarflint &lint) {
-      lint.check<T> (stack);
+    static bool check (checkstack &stack, dwarflint &lint) {
+      return lint.toplev_check<T> (stack);
     }
   };
 
@@ -65,8 +65,11 @@ namespace
 #define STUBBED_CHECK(NAME)                                            \
   struct check_debug_##NAME {};                                                \
   template<> struct do_check<check_debug_##NAME> {                     \
-    static void check (__attribute__ ((unused)) checkstack &stack,     \
-                      __attribute__ ((unused)) dwarflint &lint) {}     \
+    static bool check (__attribute__ ((unused)) checkstack &stack,     \
+                      __attribute__ ((unused)) dwarflint &lint)        \
+    {                                                                  \
+      return true;                                                     \
+    }                                                                  \
   }
   STUBBED_CHECK(str);
   STUBBED_CHECK(mac);
@@ -78,13 +81,20 @@ lowlevel_checks::lowlevel_checks (checkstack &stack, dwarflint &lint)
   // Then check all the debug sections that are there.  For each
   // existing section request that the check passes.  Re-requesting
   // already-passed checks is OK, the scheduler caches it.
+  bool passed = true;
+
 #define SEC(NAME)                                                      \
   section<sec_##NAME> *NAME =                                          \
     lint.toplev_check<section<sec_##NAME> > (stack);                   \
   if (NAME != NULL)                                                    \
-    do_check<check_debug_##NAME>::check (stack, lint);
+    if (!do_check<check_debug_##NAME>::check (stack, lint))            \
+      passed = false;
+
   DEBUGINFO_SECTIONS;
 #undef SEC
 
   lint.check<check_debug_info_refs> (stack);
+
+  if (!passed)
+    throw check_base::failed ();
 }
index 6bd8fbba9d39cfd912b3fb0453041f59adbd7e74..7c5957091b7d776a2a5ccee415f89e4b0cf1630e 100755 (executable)
@@ -35,3 +35,8 @@ testrun_compare ./dwarflint --strict aranges_terminate_early <<EOF
 warning: .debug_aranges: [0x20, 0x30): unnecessary padding with zero bytes.
 warning: .debug_aranges: addresses [0x400474, 0x400481) are covered with CUs, but not with aranges.
 EOF
+
+testrun_compare ./dwarflint --check=check_debug_aranges --strict aranges_terminate_early <<EOF
+warning: .debug_aranges: [0x20, 0x30): unnecessary padding with zero bytes.
+warning: .debug_aranges: addresses [0x400474, 0x400481) are covered with CUs, but not with aranges.
+EOF