aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2020-06-02 11:03:21 -0700
committerJonas Devlieghere <jonas@devlieghere.com>2020-06-02 11:06:11 -0700
commit5b460fb15e8bcd4b5f5ffad253b68aa2bc274049 (patch)
treeab7d28ef67fe4a16df673b25efc52d35d108097d /llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
parentcdd30542551a4c1af64b819f50982f197b61e28e (diff)
downloadllvm-5b460fb15e8bcd4b5f5ffad253b68aa2bc274049.zip
llvm-5b460fb15e8bcd4b5f5ffad253b68aa2bc274049.tar.gz
llvm-5b460fb15e8bcd4b5f5ffad253b68aa2bc274049.tar.bz2
[llvm-dwarfdump] Print [=<offset>] after --debug-* options in help output.
Some of the --debug-* options can take an optional offset. Although the man page does a good job of making that clear, it's much harder to discover from the help output. Currently the only reference to this is the following sentence: > Where applicable these parameters take an optional =<offset> argument > to dump only the entry at the specified offset. This patch changes the help output from to print [=<offset>] after the options that take an offset. --debug-info[=<offset>] - Dump the .debug_info section rdar://problem/63150066 Differential revision: https://reviews.llvm.org/D80959
Diffstat (limited to 'llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp')
-rw-r--r--llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp42
1 files changed, 33 insertions, 9 deletions
diff --git a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
index b537ac5..d9e348e 100644
--- a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
+++ b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
@@ -44,6 +44,7 @@ struct OffsetOption {
bool HasValue = false;
bool IsRequested = false;
};
+struct BoolOption : public OffsetOption {};
} // namespace
namespace llvm {
@@ -72,16 +73,39 @@ public:
return ValueOptional;
}
- StringRef getValueName() const override { return StringRef(); }
+ StringRef getValueName() const override { return StringRef("offset"); }
void printOptionDiff(const Option &O, OffsetOption V, OptVal Default,
size_t GlobalWidth) const {
printOptionName(O, GlobalWidth);
outs() << "[=offset]";
}
+};
+
+template <> class parser<BoolOption> final : public basic_parser<BoolOption> {
+public:
+ parser(Option &O) : basic_parser(O) {}
+
+ /// Return true on error.
+ bool parse(Option &O, StringRef ArgName, StringRef Arg, BoolOption &Val) {
+ if (Arg != "")
+ return O.error("this is a flag and does not take a value.");
+ Val.Val = 0;
+ Val.HasValue = false;
+ Val.IsRequested = true;
+ return false;
+ }
- // An out-of-line virtual method to provide a 'home' for this class.
- void anchor() override {};
+ enum ValueExpected getValueExpectedFlagDefault() const {
+ return ValueOptional;
+ }
+
+ StringRef getValueName() const override { return StringRef(); }
+
+ void printOptionDiff(const Option &O, OffsetOption V, OptVal Default,
+ size_t GlobalWidth) const {
+ printOptionName(O, GlobalWidth);
+ }
};
} // namespace cl
} // namespace llvm
@@ -112,10 +136,10 @@ static alias DumpAllAlias("a", desc("Alias for -all"), aliasopt(DumpAll));
static unsigned DumpType = DIDT_Null;
static std::array<llvm::Optional<uint64_t>, (unsigned)DIDT_ID_Count>
DumpOffsets;
-#define HANDLE_DWARF_SECTION(ENUM_NAME, ELF_NAME, CMDLINE_NAME) \
- static opt<OffsetOption> Dump##ENUM_NAME( \
- CMDLINE_NAME, desc("Dump the " ELF_NAME " section"), \
- cat(SectionCategory));
+#define HANDLE_DWARF_SECTION(ENUM_NAME, ELF_NAME, CMDLINE_NAME, OPTION) \
+ static opt<OPTION> Dump##ENUM_NAME(CMDLINE_NAME, \
+ desc("Dump the " ELF_NAME " section"), \
+ cat(SectionCategory));
#include "llvm/BinaryFormat/Dwarf.def"
#undef HANDLE_DWARF_SECTION
@@ -240,7 +264,7 @@ static void error(StringRef Prefix, std::error_code EC) {
exit(1);
}
-static DIDumpOptions getDumpOpts(DWARFContext& C) {
+static DIDumpOptions getDumpOpts(DWARFContext &C) {
DIDumpOptions DumpOpts;
DumpOpts.DumpType = DumpType;
DumpOpts.ChildRecurseDepth = ChildRecurseDepth;
@@ -609,7 +633,7 @@ int main(int argc, char **argv) {
// Defaults to dumping all sections, unless brief mode is specified in which
// case only the .debug_info section in dumped.
-#define HANDLE_DWARF_SECTION(ENUM_NAME, ELF_NAME, CMDLINE_NAME) \
+#define HANDLE_DWARF_SECTION(ENUM_NAME, ELF_NAME, CMDLINE_NAME, OPTION) \
if (Dump##ENUM_NAME.IsRequested) { \
DumpType |= DIDT_##ENUM_NAME; \
if (Dump##ENUM_NAME.HasValue) { \