blob: 6c848f94a832ccf45c223fc294f66e33cb4c1aa3 [file] [log] [blame]
Chris Lattner24943d22010-06-08 16:52:24 +00001//===-- CommandObject.cpp ---------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "lldb/Interpreter/CommandObject.h"
11
12#include <string>
13#include <map>
14
15#include <getopt.h>
16#include <stdlib.h>
17#include <ctype.h>
18
19#include "lldb/Core/Address.h"
Johnny Chen746323a2012-05-26 00:32:39 +000020#include "lldb/Core/ArchSpec.h"
Jim Ingham84cdc152010-06-15 19:49:27 +000021#include "lldb/Interpreter/Options.h"
Chris Lattner24943d22010-06-08 16:52:24 +000022
23// These are for the Sourcename completers.
24// FIXME: Make a separate file for the completers.
Greg Clayton5f54ac32011-02-08 05:05:52 +000025#include "lldb/Host/FileSpec.h"
Chris Lattner24943d22010-06-08 16:52:24 +000026#include "lldb/Core/FileSpecList.h"
27#include "lldb/Target/Process.h"
28#include "lldb/Target/Target.h"
29
30#include "lldb/Interpreter/CommandInterpreter.h"
31#include "lldb/Interpreter/CommandReturnObject.h"
32#include "lldb/Interpreter/ScriptInterpreter.h"
33#include "lldb/Interpreter/ScriptInterpreterPython.h"
34
35using namespace lldb;
36using namespace lldb_private;
37
38//-------------------------------------------------------------------------
39// CommandObject
40//-------------------------------------------------------------------------
41
Greg Clayton238c0a12010-09-18 01:14:36 +000042CommandObject::CommandObject
43(
44 CommandInterpreter &interpreter,
45 const char *name,
46 const char *help,
47 const char *syntax,
48 uint32_t flags
49) :
50 m_interpreter (interpreter),
Chris Lattner24943d22010-06-08 16:52:24 +000051 m_cmd_name (name),
52 m_cmd_help_short (),
53 m_cmd_help_long (),
54 m_cmd_syntax (),
Jim Inghamd40f8a62010-07-06 22:46:59 +000055 m_is_alias (false),
Caroline Ticefb355112010-10-01 17:46:38 +000056 m_flags (flags),
Greg Claytonf1252502012-02-29 04:21:24 +000057 m_arguments(),
58 m_command_override_callback (NULL),
59 m_command_override_baton (NULL)
Chris Lattner24943d22010-06-08 16:52:24 +000060{
61 if (help && help[0])
62 m_cmd_help_short = help;
63 if (syntax && syntax[0])
64 m_cmd_syntax = syntax;
65}
66
67CommandObject::~CommandObject ()
68{
69}
70
71const char *
72CommandObject::GetHelp ()
73{
74 return m_cmd_help_short.c_str();
75}
76
77const char *
78CommandObject::GetHelpLong ()
79{
80 return m_cmd_help_long.c_str();
81}
82
83const char *
84CommandObject::GetSyntax ()
85{
Caroline Ticefb355112010-10-01 17:46:38 +000086 if (m_cmd_syntax.length() == 0)
87 {
88 StreamString syntax_str;
89 syntax_str.Printf ("%s", GetCommandName());
90 if (GetOptions() != NULL)
Caroline Tice43b014a2010-10-04 22:28:36 +000091 syntax_str.Printf (" <cmd-options>");
Caroline Ticefb355112010-10-01 17:46:38 +000092 if (m_arguments.size() > 0)
93 {
94 syntax_str.Printf (" ");
Sean Callanan9798d7b2012-01-04 19:11:25 +000095 if (WantsRawCommandString())
96 syntax_str.Printf("-- ");
Caroline Ticefb355112010-10-01 17:46:38 +000097 GetFormattedCommandArguments (syntax_str);
98 }
99 m_cmd_syntax = syntax_str.GetData ();
100 }
101
Chris Lattner24943d22010-06-08 16:52:24 +0000102 return m_cmd_syntax.c_str();
103}
104
105const char *
106CommandObject::Translate ()
107{
108 //return m_cmd_func_name.c_str();
109 return "This function is currently not implemented.";
110}
111
112const char *
113CommandObject::GetCommandName ()
114{
115 return m_cmd_name.c_str();
116}
117
118void
119CommandObject::SetCommandName (const char *name)
120{
121 m_cmd_name = name;
122}
123
124void
125CommandObject::SetHelp (const char *cstr)
126{
127 m_cmd_help_short = cstr;
128}
129
130void
131CommandObject::SetHelpLong (const char *cstr)
132{
133 m_cmd_help_long = cstr;
134}
135
136void
Enrico Granatae5e34cb2011-08-17 01:30:04 +0000137CommandObject::SetHelpLong (std::string str)
138{
139 m_cmd_help_long = str;
140}
141
142void
Chris Lattner24943d22010-06-08 16:52:24 +0000143CommandObject::SetSyntax (const char *cstr)
144{
145 m_cmd_syntax = cstr;
146}
147
148Options *
149CommandObject::GetOptions ()
150{
151 // By default commands don't have options unless this virtual function
152 // is overridden by base classes.
153 return NULL;
154}
155
Chris Lattner24943d22010-06-08 16:52:24 +0000156bool
Chris Lattner24943d22010-06-08 16:52:24 +0000157CommandObject::ParseOptions
158(
159 Args& args,
Chris Lattner24943d22010-06-08 16:52:24 +0000160 CommandReturnObject &result
161)
162{
163 // See if the subclass has options?
164 Options *options = GetOptions();
165 if (options != NULL)
166 {
167 Error error;
Greg Clayton143fcc32011-04-13 00:18:08 +0000168 options->NotifyOptionParsingStarting();
Chris Lattner24943d22010-06-08 16:52:24 +0000169
170 // ParseOptions calls getopt_long, which always skips the zero'th item in the array and starts at position 1,
171 // so we need to push a dummy value into position zero.
172 args.Unshift("dummy_string");
173 error = args.ParseOptions (*options);
174
175 // The "dummy_string" will have already been removed by ParseOptions,
176 // so no need to remove it.
177
Greg Clayton143fcc32011-04-13 00:18:08 +0000178 if (error.Success())
179 error = options->NotifyOptionParsingFinished();
180
181 if (error.Success())
182 {
183 if (options->VerifyOptions (result))
184 return true;
185 }
186 else
Chris Lattner24943d22010-06-08 16:52:24 +0000187 {
188 const char *error_cstr = error.AsCString();
189 if (error_cstr)
190 {
191 // We got an error string, lets use that
Greg Clayton9c236732011-10-26 00:56:27 +0000192 result.AppendError(error_cstr);
Chris Lattner24943d22010-06-08 16:52:24 +0000193 }
194 else
195 {
196 // No error string, output the usage information into result
Greg Claytonf15996e2011-04-07 22:46:35 +0000197 options->GenerateOptionUsage (result.GetErrorStream(), this);
Chris Lattner24943d22010-06-08 16:52:24 +0000198 }
Chris Lattner24943d22010-06-08 16:52:24 +0000199 }
Greg Clayton143fcc32011-04-13 00:18:08 +0000200 result.SetStatus (eReturnStatusFailed);
201 return false;
Chris Lattner24943d22010-06-08 16:52:24 +0000202 }
203 return true;
204}
Chris Lattner24943d22010-06-08 16:52:24 +0000205
Jim Inghamda26bd22012-06-08 21:56:10 +0000206
207
208bool
209CommandObject::CheckFlags (CommandReturnObject &result)
210{
Greg Claytone71e2582011-02-04 01:58:07 +0000211 if (GetFlags().AnySet (CommandObject::eFlagProcessMustBeLaunched | CommandObject::eFlagProcessMustBePaused))
Chris Lattner24943d22010-06-08 16:52:24 +0000212 {
Greg Clayton567e7f32011-09-22 04:58:26 +0000213 Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
Greg Claytone71e2582011-02-04 01:58:07 +0000214 if (process == NULL)
Chris Lattner24943d22010-06-08 16:52:24 +0000215 {
Jim Ingham8cc3f692011-07-09 00:55:34 +0000216 // A process that is not running is considered paused.
217 if (GetFlags().Test(CommandObject::eFlagProcessMustBeLaunched))
218 {
219 result.AppendError ("Process must exist.");
220 result.SetStatus (eReturnStatusFailed);
221 return false;
222 }
Chris Lattner24943d22010-06-08 16:52:24 +0000223 }
Greg Claytone71e2582011-02-04 01:58:07 +0000224 else
Chris Lattner24943d22010-06-08 16:52:24 +0000225 {
Greg Claytone71e2582011-02-04 01:58:07 +0000226 StateType state = process->GetState();
227
228 switch (state)
Chris Lattner24943d22010-06-08 16:52:24 +0000229 {
Greg Clayton4fdf7602011-03-20 04:57:14 +0000230 case eStateInvalid:
Greg Claytone71e2582011-02-04 01:58:07 +0000231 case eStateSuspended:
232 case eStateCrashed:
233 case eStateStopped:
234 break;
235
236 case eStateConnected:
237 case eStateAttaching:
238 case eStateLaunching:
239 case eStateDetached:
240 case eStateExited:
241 case eStateUnloaded:
242 if (GetFlags().Test(CommandObject::eFlagProcessMustBeLaunched))
243 {
244 result.AppendError ("Process must be launched.");
245 result.SetStatus (eReturnStatusFailed);
246 return false;
247 }
248 break;
Chris Lattner24943d22010-06-08 16:52:24 +0000249
Greg Claytone71e2582011-02-04 01:58:07 +0000250 case eStateRunning:
251 case eStateStepping:
252 if (GetFlags().Test(CommandObject::eFlagProcessMustBePaused))
253 {
254 result.AppendError ("Process is running. Use 'process interrupt' to pause execution.");
255 result.SetStatus (eReturnStatusFailed);
256 return false;
257 }
Chris Lattner24943d22010-06-08 16:52:24 +0000258 }
259 }
260 }
Jim Inghamda26bd22012-06-08 21:56:10 +0000261 return true;
Chris Lattner24943d22010-06-08 16:52:24 +0000262}
263
264class CommandDictCommandPartialMatch
265{
266 public:
267 CommandDictCommandPartialMatch (const char *match_str)
268 {
269 m_match_str = match_str;
270 }
271 bool operator() (const std::pair<std::string, lldb::CommandObjectSP> map_element) const
272 {
273 // A NULL or empty string matches everything.
274 if (m_match_str == NULL || *m_match_str == '\0')
275 return 1;
276
277 size_t found = map_element.first.find (m_match_str, 0);
278 if (found == std::string::npos)
279 return 0;
280 else
281 return found == 0;
282 }
283
284 private:
285 const char *m_match_str;
286};
287
288int
289CommandObject::AddNamesMatchingPartialString (CommandObject::CommandMap &in_map, const char *cmd_str,
290 StringList &matches)
291{
292 int number_added = 0;
293 CommandDictCommandPartialMatch matcher(cmd_str);
294
295 CommandObject::CommandMap::iterator matching_cmds = std::find_if (in_map.begin(), in_map.end(), matcher);
296
297 while (matching_cmds != in_map.end())
298 {
299 ++number_added;
300 matches.AppendString((*matching_cmds).first.c_str());
301 matching_cmds = std::find_if (++matching_cmds, in_map.end(), matcher);;
302 }
303 return number_added;
304}
305
306int
307CommandObject::HandleCompletion
308(
309 Args &input,
310 int &cursor_index,
311 int &cursor_char_position,
312 int match_start_point,
313 int max_return_elements,
Jim Ingham802f8b02010-06-30 05:02:46 +0000314 bool &word_complete,
Chris Lattner24943d22010-06-08 16:52:24 +0000315 StringList &matches
316)
317{
Johnny Chen8042eed2012-01-20 00:59:19 +0000318 // Default implmentation of WantsCompletion() is !WantsRawCommandString().
319 // Subclasses who want raw command string but desire, for example,
320 // argument completion should override WantsCompletion() to return true,
321 // instead.
Johnny Chen120d94d2012-01-19 22:16:06 +0000322 if (WantsRawCommandString() && !WantsCompletion())
Chris Lattner24943d22010-06-08 16:52:24 +0000323 {
324 // FIXME: Abstract telling the completion to insert the completion character.
325 matches.Clear();
326 return -1;
327 }
328 else
329 {
330 // Can we do anything generic with the options?
331 Options *cur_options = GetOptions();
332 CommandReturnObject result;
333 OptionElementVector opt_element_vector;
334
335 if (cur_options != NULL)
336 {
337 // Re-insert the dummy command name string which will have been
338 // stripped off:
339 input.Unshift ("dummy-string");
340 cursor_index++;
341
342
343 // I stick an element on the end of the input, because if the last element is
344 // option that requires an argument, getopt_long will freak out.
345
346 input.AppendArgument ("<FAKE-VALUE>");
347
Jim Inghamadb84292010-06-24 20:31:04 +0000348 input.ParseArgsForCompletion (*cur_options, opt_element_vector, cursor_index);
Chris Lattner24943d22010-06-08 16:52:24 +0000349
350 input.DeleteArgumentAtIndex(input.GetArgumentCount() - 1);
351
352 bool handled_by_options;
Greg Claytonf15996e2011-04-07 22:46:35 +0000353 handled_by_options = cur_options->HandleOptionCompletion (input,
Greg Clayton63094e02010-06-23 01:19:29 +0000354 opt_element_vector,
355 cursor_index,
356 cursor_char_position,
357 match_start_point,
358 max_return_elements,
Jim Ingham802f8b02010-06-30 05:02:46 +0000359 word_complete,
Greg Clayton63094e02010-06-23 01:19:29 +0000360 matches);
Chris Lattner24943d22010-06-08 16:52:24 +0000361 if (handled_by_options)
362 return matches.GetSize();
363 }
364
365 // If we got here, the last word is not an option or an option argument.
Greg Clayton238c0a12010-09-18 01:14:36 +0000366 return HandleArgumentCompletion (input,
Greg Clayton63094e02010-06-23 01:19:29 +0000367 cursor_index,
368 cursor_char_position,
369 opt_element_vector,
370 match_start_point,
371 max_return_elements,
Jim Ingham802f8b02010-06-30 05:02:46 +0000372 word_complete,
Greg Clayton63094e02010-06-23 01:19:29 +0000373 matches);
Chris Lattner24943d22010-06-08 16:52:24 +0000374 }
375}
376
Chris Lattner24943d22010-06-08 16:52:24 +0000377bool
Greg Clayton238c0a12010-09-18 01:14:36 +0000378CommandObject::HelpTextContainsWord (const char *search_word)
Chris Lattner24943d22010-06-08 16:52:24 +0000379{
Chris Lattner24943d22010-06-08 16:52:24 +0000380 std::string options_usage_help;
381
Chris Lattner24943d22010-06-08 16:52:24 +0000382 bool found_word = false;
383
Greg Clayton13193d52012-10-13 02:07:45 +0000384 const char *short_help = GetHelp();
385 const char *long_help = GetHelpLong();
386 const char *syntax_help = GetSyntax();
Chris Lattner24943d22010-06-08 16:52:24 +0000387
Greg Clayton13193d52012-10-13 02:07:45 +0000388 if (short_help && strcasestr (short_help, search_word))
Chris Lattner24943d22010-06-08 16:52:24 +0000389 found_word = true;
Greg Clayton13193d52012-10-13 02:07:45 +0000390 else if (long_help && strcasestr (long_help, search_word))
Chris Lattner24943d22010-06-08 16:52:24 +0000391 found_word = true;
Greg Clayton13193d52012-10-13 02:07:45 +0000392 else if (syntax_help && strcasestr (syntax_help, search_word))
Chris Lattner24943d22010-06-08 16:52:24 +0000393 found_word = true;
394
395 if (!found_word
396 && GetOptions() != NULL)
397 {
398 StreamString usage_help;
Greg Claytonf15996e2011-04-07 22:46:35 +0000399 GetOptions()->GenerateOptionUsage (usage_help, this);
Chris Lattner24943d22010-06-08 16:52:24 +0000400 if (usage_help.GetSize() > 0)
401 {
402 const char *usage_text = usage_help.GetData();
Caroline Tice34391782010-10-12 22:16:53 +0000403 if (strcasestr (usage_text, search_word))
Chris Lattner24943d22010-06-08 16:52:24 +0000404 found_word = true;
405 }
406 }
407
408 return found_word;
409}
Caroline Ticefb355112010-10-01 17:46:38 +0000410
411int
412CommandObject::GetNumArgumentEntries ()
413{
414 return m_arguments.size();
415}
416
417CommandObject::CommandArgumentEntry *
418CommandObject::GetArgumentEntryAtIndex (int idx)
419{
420 if (idx < m_arguments.size())
421 return &(m_arguments[idx]);
422
423 return NULL;
424}
425
426CommandObject::ArgumentTableEntry *
427CommandObject::FindArgumentDataByType (CommandArgumentType arg_type)
428{
429 const ArgumentTableEntry *table = CommandObject::GetArgumentTable();
430
431 for (int i = 0; i < eArgTypeLastArg; ++i)
432 if (table[i].arg_type == arg_type)
433 return (ArgumentTableEntry *) &(table[i]);
434
435 return NULL;
436}
437
438void
439CommandObject::GetArgumentHelp (Stream &str, CommandArgumentType arg_type, CommandInterpreter &interpreter)
440{
441 const ArgumentTableEntry* table = CommandObject::GetArgumentTable();
442 ArgumentTableEntry *entry = (ArgumentTableEntry *) &(table[arg_type]);
443
444 // The table is *supposed* to be kept in arg_type order, but someone *could* have messed it up...
445
446 if (entry->arg_type != arg_type)
447 entry = CommandObject::FindArgumentDataByType (arg_type);
448
449 if (!entry)
450 return;
451
452 StreamString name_str;
453 name_str.Printf ("<%s>", entry->arg_name);
454
Enrico Granataff782382011-07-08 02:51:01 +0000455 if (entry->help_function)
Enrico Granata1bba6e52011-07-07 00:38:40 +0000456 {
Enrico Granataff782382011-07-08 02:51:01 +0000457 const char* help_text = entry->help_function();
Enrico Granata1bba6e52011-07-07 00:38:40 +0000458 if (!entry->help_function.self_formatting)
459 {
460 interpreter.OutputFormattedHelpText (str, name_str.GetData(), "--", help_text,
461 name_str.GetSize());
462 }
463 else
464 {
465 interpreter.OutputHelpText(str, name_str.GetData(), "--", help_text,
466 name_str.GetSize());
467 }
468 }
Caroline Ticefb355112010-10-01 17:46:38 +0000469 else
470 interpreter.OutputFormattedHelpText (str, name_str.GetData(), "--", entry->help_text, name_str.GetSize());
471}
472
473const char *
474CommandObject::GetArgumentName (CommandArgumentType arg_type)
475{
Caroline Tice4d6675c2010-10-01 19:59:14 +0000476 ArgumentTableEntry *entry = (ArgumentTableEntry *) &(CommandObject::GetArgumentTable()[arg_type]);
477
478 // The table is *supposed* to be kept in arg_type order, but someone *could* have messed it up...
479
480 if (entry->arg_type != arg_type)
481 entry = CommandObject::FindArgumentDataByType (arg_type);
482
Johnny Chen25ca9842010-10-08 22:01:52 +0000483 if (entry)
484 return entry->arg_name;
485
486 StreamString str;
487 str << "Arg name for type (" << arg_type << ") not in arg table!";
488 return str.GetData();
Caroline Ticefb355112010-10-01 17:46:38 +0000489}
490
Caroline Tice43b014a2010-10-04 22:28:36 +0000491bool
Greg Claytonb3448432011-03-24 21:19:54 +0000492CommandObject::IsPairType (ArgumentRepetitionType arg_repeat_type)
Caroline Tice43b014a2010-10-04 22:28:36 +0000493{
494 if ((arg_repeat_type == eArgRepeatPairPlain)
495 || (arg_repeat_type == eArgRepeatPairOptional)
496 || (arg_repeat_type == eArgRepeatPairPlus)
497 || (arg_repeat_type == eArgRepeatPairStar)
498 || (arg_repeat_type == eArgRepeatPairRange)
499 || (arg_repeat_type == eArgRepeatPairRangeOptional))
500 return true;
501
502 return false;
503}
504
Johnny Chen6183fcc2012-02-08 01:13:31 +0000505static CommandObject::CommandArgumentEntry
506OptSetFiltered(uint32_t opt_set_mask, CommandObject::CommandArgumentEntry &cmd_arg_entry)
507{
508 CommandObject::CommandArgumentEntry ret_val;
509 for (unsigned i = 0; i < cmd_arg_entry.size(); ++i)
510 if (opt_set_mask & cmd_arg_entry[i].arg_opt_set_association)
511 ret_val.push_back(cmd_arg_entry[i]);
512 return ret_val;
513}
514
515// Default parameter value of opt_set_mask is LLDB_OPT_SET_ALL, which means take
516// all the argument data into account. On rare cases where some argument sticks
517// with certain option sets, this function returns the option set filtered args.
Caroline Ticefb355112010-10-01 17:46:38 +0000518void
Johnny Chen6183fcc2012-02-08 01:13:31 +0000519CommandObject::GetFormattedCommandArguments (Stream &str, uint32_t opt_set_mask)
Caroline Ticefb355112010-10-01 17:46:38 +0000520{
521 int num_args = m_arguments.size();
522 for (int i = 0; i < num_args; ++i)
523 {
524 if (i > 0)
525 str.Printf (" ");
Johnny Chen6183fcc2012-02-08 01:13:31 +0000526 CommandArgumentEntry arg_entry =
527 opt_set_mask == LLDB_OPT_SET_ALL ? m_arguments[i]
528 : OptSetFiltered(opt_set_mask, m_arguments[i]);
Caroline Ticefb355112010-10-01 17:46:38 +0000529 int num_alternatives = arg_entry.size();
Caroline Tice43b014a2010-10-04 22:28:36 +0000530
531 if ((num_alternatives == 2)
532 && IsPairType (arg_entry[0].arg_repetition))
Caroline Ticefb355112010-10-01 17:46:38 +0000533 {
Caroline Tice43b014a2010-10-04 22:28:36 +0000534 const char *first_name = GetArgumentName (arg_entry[0].arg_type);
535 const char *second_name = GetArgumentName (arg_entry[1].arg_type);
536 switch (arg_entry[0].arg_repetition)
537 {
538 case eArgRepeatPairPlain:
539 str.Printf ("<%s> <%s>", first_name, second_name);
540 break;
541 case eArgRepeatPairOptional:
542 str.Printf ("[<%s> <%s>]", first_name, second_name);
543 break;
544 case eArgRepeatPairPlus:
545 str.Printf ("<%s> <%s> [<%s> <%s> [...]]", first_name, second_name, first_name, second_name);
546 break;
547 case eArgRepeatPairStar:
548 str.Printf ("[<%s> <%s> [<%s> <%s> [...]]]", first_name, second_name, first_name, second_name);
549 break;
550 case eArgRepeatPairRange:
551 str.Printf ("<%s_1> <%s_1> ... <%s_n> <%s_n>", first_name, second_name, first_name, second_name);
552 break;
553 case eArgRepeatPairRangeOptional:
554 str.Printf ("[<%s_1> <%s_1> ... <%s_n> <%s_n>]", first_name, second_name, first_name, second_name);
555 break;
Caroline Ticeb5772842011-03-23 22:31:13 +0000556 // Explicitly test for all the rest of the cases, so if new types get added we will notice the
557 // missing case statement(s).
558 case eArgRepeatPlain:
559 case eArgRepeatOptional:
560 case eArgRepeatPlus:
561 case eArgRepeatStar:
562 case eArgRepeatRange:
563 // These should not be reached, as they should fail the IsPairType test above.
564 break;
Caroline Tice43b014a2010-10-04 22:28:36 +0000565 }
Caroline Ticefb355112010-10-01 17:46:38 +0000566 }
Caroline Tice43b014a2010-10-04 22:28:36 +0000567 else
Caroline Ticefb355112010-10-01 17:46:38 +0000568 {
Caroline Tice43b014a2010-10-04 22:28:36 +0000569 StreamString names;
570 for (int j = 0; j < num_alternatives; ++j)
571 {
572 if (j > 0)
573 names.Printf (" | ");
574 names.Printf ("%s", GetArgumentName (arg_entry[j].arg_type));
575 }
576 switch (arg_entry[0].arg_repetition)
577 {
578 case eArgRepeatPlain:
579 str.Printf ("<%s>", names.GetData());
580 break;
581 case eArgRepeatPlus:
582 str.Printf ("<%s> [<%s> [...]]", names.GetData(), names.GetData());
583 break;
584 case eArgRepeatStar:
585 str.Printf ("[<%s> [<%s> [...]]]", names.GetData(), names.GetData());
586 break;
587 case eArgRepeatOptional:
588 str.Printf ("[<%s>]", names.GetData());
589 break;
590 case eArgRepeatRange:
Jason Molenda7e5fa7f2011-09-20 21:44:10 +0000591 str.Printf ("<%s_1> .. <%s_n>", names.GetData(), names.GetData());
Caroline Ticeb5772842011-03-23 22:31:13 +0000592 break;
593 // Explicitly test for all the rest of the cases, so if new types get added we will notice the
594 // missing case statement(s).
595 case eArgRepeatPairPlain:
596 case eArgRepeatPairOptional:
597 case eArgRepeatPairPlus:
598 case eArgRepeatPairStar:
599 case eArgRepeatPairRange:
600 case eArgRepeatPairRangeOptional:
601 // These should not be hit, as they should pass the IsPairType test above, and control should
602 // have gone into the other branch of the if statement.
603 break;
Caroline Tice43b014a2010-10-04 22:28:36 +0000604 }
Caroline Ticefb355112010-10-01 17:46:38 +0000605 }
606 }
607}
608
Stephen Wilson47f07852011-03-23 02:12:10 +0000609CommandArgumentType
Caroline Ticefb355112010-10-01 17:46:38 +0000610CommandObject::LookupArgumentName (const char *arg_name)
611{
612 CommandArgumentType return_type = eArgTypeLastArg;
613
614 std::string arg_name_str (arg_name);
615 size_t len = arg_name_str.length();
616 if (arg_name[0] == '<'
617 && arg_name[len-1] == '>')
618 arg_name_str = arg_name_str.substr (1, len-2);
619
Johnny Chen309c89d2011-07-14 22:20:12 +0000620 const ArgumentTableEntry *table = GetArgumentTable();
Caroline Ticefb355112010-10-01 17:46:38 +0000621 for (int i = 0; i < eArgTypeLastArg; ++i)
Johnny Chen309c89d2011-07-14 22:20:12 +0000622 if (arg_name_str.compare (table[i].arg_name) == 0)
Caroline Ticefb355112010-10-01 17:46:38 +0000623 return_type = g_arguments_data[i].arg_type;
624
625 return return_type;
626}
627
628static const char *
Jim Ingham811708c2012-08-23 23:37:31 +0000629RegisterNameHelpTextCallback ()
630{
631 return "Register names can be specified using the architecture specific names. "
Jim Inghamff72cd02012-08-23 23:47:08 +0000632 "They can also be specified using generic names. Not all generic entities have "
633 "registers backing them on all architectures. When they don't the generic name "
634 "will return an error.\n"
Jim Ingham811708c2012-08-23 23:37:31 +0000635 "The generic names defined in lldb are:\n"
636 "\n"
637 "pc - program counter register\n"
638 "ra - return address register\n"
639 "fp - frame pointer register\n"
640 "sp - stack pointer register\n"
Jim Inghamff72cd02012-08-23 23:47:08 +0000641 "flags - the flags register\n"
Jim Ingham811708c2012-08-23 23:37:31 +0000642 "arg{1-6} - integer argument passing registers.\n";
643}
644
645static const char *
Caroline Ticefb355112010-10-01 17:46:38 +0000646BreakpointIDHelpTextCallback ()
647{
Greg Clayton9c236732011-10-26 00:56:27 +0000648 return "Breakpoint ID's consist major and minor numbers; the major number "
649 "corresponds to the single entity that was created with a 'breakpoint set' "
650 "command; the minor numbers correspond to all the locations that were actually "
651 "found/set based on the major breakpoint. A full breakpoint ID might look like "
652 "3.14, meaning the 14th location set for the 3rd breakpoint. You can specify "
653 "all the locations of a breakpoint by just indicating the major breakpoint "
654 "number. A valid breakpoint id consists either of just the major id number, "
655 "or the major number, a dot, and the location number (e.g. 3 or 3.2 could "
656 "both be valid breakpoint ids).";
Caroline Ticefb355112010-10-01 17:46:38 +0000657}
658
659static const char *
660BreakpointIDRangeHelpTextCallback ()
661{
Greg Clayton9c236732011-10-26 00:56:27 +0000662 return "A 'breakpoint id list' is a manner of specifying multiple breakpoints. "
663 "This can be done through several mechanisms. The easiest way is to just "
664 "enter a space-separated list of breakpoint ids. To specify all the "
665 "breakpoint locations under a major breakpoint, you can use the major "
666 "breakpoint number followed by '.*', eg. '5.*' means all the locations under "
667 "breakpoint 5. You can also indicate a range of breakpoints by using "
668 "<start-bp-id> - <end-bp-id>. The start-bp-id and end-bp-id for a range can "
669 "be any valid breakpoint ids. It is not legal, however, to specify a range "
670 "using specific locations that cross major breakpoint numbers. I.e. 3.2 - 3.7"
671 " is legal; 2 - 5 is legal; but 3.2 - 4.4 is not legal.";
Caroline Ticefb355112010-10-01 17:46:38 +0000672}
673
Enrico Granata886bc3e2011-07-02 00:25:22 +0000674static const char *
Greg Clayton9c236732011-10-26 00:56:27 +0000675GDBFormatHelpTextCallback ()
676{
Greg Clayton966096b2011-10-26 18:35:21 +0000677 return "A GDB format consists of a repeat count, a format letter and a size letter. "
678 "The repeat count is optional and defaults to 1. The format letter is optional "
679 "and defaults to the previous format that was used. The size letter is optional "
680 "and defaults to the previous size that was used.\n"
681 "\n"
682 "Format letters include:\n"
683 "o - octal\n"
684 "x - hexadecimal\n"
685 "d - decimal\n"
686 "u - unsigned decimal\n"
687 "t - binary\n"
688 "f - float\n"
689 "a - address\n"
690 "i - instruction\n"
691 "c - char\n"
692 "s - string\n"
693 "T - OSType\n"
694 "A - float as hex\n"
695 "\n"
696 "Size letters include:\n"
697 "b - 1 byte (byte)\n"
698 "h - 2 bytes (halfword)\n"
699 "w - 4 bytes (word)\n"
700 "g - 8 bytes (giant)\n"
701 "\n"
702 "Example formats:\n"
703 "32xb - show 32 1 byte hexadecimal integer values\n"
704 "16xh - show 16 2 byte hexadecimal integer values\n"
705 "64 - show 64 2 byte hexadecimal integer values (format and size from the last format)\n"
706 "dw - show 1 4 byte decimal integer value\n"
707 ;
Greg Clayton9c236732011-10-26 00:56:27 +0000708}
709
710static const char *
Enrico Granata886bc3e2011-07-02 00:25:22 +0000711FormatHelpTextCallback ()
712{
Enrico Granata1bba6e52011-07-07 00:38:40 +0000713
714 static char* help_text_ptr = NULL;
715
716 if (help_text_ptr)
717 return help_text_ptr;
718
Enrico Granata886bc3e2011-07-02 00:25:22 +0000719 StreamString sstr;
720 sstr << "One of the format names (or one-character names) that can be used to show a variable's value:\n";
721 for (Format f = eFormatDefault; f < kNumFormats; f = Format(f+1))
722 {
Enrico Granata1bba6e52011-07-07 00:38:40 +0000723 if (f != eFormatDefault)
724 sstr.PutChar('\n');
725
Enrico Granata886bc3e2011-07-02 00:25:22 +0000726 char format_char = FormatManager::GetFormatAsFormatChar(f);
727 if (format_char)
728 sstr.Printf("'%c' or ", format_char);
729
Enrico Granata1bba6e52011-07-07 00:38:40 +0000730 sstr.Printf ("\"%s\"", FormatManager::GetFormatAsCString(f));
Enrico Granata886bc3e2011-07-02 00:25:22 +0000731 }
732
733 sstr.Flush();
734
735 std::string data = sstr.GetString();
736
Enrico Granata1bba6e52011-07-07 00:38:40 +0000737 help_text_ptr = new char[data.length()+1];
Enrico Granata886bc3e2011-07-02 00:25:22 +0000738
Enrico Granata1bba6e52011-07-07 00:38:40 +0000739 data.copy(help_text_ptr, data.length());
Enrico Granata886bc3e2011-07-02 00:25:22 +0000740
Enrico Granata1bba6e52011-07-07 00:38:40 +0000741 return help_text_ptr;
Enrico Granata886bc3e2011-07-02 00:25:22 +0000742}
743
744static const char *
Sean Callanan61ff3a32012-10-23 00:50:09 +0000745LanguageTypeHelpTextCallback ()
746{
747 static char* help_text_ptr = NULL;
748
749 if (help_text_ptr)
750 return help_text_ptr;
751
752 StreamString sstr;
753 sstr << "One of the following languages:\n";
754
Daniel Malea25b21092012-12-04 00:23:45 +0000755 for (unsigned int l = eLanguageTypeUnknown; l < eNumLanguageTypes; ++l)
Sean Callanan61ff3a32012-10-23 00:50:09 +0000756 {
Daniel Malea25b21092012-12-04 00:23:45 +0000757 sstr << " " << LanguageRuntime::GetNameForLanguageType(static_cast<LanguageType>(l)) << "\n";
Sean Callanan61ff3a32012-10-23 00:50:09 +0000758 }
759
760 sstr.Flush();
761
762 std::string data = sstr.GetString();
763
764 help_text_ptr = new char[data.length()+1];
765
766 data.copy(help_text_ptr, data.length());
767
768 return help_text_ptr;
769}
770
771static const char *
Enrico Granata1bba6e52011-07-07 00:38:40 +0000772SummaryStringHelpTextCallback()
Enrico Granata886bc3e2011-07-02 00:25:22 +0000773{
Enrico Granata1bba6e52011-07-07 00:38:40 +0000774 return
775 "A summary string is a way to extract information from variables in order to present them using a summary.\n"
776 "Summary strings contain static text, variables, scopes and control sequences:\n"
777 " - Static text can be any sequence of non-special characters, i.e. anything but '{', '}', '$', or '\\'.\n"
778 " - Variables are sequences of characters beginning with ${, ending with } and that contain symbols in the format described below.\n"
779 " - Scopes are any sequence of text between { and }. Anything included in a scope will only appear in the output summary if there were no errors.\n"
780 " - Control sequences are the usual C/C++ '\\a', '\\n', ..., plus '\\$', '\\{' and '\\}'.\n"
781 "A summary string works by copying static text verbatim, turning control sequences into their character counterpart, expanding variables and trying to expand scopes.\n"
782 "A variable is expanded by giving it a value other than its textual representation, and the way this is done depends on what comes after the ${ marker.\n"
783 "The most common sequence if ${var followed by an expression path, which is the text one would type to access a member of an aggregate types, given a variable of that type"
784 " (e.g. if type T has a member named x, which has a member named y, and if t is of type T, the expression path would be .x.y and the way to fit that into a summary string would be"
Enrico Granata91544802011-09-06 19:20:51 +0000785 " ${var.x.y}). You can also use ${*var followed by an expression path and in that case the object referred by the path will be dereferenced before being displayed."
786 " If the object is not a pointer, doing so will cause an error. For additional details on expression paths, you can type 'help expr-path'. \n"
Enrico Granata1bba6e52011-07-07 00:38:40 +0000787 "By default, summary strings attempt to display the summary for any variable they reference, and if that fails the value. If neither can be shown, nothing is displayed."
788 "In a summary string, you can also use an array index [n], or a slice-like range [n-m]. This can have two different meanings depending on what kind of object the expression"
789 " path refers to:\n"
790 " - if it is a scalar type (any basic type like int, float, ...) the expression is a bitfield, i.e. the bits indicated by the indexing operator are extracted out of the number"
791 " and displayed as an individual variable\n"
792 " - if it is an array or pointer the array items indicated by the indexing operator are shown as the result of the variable. if the expression is an array, real array items are"
793 " printed; if it is a pointer, the pointer-as-array syntax is used to obtain the values (this means, the latter case can have no range checking)\n"
Enrico Granata91544802011-09-06 19:20:51 +0000794 "If you are trying to display an array for which the size is known, you can also use [] instead of giving an exact range. This has the effect of showing items 0 thru size - 1.\n"
795 "Additionally, a variable can contain an (optional) format code, as in ${var.x.y%code}, where code can be any of the valid formats described in 'help format', or one of the"
796 " special symbols only allowed as part of a variable:\n"
797 " %V: show the value of the object by default\n"
798 " %S: show the summary of the object by default\n"
799 " %@: show the runtime-provided object description (for Objective-C, it calls NSPrintForDebugger; for C/C++ it does nothing)\n"
800 " %L: show the location of the object (memory address or a register name)\n"
801 " %#: show the number of children of the object\n"
802 " %T: show the type of the object\n"
803 "Another variable that you can use in summary strings is ${svar . This sequence works exactly like ${var, including the fact that ${*svar is an allowed sequence, but uses"
804 " the object's synthetic children provider instead of the actual objects. For instance, if you are using STL synthetic children providers, the following summary string would"
805 " count the number of actual elements stored in an std::list:\n"
806 "type summary add -s \"${svar%#}\" -x \"std::list<\"";
807}
808
809static const char *
810ExprPathHelpTextCallback()
811{
812 return
813 "An expression path is the sequence of symbols that is used in C/C++ to access a member variable of an aggregate object (class).\n"
814 "For instance, given a class:\n"
815 " class foo {\n"
816 " int a;\n"
817 " int b; .\n"
818 " foo* next;\n"
819 " };\n"
820 "the expression to read item b in the item pointed to by next for foo aFoo would be aFoo.next->b.\n"
821 "Given that aFoo could just be any object of type foo, the string '.next->b' is the expression path, because it can be attached to any foo instance to achieve the effect.\n"
822 "Expression paths in LLDB include dot (.) and arrow (->) operators, and most commands using expression paths have ways to also accept the star (*) operator.\n"
823 "The meaning of these operators is the same as the usual one given to them by the C/C++ standards.\n"
824 "LLDB also has support for indexing ([ ]) in expression paths, and extends the traditional meaning of the square brackets operator to allow bitfield extraction:\n"
825 "for objects of native types (int, float, char, ...) saying '[n-m]' as an expression path (where n and m are any positive integers, e.g. [3-5]) causes LLDB to extract"
826 " bits n thru m from the value of the variable. If n == m, [n] is also allowed as a shortcut syntax. For arrays and pointers, expression paths can only contain one index"
827 " and the meaning of the operation is the same as the one defined by C/C++ (item extraction). Some commands extend bitfield-like syntax for arrays and pointers with the"
828 " meaning of array slicing (taking elements n thru m inside the array or pointed-to memory).";
Enrico Granata886bc3e2011-07-02 00:25:22 +0000829}
830
Johnny Chen0576c242011-09-21 01:00:02 +0000831void
Johnny Chencacedfb2011-09-22 22:34:09 +0000832CommandObject::AddIDsArgumentData(CommandArgumentEntry &arg, CommandArgumentType ID, CommandArgumentType IDRange)
Johnny Chen0576c242011-09-21 01:00:02 +0000833{
834 CommandArgumentData id_arg;
835 CommandArgumentData id_range_arg;
836
837 // Create the first variant for the first (and only) argument for this command.
Johnny Chencacedfb2011-09-22 22:34:09 +0000838 id_arg.arg_type = ID;
Johnny Chen0576c242011-09-21 01:00:02 +0000839 id_arg.arg_repetition = eArgRepeatOptional;
840
841 // Create the second variant for the first (and only) argument for this command.
Johnny Chencacedfb2011-09-22 22:34:09 +0000842 id_range_arg.arg_type = IDRange;
Johnny Chen0576c242011-09-21 01:00:02 +0000843 id_range_arg.arg_repetition = eArgRepeatOptional;
844
Johnny Chenf0734cc2011-09-21 01:04:49 +0000845 // The first (and only) argument for this command could be either an id or an id_range.
Johnny Chen0576c242011-09-21 01:00:02 +0000846 // Push both variants into the entry for the first argument for this command.
847 arg.push_back(id_arg);
848 arg.push_back(id_range_arg);
849}
850
Greg Claytonaa378b12011-02-20 02:15:07 +0000851const char *
852CommandObject::GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type)
853{
854 if (arg_type >=0 && arg_type < eArgTypeLastArg)
855 return g_arguments_data[arg_type].arg_name;
856 return NULL;
857
858}
859
860const char *
861CommandObject::GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type)
862{
863 if (arg_type >=0 && arg_type < eArgTypeLastArg)
864 return g_arguments_data[arg_type].help_text;
865 return NULL;
866}
867
Jim Inghamda26bd22012-06-08 21:56:10 +0000868bool
869CommandObjectParsed::Execute (const char *args_string, CommandReturnObject &result)
870{
871 CommandOverrideCallback command_callback = GetOverrideCallback();
872 bool handled = false;
873 Args cmd_args (args_string);
874 if (command_callback)
875 {
876 Args full_args (GetCommandName ());
877 full_args.AppendArguments(cmd_args);
878 handled = command_callback (GetOverrideCallbackBaton(), full_args.GetConstArgumentVector());
879 }
880 if (!handled)
881 {
882 for (size_t i = 0; i < cmd_args.GetArgumentCount(); ++i)
883 {
884 const char *tmp_str = cmd_args.GetArgumentAtIndex (i);
885 if (tmp_str[0] == '`') // back-quote
886 cmd_args.ReplaceArgumentAtIndex (i, m_interpreter.ProcessEmbeddedScriptCommands (tmp_str));
887 }
888
889 if (!CheckFlags(result))
890 return false;
891
892 if (!ParseOptions (cmd_args, result))
893 return false;
894
895 // Call the command-specific version of 'Execute', passing it the already processed arguments.
896 handled = DoExecute (cmd_args, result);
897 }
898 return handled;
899}
900
901bool
902CommandObjectRaw::Execute (const char *args_string, CommandReturnObject &result)
903{
904 CommandOverrideCallback command_callback = GetOverrideCallback();
905 bool handled = false;
906 if (command_callback)
907 {
908 std::string full_command (GetCommandName ());
909 full_command += ' ';
910 full_command += args_string;
911 const char *argv[2] = { NULL, NULL };
912 argv[0] = full_command.c_str();
913 handled = command_callback (GetOverrideCallbackBaton(), argv);
914 }
915 if (!handled)
916 {
917 if (!CheckFlags(result))
918 return false;
919 else
920 handled = DoExecute (args_string, result);
921 }
922 return handled;
923}
924
Johnny Chen746323a2012-05-26 00:32:39 +0000925static
926const char *arch_helper()
927{
Greg Claytondc43bbf2012-05-26 17:21:14 +0000928 static StreamString g_archs_help;
Johnny Chene23940f2012-05-29 20:04:10 +0000929 if (g_archs_help.Empty())
Greg Claytondc43bbf2012-05-26 17:21:14 +0000930 {
931 StringList archs;
932 ArchSpec::AutoComplete(NULL, archs);
933 g_archs_help.Printf("These are the supported architecture names:\n");
Johnny Chene23940f2012-05-29 20:04:10 +0000934 archs.Join("\n", g_archs_help);
Greg Claytondc43bbf2012-05-26 17:21:14 +0000935 }
936 return g_archs_help.GetData();
Johnny Chen746323a2012-05-26 00:32:39 +0000937}
938
Caroline Ticefb355112010-10-01 17:46:38 +0000939CommandObject::ArgumentTableEntry
940CommandObject::g_arguments_data[] =
941{
Enrico Granata9ae9fd32011-07-07 15:49:54 +0000942 { eArgTypeAddress, "address", CommandCompletions::eNoCompletion, { NULL, false }, "A valid address in the target program's execution space." },
943 { eArgTypeAliasName, "alias-name", CommandCompletions::eNoCompletion, { NULL, false }, "The name of an abbreviation (alias) for a debugger command." },
944 { eArgTypeAliasOptions, "options-for-aliased-command", CommandCompletions::eNoCompletion, { NULL, false }, "Command options to be used as part of an alias (abbreviation) definition. (See 'help commands alias' for more information.)" },
Johnny Chen746323a2012-05-26 00:32:39 +0000945 { eArgTypeArchitecture, "arch", CommandCompletions::eArchitectureCompletion, { arch_helper, true }, "The architecture name, e.g. i386 or x86_64." },
Enrico Granata9ae9fd32011-07-07 15:49:54 +0000946 { eArgTypeBoolean, "boolean", CommandCompletions::eNoCompletion, { NULL, false }, "A Boolean value: 'true' or 'false'" },
947 { eArgTypeBreakpointID, "breakpt-id", CommandCompletions::eNoCompletion, { BreakpointIDHelpTextCallback, false }, NULL },
948 { eArgTypeBreakpointIDRange, "breakpt-id-list", CommandCompletions::eNoCompletion, { BreakpointIDRangeHelpTextCallback, false }, NULL },
949 { eArgTypeByteSize, "byte-size", CommandCompletions::eNoCompletion, { NULL, false }, "Number of bytes to use." },
950 { eArgTypeClassName, "class-name", CommandCompletions::eNoCompletion, { NULL, false }, "Then name of a class from the debug information in the program." },
951 { eArgTypeCommandName, "cmd-name", CommandCompletions::eNoCompletion, { NULL, false }, "A debugger command (may be multiple words), without any options or arguments." },
952 { eArgTypeCount, "count", CommandCompletions::eNoCompletion, { NULL, false }, "An unsigned integer." },
Sean Callanan9a91ef62012-10-24 01:12:14 +0000953 { eArgTypeDirectoryName, "directory", CommandCompletions::eDiskDirectoryCompletion, { NULL, false }, "A directory name." },
Enrico Granata9ae9fd32011-07-07 15:49:54 +0000954 { eArgTypeEndAddress, "end-address", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." },
955 { eArgTypeExpression, "expr", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." },
Enrico Granata91544802011-09-06 19:20:51 +0000956 { eArgTypeExpressionPath, "expr-path", CommandCompletions::eNoCompletion, { ExprPathHelpTextCallback, true }, NULL },
Enrico Granata9ae9fd32011-07-07 15:49:54 +0000957 { eArgTypeExprFormat, "expression-format", CommandCompletions::eNoCompletion, { NULL, false }, "[ [bool|b] | [bin] | [char|c] | [oct|o] | [dec|i|d|u] | [hex|x] | [float|f] | [cstr|s] ]" },
958 { eArgTypeFilename, "filename", CommandCompletions::eDiskFileCompletion, { NULL, false }, "The name of a file (can include path)." },
959 { eArgTypeFormat, "format", CommandCompletions::eNoCompletion, { FormatHelpTextCallback, true }, NULL },
960 { eArgTypeFrameIndex, "frame-index", CommandCompletions::eNoCompletion, { NULL, false }, "Index into a thread's list of frames." },
961 { eArgTypeFullName, "fullname", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." },
962 { eArgTypeFunctionName, "function-name", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a function." },
Sean Callanan3bfaad62012-09-13 21:11:40 +0000963 { eArgTypeFunctionOrSymbol, "function-or-symbol", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a function or symbol." },
Greg Clayton9c236732011-10-26 00:56:27 +0000964 { eArgTypeGDBFormat, "gdb-format", CommandCompletions::eNoCompletion, { GDBFormatHelpTextCallback, true }, NULL },
Enrico Granata9ae9fd32011-07-07 15:49:54 +0000965 { eArgTypeIndex, "index", CommandCompletions::eNoCompletion, { NULL, false }, "An index into a list." },
Sean Callanan61ff3a32012-10-23 00:50:09 +0000966 { eArgTypeLanguage, "language", CommandCompletions::eNoCompletion, { LanguageTypeHelpTextCallback, true }, NULL },
Enrico Granata9ae9fd32011-07-07 15:49:54 +0000967 { eArgTypeLineNum, "linenum", CommandCompletions::eNoCompletion, { NULL, false }, "Line number in a source file." },
968 { eArgTypeLogCategory, "log-category", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a category within a log channel, e.g. all (try \"log list\" to see a list of all channels and their categories." },
969 { eArgTypeLogChannel, "log-channel", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a log channel, e.g. process.gdb-remote (try \"log list\" to see a list of all channels and their categories)." },
970 { eArgTypeMethod, "method", CommandCompletions::eNoCompletion, { NULL, false }, "A C++ method name." },
971 { eArgTypeName, "name", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." },
972 { eArgTypeNewPathPrefix, "new-path-prefix", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." },
973 { eArgTypeNumLines, "num-lines", CommandCompletions::eNoCompletion, { NULL, false }, "The number of lines to use." },
974 { eArgTypeNumberPerLine, "number-per-line", CommandCompletions::eNoCompletion, { NULL, false }, "The number of items per line to display." },
975 { eArgTypeOffset, "offset", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." },
976 { eArgTypeOldPathPrefix, "old-path-prefix", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." },
977 { eArgTypeOneLiner, "one-line-command", CommandCompletions::eNoCompletion, { NULL, false }, "A command that is entered as a single line of text." },
Enrico Granata9ae9fd32011-07-07 15:49:54 +0000978 { eArgTypePid, "pid", CommandCompletions::eNoCompletion, { NULL, false }, "The process ID number." },
979 { eArgTypePlugin, "plugin", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." },
980 { eArgTypeProcessName, "process-name", CommandCompletions::eNoCompletion, { NULL, false }, "The name of the process." },
Enrico Granata91544802011-09-06 19:20:51 +0000981 { eArgTypePythonClass, "python-class", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a Python class." },
982 { eArgTypePythonFunction, "python-function", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a Python function." },
983 { eArgTypePythonScript, "python-script", CommandCompletions::eNoCompletion, { NULL, false }, "Source code written in Python." },
Enrico Granata9ae9fd32011-07-07 15:49:54 +0000984 { eArgTypeQueueName, "queue-name", CommandCompletions::eNoCompletion, { NULL, false }, "The name of the thread queue." },
Jim Ingham811708c2012-08-23 23:37:31 +0000985 { eArgTypeRegisterName, "register-name", CommandCompletions::eNoCompletion, { RegisterNameHelpTextCallback, true }, NULL },
Enrico Granata9ae9fd32011-07-07 15:49:54 +0000986 { eArgTypeRegularExpression, "regular-expression", CommandCompletions::eNoCompletion, { NULL, false }, "A regular expression." },
987 { eArgTypeRunArgs, "run-args", CommandCompletions::eNoCompletion, { NULL, false }, "Arguments to be passed to the target program when it starts executing." },
988 { eArgTypeRunMode, "run-mode", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." },
Enrico Granata6010ace2011-11-07 22:57:04 +0000989 { eArgTypeScriptedCommandSynchronicity, "script-cmd-synchronicity", CommandCompletions::eNoCompletion, { NULL, false }, "The synchronicity to use to run scripted commands with regard to LLDB event system." },
Enrico Granata9ae9fd32011-07-07 15:49:54 +0000990 { eArgTypeScriptLang, "script-language", CommandCompletions::eNoCompletion, { NULL, false }, "The scripting language to be used for script-based commands. Currently only Python is valid." },
991 { eArgTypeSearchWord, "search-word", CommandCompletions::eNoCompletion, { NULL, false }, "The word for which you wish to search for information about." },
992 { eArgTypeSelector, "selector", CommandCompletions::eNoCompletion, { NULL, false }, "An Objective-C selector name." },
993 { eArgTypeSettingIndex, "setting-index", CommandCompletions::eNoCompletion, { NULL, false }, "An index into a settings variable that is an array (try 'settings list' to see all the possible settings variables and their types)." },
994 { eArgTypeSettingKey, "setting-key", CommandCompletions::eNoCompletion, { NULL, false }, "A key into a settings variables that is a dictionary (try 'settings list' to see all the possible settings variables and their types)." },
995 { eArgTypeSettingPrefix, "setting-prefix", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a settable internal debugger variable up to a dot ('.'), e.g. 'target.process.'" },
996 { eArgTypeSettingVariableName, "setting-variable-name", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a settable internal debugger variable. Type 'settings list' to see a complete list of such variables." },
997 { eArgTypeShlibName, "shlib-name", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a shared library." },
998 { eArgTypeSourceFile, "source-file", CommandCompletions::eSourceFileCompletion, { NULL, false }, "The name of a source file.." },
999 { eArgTypeSortOrder, "sort-order", CommandCompletions::eNoCompletion, { NULL, false }, "Specify a sort order when dumping lists." },
1000 { eArgTypeStartAddress, "start-address", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." },
1001 { eArgTypeSummaryString, "summary-string", CommandCompletions::eNoCompletion, { SummaryStringHelpTextCallback, true }, NULL },
1002 { eArgTypeSymbol, "symbol", CommandCompletions::eSymbolCompletion, { NULL, false }, "Any symbol name (function name, variable, argument, etc.)" },
1003 { eArgTypeThreadID, "thread-id", CommandCompletions::eNoCompletion, { NULL, false }, "Thread ID number." },
1004 { eArgTypeThreadIndex, "thread-index", CommandCompletions::eNoCompletion, { NULL, false }, "Index into the process' list of threads." },
1005 { eArgTypeThreadName, "thread-name", CommandCompletions::eNoCompletion, { NULL, false }, "The thread's name." },
Johnny Chen309c89d2011-07-14 22:20:12 +00001006 { eArgTypeUnsignedInteger, "unsigned-integer", CommandCompletions::eNoCompletion, { NULL, false }, "An unsigned integer." },
Enrico Granata9ae9fd32011-07-07 15:49:54 +00001007 { eArgTypeUnixSignal, "unix-signal", CommandCompletions::eNoCompletion, { NULL, false }, "A valid Unix signal name or number (e.g. SIGKILL, KILL or 9)." },
1008 { eArgTypeVarName, "variable-name", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a variable in your program." },
1009 { eArgTypeValue, "value", CommandCompletions::eNoCompletion, { NULL, false }, "A value could be anything, depending on where and how it is used." },
1010 { eArgTypeWidth, "width", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." },
1011 { eArgTypeNone, "none", CommandCompletions::eNoCompletion, { NULL, false }, "No help available for this." },
Johnny Chen58dba3c2011-09-09 23:25:26 +00001012 { eArgTypePlatform, "platform-name", CommandCompletions::ePlatformPluginCompletion, { NULL, false }, "The name of an installed platform plug-in . Type 'platform list' to see a complete list of installed platforms." },
Johnny Chencacedfb2011-09-22 22:34:09 +00001013 { eArgTypeWatchpointID, "watchpt-id", CommandCompletions::eNoCompletion, { NULL, false }, "Watchpoint IDs are positive integers." },
1014 { eArgTypeWatchpointIDRange, "watchpt-id-list", CommandCompletions::eNoCompletion, { NULL, false }, "For example, '1-3' or '1 to 3'." },
Johnny Chen34bbf852011-09-12 23:38:44 +00001015 { eArgTypeWatchType, "watch-type", CommandCompletions::eNoCompletion, { NULL, false }, "Specify the type for a watchpoint." }
Caroline Ticefb355112010-10-01 17:46:38 +00001016};
1017
1018const CommandObject::ArgumentTableEntry*
1019CommandObject::GetArgumentTable ()
1020{
Greg Claytonaa378b12011-02-20 02:15:07 +00001021 // If this assertion fires, then the table above is out of date with the CommandArgumentType enumeration
1022 assert ((sizeof (CommandObject::g_arguments_data) / sizeof (CommandObject::ArgumentTableEntry)) == eArgTypeLastArg);
Caroline Ticefb355112010-10-01 17:46:38 +00001023 return CommandObject::g_arguments_data;
1024}
1025
1026