|
16 | 16 | #include "Features.h"
|
17 | 17 |
|
18 | 18 | #include <map>
|
| 19 | +#include <numeric> |
| 20 | +#include <stdexcept> |
19 | 21 |
|
20 | 22 | namespace ObjectIntrospection {
|
| 23 | +namespace { |
| 24 | + |
| 25 | +std::string_view featureHelp(Feature f) { |
| 26 | + switch (f) { |
| 27 | + case Feature::ChaseRawPointers: |
| 28 | + return "Chase raw pointers in the probed object."; |
| 29 | + case Feature::PackStructs: |
| 30 | + return "Pack structs."; |
| 31 | + case Feature::GenPaddingStats: |
| 32 | + return "Generate statistics on padding of structures."; |
| 33 | + case Feature::CaptureThriftIsset: |
| 34 | + return "Capture isset data for Thrift object."; |
| 35 | + case Feature::TypeGraph: |
| 36 | + return "Use Type Graph for code generation (CodeGen V2)."; |
| 37 | + case Feature::TypedDataSegment: |
| 38 | + return "Use Typed Data Segment in generated code."; |
| 39 | + case Feature::GenJitDebug: |
| 40 | + return "Generate debug information for the JIT object."; |
| 41 | + case Feature::JitLogging: |
| 42 | + return "Log information from the JIT code for debugging."; |
| 43 | + case Feature::PolymorphicInheritance: |
| 44 | + return "Follow polymorphic inheritance hierarchies in the probed object."; |
| 45 | + |
| 46 | + case Feature::UnknownFeature: |
| 47 | + throw std::runtime_error("should not ask for help for UnknownFeature!"); |
| 48 | + } |
| 49 | +} |
| 50 | + |
| 51 | +} // namespace |
21 | 52 |
|
22 | 53 | Feature featureFromStr(std::string_view str) {
|
23 | 54 | static const std::map<std::string_view, Feature> nameMap = {
|
@@ -45,4 +76,20 @@ const char* featureToStr(Feature f) {
|
45 | 76 | }
|
46 | 77 | }
|
47 | 78 |
|
| 79 | +void featuresHelp(std::ostream& out) { |
| 80 | + out << "FEATURES SUMMARY" << std::endl; |
| 81 | + |
| 82 | + size_t longestName = std::accumulate( |
| 83 | + allFeatures.begin(), allFeatures.end(), 0, [](size_t acc, Feature f) { |
| 84 | + return std::max(acc, std::string_view(featureToStr(f)).size()); |
| 85 | + }); |
| 86 | + |
| 87 | + for (Feature f : allFeatures) { |
| 88 | + std::string_view name(featureToStr(f)); |
| 89 | + |
| 90 | + out << " " << name << std::string(longestName - name.size() + 2, ' ') |
| 91 | + << featureHelp(f) << std::endl; |
| 92 | + } |
| 93 | +} |
| 94 | + |
48 | 95 | } // namespace ObjectIntrospection
|
0 commit comments