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
,
false
,
"no-args"
,
'a'
,
24
OptionParser::eNoArgument
,
nullptr
, {}, 0,
eArgTypeNone
,
25
"Omit function arguments."
},
26
{
LLDB_OPT_SET_1
|
LLDB_OPT_SET_2
,
false
,
"no-recognized-args"
,
't'
,
27
OptionParser::eNoArgument
,
nullptr
, {}, 0,
eArgTypeNone
,
28
"Omit recognized function arguments."
},
29
{
LLDB_OPT_SET_1
|
LLDB_OPT_SET_2
,
false
,
"no-locals"
,
'l'
,
30
OptionParser::eNoArgument
,
nullptr
, {}, 0,
eArgTypeNone
,
31
"Omit local variables."
},
32
{
LLDB_OPT_SET_1
|
LLDB_OPT_SET_2
,
false
,
"show-globals"
,
'g'
,
33
OptionParser::eNoArgument
,
nullptr
, {}, 0,
eArgTypeNone
,
34
"Show the current frame source file global and static variables."
},
35
{
LLDB_OPT_SET_1
|
LLDB_OPT_SET_2
,
false
,
"show-declaration"
,
'c'
,
36
OptionParser::eNoArgument
,
nullptr
, {}, 0,
eArgTypeNone
,
37
"Show variable declaration information (source file and line where the "
38
"variable was declared)."
},
39
{
LLDB_OPT_SET_1
|
LLDB_OPT_SET_2
,
false
,
"regex"
,
'r'
,
40
OptionParser::eNoArgument
,
nullptr
, {}, 0,
eArgTypeRegularExpression
,
41
"The <variable-name> argument for name lookups are regular expressions."
},
42
{
LLDB_OPT_SET_1
|
LLDB_OPT_SET_2
,
false
,
"scope"
,
's'
,
43
OptionParser::eNoArgument
,
nullptr
, {}, 0,
eArgTypeNone
,
44
"Show variable scope (argument, local, global, static)."
},
45
{
LLDB_OPT_SET_1
,
false
,
"summary"
,
'y'
,
OptionParser::eRequiredArgument
,
46
nullptr
, {}, 0,
eArgTypeName
,
47
"Specify the summary that the variable output should use."
},
48
{
LLDB_OPT_SET_2
,
false
,
"summary-string"
,
'z'
,
49
OptionParser::eRequiredArgument
,
nullptr
, {}, 0,
eArgTypeName
,
50
"Specify a summary string to use to format the variable output."
},
51
};
52
53
static
constexpr
auto
g_num_frame_options
= 4;
54
static
const
auto
g_variable_options_noframe
=
55
llvm::ArrayRef<OptionDefinition>(
g_variable_options
)
56
.drop_front(
g_num_frame_options
);
57
58
static
Status
ValidateNamedSummary
(
const
char
*str,
void
*) {
59
if
(!str || !str[0])
60
return
Status::FromErrorStringWithFormat
(
61
"must specify a valid named summary"
);
62
TypeSummaryImplSP
summary_sp;
63
if
(!
DataVisualization::NamedSummaryFormats::GetSummaryFormat
(
64
ConstString
(str), summary_sp))
65
return
Status::FromErrorStringWithFormat
(
66
"must specify a valid named summary"
);
67
return
Status
();
68
}
69
70
static
Status
ValidateSummaryString
(
const
char
*str,
void
*) {
71
if
(!str || !str[0])
72
return
Status::FromErrorStringWithFormat
(
73
"must specify a non-empty summary string"
);
74
return
Status
();
75
}
76
77
OptionGroupVariable::OptionGroupVariable
(
bool
show_frame_options)
78
:
include_frame_options
(show_frame_options),
show_args
(false),
79
show_recognized_args
(false),
show_locals
(false),
show_globals
(false),
80
use_regex
(false),
show_scope
(false),
show_decl
(false),
81
summary
(
ValidateNamedSummary
),
summary_string
(
ValidateSummaryString
) {}
82
83
Status
84
OptionGroupVariable::SetOptionValue
(uint32_t option_idx,
85
llvm::StringRef option_arg,
86
ExecutionContext
*execution_context) {
87
Status
error
;
88
llvm::ArrayRef<OptionDefinition> variable_options =
89
include_frame_options
?
g_variable_options
:
g_variable_options_noframe
;
90
const
int
short_option = variable_options[option_idx].short_option;
91
switch
(short_option) {
92
case
'r'
:
93
use_regex
=
true
;
94
break
;
95
case
'a'
:
96
show_args
=
false
;
97
break
;
98
case
'l'
:
99
show_locals
=
false
;
100
break
;
101
case
'g'
:
102
show_globals
=
true
;
103
break
;
104
case
'c'
:
105
show_decl
=
true
;
106
break
;
107
case
's'
:
108
show_scope
=
true
;
109
break
;
110
case
't'
:
111
show_recognized_args
=
false
;
112
break
;
113
case
'y'
:
114
error
=
summary
.SetCurrentValue(option_arg);
115
break
;
116
case
'z'
:
117
error
=
summary_string
.SetCurrentValue(option_arg);
118
break
;
119
default
:
120
llvm_unreachable(
"Unimplemented option"
);
121
}
122
123
return
error
;
124
}
125
126
void
OptionGroupVariable::OptionParsingStarting
(
127
ExecutionContext
*execution_context) {
128
show_args
=
true
;
// Frame option only
129
show_recognized_args
=
true
;
// Frame option only
130
show_locals
=
true
;
// Frame option only
131
show_globals
=
false
;
// Frame option only
132
show_decl
=
false
;
133
use_regex
=
false
;
134
show_scope
=
false
;
135
summary
.Clear();
136
summary_string
.Clear();
137
}
138
139
llvm::ArrayRef<OptionDefinition>
OptionGroupVariable::GetDefinitions
() {
140
// Show the "--no-args", "--no-recognized-args", "--no-locals" and
141
// "--show-globals" options if we are showing frame specific options
142
return
include_frame_options
?
g_variable_options
143
:
g_variable_options_noframe
;
144
}
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:70
ValidateNamedSummary
static Status ValidateNamedSummary(const char *str, void *)
Definition
OptionGroupVariable.cpp:58
g_variable_options_noframe
static const auto g_variable_options_noframe
Definition
OptionGroupVariable.cpp:54
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:53
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:304
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:40
lldb_private::OptionGroupVariable::use_regex
bool use_regex
Definition
OptionGroupVariable.h:38
lldb_private::OptionGroupVariable::SetOptionValue
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, ExecutionContext *execution_context) override
Definition
OptionGroupVariable.cpp:84
lldb_private::OptionGroupVariable::GetDefinitions
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Definition
OptionGroupVariable.cpp:139
lldb_private::OptionGroupVariable::OptionGroupVariable
OptionGroupVariable(bool show_frame_options)
Definition
OptionGroupVariable.cpp:77
lldb_private::OptionGroupVariable::show_scope
bool show_scope
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:126
lldb_private::OptionGroupVariable::summary
OptionValueString summary
Definition
OptionGroupVariable.h:39
lldb_private::OptionGroupVariable::show_locals
bool show_locals
Definition
OptionGroupVariable.h:36
lldb_private::OptionGroupVariable::show_decl
bool show_decl
Definition
OptionGroupVariable.h:38
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:111
LLDB_OPT_SET_2
#define LLDB_OPT_SET_2
Definition
lldb-defines.h:112
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:187
lldb
Definition
SBAddress.h:15
lldb::TypeSummaryImplSP
std::shared_ptr< lldb_private::TypeSummaryImpl > TypeSummaryImplSP
Definition
lldb-forward.h:486
lldb::eArgTypeName
@ eArgTypeName
Definition
lldb-enumerations.h:603
lldb::eArgTypeNone
@ eArgTypeNone
Definition
lldb-enumerations.h:647
lldb::eArgTypeRegularExpression
@ eArgTypeRegularExpression
Definition
lldb-enumerations.h:621
lldb_private::OptionDefinition
Definition
OptionDefinition.h:20
Generated on
for LLDB by
1.14.0