]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Drop checkdescriptor::{prereq,inherit}
authorPetr Machata <pmachata@redhat.com>
Fri, 8 Apr 2011 00:03:01 +0000 (02:03 +0200)
committerPetr Machata <pmachata@redhat.com>
Fri, 8 Apr 2011 00:03:01 +0000 (02:03 +0200)
- ... which was just duplicating the lint.check<> calls in check
  initializers.  It was needed for --list-checks to display all the
  checks.  Now we register all the checks that we either want to show
  in the list or run, and mark them as hidden or unscheduled as needed.
  We lose the ability to list dependees in --list-checks, but I don't
  think that is too interesting anyway.

26 files changed:
dwarflint/Makefile.am
dwarflint/check_debug_abbrev.cc
dwarflint/check_debug_aranges.cc
dwarflint/check_debug_info.cc
dwarflint/check_debug_line.cc
dwarflint/check_debug_loc_range.cc
dwarflint/check_debug_pub.cc
dwarflint/check_die_tree.cc
dwarflint/check_die_tree.hh
dwarflint/check_duplicate_DW_tag_variable.cc
dwarflint/check_dups_abstract_origin.cc
dwarflint/check_expected_trees.cc
dwarflint/check_linkage_external_die.cc
dwarflint/check_matching_ranges.cc
dwarflint/check_range_out_of_scope.cc
dwarflint/check_registrar.cc [deleted file]
dwarflint/check_registrar.hh
dwarflint/check_self_referential_die.cc
dwarflint/checkdescriptor.cc
dwarflint/checkdescriptor.hh
dwarflint/cu_coverage.cc
dwarflint/dwarflint.cc
dwarflint/highlevel_check.hh
dwarflint/lowlevel_checks.cc
dwarflint/sections.cc
dwarflint/sections.hh

index f485ef3ab051da20803bebb33b5a5ac7385db59d..56e261152c839bfe63fdb7b197e027514d63d883 100644 (file)
@@ -41,7 +41,7 @@ noinst_PROGRAMS = tests/test-coverage tests/test-wrap tests/test-all-dies-it
 dwarflint_SOURCES = \
        addr-record.cc addr-record.hh \
        all-dies-it.hh \
-       check_registrar.cc check_registrar.hh check_registrar_i.hh \
+       check_registrar.hh check_registrar_i.hh \
        checkdescriptor.cc checkdescriptor.hh checkdescriptor_i.hh \
        checked_read.cc checked_read.hh \
        checkrule.cc checkrule.hh \
index 7fb9015c467a6b36b8bc6db4ce2b3853eee8501c..3b5e3bab6ffbfbc9015b1a0d1cb2432ef32c89eb 100644 (file)
@@ -49,8 +49,7 @@ check_debug_abbrev::descriptor ()
   static checkdescriptor cd
     (checkdescriptor::create ("check_debug_abbrev")
      .groups ("@low")
-     .prereq <typeof (*_m_sec_abbr)> ()
-     .prereq <typeof (*_m_cu_headers)> ()
+     .schedule (false)
      .description (
 "Checks for low-level structure of .debug_abbrev.  In addition it "
 "checks:\n"
@@ -79,6 +78,8 @@ check_debug_abbrev::descriptor ()
   return &cd;
 }
 
+static reg<check_debug_abbrev> reg_debug_abbrev;
+
 abbrev *
 abbrev_table::find_abbrev (uint64_t abbrev_code) const
 {
index 0d3e3b30986793b0cf77f77b9c80581f550fa35d..b955970228f0c42d53cf8c5053dae77511ac9261 100644 (file)
@@ -48,9 +48,6 @@ check_debug_aranges::descriptor ()
   static checkdescriptor cd
     (checkdescriptor::create ("check_debug_aranges")
      .groups ("@low")
-     .prereq<typeof (*_m_sec_aranges)> ()
-     .prereq<typeof (*_m_info)> ()
-     .prereq<typeof (*_m_cu_coverage)> ()
      .description (
 "Checks for low-level structure of .debug_aranges.  In addition it "
 "checks:\n"
@@ -64,6 +61,8 @@ check_debug_aranges::descriptor ()
   return &cd;
 }
 
+static reg<check_debug_aranges> reg_debug_aranges;
+
 static struct cu *
 cu_find_cu (struct cu *cu_chain, uint64_t offset)
 {
index 1b23829a70f27430223c12eaa588fb7a0191e8fd..46d4ec512301ff0b31726c29db4983971c38ac51 100644 (file)
@@ -50,7 +50,7 @@ read_cu_headers::descriptor ()
 {
   static checkdescriptor cd
     (checkdescriptor::create ("read_cu_headers")
-     .prereq<typeof (*_m_sec_info)> ());
+     .hidden ());
   return &cd;
 }
 
@@ -64,11 +64,8 @@ check_debug_info::descriptor ()
   static checkdescriptor cd
     (checkdescriptor::create ("check_debug_info")
      .groups ("@low")
+     .schedule (false)
      .option (dump_die_offsets)
-     .prereq<typeof (*_m_sec_info)> ()
-     .prereq<typeof (*_m_sec_str)> ()
-     .prereq<typeof (*_m_abbrevs)> ()
-     .prereq<typeof (*_m_cu_headers)> ()
      .description (
 "Checks for low-level structure of .debug_info.  In addition it "
 "checks:\n"
@@ -102,6 +99,8 @@ check_debug_info::descriptor ()
   return &cd;
 }
 
+static reg<check_debug_info> reg_debug_info;
+
 namespace
 {
   bool
@@ -1251,8 +1250,7 @@ check_debug_info_refs::descriptor ()
   static checkdescriptor cd
     (checkdescriptor::create ("check_debug_info_refs")
      .groups ("@low")
-     .prereq<typeof (*_m_info)> ()
-     .prereq<typeof (*_m_line)> ()
+     .schedule (false)
      .description (
 "This pass checks:\n"
 " - for outstanding unresolved references from .debug_info to .debug_line\n"
@@ -1261,6 +1259,8 @@ check_debug_info_refs::descriptor ()
   return &cd;
 }
 
+static reg<check_debug_info_refs> reg_debug_info_refs;
+
 check_debug_info_refs::check_debug_info_refs (checkstack &stack,
                                              dwarflint &lint)
   : _m_info (lint.check (stack, _m_info))
@@ -1292,5 +1292,3 @@ check_debug_info_refs::check_debug_info_refs (checkstack &stack,
          << "no aranges table is associated with this CU." << std::endl;
     }
 }
-
-static reg<check_debug_info_refs> reg_debug_info_refs;
index 4a21125c3fde3ab78cf5ef1e6b4506f80927cb84..93637238e90c6a3a4732293400aa100b5db77d1e 100644 (file)
@@ -43,7 +43,7 @@ check_debug_line::descriptor ()
   static checkdescriptor cd
     (checkdescriptor::create ("check_debug_line")
      .groups ("@low")
-     .prereq<typeof (*_m_sec)> ()
+     .schedule (false)
      .description (
 "Checks for low-level structure of .debug_line.  In addition it\n"
 "checks:\n"
@@ -74,6 +74,8 @@ check_debug_line::descriptor ()
   return &cd;
 }
 
+static reg<check_debug_line> reg_debug_line;
+
 namespace
 {
   struct include_directory_t
index f87b2aa474715e9bfbb488248444e725bda5b448..74b4d272ee4db8a73fbb0ce57d5937a24fcb0a26 100644 (file)
@@ -55,8 +55,7 @@ check_debug_ranges::descriptor ()
   static checkdescriptor cd
     (checkdescriptor::create ("check_debug_ranges")
      .groups ("@low")
-     .prereq<typeof (*_m_sec_ranges)> ()
-     .prereq<typeof (*_m_info)> ()
+     .schedule (false)
      .description (
 "Checks for low-level structure of .debug_ranges.  In addition it "
 "checks:\n"
@@ -72,14 +71,15 @@ check_debug_ranges::descriptor ()
   return &cd;
 }
 
+static reg<check_debug_ranges> reg_debug_ranges;
+
 checkdescriptor const *
 check_debug_loc::descriptor ()
 {
   static checkdescriptor cd
     (checkdescriptor::create ("check_debug_loc")
      .groups ("@low")
-     .prereq<typeof (*_m_sec_loc)> ()
-     .prereq<typeof (*_m_info)> ()
+     .schedule (false)
      .description (
 "Checks for low-level structure of .debug_loc.  In addition it "
 "makes the same checks as .debug_ranges.  For location expressions "
@@ -95,6 +95,8 @@ check_debug_loc::descriptor ()
   return &cd;
 }
 
+static reg<check_debug_loc> reg_debug_loc;
+
 namespace
 {
   bool
index 0f18e682f9a893a1c6a4a476527b48aa12d495a0..c44cab4b0e9f380798ccea68e8c2a30fdb54a985 100644 (file)
@@ -1,5 +1,5 @@
 /* Low-level checking of .debug_pub*.
-   Copyright (C) 2009, 2010 Red Hat, Inc.
+   Copyright (C) 2009, 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
@@ -47,8 +47,7 @@ check_debug_pubnames::descriptor ()
   static checkdescriptor cd
     (checkdescriptor::create ("check_debug_pubnames")
      .groups ("@low")
-     .prereq<typeof (*_m_sec)> ()
-     .prereq<check_debug_info> ()
+     .schedule (false)
      .description (
 "Checks for low-level structure of .debug_pubnames.  In addition it "
 "checks:\n"
@@ -60,25 +59,31 @@ check_debug_pubnames::descriptor ()
 " - that there's only one pub section per CU\n"));
   return &cd;
 }
+
 template check_debug_pub<sec_pubnames>::check_debug_pub (checkstack &stack,
                                                         dwarflint &lint);
 
+static reg<check_debug_pubnames> reg_debug_pubnames;
+
 checkdescriptor const *
 check_debug_pubtypes::descriptor ()
 {
   static checkdescriptor cd
     (checkdescriptor::create ("check_debug_pubtypes")
      .groups ("@low")
-     .prereq<typeof (*_m_sec)> ()
-     .prereq<check_debug_info> ()
+     .schedule (false)
      .description (
 "Checks for low-level structure of .debug_pubtypes.  In addition it "
 "makes the same checks as check_debug_pubnames.\n"));
   return &cd;
 }
+
 template check_debug_pub<sec_pubtypes>::check_debug_pub (checkstack &stack,
                                                         dwarflint &lint);
 
+static reg<check_debug_pubtypes> reg_debug_pubtypes;
+
+
 template <section_id sec_id>
 bool
 check_debug_pub<sec_id>::check_pub_structural ()
index 14b2cf4e5e10c06347086eb1ca64610d6621ae71..0e0b38d499a57cd23fa472f346ad61d9e8584959 100644 (file)
@@ -45,8 +45,6 @@ namespace
       return &inst;
     }
   };
-
-  reg<check_die_tree> reg;
 }
 
 void
index 5d1c807d6d05ed61b182ea8c310a07467e3669fa..d4dabedc06b370048abccf57981d904c4a9c16dd 100644 (file)
@@ -54,7 +54,6 @@ public:
   {
     static checkdescriptor cd
       (checkdescriptor::create ("check_die_tree")
-       .inherit<highlevel_check<check_die_tree> > ()
        .hidden ()
        .description ("A pass over the DIE tree that dispatches to various per-DIE checks.\n"));
     return &cd;
@@ -103,11 +102,7 @@ private:
   public:
     static checkdescriptor const *descriptor ()
     {
-      static checkdescriptor cd
-       (checkdescriptor::create (*T::descriptor ())
-        .prereq<typeof (*_m_die_tree_check)> ()
-        .inherit<highlevel_check<check_stub> > ());
-      return &cd;
+      return T::descriptor ();
     }
 
     check_stub (checkstack &stack, dwarflint &lint)
index 822b3d8cd8fcd4adb41ba1360b03ea92efbff0ed..838e3f69340e0a6ea247d1bcd119bbf66dc4a774 100644 (file)
@@ -54,7 +54,6 @@ namespace
     static checkdescriptor const *descriptor () {
       static checkdescriptor cd
        (checkdescriptor::create ("check_duplicate_DW_tag_variable")
-        .inherit<highlevel_check<check_duplicate_DW_tag_variable> > ()
         .description (
 "Implements a check for two full DW_TAG_variable DIEs with the same "
 "DW_AT_name value.  This covers duplicate declaration, duplicate "
index 03b1c820ee8d1454bbbcec8ca52b4754df57760f..ece80a88dcb55849348ce9a2e0be8023f15f4158 100644 (file)
@@ -45,7 +45,6 @@ namespace
     {
       static checkdescriptor cd
        (checkdescriptor::create ("check_dups_abstract_origin")
-        .inherit<highlevel_check<check_dups_abstract_origin> > ()
         .description (
 "If a given attribute name is present on a DIE, it is "
 "suspicious if that attribute name appears on the DIE that's the "
index ab91a712575ffd714083a07a606de6492abd17c4..a758c7c3f27aa643d1358fff78388e095d0b9ce7 100644 (file)
@@ -46,7 +46,6 @@ namespace
     static checkdescriptor const *descriptor () {
       static checkdescriptor cd
        (checkdescriptor::create ("check_expected_trees")
-        .inherit<highlevel_check<check_expected_trees> > ()
         .description (
 "Checks whether all DIEs have the right attributes and the right children.\n"
 "Currently this is very much a work in progress.\n"));
index 3731e106e873a68b11e7fe6e7ce7fc09a2939f76..7af738ab7b810f454f43234b547330dedf23a0f8 100644 (file)
@@ -39,10 +39,8 @@ namespace
     {
       static checkdescriptor cd
        (checkdescriptor::create ("check_linkage_external_die")
-        .inherit<highlevel_check<check_linkage_external_die> > ()
-        .description (
-"Check that each DIE that has a linkage_name also has an external attribute.\n"
-                      ));
+        .description ("Check that each DIE that has a linkage_name "
+                      "also has an external attribute.\n"));
       return &cd;
     }
 
index a567ce48f556488a599846996ec4d05cbf2b532c..6f2f4eb67f3bdd274f451385c00474b00ba2c41a 100644 (file)
@@ -1,5 +1,5 @@
 /* Pedantic checking of DWARF files
-   Copyright (C) 2009,2010 Red Hat, Inc.
+   Copyright (C) 2009,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
@@ -42,7 +42,6 @@ namespace
     static checkdescriptor const *descriptor () {
       static checkdescriptor cd
        (checkdescriptor::create ("check_matching_ranges")
-        .inherit<highlevel_check<check_matching_ranges> > ()
         .description (
 "Check that the ranges in .debug_aranges and .debug_ranges match.\n"
 ));
index 131fe187e326585829fd9205e4fc0d75008fc8b9..c0312917af2d32d6a0ac4c7fe16fecae952f5260 100644 (file)
@@ -52,7 +52,6 @@ namespace
     static checkdescriptor const *descriptor () {
       static checkdescriptor cd
        (checkdescriptor::create ("check_range_out_of_scope")
-        .inherit<highlevel_check<check_range_out_of_scope> > ()
         .description (
 "Check whether PC ranges reported at DIEs fall into the containing scope.\n"));
       return &cd;
diff --git a/dwarflint/check_registrar.cc b/dwarflint/check_registrar.cc
deleted file mode 100644 (file)
index 3519848..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/* Pedantic checking of DWARF files
-   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>.  */
-
-#include "check_registrar.hh"
-#include "checkdescriptor.hh"
-#include "dwarflint.hh"
-#include "main.hh"
-#include "wrap.hh"
-
-void
-check_registrar_aux::add_deps (std::set<checkdescriptor const *> &to,
-                               checkdescriptor const *cd)
-{
-  for (std::set<checkdescriptor const *>::const_iterator it
-        = cd->prereq ().begin (); it != cd->prereq ().end (); ++it)
-    include (to, *it);
-}
-
-void
-check_registrar_aux::include (std::set<checkdescriptor const *> &to,
-                              checkdescriptor const *cd)
-{
-  if (cd->hidden ())
-    add_deps (to, cd);
-  else
-    to.insert (cd);
-}
-
-bool
-check_registrar_aux::be_verbose ()
-{
-  // We can hopefully assume that the option doesn't change during
-  // execution, so we can simply cache it this was.
-  static bool be_verbose = opt_list_checks.value () == "full";
-  return be_verbose;
-}
-
-void
-check_registrar_aux::list_one_check (checkdescriptor const &cd)
-{
-  const size_t columns = 70;
-
-  if (be_verbose ())
-    std::cout << "=== " << cd.name () << " ===";
-  else
-    std::cout << cd.name ();
-
-  checkgroups const &groups = cd.groups ();
-  if (!groups.empty ())
-    {
-      if (be_verbose ())
-       std::cout << std::endl << "groups: ";
-      else
-       std::cout << ' ';
-      std::cout << groups;
-    }
-  std::cout << std::endl;
-
-  if (be_verbose ())
-    {
-      prereqs const &prereq = cd.prereq ();
-      if (!prereq.empty ())
-       std::cout << "prerequisites: " << prereq << std::endl;
-
-      char const *desc = cd.description ();
-      if (desc != NULL)
-       std::cout << wrap_str (desc, columns).join ();
-
-      options const &opts = cd.opts ();
-      if (!opts.empty ())
-       {
-         std::cout << "recognized options:" << std::endl;
-         argp a = opts.build_argp ();
-         argp_help (&a, stdout, ARGP_HELP_LONG, NULL);
-       }
-
-      std::cout << std::endl;
-    }
-}
index a95bf500fc15e81a7422700ba8f43100483ef706..2cf3085ce45eca5a7e6652ef1e767963b57c430f 100644 (file)
@@ -36,11 +36,6 @@ namespace check_registrar_aux
 {
   bool be_verbose ();
   void list_one_check (checkdescriptor const &cd);
-
-  void include (std::set<checkdescriptor const *> &to,
-               checkdescriptor const *cd);
-  void add_deps (std::set<checkdescriptor const *> &to,
-                checkdescriptor const *cd);
 }
 
 template <class Item>
@@ -60,10 +55,10 @@ public:
   checkdescriptors_t
   get_descriptors () const
   {
-    std::set<checkdescriptor const *> descriptors;
+    checkdescriptors_t ret;
     for (typename _super_t::const_iterator it = begin (); it != end (); ++it)
-      check_registrar_aux::include (descriptors, (*it)->descriptor ());
-    return checkdescriptors_t (descriptors.begin (), descriptors.end ());
+      ret.push_back ((*it)->descriptor ());
+    return ret;
   }
 };
 
index c254934810b707290a111e6cf10d1a9ed694f091..e81560aa62348ef69633a52d9ed15689d2ac7769 100644 (file)
@@ -39,7 +39,6 @@ namespace
     {
       static checkdescriptor cd
        (checkdescriptor::create ("check_self_referential_die")
-        .inherit<highlevel_check<check_self_referential_die> > ()
         .description (
 "A reference attribute referencing the DIE itself is suspicious.\n"
 "One example is a DW_AT_containing_type pointing to itself.\n"
index a74d69c01926fba158533572be84c11af18b52e7..9fdde4a8b542e75c31ed937ac463baa677a54e29 100644 (file)
@@ -24,6 +24,7 @@
    <http://www.openinventionnetwork.com>.  */
 
 #include "checkdescriptor.hh"
+#include "wrap.hh"
 #include <sstream>
 #include <cassert>
 
@@ -42,32 +43,19 @@ operator << (std::ostream &o, checkgroups const &groups)
   return o;
 }
 
-std::ostream &
-operator << (std::ostream &o, prereqs const &p)
-{
-  o << "(";
-  for (prereqs::const_iterator it = p.begin (); it != p.end (); ++it)
-    {
-      if (it != p.begin ())
-       o << ',';
-      o << (*it)->name ();
-    }
-  o << ")";
-  return o;
-}
-
 checkdescriptor::create::create (char const *name)
   : _m_name (name)
   , _m_description (NULL)
   , _m_hidden (false)
+  , _m_schedule (true)
 {}
 
 checkdescriptor::create::create (checkdescriptor const &base)
   : _m_groups (base.groups ())
-  , _m_prereq (base.prereq ())
   , _m_name (base.name ())
   , _m_description (base.description ())
   , _m_hidden (base.hidden ())
+  , _m_schedule (base.schedule ())
   , _m_opts (base.opts ())
 {}
 
@@ -81,12 +69,21 @@ checkdescriptor::create::groups (char const *a_groups)
   return *this;
 }
 
+checkdescriptor::checkdescriptor ()
+  : _m_name (NULL)
+  , _m_description (NULL)
+  , _m_groups ()
+  , _m_hidden (false)
+  , _m_schedule (true)
+  , _m_opts ()
+{}
+
 checkdescriptor::checkdescriptor (create const &c)
   : _m_name (c._m_name)
   , _m_description (c._m_description)
   , _m_groups (c._m_groups)
-  , _m_prereq (c._m_prereq)
   , _m_hidden (c._m_hidden)
+  , _m_schedule (c._m_schedule)
   , _m_opts (c._m_opts)
 {}
 
@@ -95,3 +92,42 @@ checkdescriptor::in_group (std::string const &group) const
 {
   return _m_groups.find (group) != _m_groups.end ();
 }
+
+void
+checkdescriptor::list (bool verbose) const
+{
+  const size_t columns = 70;
+
+  if (verbose)
+    std::cout << "=== " << name () << " ===";
+  else
+    std::cout << name ();
+
+  checkgroups const &g = groups ();
+  if (!g.empty ())
+    {
+      if (verbose)
+       std::cout << std::endl << "groups: ";
+      else
+       std::cout << ' ';
+      std::cout << g;
+    }
+  std::cout << std::endl;
+
+  if (verbose)
+    {
+      char const *desc = description ();
+      if (desc != NULL)
+       std::cout << wrap_str (desc, columns).join ();
+
+      options const &o = opts ();
+      if (!o.empty ())
+       {
+         std::cout << "recognized options:" << std::endl;
+         argp a = o.build_argp ();
+         argp_help (&a, stdout, ARGP_HELP_LONG, NULL);
+       }
+
+      std::cout << std::endl;
+    }
+}
index 2127d5f54d42417ce708f7654121695c54a3d8b8..2382cc27d33ccd26efc452c1f3070fe33747c401 100644 (file)
@@ -38,23 +38,16 @@ struct checkgroups
 {};
 std::ostream &operator << (std::ostream &o, checkgroups const &groups);
 
-struct checkdescriptor;
-
-struct prereqs
-  : public std::set<checkdescriptor const *>
-{};
-std::ostream &operator << (std::ostream &o, prereqs const &p);
-
 struct checkdescriptor
 {
   class create
   {
     friend class checkdescriptor;
     checkgroups _m_groups;
-    prereqs _m_prereq;
     char const *const _m_name;
     char const *_m_description;
     bool _m_hidden;
+    bool _m_schedule;
     options _m_opts;
 
   public:
@@ -68,10 +61,6 @@ struct checkdescriptor
       return *this;
     }
 
-    template <class T> create &prereq ();
-
-    template <class T> create &inherit ();
-
     create hidden ()
     {
       _m_hidden = true;
@@ -83,47 +72,37 @@ struct checkdescriptor
       _m_opts.add (&opt);
       return *this;
     }
+
+    create schedule (bool whether)
+    {
+      _m_schedule = whether;
+      return *this;
+    }
   };
 
+  checkdescriptor ();
   checkdescriptor (create const &c);
 
   char const *name () const { return _m_name; }
   char const *description () const { return _m_description; }
-  prereqs const &prereq () const { return _m_prereq; }
 
   checkgroups const &groups () const { return _m_groups; }
   bool in_group (std::string const &group) const;
 
   bool hidden () const { return _m_hidden; }
+  bool schedule () const { return _m_schedule; }
 
   options const &opts () const { return _m_opts; }
 
+  void list (bool verbose) const;
+
 private:
   char const *const _m_name;
   char const *const _m_description;
   checkgroups const _m_groups;
-  prereqs const _m_prereq;
-  bool _m_hidden;
+  bool const _m_hidden;
+  bool const _m_schedule;
   options const _m_opts;
 };
 
-template <class T>
-checkdescriptor::create &
-checkdescriptor::create::prereq ()
-{
-  _m_prereq.insert (T::descriptor ());
-  return *this;
-}
-
-template <class T>
-checkdescriptor::create &
-checkdescriptor::create::inherit ()
-{
-  checkdescriptor const &cd = *T::descriptor ();
-  for (prereqs::const_iterator it = cd.prereq ().begin ();
-       it != cd.prereq ().end (); ++it)
-    _m_prereq.insert (*it);
-  return *this;
-}
-
 #endif//DWARFLINT_CHECKDESCRIPTOR_HH
index f836040b11c26085f2ee2e06aab9e359f647ea58..c09ecabda651832040e9d7442aecb9bbaa42b1b4 100644 (file)
@@ -1,5 +1,5 @@
 /* Pedantic checking of DWARF files
-   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
@@ -33,8 +33,7 @@ cu_coverage::descriptor ()
 {
   static checkdescriptor cd
     (checkdescriptor::create ("cu_coverage")
-     .prereq<typeof (*_m_info)> ()
-     .prereq<typeof (*_m_ranges)> ());
+     .hidden ());
   return &cd;
 }
 
index 86468d90734a89d293d2d5d6a39f129eb16db43d..b0ea7db93a7dc657b70f2118eb3d3ba41de17614 100644 (file)
@@ -32,6 +32,7 @@
 #include "checks.hh"
 #include "check_registrar.hh"
 #include "files.hh"
+#include "main.hh"
 
 #include <fcntl.h>
 #include <cstring>
@@ -57,10 +58,11 @@ void
 main_check_registrar::run (dwarflint &lint)
 {
   for (const_iterator it = begin (); it != end (); ++it)
-    {
-      checkstack stack;
-      (*it)->run (stack, lint);
-    }
+    if ((*it)->descriptor ()->schedule ())
+      {
+       checkstack stack;
+       (*it)->run (stack, lint);
+      }
 }
 
 dwarflint::dwarflint (char const *a_fname, checkrules const &a_rules)
@@ -115,13 +117,23 @@ dwarflint::main_registrar ()
 
 namespace
 {
+  bool
+  be_verbose ()
+  {
+    // We can hopefully assume that the option doesn't change during
+    // execution, so we can simply cache it this was.
+    static bool be_verbose = opt_list_checks.value () == "full";
+    return be_verbose;
+  }
+
   template <class T>
   void
   list_part_checks (T const &descriptors)
   {
     for (typename T::const_iterator it = descriptors.begin ();
         it != descriptors.end (); ++it)
-      check_registrar_aux::list_one_check (**it);
+      if (!(*it)->hidden ())
+       (*it)->list (be_verbose ());
   }
 }
 
@@ -130,7 +142,7 @@ dwarflint::list_checks ()
 {
   list_part_checks (dwarflint::main_registrar ()->get_descriptors ());
 
-  if (!check_registrar_aux::be_verbose ())
+  if (!be_verbose ())
     std::cout
       << "Use --list-checks=full to get more detailed description."
       << std::endl;
index 26dfbd3551bdc0852e7ca38f7fb858a0f3693999..007756a41f9e5aca13ea25287e1cf2ba450f5c39 100644 (file)
@@ -73,9 +73,7 @@ class highlevel_check
   open_highlevel_dwarf *_m_loader;
 public:
   static checkdescriptor const *descriptor () {
-    static checkdescriptor cd
-      (checkdescriptor::create ("highlevel_check")
-       .prereq<typeof (*highlevel_check_i::_m_loader)> ());
+    static checkdescriptor cd ("highlevel_check");
     return &cd;
   }
 
index 77e6bbbff282573635cf2ee80f0267b33a58ad84..987c56dfb253db9480cf891f9a69ed343ada3c80 100644 (file)
@@ -1,5 +1,5 @@
 /* Scheduler for low_level checks
-   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
@@ -37,19 +37,10 @@ lowlevel_checks::descriptor ()
 {
   static checkdescriptor cd
     (checkdescriptor::create ("lowlevel_checks")
-     .prereq<check_debug_info> ()
-     .prereq<check_debug_abbrev> ()
-     .prereq<check_debug_aranges> ()
-     .prereq<check_debug_pubnames> ()
-     .prereq<check_debug_pubtypes> ()
-     .prereq<check_debug_line> ()
-     .prereq<check_debug_loc> ()
-     .prereq<check_debug_ranges> ()
-     .prereq<check_debug_info_refs> ()
-     .hidden ()
-     );
+     .hidden ());
   return &cd;
 }
+
 static reg<lowlevel_checks> reg_lowlevel_checks;
 
 namespace
index f9a64b08a0e6e713cd1d424b2c71832d5a59784c..6f9f2546146c0f7e2977dde61b60a11aba867c07 100644 (file)
@@ -48,9 +48,7 @@ load_sections::descriptor ()
 checkdescriptor const *
 section_base::descriptor ()
 {
-  static checkdescriptor cd
-    (checkdescriptor::create ()
-     .prereq<typeof (*sections)> ());
+  static checkdescriptor cd;
   return &cd;
 }
 
index 1d488fbc6100e3907879a2f999955c83d710dc7a..ba059d5768ce0577978f7571e40cfb98fb630aaa 100644 (file)
@@ -1,5 +1,5 @@
 /* Low-level section handling.
-   Copyright (C) 2009, 2010 Red Hat, Inc.
+   Copyright (C) 2009, 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
@@ -68,7 +68,6 @@ public:
   static checkdescriptor const *descriptor () {
     static checkdescriptor cd
       (checkdescriptor::create (section_name[sec_id])
-       .inherit<section_base> ()
        .hidden ());
     return &cd;
   }