]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Use wrapper to print check descriptions
authorPetr Machata <pmachata@redhat.com>
Fri, 1 Oct 2010 14:51:48 +0000 (16:51 +0200)
committerPetr Machata <pmachata@redhat.com>
Fri, 1 Oct 2010 14:51:48 +0000 (16:51 +0200)
- this should make it easier to write them
- also use argp to print out properly formatted help for each check.  Drop
  a bunch of code that was necessary to do things the old way

13 files changed:
dwarflint/check_debug_abbrev.cc
dwarflint/check_debug_aranges.cc
dwarflint/check_debug_info.cc
dwarflint/check_debug_line.cc
dwarflint/check_debug_loc_range.cc
dwarflint/check_debug_pub.cc
dwarflint/check_duplicate_DW_tag_variable.cc
dwarflint/check_dups_abstract_origin.cc
dwarflint/check_nodebug.cc
dwarflint/dwarflint.cc
dwarflint/locstats.cc
dwarflint/option.cc
dwarflint/option.hh

index ed19b134f11e59ba21c0fa66e5d590b8b9c9f8fb..e62445d23e8acb9553cbad4efb2707c9b7598e95 100644 (file)
@@ -50,29 +50,29 @@ check_debug_abbrev::descriptor ()
      .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;
 }
index 99f8669b23dd7190640f42ab6ed6f5c04660b25d..87f96832a94993addd73c9af6030359fecc8f64c 100644 (file)
@@ -52,10 +52,10 @@ check_debug_aranges::descriptor ()
      .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"
index 3b4942a65f7b2d3627aa7164d8c5857d2aa2391c..87b81c885145b00ab941566b7d7bdebbad7874e4 100644 (file)
@@ -65,34 +65,34 @@ check_debug_info::descriptor ()
      .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;
 }
@@ -1303,8 +1303,8 @@ check_debug_info_refs::descriptor ()
      .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;
 }
 
index fe44618a4f7277d5502e68b0611ea446d7fc6170..d4675babb06f0f4eacd1fba46eb81e0c4c8db845 100644 (file)
@@ -47,29 +47,29 @@ check_debug_line::descriptor ()
      .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;
 }
index b8456b91920a9f3b4bf1cb486804347a92bc2ebe..7bbca1d6fb4955584cd341c5dcbfa979dcfcb2ed 100644 (file)
@@ -57,17 +57,17 @@ check_debug_ranges::descriptor ()
      .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;
 }
 
@@ -80,17 +80,17 @@ check_debug_loc::descriptor ()
      .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;
 }
 
index 008355863fb02c4d1949803e4f812c929183d02f..568db432906ba4cf7db268827d7df902712a8872 100644 (file)
@@ -50,11 +50,11 @@ check_debug_pubnames::descriptor ()
      .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"));
@@ -72,7 +72,7 @@ check_debug_pubtypes::descriptor ()
      .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;
 }
index 3fb11632a1f03758a6c412b6b87c787dc270c5c4..80f966326a2598aa8d76584f46703ab8009841c1 100644 (file)
@@ -57,8 +57,8 @@ namespace
        (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"));
index ec786561f89c73b472578f00e3dfba0963a741a8..b746bba31663424672768f9063512230a2f77bab 100644 (file)
@@ -48,8 +48,8 @@ namespace
        (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;
index f658c615e142cc2bda5cdebf037eb7abe3d71b77..a5ed1c19acf86bc2146f107af8e10c0166e66955 100644 (file)
@@ -43,7 +43,7 @@ public:
        .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;
   }
index 6d01f7e028c3a28e56e9e07f2736c27e189500ff..f00c1c175461ed3b0e230dc68b719bd0376188b5 100644 (file)
@@ -27,6 +27,7 @@
 #include "messages.hh"
 #include "checks.hh"
 #include "main.hh"
+#include "wrap.hh"
 
 #include <fcntl.h>
 #include <cstring>
@@ -134,6 +135,7 @@ dwarflint::check_registrar::list_checks () const
 {
   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)
@@ -160,17 +162,17 @@ dwarflint::check_registrar::list_checks () const
          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;
index 0fb40282a386576bb0623417ce0c5d695fa3ff6c..7f7571d29a634774709d77505a1168ed758dad5b 100644 (file)
@@ -67,13 +67,13 @@ or special value 0.0 indicating cases with no coverage whatsoever \
         .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;
     }
 
index 99cfd0f24cc64a0a4cf1fe5fbec09d4053def5c6..99277270e94bfffacfb6c2d0a299919980887f24 100644 (file)
@@ -209,44 +209,4 @@ option_common::option_common (char const *description,
   , _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;
index 15a9bf46365ba507034806123c49fa3a1b1c562c..45109a992001235654d37839d31f2e6fde935d07 100644 (file)
@@ -93,12 +93,12 @@ protected:
   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
@@ -132,8 +132,6 @@ public:
   {
     return _m_opt.key;
   }
-
-  std::string format () const;
 };
 
 template<class arg_type>