]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Add an ability to list registered checks
authorPetr Machata <pmachata@redhat.com>
Fri, 27 Aug 2010 15:41:53 +0000 (17:41 +0200)
committerPetr Machata <pmachata@redhat.com>
Fri, 27 Aug 2010 15:41:53 +0000 (17:41 +0200)
- because the check descriptor is quite simple as of now, the usefulness
  of this is rather limited
- plus unregistered checks are not listed, which means that the user will
  never know about prereqs like .debug_info.  Hard to say whether this is
  a problem or not

dwarflint/checks.hh
dwarflint/dwarflint.cc
dwarflint/dwarflint.hh
dwarflint/main.cc

index 146894c283eaa8adb38eb96aa2997222ed897b8d..08591b60222e82994b6fa71c324153d387c61fc3 100644 (file)
@@ -147,6 +147,11 @@ struct reg
   {
     lint.toplev_check <T> (stack);
   }
+
+  virtual void list () const
+  {
+    dwarflint::list_check (T::descriptor ());
+  }
 };
 
 #endif//DWARFLINT_CHECKS_HH
index 83491ee67ce9186e705b2f96696e70650461194b..541f00a5f721c79a7b60f6e574322def0ee54584 100644 (file)
@@ -81,6 +81,20 @@ dwarflint::check_registrar::enroll (dwarflint &lint)
     }
 }
 
+void
+dwarflint::check_registrar::list_checks () const
+{
+  for (std::vector <item *>::const_iterator it = _m_items.begin ();
+       it != _m_items.end (); ++it)
+    (*it)->list ();
+}
+
+void
+dwarflint::list_check (checkdescriptor const &cd)
+{
+  std::cout << cd.name << std::endl;
+}
+
 namespace
 {
   bool
index ccd0bdf9608cbf8f46573875ee4cacd0bcccc409..b464a598e529271da6f7d79d38bdd3a2dc6d788d 100644 (file)
@@ -83,6 +83,7 @@ public:
     struct item
     {
       virtual void run (checkstack &stack, dwarflint &lint) = 0;
+      virtual void list () const = 0;
     };
 
     static check_registrar *inst ()
@@ -96,6 +97,8 @@ public:
       _m_items.push_back (i);
     }
 
+    void list_checks () const;
+
   private:
     friend class dwarflint;
     void enroll (dwarflint &lint);
@@ -118,8 +121,10 @@ public:
     return check<T> (stack);
   }
 
-  template <class T> T *toplev_check (checkstack &stack,
-                                     T *tag = NULL);
+  template <class T>
+  T *toplev_check (checkstack &stack, T *tag = NULL);
+
+  static void list_check (checkdescriptor const &cd);
 };
 
 #endif//DWARFLINT_HH
index ccf35c5ed1472d925d16e564f2275fdcf74374ef..0613addd0177b97e9d34ce9e5e5632e6d800a359 100644 (file)
@@ -50,6 +50,7 @@ const char *argp_program_bug_address = PACKAGE_BUGREPORT;
 #define ARGP_nohl       304
 #define ARGP_dump_off   305
 #define ARGP_check      306
+#define ARGP_list_checks 307
 
 /* Definitions of arguments for argp functions.  */
 static const struct argp_option options[] =
@@ -75,6 +76,8 @@ the DIE referring to the entry in consideration"), 0 },
     N_("Dump DIE offsets to stderr as the tree is iterated."), 0 },
   { "check", ARGP_check, "[+-][@]name,...", 0,
     N_("Only run selected checks."), 0 },
+  { "list-checks", ARGP_list_checks, NULL, 0,
+    N_("List all the available checks."), 0 },
   { NULL, 0, NULL, 0, NULL, 0 }
 };
 
@@ -191,6 +194,10 @@ parse_opt (int key, char *arg __attribute__ ((unused)),
       }
       break;
 
+    case ARGP_list_checks:
+      dwarflint::check_registrar::inst ()->list_checks ();
+      std::exit (0);
+
     case 'i':
       tolerate_nodebug = true;
       break;