dwarflint_SOURCES = \
main.cc \
checkdescriptor.cc checkdescriptor.hh checkdescriptor.ii \
- dwarflint.cc dwarflint.hh misc.h \
+ checkrule.cc checkrule.hh \
+ dwarflint.cc dwarflint.hh dwarflint.ii misc.h \
low.c low.h \
expected-at.cc expected.hh \
coverage.cc coverage.h \
- readctx.c readctx.h \
+ readctx.c readctx.h \
pri.cc pri.hh \
messages.cc messages.h \
section_id.cc section_id.h \
Network licensing program, please visit www.openinventionnetwork.com
<http://www.openinventionnetwork.com>. */
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
#include "highlevel_check.hh"
-#include "../src/dwarfstrings.h"
#include "all-dies-it.hh"
#include "pri.hh"
#include "messages.h"
--- /dev/null
+/*
+ Copyright (C) 2010 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 "checkrule.hh"
+#include "checkdescriptor.hh"
+#include "dwarflint.hh"
+#include <cassert>
+
+checkrule::checkrule (std::string const &a_name, action_t an_action)
+ : _m_name (a_name)
+ , _m_action (an_action)
+{
+}
+
+namespace
+{
+ bool
+ rule_matches (std::string const &name,
+ checkdescriptor const &cd)
+ {
+ if (name == "@all")
+ return true;
+ if (name == "@none")
+ return false;
+ if (name == cd.name ())
+ return true;
+ return cd.in_group (name);
+ }
+}
+
+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 ());
+ if (stack.back ()->hidden ())
+ return true;
+
+ bool should = false;
+ for (const_iterator it = begin (); it != end (); ++it)
+ {
+ std::string const &rule_name = it->name ();
+ bool nflag = it->action () == checkrule::request;
+ if (nflag == should)
+ continue;
+
+ for (checkstack::const_iterator jt = stack.begin ();
+ jt != stack.end (); ++jt)
+ if (rule_matches (rule_name, **jt))
+ {
+ //std::cout << " rule: " << rule_name << " " << nflag << std::endl;
+ should = nflag;
+ break;
+ }
+ }
+
+ return should;
+}
--- /dev/null
+/*
+ Copyright (C) 2010 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>. */
+
+#ifndef DWARFLINT_CHECKRULE_HH
+#define DWARFLINT_CHECKRULE_HH
+
+#include <vector>
+#include <string>
+#include "dwarflint.ii"
+
+struct checkrule
+{
+ enum action_t
+ {
+ forbid,
+ request,
+ };
+
+private:
+ std::string _m_name;
+ action_t _m_action;
+
+public:
+ checkrule (std::string const &name, action_t action);
+
+ std::string const &name () const { return _m_name; }
+ action_t action () const { return _m_action; }
+};
+
+class checkrules
+ : public std::vector<checkrule>
+{
+public:
+ bool should_check (checkstack const &stack) const;
+};
+
+#endif//DWARFLINT_CHECKRULE_HH
}
}
-dwarflint::dwarflint (char const *a_fname, check_rules const &rules)
+dwarflint::dwarflint (char const *a_fname, checkrules const &rules)
: _m_fname (a_fname)
, _m_fd (get_fd (_m_fname))
, _m_rules (rules)
<< std::endl;
}
-namespace
-{
- bool
- rule_matches (std::string const &name,
- checkdescriptor const &cd)
- {
- if (name == "@all")
- return true;
- if (name == "@none")
- return false;
- if (name == cd.name ())
- return true;
- return cd.in_group (name);
- }
-}
-
-bool
-check_rules::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 ());
- if (stack.back ()->hidden ())
- return true;
-
- bool should = false;
- for (const_iterator it = begin (); it != end (); ++it)
- {
- std::string const &rule_name = it->name;
- bool nflag = it->action == check_rule::request;
- if (nflag == should)
- continue;
-
- for (checkstack::const_iterator jt = stack.begin ();
- jt != stack.end (); ++jt)
- if (rule_matches (rule_name, **jt))
- {
- //std::cout << " rule: " << rule_name << " " << nflag << std::endl;
- should = nflag;
- break;
- }
- }
-
- return should;
-}
-
-
void *const dwarflint::marker = (void *)-1;
void *
#include <map>
#include <vector>
#include <stdexcept>
-#include <string>
#include <iosfwd>
#include "../libelf/libelf.h"
#include "checks.ii"
#include "checkdescriptor.ii"
+#include "checkrule.hh"
class checkstack
: public std::vector <checkdescriptor const *>
{};
std::ostream &operator << (std::ostream &o, checkstack const &stack);
-struct check_rule
-{
- enum action_t
- {
- forbid,
- request,
- };
-
- std::string name;
- action_t action;
-
- check_rule (std::string const &a_name, action_t an_action)
- : name (a_name)
- , action (an_action)
- {}
-};
-class check_rules
- : public std::vector<check_rule>
-{
- friend class dwarflint;
- bool should_check (checkstack const &stack) const;
-};
-
class dwarflint
{
typedef std::map <void const *, class check_base *> check_map;
check_map _m_checks;
char const *_m_fname;
int _m_fd;
- check_rules const &_m_rules;
+ checkrules const &_m_rules;
static void *const marker;
std::vector <item *> _m_items;
};
- dwarflint (char const *fname, check_rules const &rules);
+ dwarflint (char const *fname, checkrules const &rules);
~dwarflint ();
int fd () { return _m_fd; }
char const *fname () { return _m_fname; }
--- /dev/null
+class checkstack;
+class dwarflint;
struct check_option_t
: public option_common
{
- struct initial_check_rules
- : public check_rules
+ struct initial_checkrules
+ : public checkrules
{
- initial_check_rules () {
- push_back (check_rule ("@all", check_rule::request));
- push_back (check_rule ("@nodefault", check_rule::forbid));
+ initial_checkrules () {
+ push_back (checkrule ("@all", checkrule::request));
+ push_back (checkrule ("@nodefault", checkrule::forbid));
}
} rules;
act = request;
}
- check_rule::action_t action
- = act == request ? check_rule::request : check_rule::forbid;
- rules.push_back (check_rule (item, action));
+ checkrule::action_t action
+ = act == request ? checkrule::request : checkrule::forbid;
+ rules.push_back (checkrule (item, action));
}
return 0;
}