• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // OptionGroupFormat
20 
21 class OptionGroupFormat : public OptionGroup {
22 public:
23   static const uint32_t OPTION_GROUP_FORMAT = LLDB_OPT_SET_1;
24   static const uint32_t OPTION_GROUP_GDB_FMT = LLDB_OPT_SET_2;
25   static const uint32_t OPTION_GROUP_SIZE = LLDB_OPT_SET_3;
26   static const uint32_t OPTION_GROUP_COUNT = LLDB_OPT_SET_4;
27 
28   OptionGroupFormat(
29       lldb::Format default_format,
30       uint64_t default_byte_size =
31           UINT64_MAX, // Pass UINT64_MAX to disable the "--size" option
32       uint64_t default_count =
33           UINT64_MAX); // Pass UINT64_MAX to disable the "--count" option
34 
35   ~OptionGroupFormat() override;
36 
37   llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
38 
39   Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
40                         ExecutionContext *execution_context) override;
41   Status SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
42 
43   void OptionParsingStarting(ExecutionContext *execution_context) override;
44 
GetFormat()45   lldb::Format GetFormat() const { return m_format.GetCurrentValue(); }
46 
GetFormatValue()47   OptionValueFormat &GetFormatValue() { return m_format; }
48 
GetFormatValue()49   const OptionValueFormat &GetFormatValue() const { return m_format; }
50 
GetByteSizeValue()51   OptionValueUInt64 &GetByteSizeValue() { return m_byte_size; }
52 
GetByteSizeValue()53   const OptionValueUInt64 &GetByteSizeValue() const { return m_byte_size; }
54 
GetCountValue()55   OptionValueUInt64 &GetCountValue() { return m_count; }
56 
GetCountValue()57   const OptionValueUInt64 &GetCountValue() const { return m_count; }
58 
HasGDBFormat()59   bool HasGDBFormat() const { return m_has_gdb_format; }
60 
AnyOptionWasSet()61   bool AnyOptionWasSet() const {
62     return m_format.OptionWasSet() || m_byte_size.OptionWasSet() ||
63            m_count.OptionWasSet();
64   }
65 
66 protected:
67   bool ParserGDBFormatLetter(ExecutionContext *execution_context,
68                              char format_letter, lldb::Format &format,
69                              uint32_t &byte_size);
70 
71   OptionValueFormat m_format;
72   OptionValueUInt64 m_byte_size;
73   OptionValueUInt64 m_count;
74   char m_prev_gdb_format;
75   char m_prev_gdb_size;
76   bool m_has_gdb_format;
77 };
78 
79 } // namespace lldb_private
80 
81 #endif // LLDB_INTERPRETER_OPTIONGROUPFORMAT_H
82