Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:50

0001 //===-- OptionGroupFormat.h -------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_INTERPRETER_OPTIONGROUPFORMAT_H
0010 #define LLDB_INTERPRETER_OPTIONGROUPFORMAT_H
0011 
0012 #include "lldb/Interpreter/OptionValueFormat.h"
0013 #include "lldb/Interpreter/OptionValueSInt64.h"
0014 #include "lldb/Interpreter/OptionValueUInt64.h"
0015 #include "lldb/Interpreter/Options.h"
0016 
0017 namespace lldb_private {
0018 
0019 typedef std::vector<std::tuple<lldb::CommandArgumentType, const char *>>
0020     OptionGroupFormatUsageTextVector;
0021 
0022 // OptionGroupFormat
0023 
0024 class OptionGroupFormat : public OptionGroup {
0025 public:
0026   static const uint32_t OPTION_GROUP_FORMAT = LLDB_OPT_SET_1;
0027   static const uint32_t OPTION_GROUP_GDB_FMT = LLDB_OPT_SET_2;
0028   static const uint32_t OPTION_GROUP_SIZE = LLDB_OPT_SET_3;
0029   static const uint32_t OPTION_GROUP_COUNT = LLDB_OPT_SET_4;
0030 
0031   OptionGroupFormat(
0032       lldb::Format default_format,
0033       uint64_t default_byte_size =
0034           UINT64_MAX, // Pass UINT64_MAX to disable the "--size" option
0035       uint64_t default_count =
0036           UINT64_MAX, // Pass UINT64_MAX to disable the "--count" option
0037       OptionGroupFormatUsageTextVector usage_text_vector = {}
0038       // Use to override default option usage text with the command specific one
0039   );
0040 
0041   ~OptionGroupFormat() override = default;
0042 
0043   llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
0044 
0045   Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
0046                         ExecutionContext *execution_context) override;
0047 
0048   void OptionParsingStarting(ExecutionContext *execution_context) override;
0049 
0050   lldb::Format GetFormat() const { return m_format.GetCurrentValue(); }
0051 
0052   OptionValueFormat &GetFormatValue() { return m_format; }
0053 
0054   const OptionValueFormat &GetFormatValue() const { return m_format; }
0055 
0056   OptionValueUInt64 &GetByteSizeValue() { return m_byte_size; }
0057 
0058   const OptionValueUInt64 &GetByteSizeValue() const { return m_byte_size; }
0059 
0060   OptionValueUInt64 &GetCountValue() { return m_count; }
0061 
0062   const OptionValueUInt64 &GetCountValue() const { return m_count; }
0063 
0064   bool HasGDBFormat() const { return m_has_gdb_format; }
0065 
0066   bool AnyOptionWasSet() const {
0067     return m_format.OptionWasSet() || m_byte_size.OptionWasSet() ||
0068            m_count.OptionWasSet();
0069   }
0070 
0071 protected:
0072   bool ParserGDBFormatLetter(ExecutionContext *execution_context,
0073                              char format_letter, lldb::Format &format,
0074                              uint32_t &byte_size);
0075 
0076   OptionValueFormat m_format;
0077   OptionValueUInt64 m_byte_size;
0078   OptionValueUInt64 m_count;
0079   char m_prev_gdb_format;
0080   char m_prev_gdb_size;
0081   bool m_has_gdb_format;
0082   OptionDefinition m_option_definitions[4];
0083 };
0084 
0085 } // namespace lldb_private
0086 
0087 #endif // LLDB_INTERPRETER_OPTIONGROUPFORMAT_H