1 //===-- OptionGroupFormat.h -------------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef LLDB_INTERPRETER_OPTIONGROUPFORMAT_H 10 #define LLDB_INTERPRETER_OPTIONGROUPFORMAT_H 11 12 #include "lldb/Interpreter/OptionValueFormat.h" 13 #include "lldb/Interpreter/OptionValueSInt64.h" 14 #include "lldb/Interpreter/OptionValueUInt64.h" 15 #include "lldb/Interpreter/Options.h" 16 17 namespace lldb_private { 18 19 typedef std::vector<std::tuple<lldb::CommandArgumentType, const char *>> 20 OptionGroupFormatUsageTextVector; 21 22 // OptionGroupFormat 23 24 class OptionGroupFormat : public OptionGroup { 25 public: 26 static const uint32_t OPTION_GROUP_FORMAT = LLDB_OPT_SET_1; 27 static const uint32_t OPTION_GROUP_GDB_FMT = LLDB_OPT_SET_2; 28 static const uint32_t OPTION_GROUP_SIZE = LLDB_OPT_SET_3; 29 static const uint32_t OPTION_GROUP_COUNT = LLDB_OPT_SET_4; 30 31 OptionGroupFormat( 32 lldb::Format default_format, 33 uint64_t default_byte_size = 34 UINT64_MAX, // Pass UINT64_MAX to disable the "--size" option 35 uint64_t default_count = 36 UINT64_MAX, // Pass UINT64_MAX to disable the "--count" option 37 OptionGroupFormatUsageTextVector usage_text_vector = {} 38 // Use to override default option usage text with the command specific one 39 ); 40 41 ~OptionGroupFormat() override = default; 42 43 llvm::ArrayRef<OptionDefinition> GetDefinitions() override; 44 45 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, 46 ExecutionContext *execution_context) override; 47 48 void OptionParsingStarting(ExecutionContext *execution_context) override; 49 GetFormat()50 lldb::Format GetFormat() const { return m_format.GetCurrentValue(); } 51 GetFormatValue()52 OptionValueFormat &GetFormatValue() { return m_format; } 53 GetFormatValue()54 const OptionValueFormat &GetFormatValue() const { return m_format; } 55 GetByteSizeValue()56 OptionValueUInt64 &GetByteSizeValue() { return m_byte_size; } 57 GetByteSizeValue()58 const OptionValueUInt64 &GetByteSizeValue() const { return m_byte_size; } 59 GetCountValue()60 OptionValueUInt64 &GetCountValue() { return m_count; } 61 GetCountValue()62 const OptionValueUInt64 &GetCountValue() const { return m_count; } 63 HasGDBFormat()64 bool HasGDBFormat() const { return m_has_gdb_format; } 65 AnyOptionWasSet()66 bool AnyOptionWasSet() const { 67 return m_format.OptionWasSet() || m_byte_size.OptionWasSet() || 68 m_count.OptionWasSet(); 69 } 70 71 protected: 72 bool ParserGDBFormatLetter(ExecutionContext *execution_context, 73 char format_letter, lldb::Format &format, 74 uint32_t &byte_size); 75 76 OptionValueFormat m_format; 77 OptionValueUInt64 m_byte_size; 78 OptionValueUInt64 m_count; 79 char m_prev_gdb_format; 80 char m_prev_gdb_size; 81 bool m_has_gdb_format; 82 OptionDefinition m_option_definitions[4]; 83 }; 84 85 } // namespace lldb_private 86 87 #endif // LLDB_INTERPRETER_OPTIONGROUPFORMAT_H 88