mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-09 21:24:14 +00:00
help: improve feature descriptions
This commit is contained in:
parent
db243d9845
commit
3da628b852
@ -16,8 +16,39 @@
|
|||||||
#include "Features.h"
|
#include "Features.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <numeric>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
namespace ObjectIntrospection {
|
namespace ObjectIntrospection {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
std::string_view featureHelp(Feature f) {
|
||||||
|
switch (f) {
|
||||||
|
case Feature::ChaseRawPointers:
|
||||||
|
return "Chase raw pointers in the probed object.";
|
||||||
|
case Feature::PackStructs:
|
||||||
|
return "Pack structs.";
|
||||||
|
case Feature::GenPaddingStats:
|
||||||
|
return "Generate statistics on padding of structures.";
|
||||||
|
case Feature::CaptureThriftIsset:
|
||||||
|
return "Capture isset data for Thrift object.";
|
||||||
|
case Feature::TypeGraph:
|
||||||
|
return "Use Type Graph for code generation (CodeGen V2).";
|
||||||
|
case Feature::TypedDataSegment:
|
||||||
|
return "Use Typed Data Segment in generated code.";
|
||||||
|
case Feature::GenJitDebug:
|
||||||
|
return "Generate debug information for the JIT object.";
|
||||||
|
case Feature::JitLogging:
|
||||||
|
return "Log information from the JIT code for debugging.";
|
||||||
|
case Feature::PolymorphicInheritance:
|
||||||
|
return "Follow polymorphic inheritance hierarchies in the probed object.";
|
||||||
|
|
||||||
|
case Feature::UnknownFeature:
|
||||||
|
throw std::runtime_error("should not ask for help for UnknownFeature!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
Feature featureFromStr(std::string_view str) {
|
Feature featureFromStr(std::string_view str) {
|
||||||
static const std::map<std::string_view, Feature> nameMap = {
|
static const std::map<std::string_view, Feature> nameMap = {
|
||||||
@ -45,4 +76,20 @@ const char* featureToStr(Feature f) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void featuresHelp(std::ostream& out) {
|
||||||
|
out << "FEATURES SUMMARY" << std::endl;
|
||||||
|
|
||||||
|
size_t longestName = std::accumulate(
|
||||||
|
allFeatures.begin(), allFeatures.end(), 0, [](size_t acc, Feature f) {
|
||||||
|
return std::max(acc, std::string_view(featureToStr(f)).size());
|
||||||
|
});
|
||||||
|
|
||||||
|
for (Feature f : allFeatures) {
|
||||||
|
std::string_view name(featureToStr(f));
|
||||||
|
|
||||||
|
out << " " << name << std::string(longestName - name.size() + 2, ' ')
|
||||||
|
<< featureHelp(f) << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ObjectIntrospection
|
} // namespace ObjectIntrospection
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <ostream>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
#include "oi/EnumBitset.h"
|
#include "oi/EnumBitset.h"
|
||||||
@ -42,6 +43,7 @@ enum class Feature {
|
|||||||
|
|
||||||
Feature featureFromStr(std::string_view);
|
Feature featureFromStr(std::string_view);
|
||||||
const char* featureToStr(Feature);
|
const char* featureToStr(Feature);
|
||||||
|
void featuresHelp(std::ostream& out);
|
||||||
|
|
||||||
constexpr std::array allFeatures = {
|
constexpr std::array allFeatures = {
|
||||||
#define X(name, _) Feature::name,
|
#define X(name, _) Feature::name,
|
||||||
|
23
oi/OID.cpp
23
oi/OID.cpp
@ -145,25 +145,18 @@ constexpr static OIOpts opts{
|
|||||||
OIOpt{'a', "log-all-structs", no_argument, nullptr, "Log all structures"},
|
OIOpt{'a', "log-all-structs", no_argument, nullptr, "Log all structures"},
|
||||||
OIOpt{'m', "mode", required_argument, "[prod]",
|
OIOpt{'m', "mode", required_argument, "[prod]",
|
||||||
"Allows to specify a mode of operation/group of settings"},
|
"Allows to specify a mode of operation/group of settings"},
|
||||||
OIOpt{'f', "enable-feature", required_argument, nullptr,
|
OIOpt{'f', "enable-feature", required_argument, "FEATURE",
|
||||||
"Enable a specific feature: ["
|
"Enable feature"},
|
||||||
#define X(name, str) str ","
|
OIOpt{'F', "disable-feature", required_argument, "FEATURE",
|
||||||
OI_FEATURE_LIST
|
"Disable feature"},
|
||||||
#undef X
|
|
||||||
"]"},
|
|
||||||
OIOpt{'F', "disable-feature", required_argument, nullptr,
|
|
||||||
"Disable a specific feature: ["
|
|
||||||
#define X(name, str) str ","
|
|
||||||
OI_FEATURE_LIST
|
|
||||||
#undef X
|
|
||||||
"]"},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void usage() {
|
void usage() {
|
||||||
std::cout << "usage: oid ...\n";
|
std::cerr << "usage: oid ...\n";
|
||||||
std::cout << opts;
|
std::cerr << opts << std::endl;
|
||||||
|
featuresHelp(std::cerr);
|
||||||
|
|
||||||
std::cout << "\n\tFor problem reporting, questions and general comments "
|
std::cerr << "\n\tFor problem reporting, questions and general comments "
|
||||||
"please pop along"
|
"please pop along"
|
||||||
"\n\tto the Object Introspection Workplace group at "
|
"\n\tto the Object Introspection Workplace group at "
|
||||||
"https://fburl.com/oid.\n"
|
"https://fburl.com/oid.\n"
|
||||||
|
@ -42,18 +42,10 @@ constexpr static OIOpts opts{
|
|||||||
OIOpt{'J', "dump-json", optional_argument, "[oid_out.json]",
|
OIOpt{'J', "dump-json", optional_argument, "[oid_out.json]",
|
||||||
"File to dump the results to, as JSON\n"
|
"File to dump the results to, as JSON\n"
|
||||||
"(in addition to the default RocksDB output)"},
|
"(in addition to the default RocksDB output)"},
|
||||||
OIOpt{'f', "enable-feature", required_argument, nullptr,
|
OIOpt{'f', "enable-feature", required_argument, "FEATURE",
|
||||||
"Enable a specific feature: ["
|
"Enable feature"},
|
||||||
#define X(name, str) str ","
|
OIOpt{'F', "disable-feature", required_argument, "FEATURE",
|
||||||
OI_FEATURE_LIST
|
"Disable feature"},
|
||||||
#undef X
|
|
||||||
"]"},
|
|
||||||
OIOpt{'F', "disable-feature", required_argument, nullptr,
|
|
||||||
"Disable a specific feature: ["
|
|
||||||
#define X(name, str) str ","
|
|
||||||
OI_FEATURE_LIST
|
|
||||||
#undef X
|
|
||||||
"]"},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void usage(std::ostream& out) {
|
static void usage(std::ostream& out) {
|
||||||
@ -65,7 +57,8 @@ static void usage(std::ostream& out) {
|
|||||||
|
|
||||||
out << "\nusage: oitb [opts...] [--] <path-th> <path-pd> "
|
out << "\nusage: oitb [opts...] [--] <path-th> <path-pd> "
|
||||||
"<path-dataseg-dump>\n";
|
"<path-dataseg-dump>\n";
|
||||||
out << opts;
|
out << opts << std::endl;
|
||||||
|
featuresHelp(out);
|
||||||
|
|
||||||
out << std::endl;
|
out << std::endl;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user