[llvm] r313085 - Clean up the --help output of llvm-dwarfdump by hiding irrelevant options.

Adrian Prantl via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 12 15:32:53 PDT 2017


Author: adrian
Date: Tue Sep 12 15:32:53 2017
New Revision: 313085

URL: http://llvm.org/viewvc/llvm-project?rev=313085&view=rev
Log:
Clean up the --help output of llvm-dwarfdump by hiding irrelevant options.

Added:
    llvm/trunk/test/tools/llvm-dwarfdump/X86/cmdline.test
Modified:
    llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp

Added: llvm/trunk/test/tools/llvm-dwarfdump/X86/cmdline.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwarfdump/X86/cmdline.test?rev=313085&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-dwarfdump/X86/cmdline.test (added)
+++ llvm/trunk/test/tools/llvm-dwarfdump/X86/cmdline.test Tue Sep 12 15:32:53 2017
@@ -0,0 +1,9 @@
+RUN: llvm-dwarfdump -h 2>&1 | FileCheck --check-prefix=HELP %s
+RUN: llvm-dwarfdump --help 2>&1 | FileCheck --check-prefix=HELP %s
+HELP: USAGE: llvm-dwarfdump [options] <input object files or .dSYM bundles>
+HELP: Section-specific Dump Options
+HELP: -debug-info            - Dump the .debug_info section
+HELP-NOT: -reverse-iterate
+
+RUN: llvm-dwarfdump --version 2>&1 | FileCheck --check-prefix=VERSION %s
+VERSION: {{ version }}

Modified: llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp?rev=313085&r1=313084&r2=313085&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp (original)
+++ llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp Tue Sep 12 15:32:53 2017
@@ -36,31 +36,44 @@
 using namespace llvm;
 using namespace object;
 
-static cl::list<std::string>
-InputFilenames(cl::Positional, cl::desc("<input object files or .dSYM bundles>"),
-               cl::ZeroOrMore);
-
-static cl::opt<bool> DumpAll("all", cl::desc("Dump all debug info sections"));
-static cl::alias DumpAllAlias("a", cl::desc("Alias for --all"),
-                              cl::aliasopt(DumpAll));
+namespace {
+using namespace llvm::cl;
+
+OptionCategory DwarfDumpCategory("Specific Options");
+static opt<bool> Help("h", desc("Alias for -help"), Hidden,
+                      cat(DwarfDumpCategory));
+static list<std::string>
+    InputFilenames(Positional, desc("<input object files or .dSYM bundles>"),
+                   ZeroOrMore, cat(DwarfDumpCategory));
+
+cl::OptionCategory
+    SectionCategory("Section-specific Dump Options",
+                    "These control which sections are dumped.");
+static opt<bool> DumpAll("all", desc("Dump all debug info sections"),
+                         cat(SectionCategory));
+static alias DumpAllAlias("a", desc("Alias for -all"), aliasopt(DumpAll));
 
 static uint64_t DumpType = DIDT_Null;
 #define HANDLE_DWARF_SECTION(ENUM_NAME, ELF_NAME, CMDLINE_NAME)                \
-  static cl::opt<bool> Dump##ENUM_NAME(                                        \
-      CMDLINE_NAME, cl::desc("Dump the " ELF_NAME " section"));
+  static opt<bool> Dump##ENUM_NAME(CMDLINE_NAME,                               \
+                                   desc("Dump the " ELF_NAME " section"),      \
+                                   cat(SectionCategory));
 #include "llvm/BinaryFormat/Dwarf.def"
 #undef HANDLE_DWARF_SECTION
 
-static cl::opt<bool>
+static opt<bool>
     SummarizeTypes("summarize-types",
-                   cl::desc("Abbreviate the description of type unit entries"));
-static cl::opt<bool> Verify("verify", cl::desc("Verify the DWARF debug info"));
-static cl::opt<bool> Quiet("quiet",
-                           cl::desc("Use with -verify to not emit to STDOUT."));
-static cl::opt<bool> Verbose("verbose",
-                             cl::desc("Print more low-level encoding details"));
-static cl::alias VerboseAlias("v", cl::desc("Alias for -verbose"),
-                              cl::aliasopt(Verbose));
+                   desc("Abbreviate the description of type unit entries"));
+static opt<bool> Verify("verify", desc("Verify the DWARF debug info"),
+                        cat(DwarfDumpCategory));
+static opt<bool> Quiet("quiet", desc("Use with -verify to not emit to STDOUT."),
+                       cat(DwarfDumpCategory));
+static opt<bool> Verbose("verbose",
+                         desc("Print more low-level encoding details"),
+                         cat(DwarfDumpCategory));
+static alias VerboseAlias("v", desc("Alias for -verbose"), aliasopt(Verbose),
+                          cat(DwarfDumpCategory));
+} // namespace
 
 static void error(StringRef Filename, std::error_code EC) {
   if (!EC)
@@ -190,7 +203,16 @@ int main(int argc, char **argv) {
   llvm::InitializeAllTargetInfos();
   llvm::InitializeAllTargetMCs();
 
-  cl::ParseCommandLineOptions(argc, argv, "llvm dwarf dumper\n");
+  HideUnrelatedOptions({&DwarfDumpCategory, &SectionCategory});
+  cl::ParseCommandLineOptions(
+      argc, argv,
+      "pretty-print DWARF debug information in object files"
+      " and debug info archives.\n");
+
+  if (Help) {
+    PrintHelpMessage(/*Hidden =*/false, /*Categorized =*/true);
+    return 0;
+  }
 
   // Defaults to dumping all sections, unless brief mode is specified in which
   // case only the .debug_info section in dumped.




More information about the llvm-commits mailing list