From: Petr Machata Date: Fri, 27 Aug 2010 15:41:53 +0000 (+0200) Subject: dwarflint: Add an ability to list registered checks X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c6538709f0f4f61903c58f95c53ce43f7f8a02e1;p=thirdparty%2Felfutils.git dwarflint: Add an ability to list registered checks - 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 --- diff --git a/dwarflint/checks.hh b/dwarflint/checks.hh index 146894c28..08591b602 100644 --- a/dwarflint/checks.hh +++ b/dwarflint/checks.hh @@ -147,6 +147,11 @@ struct reg { lint.toplev_check (stack); } + + virtual void list () const + { + dwarflint::list_check (T::descriptor ()); + } }; #endif//DWARFLINT_CHECKS_HH diff --git a/dwarflint/dwarflint.cc b/dwarflint/dwarflint.cc index 83491ee67..541f00a5f 100644 --- a/dwarflint/dwarflint.cc +++ b/dwarflint/dwarflint.cc @@ -81,6 +81,20 @@ dwarflint::check_registrar::enroll (dwarflint &lint) } } +void +dwarflint::check_registrar::list_checks () const +{ + for (std::vector ::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 diff --git a/dwarflint/dwarflint.hh b/dwarflint/dwarflint.hh index ccd0bdf96..b464a598e 100644 --- a/dwarflint/dwarflint.hh +++ b/dwarflint/dwarflint.hh @@ -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 (stack); } - template T *toplev_check (checkstack &stack, - T *tag = NULL); + template + T *toplev_check (checkstack &stack, T *tag = NULL); + + static void list_check (checkdescriptor const &cd); }; #endif//DWARFLINT_HH diff --git a/dwarflint/main.cc b/dwarflint/main.cc index ccf35c5ed..0613addd0 100644 --- a/dwarflint/main.cc +++ b/dwarflint/main.cc @@ -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;