LLDB mainline
CommandOptionArgumentTable.cpp
Go to the documentation of this file.
1//===-- CommandOptionArgumentTable.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
13
14using namespace lldb;
15using namespace lldb_private;
16
17namespace lldb_private {
19 return "Register names can be specified using the architecture specific "
20 "names. "
21 "They can also be specified using generic names. Not all generic "
22 "entities have "
23 "registers backing them on all architectures. When they don't the "
24 "generic name "
25 "will return an error.\n"
26 "The generic names defined in lldb are:\n"
27 "\n"
28 "pc - program counter register\n"
29 "ra - return address register\n"
30 "fp - frame pointer register\n"
31 "sp - stack pointer register\n"
32 "flags - the flags register\n"
33 "arg{1-6} - integer argument passing registers.\n";
34}
35
37 return "Breakpoints are identified using major and minor numbers; the major "
38 "number corresponds to the single entity that was created with a "
39 "'breakpoint "
40 "set' command; the minor numbers correspond to all the locations that "
41 "were "
42 "actually found/set based on the major breakpoint. A full breakpoint "
43 "ID might "
44 "look like 3.14, meaning the 14th location set for the 3rd "
45 "breakpoint. You "
46 "can specify all the locations of a breakpoint by just indicating the "
47 "major "
48 "breakpoint number. A valid breakpoint ID consists either of just the "
49 "major "
50 "number, or the major number followed by a dot and the location "
51 "number (e.g. "
52 "3 or 3.2 could both be valid breakpoint IDs.)\n"
53 "\n"
54 "You can use . to refer to the breakpoint location(s) at which the "
55 "current thread is stopped.";
56}
57
59 return "A 'breakpoint ID list' is a manner of specifying multiple "
60 "breakpoints. "
61 "This can be done through several mechanisms. The easiest way is to "
62 "just "
63 "enter a space-separated list of breakpoint IDs. To specify all the "
64 "breakpoint locations under a major breakpoint, you can use the major "
65 "breakpoint number followed by '.*', eg. '5.*' means all the "
66 "locations under "
67 "breakpoint 5. You can also indicate a range of breakpoints by using "
68 "<start-bp-id> - <end-bp-id>. The start-bp-id and end-bp-id for a "
69 "range can "
70 "be any valid breakpoint IDs. It is not legal, however, to specify a "
71 "range "
72 "using specific locations that cross major breakpoint numbers. I.e. "
73 "3.2 - 3.7"
74 " is legal; 2 - 5 is legal; but 3.2 - 4.4 is not legal.";
75}
76
78 return "A name that can be added to a breakpoint when it is created, or "
79 "later "
80 "on with the \"breakpoint name add\" command. "
81 "Breakpoint names can be used to specify breakpoints in all the "
82 "places breakpoint IDs "
83 "and breakpoint ID ranges can be used. As such they provide a "
84 "convenient way to group breakpoints, "
85 "and to operate on breakpoints you create without having to track the "
86 "breakpoint number. "
87 "Note, the attributes you set when using a breakpoint name in a "
88 "breakpoint command don't "
89 "adhere to the name, but instead are set individually on all the "
90 "breakpoints currently tagged with that "
91 "name. Future breakpoints "
92 "tagged with that name will not pick up the attributes previously "
93 "given using that name. "
94 "In order to distinguish breakpoint names from breakpoint IDs and "
95 "ranges, "
96 "names must start with a letter from a-z or A-Z and cannot contain "
97 "spaces, \".\" or \"-\". "
98 "Also, breakpoint names can only be applied to breakpoints, not to "
99 "breakpoint locations.";
100}
101
102llvm::StringRef GDBFormatHelpTextCallback() {
103 return "A GDB format consists of a repeat count, a format letter and a size "
104 "letter. "
105 "The repeat count is optional and defaults to 1. The format letter is "
106 "optional "
107 "and defaults to the previous format that was used. The size letter "
108 "is optional "
109 "and defaults to the previous size that was used.\n"
110 "\n"
111 "Format letters include:\n"
112 "o - octal\n"
113 "x - hexadecimal\n"
114 "d - decimal\n"
115 "u - unsigned decimal\n"
116 "t - binary\n"
117 "f - float\n"
118 "a - address\n"
119 "i - instruction\n"
120 "c - char\n"
121 "s - string\n"
122 "T - OSType\n"
123 "A - float as hex\n"
124 "\n"
125 "Size letters include:\n"
126 "b - 1 byte (byte)\n"
127 "h - 2 bytes (halfword)\n"
128 "w - 4 bytes (word)\n"
129 "g - 8 bytes (giant)\n"
130 "\n"
131 "Example formats:\n"
132 "32xb - show 32 1 byte hexadecimal integer values\n"
133 "16xh - show 16 2 byte hexadecimal integer values\n"
134 "64 - show 64 2 byte hexadecimal integer values (format and size "
135 "from the last format)\n"
136 "dw - show 1 4 byte decimal integer value\n";
137}
138
139llvm::StringRef FormatHelpTextCallback() {
140 static std::string help_text;
141
142 if (!help_text.empty())
143 return help_text;
144
145 StreamString sstr;
146 sstr << "One of the format names (or one-character names) that can be used "
147 "to show a variable's value:\n";
148 for (Format f = eFormatDefault; f < kNumFormats; f = Format(f + 1)) {
149 if (f != eFormatDefault)
150 sstr.PutChar('\n');
151
152 char format_char = FormatManager::GetFormatAsFormatChar(f);
153 if (format_char)
154 sstr.Printf("'%c' or ", format_char);
155
156 sstr.Printf("\"%s\"", FormatManager::GetFormatAsCString(f));
157 }
158
159 sstr.Flush();
160
161 help_text = std::string(sstr.GetString());
162
163 return help_text;
164}
165
167 static std::string help_text;
168
169 if (!help_text.empty())
170 return help_text;
171
172 StreamString sstr;
173 sstr << "One of the following languages:\n";
174
175 Language::PrintAllLanguages(sstr, " ", "\n");
176
177 sstr.Flush();
178
179 help_text = std::string(sstr.GetString());
180
181 return help_text;
182}
183
185 return "A summary string is a way to extract information from variables in "
186 "order to present them using a summary.\n"
187 "Summary strings contain static text, variables, scopes and control "
188 "sequences:\n"
189 " - Static text can be any sequence of non-special characters, i.e. "
190 "anything but '{', '}', '$', or '\\'.\n"
191 " - Variables are sequences of characters beginning with ${, ending "
192 "with } and that contain symbols in the format described below.\n"
193 " - Scopes are any sequence of text between { and }. Anything "
194 "included in a scope will only appear in the output summary if there "
195 "were no errors.\n"
196 " - Control sequences are the usual C/C++ '\\a', '\\n', ..., plus "
197 "'\\$', '\\{' and '\\}'.\n"
198 "A summary string works by copying static text verbatim, turning "
199 "control sequences into their character counterpart, expanding "
200 "variables and trying to expand scopes.\n"
201 "A variable is expanded by giving it a value other than its textual "
202 "representation, and the way this is done depends on what comes after "
203 "the ${ marker.\n"
204 "The most common sequence if ${var followed by an expression path, "
205 "which is the text one would type to access a member of an aggregate "
206 "types, given a variable of that type"
207 " (e.g. if type T has a member named x, which has a member named y, "
208 "and if t is of type T, the expression path would be .x.y and the way "
209 "to fit that into a summary string would be"
210 " ${var.x.y}). You can also use ${*var followed by an expression path "
211 "and in that case the object referred by the path will be "
212 "dereferenced before being displayed."
213 " If the object is not a pointer, doing so will cause an error. For "
214 "additional details on expression paths, you can type 'help "
215 "expr-path'. \n"
216 "By default, summary strings attempt to display the summary for any "
217 "variable they reference, and if that fails the value. If neither can "
218 "be shown, nothing is displayed."
219 "In a summary string, you can also use an array index [n], or a "
220 "slice-like range [n-m]. This can have two different meanings "
221 "depending on what kind of object the expression"
222 " path refers to:\n"
223 " - if it is a scalar type (any basic type like int, float, ...) the "
224 "expression is a bitfield, i.e. the bits indicated by the indexing "
225 "operator are extracted out of the number"
226 " and displayed as an individual variable\n"
227 " - if it is an array or pointer the array items indicated by the "
228 "indexing operator are shown as the result of the variable. if the "
229 "expression is an array, real array items are"
230 " printed; if it is a pointer, the pointer-as-array syntax is used to "
231 "obtain the values (this means, the latter case can have no range "
232 "checking)\n"
233 "If you are trying to display an array for which the size is known, "
234 "you can also use [] instead of giving an exact range. This has the "
235 "effect of showing items 0 thru size - 1.\n"
236 "Additionally, a variable can contain an (optional) format code, as "
237 "in ${var.x.y%code}, where code can be any of the valid formats "
238 "described in 'help format', or one of the"
239 " special symbols only allowed as part of a variable:\n"
240 " %V: show the value of the object by default\n"
241 " %S: show the summary of the object by default\n"
242 " %@: show the runtime-provided object description (for "
243 "Objective-C, it calls NSPrintForDebugger; for C/C++ it does "
244 "nothing)\n"
245 " %L: show the location of the object (memory address or a "
246 "register name)\n"
247 " %#: show the number of children of the object\n"
248 " %T: show the type of the object\n"
249 "Another variable that you can use in summary strings is ${svar . "
250 "This sequence works exactly like ${var, including the fact that "
251 "${*svar is an allowed sequence, but uses"
252 " the object's synthetic children provider instead of the actual "
253 "objects. For instance, if you are using STL synthetic children "
254 "providers, the following summary string would"
255 " count the number of actual elements stored in an std::list:\n"
256 "type summary add -s \"${svar%#}\" -x \"std::list<\"";
257}
258
259llvm::StringRef ExprPathHelpTextCallback() {
260 return "An expression path is the sequence of symbols that is used in C/C++ "
261 "to access a member variable of an aggregate object (class).\n"
262 "For instance, given a class:\n"
263 " class foo {\n"
264 " int a;\n"
265 " int b; .\n"
266 " foo* next;\n"
267 " };\n"
268 "the expression to read item b in the item pointed to by next for foo "
269 "aFoo would be aFoo.next->b.\n"
270 "Given that aFoo could just be any object of type foo, the string "
271 "'.next->b' is the expression path, because it can be attached to any "
272 "foo instance to achieve the effect.\n"
273 "Expression paths in LLDB include dot (.) and arrow (->) operators, "
274 "and most commands using expression paths have ways to also accept "
275 "the star (*) operator.\n"
276 "The meaning of these operators is the same as the usual one given to "
277 "them by the C/C++ standards.\n"
278 "LLDB also has support for indexing ([ ]) in expression paths, and "
279 "extends the traditional meaning of the square brackets operator to "
280 "allow bitfield extraction:\n"
281 "for objects of native types (int, float, char, ...) saying '[n-m]' "
282 "as an expression path (where n and m are any positive integers, e.g. "
283 "[3-5]) causes LLDB to extract"
284 " bits n thru m from the value of the variable. If n == m, [n] is "
285 "also allowed as a shortcut syntax. For arrays and pointers, "
286 "expression paths can only contain one index"
287 " and the meaning of the operation is the same as the one defined by "
288 "C/C++ (item extraction). Some commands extend bitfield-like syntax "
289 "for arrays and pointers with the"
290 " meaning of array slicing (taking elements n thru m inside the array "
291 "or pointed-to memory).";
292}
293
294llvm::StringRef arch_helper() {
295 static StreamString g_archs_help;
296 if (g_archs_help.Empty()) {
297 StringList archs;
298
300 g_archs_help.Printf("These are the supported architecture names:\n");
301 archs.Join("\n", g_archs_help);
302 }
303 return g_archs_help.GetString();
304}
305
306template <int I> struct TableValidator : TableValidator<I + 1> {
307 static_assert(
308 g_argument_table[I].arg_type == I,
309 "g_argument_table order doesn't match CommandArgumentType enumeration");
310};
311
312template <> struct TableValidator<eArgTypeLastArg> {};
313
315
316} // namespace lldb_private
static void ListSupportedArchNames(StringList &list)
Definition ArchSpec.cpp:290
static const char * GetFormatAsCString(lldb::Format format)
static char GetFormatAsFormatChar(lldb::Format format)
static void PrintAllLanguages(Stream &s, const char *prefix, const char *suffix)
Definition Language.cpp:327
void Flush() override
Flush the stream.
llvm::StringRef GetString() const
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition Stream.cpp:134
size_t PutChar(char ch)
Definition Stream.cpp:131
void Join(const char *separator, Stream &strm)
A class that represents a running process on the host machine.
llvm::StringRef GDBFormatHelpTextCallback()
llvm::StringRef arch_helper()
llvm::StringRef SummaryStringHelpTextCallback()
llvm::StringRef RegisterNameHelpTextCallback()
llvm::StringRef ExprPathHelpTextCallback()
llvm::StringRef BreakpointIDRangeHelpTextCallback()
TableValidator< 0 > validator
llvm::StringRef BreakpointIDHelpTextCallback()
llvm::StringRef LanguageTypeHelpTextCallback()
llvm::StringRef BreakpointNameHelpTextCallback()
llvm::StringRef FormatHelpTextCallback()
static constexpr CommandObject::ArgumentTableEntry g_argument_table[]
Format
Display format definitions.