static reg<check_debug_abbrev> reg_debug_abbrev;
+checkdescriptor &
+check_debug_abbrev::descriptor ()
+{
+ static checkdescriptor cd
+ (checkdescriptor::create ("check_debug_abbrev")
+ .groups ("@low")
+ .prereq <typeof (*_m_sec_abbr)> ());
+ return cd;
+}
+
struct abbrev *
abbrev_table_find_abbrev (struct abbrev_table const *abbrevs,
uint64_t abbrev_code)
#ifndef DWARFLINT_CHECK_DEBUG_ABBREV_HH
#define DWARFLINT_CHECK_DEBUG_ABBREV_HH
+#include "low.h"
+#include "checks.hh"
+#include "sections.ii"
+
class check_debug_abbrev
: public check<check_debug_abbrev>
{
section<sec_abbrev> *_m_sec_abbr;
public:
- static checkdescriptor descriptor () {
- static checkdescriptor cd
- (checkdescriptor::create ("check_debug_abbrev")
- .groups ("@low"));
- return cd;
- }
+ static checkdescriptor &descriptor ();
// offset -> abbreviations
typedef std::map< ::Dwarf_Off, abbrev_table> abbrev_map;
static reg<check_debug_aranges> reg_debug_aranges;
+checkdescriptor
+check_debug_aranges::descriptor ()
+{
+ static checkdescriptor cd
+ (checkdescriptor::create ("check_debug_aranges")
+ .groups ("@low")
+ .prereq<typeof (*_m_sec_aranges)> ());
+ return cd;
+}
+
check_debug_aranges::check_debug_aranges (checkstack &stack, dwarflint &lint)
: _m_sec_aranges (lint.check (stack, _m_sec_aranges))
{
Network licensing program, please visit www.openinventionnetwork.com
<http://www.openinventionnetwork.com>. */
-#ifndef DWARFLINT_CHECKS_LOW_HH
-#define DWARFLINT_CHECKS_LOW_HH
+#ifndef DWARFLINT_CHECK_DEBUG_ARANGES_HH
+#define DWARFLINT_CHECK_DEBUG_ARANGES_HH
#include "low.h"
#include "checks.hh"
section<sec_aranges> *_m_sec_aranges;
public:
- static checkdescriptor descriptor () {
- static checkdescriptor cd
- (checkdescriptor::create ("check_debug_aranges")
- .groups ("@low"));
- return cd;
- }
-
+ static checkdescriptor descriptor ();
check_debug_aranges (checkstack &stack, dwarflint &lint);
};
-#endif//DWARFLINT_CHECKS_LOW_HH
+#endif//DWARFLINT_CHECK_DEBUG_ARANGES_HH
#include "check_debug_abbrev.hh"
#include "check_debug_info.hh"
+checkdescriptor
+read_cu_headers::descriptor ()
+{
+ static checkdescriptor cd
+ (checkdescriptor::create ("read_cu_headers")
+ .prereq<typeof (*_m_sec_info)> ());
+ return cd;
+}
+
static reg<check_debug_info> reg_debug_info;
+checkdescriptor
+check_debug_info::descriptor ()
+{
+ static checkdescriptor cd
+ (checkdescriptor::create ("check_debug_info")
+ .groups ("@low")
+ .prereq<typeof (*_m_sec_info)> ()
+ .prereq<typeof (*_m_sec_abbrev)> ()
+ .prereq<typeof (*_m_sec_str)> ()
+ .prereq<typeof (*_m_abbrevs)> ()
+ .prereq<typeof (*_m_cu_headers)> ()
+ );
+ return cd;
+}
+
namespace
{
bool
#ifndef DWARFLINT_CHECK_DEBUG_INFO_HH
#define DWARFLINT_CHECK_DEBUG_INFO_HH
+#include "low.h"
+#include "checks.hh"
#include "check_debug_abbrev.ii"
#include "sections.ii"
-#include "checks.hh"
-#include "low.h"
/** The pass for reading basic .debug_info data -- the layout of
sections and their headers. */
section<sec_info> *_m_sec_info;
public:
- static checkdescriptor descriptor () {
- static checkdescriptor cd ("read_cu_headers @low");
- return cd;
- }
-
+ static checkdescriptor descriptor ();
std::vector<cu_head> const cu_headers;
read_cu_headers (checkstack &stack, dwarflint &lint);
};
void check_info_structural ();
public:
- static checkdescriptor descriptor () {
- static checkdescriptor cd ("check_debug_info");
- return cd;
- }
+ static checkdescriptor descriptor ();
// The check pass adds all low_pc/high_pc ranges loaded from DIE
// tree into this following cu_cov structure. If it finds any
static checkdescriptor descriptor () {
static checkdescriptor cd
(checkdescriptor::create ("check_debug_line")
- .groups ("@low"));
+ .groups ("@low")
+ .prereq<typeof (*_m_sec)> ());
return cd;
}
#include "../src/dwarf-opcodes.h"
#include "pri.hh"
+static reg<check_debug_ranges> reg_debug_ranges;
+
+checkdescriptor const &
+check_debug_ranges::descriptor ()
+{
+ static checkdescriptor cd
+ (checkdescriptor::create ("check_debug_ranges")
+ .groups ("@low")
+ .prereq<typeof (*_m_sec_ranges)> ()
+ .prereq<typeof (*_m_cus)> ());
+ return cd;
+}
+
+static reg<check_debug_loc> reg_debug_loc;
+
+checkdescriptor const &
+check_debug_loc::descriptor ()
+{
+ static checkdescriptor cd
+ (checkdescriptor::create ("check_debug_loc")
+ .groups ("@low")
+ .prereq<typeof (*_m_sec_loc)> ()
+ .prereq<typeof (*_m_cus)> ());
+ return cd;
+}
+
namespace
{
void
return true;
}
-
-namespace
-{
- reg<check_debug_ranges> reg_debug_ranges;
- reg<check_debug_loc> reg_debug_loc;
-}
Network licensing program, please visit www.openinventionnetwork.com
<http://www.openinventionnetwork.com>. */
+#include "low.h"
+#include "checks.hh"
#include "sections.ii"
#include "check_debug_info.ii"
-#include "checks.hh"
#include "messages.h"
-#include "low.h"
class check_debug_ranges
: public check<check_debug_ranges>
check_debug_info *_m_cus;
public:
- static checkdescriptor descriptor () {
- static checkdescriptor cd
- (checkdescriptor::create ("check_debug_ranges")
- .groups ("@low"));
- return cd;
- }
-
+ static checkdescriptor const &descriptor ();
check_debug_ranges (checkstack &stack, dwarflint &lint);
};
check_debug_info *_m_cus;
public:
- static checkdescriptor descriptor () {
- static checkdescriptor cd
- (checkdescriptor::create ("check_debug_loc")
- .groups ("@low"));
- return cd;
- }
-
+ static checkdescriptor const &descriptor ();
check_debug_loc (checkstack &stack, dwarflint &lint);
};
static std::string name
= (std::string)"check_"
+ (section_t::descriptor ().name () + 1);
- static checkdescriptor cd (name.c_str ());
+ static checkdescriptor cd
+ (checkdescriptor::create (name.c_str ())
+ .prereq<typeof (*_m_sec)> ());
return cd;
}
static checkdescriptor 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\n"
"DW_AT_name value. This covers duplicate declaration, duplicate\n"
static checkdescriptor descriptor () {
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\n"
"suspicious if that attribute name appears on the DIE that's the\n"
{
public:
static checkdescriptor descriptor () {
- static checkdescriptor cd ("check_expected_trees");
+ 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"));
return cd;
}
{
public:
static checkdescriptor descriptor () {
- static checkdescriptor cd ("check_matching_ranges");
+ static checkdescriptor cd
+ (checkdescriptor::create ("check_matching_ranges")
+ .inherit<highlevel_check<check_matching_ranges> > ());
return cd;
}
public:
static checkdescriptor descriptor () {
- static checkdescriptor cd ("check_range_out_of_scope");
+ 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;
}
: _m_name (c.name)
, _m_description (c.desc)
, _m_groups (c.g)
+ , _m_prereq (c.p)
{}
bool
struct create
{
checkgroups g;
+ checkgroups p;
char const *const name;
char const *desc;
- create (char const *name);
+ create (char const *name = NULL);
create &groups (char const *name);
create &description (char const *d)
{ desc = d; return *this; }
+
+ template <class T> create &prereq ();
+
+ template <class T> create &inherit ();
};
checkdescriptor (create const &c);
char const *name () const { return _m_name; }
char const *description () const { return _m_description; }
+ checkgroups const &prereq () const { return _m_prereq; }
checkgroups const &groups () const { return _m_groups; }
bool in_group (std::string const &group) const;
char const *const _m_name;
char const *const _m_description;
checkgroups const _m_groups;
+ checkgroups const _m_prereq;
};
+template <class T>
+checkdescriptor::create &
+checkdescriptor::create::prereq ()
+{
+ p.insert (T::descriptor ().name ());
+ return *this;
+}
+
+template <class T>
+checkdescriptor::create &
+checkdescriptor::create::inherit ()
+{
+ checkdescriptor const &cd = T::descriptor ();
+ for (checkgroups::const_iterator it = cd.prereq ().begin ();
+ it != cd.prereq ().end (); ++it)
+ p.insert (*it);
+ return *this;
+}
+
#endif//DWARFLINT_CHECKDESCRIPTOR_HH
it != _m_items.end (); ++it)
{
checkdescriptor const &cd = (*it)->descriptor ();
- std::cout << cd.name () << ' ' << cd.groups () << std::endl;
+ 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)
{
+ checkgroups const &prereq = cd.prereq ();
+ if (!prereq.empty ())
+ std::cout << "prerequisites: " << prereq << std::endl;
char const *desc = cd.description ();
if (desc != NULL)
std::cout << desc;
{
open_highlevel_dwarf *_m_loader;
public:
+ static checkdescriptor const &descriptor () {
+ static checkdescriptor cd
+ (checkdescriptor::create ("open_highlevel_dwarf")
+ .prereq<typeof (*_m_loader)> ());
+ return cd;
+ }
+
elfutils::dwarf const &dw;
explicit highlevel_check (checkstack &stack, dwarflint &lint)
#include "pri.hh"
#include "options.h"
+checkdescriptor const &
+load_sections::descriptor ()
+{
+ static checkdescriptor cd ("load_sections");
+ return cd;
+}
+
+checkdescriptor const &
+section_base::descriptor ()
+{
+ static checkdescriptor cd
+ (checkdescriptor::create ()
+ .prereq<typeof (*sections)> ());
+ return cd;
+}
+
namespace
{
int
: public check<load_sections>
{
public:
- static checkdescriptor descriptor () {
- static checkdescriptor cd ("load_sections");
- return cd;
- }
+ static checkdescriptor const &descriptor ();
elf_file file;
load_sections (checkstack &stack, dwarflint &lint);
{
load_sections *sections;
sec &get_sec_or_throw (section_id secid);
+
public:
+ static checkdescriptor const &descriptor ();
+
sec §
elf_file &file;
section_base (checkstack &stack,
{
public:
static checkdescriptor const &descriptor () {
- static checkdescriptor cd(section_name[sec_id]);
+ static checkdescriptor cd
+ (checkdescriptor::create (section_name[sec_id])
+ .inherit<section_base> ());
return cd;
}