Skip to content

Commit 7c5b45d

Browse files
committed
Clean up the --help output of llvm-dwarfdump by hiding irrelevant options.
llvm-svn: 313085
1 parent f922501 commit 7c5b45d

File tree

2 files changed

+50
-19
lines changed

2 files changed

+50
-19
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
RUN: llvm-dwarfdump -h 2>&1 | FileCheck --check-prefix=HELP %s
2+
RUN: llvm-dwarfdump --help 2>&1 | FileCheck --check-prefix=HELP %s
3+
HELP: USAGE: llvm-dwarfdump [options] <input object files or .dSYM bundles>
4+
HELP: Section-specific Dump Options
5+
HELP: -debug-info - Dump the .debug_info section
6+
HELP-NOT: -reverse-iterate
7+
8+
RUN: llvm-dwarfdump --version 2>&1 | FileCheck --check-prefix=VERSION %s
9+
VERSION: {{ version }}

llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,31 +36,44 @@
3636
using namespace llvm;
3737
using namespace object;
3838

39-
static cl::list<std::string>
40-
InputFilenames(cl::Positional, cl::desc("<input object files or .dSYM bundles>"),
41-
cl::ZeroOrMore);
42-
43-
static cl::opt<bool> DumpAll("all", cl::desc("Dump all debug info sections"));
44-
static cl::alias DumpAllAlias("a", cl::desc("Alias for --all"),
45-
cl::aliasopt(DumpAll));
39+
namespace {
40+
using namespace llvm::cl;
41+
42+
OptionCategory DwarfDumpCategory("Specific Options");
43+
static opt<bool> Help("h", desc("Alias for -help"), Hidden,
44+
cat(DwarfDumpCategory));
45+
static list<std::string>
46+
InputFilenames(Positional, desc("<input object files or .dSYM bundles>"),
47+
ZeroOrMore, cat(DwarfDumpCategory));
48+
49+
cl::OptionCategory
50+
SectionCategory("Section-specific Dump Options",
51+
"These control which sections are dumped.");
52+
static opt<bool> DumpAll("all", desc("Dump all debug info sections"),
53+
cat(SectionCategory));
54+
static alias DumpAllAlias("a", desc("Alias for -all"), aliasopt(DumpAll));
4655

4756
static uint64_t DumpType = DIDT_Null;
4857
#define HANDLE_DWARF_SECTION(ENUM_NAME, ELF_NAME, CMDLINE_NAME) \
49-
static cl::opt<bool> Dump##ENUM_NAME( \
50-
CMDLINE_NAME, cl::desc("Dump the " ELF_NAME " section"));
58+
static opt<bool> Dump##ENUM_NAME(CMDLINE_NAME, \
59+
desc("Dump the " ELF_NAME " section"), \
60+
cat(SectionCategory));
5161
#include "llvm/BinaryFormat/Dwarf.def"
5262
#undef HANDLE_DWARF_SECTION
5363

54-
static cl::opt<bool>
64+
static opt<bool>
5565
SummarizeTypes("summarize-types",
56-
cl::desc("Abbreviate the description of type unit entries"));
57-
static cl::opt<bool> Verify("verify", cl::desc("Verify the DWARF debug info"));
58-
static cl::opt<bool> Quiet("quiet",
59-
cl::desc("Use with -verify to not emit to STDOUT."));
60-
static cl::opt<bool> Verbose("verbose",
61-
cl::desc("Print more low-level encoding details"));
62-
static cl::alias VerboseAlias("v", cl::desc("Alias for -verbose"),
63-
cl::aliasopt(Verbose));
66+
desc("Abbreviate the description of type unit entries"));
67+
static opt<bool> Verify("verify", desc("Verify the DWARF debug info"),
68+
cat(DwarfDumpCategory));
69+
static opt<bool> Quiet("quiet", desc("Use with -verify to not emit to STDOUT."),
70+
cat(DwarfDumpCategory));
71+
static opt<bool> Verbose("verbose",
72+
desc("Print more low-level encoding details"),
73+
cat(DwarfDumpCategory));
74+
static alias VerboseAlias("v", desc("Alias for -verbose"), aliasopt(Verbose),
75+
cat(DwarfDumpCategory));
76+
} // namespace
6477

6578
static void error(StringRef Filename, std::error_code EC) {
6679
if (!EC)
@@ -190,7 +203,16 @@ int main(int argc, char **argv) {
190203
llvm::InitializeAllTargetInfos();
191204
llvm::InitializeAllTargetMCs();
192205

193-
cl::ParseCommandLineOptions(argc, argv, "llvm dwarf dumper\n");
206+
HideUnrelatedOptions({&DwarfDumpCategory, &SectionCategory});
207+
cl::ParseCommandLineOptions(
208+
argc, argv,
209+
"pretty-print DWARF debug information in object files"
210+
" and debug info archives.\n");
211+
212+
if (Help) {
213+
PrintHelpMessage(/*Hidden =*/false, /*Categorized =*/true);
214+
return 0;
215+
}
194216

195217
// Defaults to dumping all sections, unless brief mode is specified in which
196218
// case only the .debug_info section in dumped.

0 commit comments

Comments
 (0)