From: Adrian Prantl Date: Tue, 12 Sep 2017 22:32:53 +0000 (+0000) Subject: Clean up the --help output of llvm-dwarfdump by hiding irrelevant options. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=623927eb7fee61e681a489cc4c7f6920eab379d8;p=llvm Clean up the --help output of llvm-dwarfdump by hiding irrelevant options. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313085 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/tools/llvm-dwarfdump/X86/cmdline.test b/test/tools/llvm-dwarfdump/X86/cmdline.test new file mode 100644 index 00000000000..24efd76019f --- /dev/null +++ b/test/tools/llvm-dwarfdump/X86/cmdline.test @@ -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] +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 }} diff --git a/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/tools/llvm-dwarfdump/llvm-dwarfdump.cpp index 5ebcc81ac9c..9fded20eeb5 100644 --- a/tools/llvm-dwarfdump/llvm-dwarfdump.cpp +++ b/tools/llvm-dwarfdump/llvm-dwarfdump.cpp @@ -36,31 +36,44 @@ using namespace llvm; using namespace object; -static cl::list -InputFilenames(cl::Positional, cl::desc(""), - cl::ZeroOrMore); - -static cl::opt 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 Help("h", desc("Alias for -help"), Hidden, + cat(DwarfDumpCategory)); +static list + InputFilenames(Positional, desc(""), + ZeroOrMore, cat(DwarfDumpCategory)); + +cl::OptionCategory + SectionCategory("Section-specific Dump Options", + "These control which sections are dumped."); +static opt 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 Dump##ENUM_NAME( \ - CMDLINE_NAME, cl::desc("Dump the " ELF_NAME " section")); + static opt 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 +static opt SummarizeTypes("summarize-types", - cl::desc("Abbreviate the description of type unit entries")); -static cl::opt Verify("verify", cl::desc("Verify the DWARF debug info")); -static cl::opt Quiet("quiet", - cl::desc("Use with -verify to not emit to STDOUT.")); -static cl::opt 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 Verify("verify", desc("Verify the DWARF debug info"), + cat(DwarfDumpCategory)); +static opt Quiet("quiet", desc("Use with -verify to not emit to STDOUT."), + cat(DwarfDumpCategory)); +static opt 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.