LLDB
mainline
llvm-project
lldb
source
Interpreter
OptionGroupVariable.cpp
Go to the documentation of this file.
1
//===-- OptionGroupVariable.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
9
#include "
lldb/Interpreter/OptionGroupVariable.h
"
10
11
#include "
lldb/DataFormatters/DataVisualization.h
"
12
#include "
lldb/Host/OptionParser.h
"
13
#include "
lldb/Interpreter/CommandInterpreter.h
"
14
#include "
lldb/Target/Target.h
"
15
#include "
lldb/Utility/Status.h
"
16
17
using namespace
lldb
;
18
using namespace
lldb_private
;
19
20
// if you add any options here, remember to update the counters in
21
// OptionGroupVariable::GetNumDefinitions()
22
static
constexpr
OptionDefinition
g_variable_options
[] = {
23
{
LLDB_OPT_SET_1
|
LLDB_OPT_SET_2
,
24
false
,
25
"no-args"
,
26
'a'
,
27
OptionParser::eNoArgument
,
28
nullptr
,
29
{},
30
0,
31
eArgTypeNone
,
32
"Omit function arguments."
},
33
{
LLDB_OPT_SET_1
|
LLDB_OPT_SET_2
,
34
false
,
35
"no-recognized-args"
,
36
't'
,
37
OptionParser::eNoArgument
,
38
nullptr
,
39
{},
40
0,
41
eArgTypeNone
,
42
"Omit recognized function arguments."
},
43
{
LLDB_OPT_SET_1
|
LLDB_OPT_SET_2
,
44
false
,
45
"no-locals"
,
46
'l'
,
47
OptionParser::eNoArgument
,
48
nullptr
,
49
{},
50
0,
51
eArgTypeNone
,
52
"Omit local variables."
},
53
{
LLDB_OPT_SET_1
|
LLDB_OPT_SET_2
,
54
false
,
55
"show-globals"
,
56
'g'
,
57
OptionParser::eNoArgument
,
58
nullptr
,
59
{},
60
0,
61
eArgTypeNone
,
62
"Show the current frame source file global and static variables."
},
63
{
LLDB_OPT_SET_1
|
LLDB_OPT_SET_2
,
64
false
,
65
"no-synthetic"
,
66
'e'
,
// Use 'e' for synthEtic - s and y are both taken.
67
OptionParser::eNoArgument
,
68
nullptr
,
69
{},
70
0,
71
eArgTypeNone
,
72
"Omit synthetic variables."
},
73
{
LLDB_OPT_SET_1
|
LLDB_OPT_SET_2
,
74
false
,
75
"show-declaration"
,
76
'c'
,
77
OptionParser::eNoArgument
,
78
nullptr
,
79
{},
80
0,
81
eArgTypeNone
,
82
"Show variable declaration information (source file and line where the "
83
"variable was declared)."
},
84
{
LLDB_OPT_SET_1
|
LLDB_OPT_SET_2
,
85
false
,
86
"regex"
,
87
'r'
,
88
OptionParser::eNoArgument
,
89
nullptr
,
90
{},
91
0,
92
eArgTypeRegularExpression
,
93
"The <variable-name> argument for name lookups are regular expressions."
},
94
{
LLDB_OPT_SET_1
|
LLDB_OPT_SET_2
,
95
false
,
96
"scope"
,
97
's'
,
98
OptionParser::eNoArgument
,
99
nullptr
,
100
{},
101
0,
102
eArgTypeNone
,
103
"Show variable scope (argument, local, global, static)."
},
104
{
LLDB_OPT_SET_1
,
105
false
,
106
"summary"
,
107
'y'
,
108
OptionParser::eRequiredArgument
,
109
nullptr
,
110
{},
111
0,
112
eArgTypeName
,
113
"Specify the summary that the variable output should use."
},
114
{
LLDB_OPT_SET_2
,
115
false
,
116
"summary-string"
,
117
'z'
,
118
OptionParser::eRequiredArgument
,
119
nullptr
,
120
{},
121
0,
122
eArgTypeName
,
123
"Specify a summary string to use to format the variable output."
},
124
};
125
126
static
constexpr
auto
g_num_frame_options
= 4;
127
static
const
auto
g_variable_options_noframe
=
128
llvm::ArrayRef<OptionDefinition>(
g_variable_options
)
129
.drop_front(
g_num_frame_options
);
130
131
static
Status
ValidateNamedSummary
(
const
char
*str,
void
*) {
132
if
(!str || !str[0])
133
return
Status::FromErrorStringWithFormat
(
134
"must specify a valid named summary"
);
135
TypeSummaryImplSP
summary_sp;
136
if
(!
DataVisualization::NamedSummaryFormats::GetSummaryFormat
(
137
ConstString
(str), summary_sp))
138
return
Status::FromErrorStringWithFormat
(
139
"must specify a valid named summary"
);
140
return
Status
();
141
}
142
143
static
Status
ValidateSummaryString
(
const
char
*str,
void
*) {
144
if
(!str || !str[0])
145
return
Status::FromErrorStringWithFormat
(
146
"must specify a non-empty summary string"
);
147
return
Status
();
148
}
149
150
OptionGroupVariable::OptionGroupVariable
(
bool
show_frame_options)
151
:
include_frame_options
(show_frame_options),
show_args
(false),
152
show_recognized_args
(false),
show_locals
(false),
show_globals
(false),
153
show_synthetic
(true),
use_regex
(false),
show_scope
(false),
154
show_decl
(false),
summary
(
ValidateNamedSummary
),
155
summary_string
(
ValidateSummaryString
) {}
156
157
Status
158
OptionGroupVariable::SetOptionValue
(uint32_t option_idx,
159
llvm::StringRef option_arg,
160
ExecutionContext
*execution_context) {
161
Status
error
;
162
llvm::ArrayRef<OptionDefinition> variable_options =
163
include_frame_options
?
g_variable_options
:
g_variable_options_noframe
;
164
const
int
short_option = variable_options[option_idx].short_option;
165
switch
(short_option) {
166
case
'r'
:
167
use_regex
=
true
;
168
break
;
169
case
'a'
:
170
show_args
=
false
;
171
break
;
172
case
'l'
:
173
show_locals
=
false
;
174
break
;
175
case
'g'
:
176
show_globals
=
true
;
177
break
;
178
case
'e'
:
179
show_synthetic
=
false
;
180
break
;
181
case
'c'
:
182
show_decl
=
true
;
183
break
;
184
case
's'
:
185
show_scope
=
true
;
186
break
;
187
case
't'
:
188
show_recognized_args
=
false
;
189
break
;
190
case
'y'
:
191
error
=
summary
.SetCurrentValue(option_arg);
192
break
;
193
case
'z'
:
194
error
=
summary_string
.SetCurrentValue(option_arg);
195
break
;
196
default
:
197
llvm_unreachable(
"Unimplemented option"
);
198
}
199
200
return
error
;
201
}
202
203
void
OptionGroupVariable::OptionParsingStarting
(
204
ExecutionContext
*execution_context) {
205
show_args
=
true
;
// Frame option only
206
show_recognized_args
=
true
;
// Frame option only
207
show_locals
=
true
;
// Frame option only
208
show_globals
=
false
;
// Frame option only
209
show_synthetic
=
true
;
// Frame option only
210
show_decl
=
false
;
211
use_regex
=
false
;
212
show_scope
=
false
;
213
summary
.Clear();
214
summary_string
.Clear();
215
}
216
217
llvm::ArrayRef<OptionDefinition>
OptionGroupVariable::GetDefinitions
() {
218
// Show the "--no-args", "--no-recognized-args", "--no-locals" and
219
// "--show-globals" options if we are showing frame specific options
220
return
include_frame_options
?
g_variable_options
221
:
g_variable_options_noframe
;
222
}
CommandInterpreter.h
error
static llvm::raw_ostream & error(Stream &strm)
Definition
CommandReturnObject.cpp:18
DataVisualization.h
ValidateSummaryString
static Status ValidateSummaryString(const char *str, void *)
Definition
OptionGroupVariable.cpp:143
ValidateNamedSummary
static Status ValidateNamedSummary(const char *str, void *)
Definition
OptionGroupVariable.cpp:131
g_variable_options_noframe
static const auto g_variable_options_noframe
Definition
OptionGroupVariable.cpp:127
g_variable_options
static constexpr OptionDefinition g_variable_options[]
Definition
OptionGroupVariable.cpp:22
g_num_frame_options
static constexpr auto g_num_frame_options
Definition
OptionGroupVariable.cpp:126
OptionGroupVariable.h
OptionParser.h
Status.h
Target.h
lldb_private::ConstString
A uniqued constant string class.
Definition
ConstString.h:40
lldb_private::DataVisualization::NamedSummaryFormats::GetSummaryFormat
static bool GetSummaryFormat(ConstString type, lldb::TypeSummaryImplSP &entry)
Definition
DataVisualization.cpp:170
lldb_private::ExecutionContext
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
Definition
ExecutionContext.h:294
lldb_private::OptionGroupVariable::include_frame_options
bool include_frame_options
Definition
OptionGroupVariable.h:32
lldb_private::OptionGroupVariable::summary_string
OptionValueString summary_string
Definition
OptionGroupVariable.h:41
lldb_private::OptionGroupVariable::use_regex
bool use_regex
Definition
OptionGroupVariable.h:39
lldb_private::OptionGroupVariable::SetOptionValue
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, ExecutionContext *execution_context) override
Definition
OptionGroupVariable.cpp:158
lldb_private::OptionGroupVariable::GetDefinitions
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Definition
OptionGroupVariable.cpp:217
lldb_private::OptionGroupVariable::OptionGroupVariable
OptionGroupVariable(bool show_frame_options)
Definition
OptionGroupVariable.cpp:150
lldb_private::OptionGroupVariable::show_scope
bool show_scope
Definition
OptionGroupVariable.h:39
lldb_private::OptionGroupVariable::show_synthetic
bool show_synthetic
Definition
OptionGroupVariable.h:38
lldb_private::OptionGroupVariable::show_globals
bool show_globals
Definition
OptionGroupVariable.h:37
lldb_private::OptionGroupVariable::OptionParsingStarting
void OptionParsingStarting(ExecutionContext *execution_context) override
Definition
OptionGroupVariable.cpp:203
lldb_private::OptionGroupVariable::summary
OptionValueString summary
Definition
OptionGroupVariable.h:40
lldb_private::OptionGroupVariable::show_locals
bool show_locals
Definition
OptionGroupVariable.h:36
lldb_private::OptionGroupVariable::show_decl
bool show_decl
Definition
OptionGroupVariable.h:39
lldb_private::OptionGroupVariable::show_args
bool show_args
Definition
OptionGroupVariable.h:33
lldb_private::OptionGroupVariable::show_recognized_args
bool show_recognized_args
Definition
OptionGroupVariable.h:34
lldb_private::OptionParser::eNoArgument
@ eNoArgument
Definition
OptionParser.h:35
lldb_private::OptionParser::eRequiredArgument
@ eRequiredArgument
Definition
OptionParser.h:35
lldb_private::Status
An error handling class.
Definition
Status.h:118
lldb_private::Status::FromErrorStringWithFormat
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Definition
Status.cpp:106
LLDB_OPT_SET_1
#define LLDB_OPT_SET_1
Definition
lldb-defines.h:116
LLDB_OPT_SET_2
#define LLDB_OPT_SET_2
Definition
lldb-defines.h:117
lldb_private
A class that represents a running process on the host machine.
Definition
SBAddressRange.h:14
lldb_private::LineStatus::Status
@ Status
Definition
lldb-private-enumerations.h:196
lldb
Definition
SBAddress.h:15
lldb::TypeSummaryImplSP
std::shared_ptr< lldb_private::TypeSummaryImpl > TypeSummaryImplSP
Definition
lldb-forward.h:494
lldb::eArgTypeName
@ eArgTypeName
Definition
lldb-enumerations.h:617
lldb::eArgTypeNone
@ eArgTypeNone
Definition
lldb-enumerations.h:661
lldb::eArgTypeRegularExpression
@ eArgTypeRegularExpression
Definition
lldb-enumerations.h:635
lldb_private::OptionDefinition
Definition
OptionDefinition.h:20
Generated on
for LLDB by
1.14.0