LLDB mainline
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
10
14#include "lldb/Target/Target.h"
15#include "lldb/Utility/Status.h"
16
17using namespace lldb;
18using namespace lldb_private;
19
20// if you add any options here, remember to update the counters in
21// OptionGroupVariable::GetNumDefinitions()
24 false,
25 "no-args",
26 'a',
28 nullptr,
29 {},
30 0,
32 "Omit function arguments."},
34 false,
35 "no-recognized-args",
36 't',
38 nullptr,
39 {},
40 0,
42 "Omit recognized function arguments."},
44 false,
45 "no-locals",
46 'l',
48 nullptr,
49 {},
50 0,
52 "Omit local variables."},
54 false,
55 "show-globals",
56 'g',
58 nullptr,
59 {},
60 0,
62 "Show the current frame source file global and static variables."},
64 false,
65 "no-synthetic",
66 'e', // Use 'e' for synthEtic - s and y are both taken.
68 nullptr,
69 {},
70 0,
72 "Omit synthetic variables."},
74 false,
75 "show-declaration",
76 'c',
78 nullptr,
79 {},
80 0,
82 "Show variable declaration information (source file and line where the "
83 "variable was declared)."},
85 false,
86 "regex",
87 'r',
89 nullptr,
90 {},
91 0,
93 "The <variable-name> argument for name lookups are regular expressions."},
95 false,
96 "scope",
97 's',
99 nullptr,
100 {},
101 0,
103 "Show variable scope (argument, local, global, static)."},
105 false,
106 "summary",
107 'y',
109 nullptr,
110 {},
111 0,
113 "Specify the summary that the variable output should use."},
115 false,
116 "summary-string",
117 'z',
119 nullptr,
120 {},
121 0,
123 "Specify a summary string to use to format the variable output."},
124};
125
126static constexpr auto g_num_frame_options = 4;
127static const auto g_variable_options_noframe =
128 llvm::ArrayRef<OptionDefinition>(g_variable_options)
129 .drop_front(g_num_frame_options);
130
131static Status ValidateNamedSummary(const char *str, void *) {
132 if (!str || !str[0])
134 "must specify a valid named summary");
135 TypeSummaryImplSP summary_sp;
137 ConstString(str), summary_sp))
139 "must specify a valid named summary");
140 return Status();
141}
142
143static Status ValidateSummaryString(const char *str, void *) {
144 if (!str || !str[0])
146 "must specify a non-empty summary string");
147 return Status();
148}
149
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),
156
157Status
159 llvm::StringRef option_arg,
160 ExecutionContext *execution_context) {
162 llvm::ArrayRef<OptionDefinition> variable_options =
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
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
217llvm::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
222}
static llvm::raw_ostream & error(Stream &strm)
static Status ValidateSummaryString(const char *str, void *)
static Status ValidateNamedSummary(const char *str, void *)
static const auto g_variable_options_noframe
static constexpr OptionDefinition g_variable_options[]
static constexpr auto g_num_frame_options
A uniqued constant string class.
Definition ConstString.h:40
static bool GetSummaryFormat(ConstString type, lldb::TypeSummaryImplSP &entry)
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, ExecutionContext *execution_context) override
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
OptionGroupVariable(bool show_frame_options)
void OptionParsingStarting(ExecutionContext *execution_context) override
An error handling class.
Definition Status.h:118
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Definition Status.cpp:106
#define LLDB_OPT_SET_1
#define LLDB_OPT_SET_2
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::TypeSummaryImpl > TypeSummaryImplSP
@ eArgTypeRegularExpression