.prereq <typeof (*_m_sec_abbr)> ()
.prereq <typeof (*_m_cu_headers)> ()
.description (
-"Checks for low-level structure of .debug_abbrev. In addition it\n"
+"Checks for low-level structure of .debug_abbrev. In addition it "
"checks:\n"
" - that all abbreviation tables are non-empty\n"
-" - that certain attribute forms match expectations (mainly those that\n"
-" we have to work with in subsequent check passes. For example we\n"
-" check that DW_AT_low_pc has a form of DW_FORM_{,ref_}addr)\n"
-" - that all CUs that share an abbrev table are of the same DWARF\n"
-" version\n"
+" - that certain attribute forms match expectations (mainly those that "
+"we have to work with in subsequent check passes. For example we "
+"check that DW_AT_low_pc has a form of DW_FORM_{,ref_}addr)\n"
+" - that all CUs that share an abbrev table are of the same DWARF "
+"version\n"
" - that each abbrev table is used\n"
" - that abbrevs don't share abbrev codes\n"
-" - that abbrev tags, attribute names and attribute forms are all known\n"
-" (note that this assumes that elfutils know about all tags used in\n"
-" practice. Be sure to build against recent-enough version)\n"
+" - that abbrev tags, attribute names and attribute forms are all known "
+"(note that this assumes that elfutils know about all tags used in "
+"practice. Be sure to build against recent-enough version)\n"
" - that the value of has_children is either 0 or 1\n"
-" - that DW_AT_sibling isn't formed as DW_FORM_ref_addr, and that it\n"
-" isn't present at childless abbrevs\n"
+" - that DW_AT_sibling isn't formed as DW_FORM_ref_addr, and that it "
+"isn't present at childless abbrevs\n"
" - that attributes are not duplicated at abbrev\n"
-" - that DW_AT_high_pc is never used without DW_AT_low_pc. If both are\n"
-" used, that DW_AT_ranges isn't also used\n"
-"This check generally requires CU headers to be readable, i.e. that the\n"
-".debug_info section is roughly well-defined. If that isn't the case,\n"
-"many checks will still be done, operating under assumption that what\n"
-"we see is the latest DWARF format. This may render some checks\n"
+" - that DW_AT_high_pc is never used without DW_AT_low_pc. If both are "
+"used, that DW_AT_ranges isn't also used\n"
+"This check generally requires CU headers to be readable, i.e. that the "
+".debug_info section is roughly well-defined. If that isn't the case, "
+"many checks will still be done, operating under assumption that what "
+"we see is the latest DWARF format. This may render some checks "
"inaccurate.\n"));
return &cd;
}
.prereq<typeof (*_m_info)> ()
.prereq<typeof (*_m_cu_coverage)> ()
.description (
-"Checks for low-level structure of .debug_aranges. In addition it\n"
+"Checks for low-level structure of .debug_aranges. In addition it "
"checks:\n"
-" - that relocations are valid. In ET_REL files that certain fields\n"
-" are relocated\n"
+" - that relocations are valid. In ET_REL files that certain fields "
+"are relocated\n"
" - for dangling and duplicate CU references\n"
" - for garbage inside padding\n"
" - for zero-length ranges\n"
.prereq<typeof (*_m_abbrevs)> ()
.prereq<typeof (*_m_cu_headers)> ()
.description (
-"Checks for low-level structure of .debug_info. In addition it\n"
+"Checks for low-level structure of .debug_info. In addition it "
"checks:\n"
" - for dangling reference to .debug_abbrev section\n"
" - that reported CU address sizes are consistent\n"
" - that rangeptr values are aligned to CU address size\n"
-" - it is checked that DW_AT_low_pc and DW_AT_high_pc are relocated\n"
-" consistently\n"
-" - that DIE references are well formed (both intra-CU and inter-CU)\n"
-" and that local reference isn't needlessly formed as global\n"
-" - that .debug_string references are well formed and referred strings\n"
-" are properly NUL-terminated\n"
+" - it is checked that DW_AT_low_pc and DW_AT_high_pc are relocated "
+"consistently\n"
+" - that DIE references are well formed (both intra-CU and inter-CU) "
+"and that local reference isn't needlessly formed as global\n"
+" - that .debug_string references are well formed and referred strings "
+"are properly NUL-terminated\n"
" - that referenced abbreviations actually exist\n"
-" - that DIEs with children have the DW_AT_sibling attribute and that\n"
-" the sibling actually is at the address reported at that attribute\n"
+" - that DIEs with children have the DW_AT_sibling attribute and that "
+"the sibling actually is at the address reported at that attribute\n"
" - that the DIE chain is terminated\n"
" - that the last sibling in chain has no DW_AT_sibling attribute\n"
-" - that the DIE with children actually has children (i.e. that the\n"
-" chain is not empty)\n"
-" - for format constraints (such as that there are no 64-bit CUs inside\n"
-" DWARF 2 file)\n"
-" - in 32-bit CUs, that location attributes are not formed with\n"
-" DW_FORM_data8\n"
-" - all the attribute checks done by check_debug_abbrev are done here\n"
-" for attributes with DW_FORM_indirect. Indirect form is forbidden\n"
-" to be again indirect\n"
+" - that the DIE with children actually has children (i.e. that the "
+"chain is not empty)\n"
+" - for format constraints (such as that there are no 64-bit CUs inside "
+"DWARF 2 file)\n"
+" - in 32-bit CUs, that location attributes are not formed with "
+"DW_FORM_data8\n"
+" - all the attribute checks done by check_debug_abbrev are done here "
+"for attributes with DW_FORM_indirect. Indirect form is forbidden "
+"to be again indirect\n"
" - that all abbreviations are used\n"
-" - that relocations are valid. In ET_REL files that certain fields\n"
-" are relocated\n"
+" - that relocations are valid. In ET_REL files that certain fields "
+"are relocated\n"
));
return &cd;
}
.description (
"This pass checks:\n"
" - for outstanding unresolved references from .debug_info to .debug_line\n"
-" - that each CU has an associated aranges entry (that even if there is\n"
-" no .debug_aranges to begin with).\n"));
+" - that each CU has an associated aranges entry (that even if there is "
+"no .debug_aranges to begin with).\n"));
return &cd;
}
.description (
"Checks for low-level structure of .debug_line. In addition it\n"
"checks:\n"
-" - for normalized values of certain attributes (such as that\n"
-" default_is_stmt is 0 or 1, even though technically any non-zero\n"
-" value is allowed).\n"
-" - for valid setting of opcode base (i.e. non-zero) and any file\n"
-" indices\n"
+" - for normalized values of certain attributes (such as that "
+"default_is_stmt is 0 or 1, even though technically any non-zero "
+"value is allowed).\n"
+" - for valid setting of opcode base (i.e. non-zero) and any file"
+"indices\n"
" - that all include directories and all files are used\n"
-" - that files with absolute paths don't refer to include directories,\n"
-" and otherwise that the directory reference is valid\n"
-" - that each used standard or extended opcode is known (note that this\n"
-" assumes that elfutils know about all opcodes used in practice. Be\n"
-" sure to build against recent-enough version).\n"
-" - that the line number program is properly terminated with the\n"
-" DW_LNE_end_sequence instruction and that it contains at least one\n"
-" other instruction\n"
-" - that relocations are valid. In ET_REL files that certain fields\n"
-" are relocated\n"
-"Furthermore, if .debug_info is valid, it is checked that each line\n"
+" - that files with absolute paths don't refer to include directories,"
+"and otherwise that the directory reference is valid\n"
+" - that each used standard or extended opcode is known (note that this "
+"assumes that elfutils know about all opcodes used in practice. Be "
+"sure to build against recent-enough version).\n"
+" - that the line number program is properly terminated with the "
+"DW_LNE_end_sequence instruction and that it contains at least one "
+"other instruction\n"
+" - that relocations are valid. In ET_REL files that certain fields "
+"are relocated\n"
+"Furthermore, if .debug_info is valid, it is checked that each line "
"table is used by some CU.\n"
"TODOs:\n"
-" - overlaps in defined addresses are probably OK, one instruction can\n"
-" be derived from several statements. But certain flags in table\n"
-" should be consistent in that case, namely is_stmt, basic_block,\n"
-" end_sequence, prologue_end, epilogue_begin, isa.\n"
+" - overlaps in defined addresses are probably OK, one instruction can "
+"be derived from several statements. But certain flags in table "
+"should be consistent in that case, namely is_stmt, basic_block, "
+"end_sequence, prologue_end, epilogue_begin, isa.\n"
));
return &cd;
}
.prereq<typeof (*_m_sec_ranges)> ()
.prereq<typeof (*_m_info)> ()
.description (
-"Checks for low-level structure of .debug_ranges. In addition it\n"
+"Checks for low-level structure of .debug_ranges. In addition it "
"checks:\n"
" - for overlapping and dangling references from .debug_info\n"
" - that base address is set and that it actually changes the address\n"
" - that ranges have a positive size\n"
" - that there are no unreferenced holes in the section\n"
-" - that relocations are valid. In ET_REL files that certain fields\n"
-" are relocated\n"
-" - neither or both of range start and range end are expected to be\n"
-" relocated. It's expected that they are both relocated against the\n"
-" same section.\n"));
+" - that relocations are valid. In ET_REL files that certain fields "
+"are relocated\n"
+" - neither or both of range start and range end are expected to be "
+"relocated. It's expected that they are both relocated against the "
+"same section.\n"));
return &cd;
}
.prereq<typeof (*_m_sec_loc)> ()
.prereq<typeof (*_m_info)> ()
.description (
-"Checks for low-level structure of .debug_loc. In addition it\n"
-"makes the same checks as .debug_ranges. For location expressions\n"
+"Checks for low-level structure of .debug_loc. In addition it "
+"makes the same checks as .debug_ranges. For location expressions "
"it further checks:\n"
-" - that DW_OP_bra and DW_OP_skip argument is non-zero and doesn't\n"
-" escape the expression. In addition it is required that the jump\n"
-" ends on another instruction, not arbitrarily in the middle of the\n"
-" byte stream, even if that position happened to be interpretable as\n"
-" another well-defined instruction stream.\n"
+" - that DW_OP_bra and DW_OP_skip argument is non-zero and doesn't "
+"escape the expression. In addition it is required that the jump "
+"ends on another instruction, not arbitrarily in the middle of the "
+"byte stream, even if that position happened to be interpretable as "
+"another well-defined instruction stream.\n"
" - on 32-bit machines it rejects DW_OP_const8u and DW_OP_const8s\n"
-" - on 32-bit machines it checks that ULEB128-encoded arguments aren't\n"
-" quantities that don't fit into 32 bits\n"));
+" - on 32-bit machines it checks that ULEB128-encoded arguments aren't "
+"quantities that don't fit into 32 bits\n"));
return &cd;
}
.prereq<typeof (*_m_sec)> ()
.prereq<check_debug_info> ()
.description (
-"Checks for low-level structure of .debug_pubnames. In addition it\n"
+"Checks for low-level structure of .debug_pubnames. In addition it "
"checks:\n"
" - for garbage inside padding\n"
-" - that relocations are valid. In ET_REL files that certain fields\n"
-" are relocated\n"
+" - that relocations are valid. In ET_REL files that certain fields "
+"are relocated\n"
"Furthermore, if .debug_info is valid, it is checked:\n"
" - that references point to actual CUs and DIEs\n"
" - that there's only one pub section per CU\n"));
.prereq<typeof (*_m_sec)> ()
.prereq<check_debug_info> ()
.description (
-"Checks for low-level structure of .debug_pubtypes. In addition it\n"
+"Checks for low-level structure of .debug_pubtypes. In addition it "
"makes the same checks as check_debug_pubnames.\n"));
return &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"
+"Implements a check for two full DW_TAG_variable DIEs with the same "
+"DW_AT_name value. This covers duplicate declaration, duplicate "
"definition and declaration with definition.\n"
" https://fedorahosted.org/pipermail/elfutils-devel/2010-July/001497.html\n"
" http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39524\n"));
(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"
+"If a given attribute name is present on a DIE, it is "
+"suspicious if that attribute name appears on the DIE that's the "
"first DIE's DW_AT_abstract_origin or DW_AT_specification.\n"
" https://bugzilla.redhat.com/show_bug.cgi?id=527430\n"));
return &cd;
.groups ("@low")
.option (ignore_missing)
.description (
-"Checks that there are at least essential debuginfo sections present\n"
+"Checks that there are at least essential debuginfo sections present "
"in the ELF file.\n"));
return &cd;
}
#include "messages.hh"
#include "checks.hh"
#include "main.hh"
+#include "wrap.hh"
#include <fcntl.h>
#include <cstring>
{
bool be_verbose = opt_list_checks.value () == "full";
checkdescriptors_t descriptors = get_descriptors ();
+ const size_t columns = 70;
for (checkdescriptors_t::const_iterator it = descriptors.begin ();
it != descriptors.end (); ++it)
prereqs const &prereq = cd.prereq ();
if (!prereq.empty ())
std::cout << "prerequisites: " << prereq << std::endl;
+
char const *desc = cd.description ();
if (desc != NULL)
- std::cout << desc;
+ std::cout << wrap_str (desc, columns).join ();
options const &opts = cd.opts ();
if (!opts.empty ())
{
std::cout << "recognized options:" << std::endl;
- for (options::const_iterator ot = opts.begin ();
- ot != opts.end (); ++ot)
- std::cout << " " << ot->second->format () << std::endl;
+ argp a = opts.build_argp ();
+ argp_help (&a, stdout, ARGP_HELP_LONG, NULL);
}
std::cout << std::endl;
.option (opt_dump)
.option (opt_tabulation_rule)
.description (
-"Computes a location info coverage statistics. Goes through the whole\n"
-"DIE graph, looking at each variable and formal parameter, and\n"
-"determining scope coverage of its location information. In other\n"
-"words for how big a part of scope we know, where the variable\n"
+"Computes a location info coverage statistics. Goes through the whole "
+"DIE graph, looking at each variable and formal parameter, and "
+"determining scope coverage of its location information. In other "
+"words for how big a part of scope we know, where the variable "
"\"lives\".\n"
-" https://fedorahosted.org/pipermail/elfutils-devel/2010-July/001498.html\n"
-" https://fedorahosted.org/pipermail/elfutils-devel/2010-September/001602.html\n"));
+" - https://fedorahosted.org/pipermail/elfutils-devel/2010-July/001498.html\n"
+" - https://fedorahosted.org/pipermail/elfutils-devel/2010-September/001602.html\n"));
return &cd;
}
, _m_seen (false)
{}
-std::string
-option_common::format () const
-{
- std::string ret;
- bool has_short = _m_opt.key < 127;
- if (has_short)
- {
- char buf[3] = {};
- std::sprintf (buf, "-%c", _m_opt.key);
- ret += buf;
- }
-
- if (_m_opt.name != NULL)
- {
- if (has_short)
- ret += ", ";
- ret += "--";
- ret += _m_opt.name;
- }
-
- if (_m_opt.arg != NULL)
- {
- bool optional = !!(_m_opt.flags & OPTION_ARG_OPTIONAL);
- if (optional)
- ret += '[';
- ret += '=';
- ret += _m_opt.arg;
- if (optional)
- ret += ']';
- }
-
- if (_m_opt.doc != NULL)
- {
- ret += "\t";
- ret += _m_opt.doc;
- }
-
- return ret;
-}
-
options global_opts;
static int get_short_option (char opt_short);
public:
+ virtual ~option_i () {}
+
virtual bool seen () const = 0;
virtual argp_option const &build_option () const = 0;
virtual error_t parse_opt (char *arg, argp_state *state) = 0;
virtual int key () const = 0;
- virtual std::string format () const = 0;
- virtual ~option_i () {}
};
class option_common
{
return _m_opt.key;
}
-
- std::string format () const;
};
template<class arg_type>