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
20 {
22 "read",
23 "Watch for read",
24 },
25 {
27 "write",
28 "Watch for write",
29 },
30 {
32 "modify",
33 "Watch for modifications",
34 },
35 {
37 "read_write",
38 "Watch for read/write",
39 },
40};
41
42static constexpr OptionDefinition g_option_table[] = {
45 "Specify the type of watching to perform."},
47 nullptr, {}, 0, eArgTypeByteSize,
48 "Number of bytes to use to watch a region."},
50 false,
51 "language",
52 'l',
54 nullptr,
55 {},
56 0,
58 "Language of expression to run"}};
59
62 llvm::StringRef option_arg,
63 ExecutionContext *execution_context) {
65 const int short_option = g_option_table[option_idx].short_option;
66 switch (short_option) {
67 case 'l': {
70 StreamString sstr;
71 sstr.Printf("Unknown language type: '%s' for expression. List of "
72 "supported languages:\n",
73 option_arg.str().c_str());
75 error.SetErrorString(sstr.GetString());
76 }
77 break;
78 }
79 case 'w': {
80 WatchType tmp_watch_type;
82 option_arg, g_option_table[option_idx].enum_values, 0, error);
83 if (error.Success()) {
84 watch_type = tmp_watch_type;
86 }
87 break;
88 }
89 case 's':
91 if (watch_size.GetCurrentValue() == 0)
92 error.SetErrorStringWithFormat("invalid --size option value '%s'",
93 option_arg.str().c_str());
94 break;
95
96 default:
97 llvm_unreachable("Unimplemented option");
98 }
99
100 return error;
101}
102
104 ExecutionContext *execution_context) {
105 watch_type_specified = false;
109}
110
111llvm::ArrayRef<OptionDefinition> OptionGroupWatchpoint::GetDefinitions() {
112 return llvm::ArrayRef(g_option_table);
113}
static llvm::raw_ostream & error(Stream &strm)
static constexpr OptionDefinition g_option_table[]
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:273
static lldb::LanguageType GetLanguageTypeFromString(const char *string)=delete
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, ExecutionContext *execution_context) override
WatchType
eWatchRead == LLDB_WATCH_TYPE_READ eWatchWrite == LLDB_WATCH_TYPE_WRITE eWatchModify == LLDB_WATCH_TY...
void OptionParsingStarting(ExecutionContext *execution_context) override
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign) override
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:134
#define LLDB_OPT_SET_1
Definition: lldb-defines.h:111
#define LLDB_OPT_SET_2
Definition: lldb-defines.h:112
A class that represents a running process on the host machine.
llvm::ArrayRef< OptionEnumValueElement > OptionEnumValues
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.