LLDB mainline
OptionGroupWatchpoint.cpp
Go to the documentation of this file.
1//===-- OptionGroupWatchpoint.cpp -----------------------------------------===//
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
10
15
16using namespace lldb;
17using namespace lldb_private;
18
19static constexpr OptionEnumValueElement g_watch_type[] = {
20 {
22 "read",
23 "Watch for read",
24 },
25 {
27 "write",
28 "Watch for write",
29 },
30 {
32 "read_write",
33 "Watch for read/write",
34 },
35};
36
37static constexpr OptionEnumValueElement g_watch_size[] = {
38 {
39 1,
40 "1",
41 "Watch for byte size of 1",
42 },
43 {
44 2,
45 "2",
46 "Watch for byte size of 2",
47 },
48 {
49 4,
50 "4",
51 "Watch for byte size of 4",
52 },
53 {
54 8,
55 "8",
56 "Watch for byte size of 8",
57 },
58};
59
60static constexpr OptionDefinition g_option_table[] = {
62 nullptr, OptionEnumValues(g_watch_type), 0, eArgTypeWatchType,
63 "Specify the type of watching to perform."},
65 nullptr, OptionEnumValues(g_watch_size), 0, eArgTypeByteSize,
66 "Number of bytes to use to watch a region."},
68 false,
69 "language",
70 'l',
72 nullptr,
73 {},
74 0,
76 "Language of expression to run"}};
77
79 for (const auto& size : g_watch_size) {
80 if (0 == size.value)
81 break;
82 if (watch_size == size.value)
83 return true;
84 }
85 return false;
86}
87
90 llvm::StringRef option_arg,
91 ExecutionContext *execution_context) {
93 const int short_option = g_option_table[option_idx].short_option;
94 switch (short_option) {
95 case 'l': {
98 StreamString sstr;
99 sstr.Printf("Unknown language type: '%s' for expression. List of "
100 "supported languages:\n",
101 option_arg.str().c_str());
103 error.SetErrorString(sstr.GetString());
104 }
105 break;
106 }
107 case 'w': {
108 WatchType tmp_watch_type;
110 option_arg, g_option_table[option_idx].enum_values, 0, error);
111 if (error.Success()) {
112 watch_type = tmp_watch_type;
114 }
115 break;
116 }
117 case 's':
119 option_arg, g_option_table[option_idx].enum_values, 0, error);
120 break;
121
122 default:
123 llvm_unreachable("Unimplemented option");
124 }
125
126 return error;
127}
128
130 ExecutionContext *execution_context) {
131 watch_type_specified = false;
133 watch_size = 0;
135}
136
137llvm::ArrayRef<OptionDefinition> OptionGroupWatchpoint::GetDefinitions() {
138 return llvm::ArrayRef(g_option_table);
139}
static llvm::raw_ostream & error(Stream &strm)
static constexpr OptionDefinition g_option_table[]
static constexpr OptionEnumValueElement g_watch_size[]
static constexpr OptionEnumValueElement g_watch_type[]
static constexpr OptionDefinition g_option_table[]
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
static void PrintSupportedLanguagesForExpressions(Stream &s, llvm::StringRef prefix, llvm::StringRef suffix)
Prints to the specified stream 's' each language type that the current target supports for expression...
Definition: Language.cpp:239
static lldb::LanguageType GetLanguageTypeFromString(const char *string)=delete
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, ExecutionContext *execution_context) override
void OptionParsingStarting(ExecutionContext *execution_context) override
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
static bool IsWatchSizeSupported(uint32_t watch_size)
An error handling class.
Definition: Status.h:44
llvm::StringRef GetString() const
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:107
#define LLDB_OPT_SET_1
Definition: lldb-defines.h:102
#define LLDB_OPT_SET_2
Definition: lldb-defines.h:103
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
Definition: SBAddress.h:15
@ eLanguageTypeUnknown
Unknown or invalid language value.
@ eArgTypeByteSize
@ eArgTypeLanguage
@ eArgTypeWatchType
static int64_t ToOptionEnum(llvm::StringRef s, const OptionEnumValues &enum_values, int32_t fail_value, Status &error)
int short_option
Single character for this option.