blob: 5618b6ccc3f35d623f83ae91c18d4166a9f9e40c [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"
Jim Ingham84cdc152010-06-15 19:49:27 +000020#include "lldb/Interpreter/Options.h"
Chris Lattner24943d22010-06-08 16:52:24 +000021
22// These are for the Sourcename completers.
23// FIXME: Make a separate file for the completers.
Greg Clayton5f54ac32011-02-08 05:05:52 +000024#include "lldb/Host/FileSpec.h"
Chris Lattner24943d22010-06-08 16:52:24 +000025#include "lldb/Core/FileSpecList.h"
26#include "lldb/Target/Process.h"
27#include "lldb/Target/Target.h"
28
29#include "lldb/Interpreter/CommandInterpreter.h"
30#include "lldb/Interpreter/CommandReturnObject.h"
31#include "lldb/Interpreter/ScriptInterpreter.h"
32#include "lldb/Interpreter/ScriptInterpreterPython.h"
33
34using namespace lldb;
35using namespace lldb_private;
36
37//-------------------------------------------------------------------------
38// CommandObject
39//-------------------------------------------------------------------------
40
Greg Clayton238c0a12010-09-18 01:14:36 +000041CommandObject::CommandObject
42(
43 CommandInterpreter &interpreter,
44 const char *name,
45 const char *help,
46 const char *syntax,
47 uint32_t flags
48) :
49 m_interpreter (interpreter),
Chris Lattner24943d22010-06-08 16:52:24 +000050 m_cmd_name (name),
51 m_cmd_help_short (),
52 m_cmd_help_long (),
53 m_cmd_syntax (),
Jim Inghamd40f8a62010-07-06 22:46:59 +000054 m_is_alias (false),
Caroline Ticefb355112010-10-01 17:46:38 +000055 m_flags (flags),
56 m_arguments()
Chris Lattner24943d22010-06-08 16:52:24 +000057{
58 if (help && help[0])
59 m_cmd_help_short = help;
60 if (syntax && syntax[0])
61 m_cmd_syntax = syntax;
62}
63
64CommandObject::~CommandObject ()
65{
66}
67
68const char *
69CommandObject::GetHelp ()
70{
71 return m_cmd_help_short.c_str();
72}
73
74const char *
75CommandObject::GetHelpLong ()
76{
77 return m_cmd_help_long.c_str();
78}
79
80const char *
81CommandObject::GetSyntax ()
82{
Caroline Ticefb355112010-10-01 17:46:38 +000083 if (m_cmd_syntax.length() == 0)
84 {
85 StreamString syntax_str;
86 syntax_str.Printf ("%s", GetCommandName());
87 if (GetOptions() != NULL)
Caroline Tice43b014a2010-10-04 22:28:36 +000088 syntax_str.Printf (" <cmd-options>");
Caroline Ticefb355112010-10-01 17:46:38 +000089 if (m_arguments.size() > 0)
90 {
91 syntax_str.Printf (" ");
Sean Callanan9798d7b2012-01-04 19:11:25 +000092 if (WantsRawCommandString())
93 syntax_str.Printf("-- ");
Caroline Ticefb355112010-10-01 17:46:38 +000094 GetFormattedCommandArguments (syntax_str);
95 }
96 m_cmd_syntax = syntax_str.GetData ();
97 }
98
Chris Lattner24943d22010-06-08 16:52:24 +000099 return m_cmd_syntax.c_str();
100}
101
102const char *
103CommandObject::Translate ()
104{
105 //return m_cmd_func_name.c_str();
106 return "This function is currently not implemented.";
107}
108
109const char *
110CommandObject::GetCommandName ()
111{
112 return m_cmd_name.c_str();
113}
114
115void
116CommandObject::SetCommandName (const char *name)
117{
118 m_cmd_name = name;
119}
120
121void
122CommandObject::SetHelp (const char *cstr)
123{
124 m_cmd_help_short = cstr;
125}
126
127void
128CommandObject::SetHelpLong (const char *cstr)
129{
130 m_cmd_help_long = cstr;
131}
132
133void
Enrico Granatae5e34cb2011-08-17 01:30:04 +0000134CommandObject::SetHelpLong (std::string str)
135{
136 m_cmd_help_long = str;
137}
138
139void
Chris Lattner24943d22010-06-08 16:52:24 +0000140CommandObject::SetSyntax (const char *cstr)
141{
142 m_cmd_syntax = cstr;
143}
144
145Options *
146CommandObject::GetOptions ()
147{
148 // By default commands don't have options unless this virtual function
149 // is overridden by base classes.
150 return NULL;
151}
152
153Flags&
154CommandObject::GetFlags()
155{
156 return m_flags;
157}
158
159const Flags&
160CommandObject::GetFlags() const
161{
162 return m_flags;
163}
164
165bool
166CommandObject::ExecuteCommandString
167(
168 const char *command_line,
Chris Lattner24943d22010-06-08 16:52:24 +0000169 CommandReturnObject &result
170)
171{
172 Args command_args(command_line);
Greg Clayton238c0a12010-09-18 01:14:36 +0000173 return ExecuteWithOptions (command_args, result);
Chris Lattner24943d22010-06-08 16:52:24 +0000174}
175
176bool
177CommandObject::ParseOptions
178(
179 Args& args,
Chris Lattner24943d22010-06-08 16:52:24 +0000180 CommandReturnObject &result
181)
182{
183 // See if the subclass has options?
184 Options *options = GetOptions();
185 if (options != NULL)
186 {
187 Error error;
Greg Clayton143fcc32011-04-13 00:18:08 +0000188 options->NotifyOptionParsingStarting();
Chris Lattner24943d22010-06-08 16:52:24 +0000189
190 // ParseOptions calls getopt_long, which always skips the zero'th item in the array and starts at position 1,
191 // so we need to push a dummy value into position zero.
192 args.Unshift("dummy_string");
193 error = args.ParseOptions (*options);
194
195 // The "dummy_string" will have already been removed by ParseOptions,
196 // so no need to remove it.
197
Greg Clayton143fcc32011-04-13 00:18:08 +0000198 if (error.Success())
199 error = options->NotifyOptionParsingFinished();
200
201 if (error.Success())
202 {
203 if (options->VerifyOptions (result))
204 return true;
205 }
206 else
Chris Lattner24943d22010-06-08 16:52:24 +0000207 {
208 const char *error_cstr = error.AsCString();
209 if (error_cstr)
210 {
211 // We got an error string, lets use that
Greg Clayton9c236732011-10-26 00:56:27 +0000212 result.AppendError(error_cstr);
Chris Lattner24943d22010-06-08 16:52:24 +0000213 }
214 else
215 {
216 // No error string, output the usage information into result
Greg Claytonf15996e2011-04-07 22:46:35 +0000217 options->GenerateOptionUsage (result.GetErrorStream(), this);
Chris Lattner24943d22010-06-08 16:52:24 +0000218 }
Chris Lattner24943d22010-06-08 16:52:24 +0000219 }
Greg Clayton143fcc32011-04-13 00:18:08 +0000220 result.SetStatus (eReturnStatusFailed);
221 return false;
Chris Lattner24943d22010-06-08 16:52:24 +0000222 }
223 return true;
224}
225bool
Greg Clayton238c0a12010-09-18 01:14:36 +0000226CommandObject::ExecuteWithOptions (Args& args, CommandReturnObject &result)
Chris Lattner24943d22010-06-08 16:52:24 +0000227{
228 for (size_t i = 0; i < args.GetArgumentCount(); ++i)
229 {
230 const char *tmp_str = args.GetArgumentAtIndex (i);
231 if (tmp_str[0] == '`') // back-quote
Greg Clayton238c0a12010-09-18 01:14:36 +0000232 args.ReplaceArgumentAtIndex (i, m_interpreter.ProcessEmbeddedScriptCommands (tmp_str));
Chris Lattner24943d22010-06-08 16:52:24 +0000233 }
234
Greg Claytone71e2582011-02-04 01:58:07 +0000235 if (GetFlags().AnySet (CommandObject::eFlagProcessMustBeLaunched | CommandObject::eFlagProcessMustBePaused))
Chris Lattner24943d22010-06-08 16:52:24 +0000236 {
Greg Clayton567e7f32011-09-22 04:58:26 +0000237 Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
Greg Claytone71e2582011-02-04 01:58:07 +0000238 if (process == NULL)
Chris Lattner24943d22010-06-08 16:52:24 +0000239 {
Jim Ingham8cc3f692011-07-09 00:55:34 +0000240 // A process that is not running is considered paused.
241 if (GetFlags().Test(CommandObject::eFlagProcessMustBeLaunched))
242 {
243 result.AppendError ("Process must exist.");
244 result.SetStatus (eReturnStatusFailed);
245 return false;
246 }
Chris Lattner24943d22010-06-08 16:52:24 +0000247 }
Greg Claytone71e2582011-02-04 01:58:07 +0000248 else
Chris Lattner24943d22010-06-08 16:52:24 +0000249 {
Greg Claytone71e2582011-02-04 01:58:07 +0000250 StateType state = process->GetState();
251
252 switch (state)
Chris Lattner24943d22010-06-08 16:52:24 +0000253 {
Greg Clayton4fdf7602011-03-20 04:57:14 +0000254 case eStateInvalid:
Greg Claytone71e2582011-02-04 01:58:07 +0000255 case eStateSuspended:
256 case eStateCrashed:
257 case eStateStopped:
258 break;
259
260 case eStateConnected:
261 case eStateAttaching:
262 case eStateLaunching:
263 case eStateDetached:
264 case eStateExited:
265 case eStateUnloaded:
266 if (GetFlags().Test(CommandObject::eFlagProcessMustBeLaunched))
267 {
268 result.AppendError ("Process must be launched.");
269 result.SetStatus (eReturnStatusFailed);
270 return false;
271 }
272 break;
Chris Lattner24943d22010-06-08 16:52:24 +0000273
Greg Claytone71e2582011-02-04 01:58:07 +0000274 case eStateRunning:
275 case eStateStepping:
276 if (GetFlags().Test(CommandObject::eFlagProcessMustBePaused))
277 {
278 result.AppendError ("Process is running. Use 'process interrupt' to pause execution.");
279 result.SetStatus (eReturnStatusFailed);
280 return false;
281 }
Chris Lattner24943d22010-06-08 16:52:24 +0000282 }
283 }
284 }
285
Greg Clayton238c0a12010-09-18 01:14:36 +0000286 if (!ParseOptions (args, result))
Chris Lattner24943d22010-06-08 16:52:24 +0000287 return false;
288
289 // Call the command-specific version of 'Execute', passing it the already processed arguments.
Greg Clayton238c0a12010-09-18 01:14:36 +0000290 return Execute (args, result);
Chris Lattner24943d22010-06-08 16:52:24 +0000291}
292
293class CommandDictCommandPartialMatch
294{
295 public:
296 CommandDictCommandPartialMatch (const char *match_str)
297 {
298 m_match_str = match_str;
299 }
300 bool operator() (const std::pair<std::string, lldb::CommandObjectSP> map_element) const
301 {
302 // A NULL or empty string matches everything.
303 if (m_match_str == NULL || *m_match_str == '\0')
304 return 1;
305
306 size_t found = map_element.first.find (m_match_str, 0);
307 if (found == std::string::npos)
308 return 0;
309 else
310 return found == 0;
311 }
312
313 private:
314 const char *m_match_str;
315};
316
317int
318CommandObject::AddNamesMatchingPartialString (CommandObject::CommandMap &in_map, const char *cmd_str,
319 StringList &matches)
320{
321 int number_added = 0;
322 CommandDictCommandPartialMatch matcher(cmd_str);
323
324 CommandObject::CommandMap::iterator matching_cmds = std::find_if (in_map.begin(), in_map.end(), matcher);
325
326 while (matching_cmds != in_map.end())
327 {
328 ++number_added;
329 matches.AppendString((*matching_cmds).first.c_str());
330 matching_cmds = std::find_if (++matching_cmds, in_map.end(), matcher);;
331 }
332 return number_added;
333}
334
335int
336CommandObject::HandleCompletion
337(
338 Args &input,
339 int &cursor_index,
340 int &cursor_char_position,
341 int match_start_point,
342 int max_return_elements,
Jim Ingham802f8b02010-06-30 05:02:46 +0000343 bool &word_complete,
Chris Lattner24943d22010-06-08 16:52:24 +0000344 StringList &matches
345)
346{
Johnny Chen8042eed2012-01-20 00:59:19 +0000347 // Default implmentation of WantsCompletion() is !WantsRawCommandString().
348 // Subclasses who want raw command string but desire, for example,
349 // argument completion should override WantsCompletion() to return true,
350 // instead.
Johnny Chen120d94d2012-01-19 22:16:06 +0000351 if (WantsRawCommandString() && !WantsCompletion())
Chris Lattner24943d22010-06-08 16:52:24 +0000352 {
353 // FIXME: Abstract telling the completion to insert the completion character.
354 matches.Clear();
355 return -1;
356 }
357 else
358 {
359 // Can we do anything generic with the options?
360 Options *cur_options = GetOptions();
361 CommandReturnObject result;
362 OptionElementVector opt_element_vector;
363
364 if (cur_options != NULL)
365 {
366 // Re-insert the dummy command name string which will have been
367 // stripped off:
368 input.Unshift ("dummy-string");
369 cursor_index++;
370
371
372 // I stick an element on the end of the input, because if the last element is
373 // option that requires an argument, getopt_long will freak out.
374
375 input.AppendArgument ("<FAKE-VALUE>");
376
Jim Inghamadb84292010-06-24 20:31:04 +0000377 input.ParseArgsForCompletion (*cur_options, opt_element_vector, cursor_index);
Chris Lattner24943d22010-06-08 16:52:24 +0000378
379 input.DeleteArgumentAtIndex(input.GetArgumentCount() - 1);
380
381 bool handled_by_options;
Greg Claytonf15996e2011-04-07 22:46:35 +0000382 handled_by_options = cur_options->HandleOptionCompletion (input,
Greg Clayton63094e02010-06-23 01:19:29 +0000383 opt_element_vector,
384 cursor_index,
385 cursor_char_position,
386 match_start_point,
387 max_return_elements,
Jim Ingham802f8b02010-06-30 05:02:46 +0000388 word_complete,
Greg Clayton63094e02010-06-23 01:19:29 +0000389 matches);
Chris Lattner24943d22010-06-08 16:52:24 +0000390 if (handled_by_options)
391 return matches.GetSize();
392 }
393
394 // If we got here, the last word is not an option or an option argument.
Greg Clayton238c0a12010-09-18 01:14:36 +0000395 return HandleArgumentCompletion (input,
Greg Clayton63094e02010-06-23 01:19:29 +0000396 cursor_index,
397 cursor_char_position,
398 opt_element_vector,
399 match_start_point,
400 max_return_elements,
Jim Ingham802f8b02010-06-30 05:02:46 +0000401 word_complete,
Greg Clayton63094e02010-06-23 01:19:29 +0000402 matches);
Chris Lattner24943d22010-06-08 16:52:24 +0000403 }
404}
405
Chris Lattner24943d22010-06-08 16:52:24 +0000406bool
Greg Clayton238c0a12010-09-18 01:14:36 +0000407CommandObject::HelpTextContainsWord (const char *search_word)
Chris Lattner24943d22010-06-08 16:52:24 +0000408{
409 const char *short_help;
410 const char *long_help;
411 const char *syntax_help;
412 std::string options_usage_help;
413
414
415 bool found_word = false;
416
417 short_help = GetHelp();
418 long_help = GetHelpLong();
419 syntax_help = GetSyntax();
420
Caroline Tice34391782010-10-12 22:16:53 +0000421 if (strcasestr (short_help, search_word))
Chris Lattner24943d22010-06-08 16:52:24 +0000422 found_word = true;
Caroline Tice34391782010-10-12 22:16:53 +0000423 else if (strcasestr (long_help, search_word))
Chris Lattner24943d22010-06-08 16:52:24 +0000424 found_word = true;
Caroline Tice34391782010-10-12 22:16:53 +0000425 else if (strcasestr (syntax_help, search_word))
Chris Lattner24943d22010-06-08 16:52:24 +0000426 found_word = true;
427
428 if (!found_word
429 && GetOptions() != NULL)
430 {
431 StreamString usage_help;
Greg Claytonf15996e2011-04-07 22:46:35 +0000432 GetOptions()->GenerateOptionUsage (usage_help, this);
Chris Lattner24943d22010-06-08 16:52:24 +0000433 if (usage_help.GetSize() > 0)
434 {
435 const char *usage_text = usage_help.GetData();
Caroline Tice34391782010-10-12 22:16:53 +0000436 if (strcasestr (usage_text, search_word))
Chris Lattner24943d22010-06-08 16:52:24 +0000437 found_word = true;
438 }
439 }
440
441 return found_word;
442}
Caroline Ticefb355112010-10-01 17:46:38 +0000443
444int
445CommandObject::GetNumArgumentEntries ()
446{
447 return m_arguments.size();
448}
449
450CommandObject::CommandArgumentEntry *
451CommandObject::GetArgumentEntryAtIndex (int idx)
452{
453 if (idx < m_arguments.size())
454 return &(m_arguments[idx]);
455
456 return NULL;
457}
458
459CommandObject::ArgumentTableEntry *
460CommandObject::FindArgumentDataByType (CommandArgumentType arg_type)
461{
462 const ArgumentTableEntry *table = CommandObject::GetArgumentTable();
463
464 for (int i = 0; i < eArgTypeLastArg; ++i)
465 if (table[i].arg_type == arg_type)
466 return (ArgumentTableEntry *) &(table[i]);
467
468 return NULL;
469}
470
471void
472CommandObject::GetArgumentHelp (Stream &str, CommandArgumentType arg_type, CommandInterpreter &interpreter)
473{
474 const ArgumentTableEntry* table = CommandObject::GetArgumentTable();
475 ArgumentTableEntry *entry = (ArgumentTableEntry *) &(table[arg_type]);
476
477 // The table is *supposed* to be kept in arg_type order, but someone *could* have messed it up...
478
479 if (entry->arg_type != arg_type)
480 entry = CommandObject::FindArgumentDataByType (arg_type);
481
482 if (!entry)
483 return;
484
485 StreamString name_str;
486 name_str.Printf ("<%s>", entry->arg_name);
487
Enrico Granataff782382011-07-08 02:51:01 +0000488 if (entry->help_function)
Enrico Granata1bba6e52011-07-07 00:38:40 +0000489 {
Enrico Granataff782382011-07-08 02:51:01 +0000490 const char* help_text = entry->help_function();
Enrico Granata1bba6e52011-07-07 00:38:40 +0000491 if (!entry->help_function.self_formatting)
492 {
493 interpreter.OutputFormattedHelpText (str, name_str.GetData(), "--", help_text,
494 name_str.GetSize());
495 }
496 else
497 {
498 interpreter.OutputHelpText(str, name_str.GetData(), "--", help_text,
499 name_str.GetSize());
500 }
501 }
Caroline Ticefb355112010-10-01 17:46:38 +0000502 else
503 interpreter.OutputFormattedHelpText (str, name_str.GetData(), "--", entry->help_text, name_str.GetSize());
504}
505
506const char *
507CommandObject::GetArgumentName (CommandArgumentType arg_type)
508{
Caroline Tice4d6675c2010-10-01 19:59:14 +0000509 ArgumentTableEntry *entry = (ArgumentTableEntry *) &(CommandObject::GetArgumentTable()[arg_type]);
510
511 // The table is *supposed* to be kept in arg_type order, but someone *could* have messed it up...
512
513 if (entry->arg_type != arg_type)
514 entry = CommandObject::FindArgumentDataByType (arg_type);
515
Johnny Chen25ca9842010-10-08 22:01:52 +0000516 if (entry)
517 return entry->arg_name;
518
519 StreamString str;
520 str << "Arg name for type (" << arg_type << ") not in arg table!";
521 return str.GetData();
Caroline Ticefb355112010-10-01 17:46:38 +0000522}
523
Caroline Tice43b014a2010-10-04 22:28:36 +0000524bool
Greg Claytonb3448432011-03-24 21:19:54 +0000525CommandObject::IsPairType (ArgumentRepetitionType arg_repeat_type)
Caroline Tice43b014a2010-10-04 22:28:36 +0000526{
527 if ((arg_repeat_type == eArgRepeatPairPlain)
528 || (arg_repeat_type == eArgRepeatPairOptional)
529 || (arg_repeat_type == eArgRepeatPairPlus)
530 || (arg_repeat_type == eArgRepeatPairStar)
531 || (arg_repeat_type == eArgRepeatPairRange)
532 || (arg_repeat_type == eArgRepeatPairRangeOptional))
533 return true;
534
535 return false;
536}
537
Johnny Chen6183fcc2012-02-08 01:13:31 +0000538static CommandObject::CommandArgumentEntry
539OptSetFiltered(uint32_t opt_set_mask, CommandObject::CommandArgumentEntry &cmd_arg_entry)
540{
541 CommandObject::CommandArgumentEntry ret_val;
542 for (unsigned i = 0; i < cmd_arg_entry.size(); ++i)
543 if (opt_set_mask & cmd_arg_entry[i].arg_opt_set_association)
544 ret_val.push_back(cmd_arg_entry[i]);
545 return ret_val;
546}
547
548// Default parameter value of opt_set_mask is LLDB_OPT_SET_ALL, which means take
549// all the argument data into account. On rare cases where some argument sticks
550// with certain option sets, this function returns the option set filtered args.
Caroline Ticefb355112010-10-01 17:46:38 +0000551void
Johnny Chen6183fcc2012-02-08 01:13:31 +0000552CommandObject::GetFormattedCommandArguments (Stream &str, uint32_t opt_set_mask)
Caroline Ticefb355112010-10-01 17:46:38 +0000553{
554 int num_args = m_arguments.size();
555 for (int i = 0; i < num_args; ++i)
556 {
557 if (i > 0)
558 str.Printf (" ");
Johnny Chen6183fcc2012-02-08 01:13:31 +0000559 CommandArgumentEntry arg_entry =
560 opt_set_mask == LLDB_OPT_SET_ALL ? m_arguments[i]
561 : OptSetFiltered(opt_set_mask, m_arguments[i]);
Caroline Ticefb355112010-10-01 17:46:38 +0000562 int num_alternatives = arg_entry.size();
Caroline Tice43b014a2010-10-04 22:28:36 +0000563
564 if ((num_alternatives == 2)
565 && IsPairType (arg_entry[0].arg_repetition))
Caroline Ticefb355112010-10-01 17:46:38 +0000566 {
Caroline Tice43b014a2010-10-04 22:28:36 +0000567 const char *first_name = GetArgumentName (arg_entry[0].arg_type);
568 const char *second_name = GetArgumentName (arg_entry[1].arg_type);
569 switch (arg_entry[0].arg_repetition)
570 {
571 case eArgRepeatPairPlain:
572 str.Printf ("<%s> <%s>", first_name, second_name);
573 break;
574 case eArgRepeatPairOptional:
575 str.Printf ("[<%s> <%s>]", first_name, second_name);
576 break;
577 case eArgRepeatPairPlus:
578 str.Printf ("<%s> <%s> [<%s> <%s> [...]]", first_name, second_name, first_name, second_name);
579 break;
580 case eArgRepeatPairStar:
581 str.Printf ("[<%s> <%s> [<%s> <%s> [...]]]", first_name, second_name, first_name, second_name);
582 break;
583 case eArgRepeatPairRange:
584 str.Printf ("<%s_1> <%s_1> ... <%s_n> <%s_n>", first_name, second_name, first_name, second_name);
585 break;
586 case eArgRepeatPairRangeOptional:
587 str.Printf ("[<%s_1> <%s_1> ... <%s_n> <%s_n>]", first_name, second_name, first_name, second_name);
588 break;
Caroline Ticeb5772842011-03-23 22:31:13 +0000589 // Explicitly test for all the rest of the cases, so if new types get added we will notice the
590 // missing case statement(s).
591 case eArgRepeatPlain:
592 case eArgRepeatOptional:
593 case eArgRepeatPlus:
594 case eArgRepeatStar:
595 case eArgRepeatRange:
596 // These should not be reached, as they should fail the IsPairType test above.
597 break;
Caroline Tice43b014a2010-10-04 22:28:36 +0000598 }
Caroline Ticefb355112010-10-01 17:46:38 +0000599 }
Caroline Tice43b014a2010-10-04 22:28:36 +0000600 else
Caroline Ticefb355112010-10-01 17:46:38 +0000601 {
Caroline Tice43b014a2010-10-04 22:28:36 +0000602 StreamString names;
603 for (int j = 0; j < num_alternatives; ++j)
604 {
605 if (j > 0)
606 names.Printf (" | ");
607 names.Printf ("%s", GetArgumentName (arg_entry[j].arg_type));
608 }
609 switch (arg_entry[0].arg_repetition)
610 {
611 case eArgRepeatPlain:
612 str.Printf ("<%s>", names.GetData());
613 break;
614 case eArgRepeatPlus:
615 str.Printf ("<%s> [<%s> [...]]", names.GetData(), names.GetData());
616 break;
617 case eArgRepeatStar:
618 str.Printf ("[<%s> [<%s> [...]]]", names.GetData(), names.GetData());
619 break;
620 case eArgRepeatOptional:
621 str.Printf ("[<%s>]", names.GetData());
622 break;
623 case eArgRepeatRange:
Jason Molenda7e5fa7f2011-09-20 21:44:10 +0000624 str.Printf ("<%s_1> .. <%s_n>", names.GetData(), names.GetData());
Caroline Ticeb5772842011-03-23 22:31:13 +0000625 break;
626 // Explicitly test for all the rest of the cases, so if new types get added we will notice the
627 // missing case statement(s).
628 case eArgRepeatPairPlain:
629 case eArgRepeatPairOptional:
630 case eArgRepeatPairPlus:
631 case eArgRepeatPairStar:
632 case eArgRepeatPairRange:
633 case eArgRepeatPairRangeOptional:
634 // These should not be hit, as they should pass the IsPairType test above, and control should
635 // have gone into the other branch of the if statement.
636 break;
Caroline Tice43b014a2010-10-04 22:28:36 +0000637 }
Caroline Ticefb355112010-10-01 17:46:38 +0000638 }
639 }
640}
641
Stephen Wilson47f07852011-03-23 02:12:10 +0000642CommandArgumentType
Caroline Ticefb355112010-10-01 17:46:38 +0000643CommandObject::LookupArgumentName (const char *arg_name)
644{
645 CommandArgumentType return_type = eArgTypeLastArg;
646
647 std::string arg_name_str (arg_name);
648 size_t len = arg_name_str.length();
649 if (arg_name[0] == '<'
650 && arg_name[len-1] == '>')
651 arg_name_str = arg_name_str.substr (1, len-2);
652
Johnny Chen309c89d2011-07-14 22:20:12 +0000653 const ArgumentTableEntry *table = GetArgumentTable();
Caroline Ticefb355112010-10-01 17:46:38 +0000654 for (int i = 0; i < eArgTypeLastArg; ++i)
Johnny Chen309c89d2011-07-14 22:20:12 +0000655 if (arg_name_str.compare (table[i].arg_name) == 0)
Caroline Ticefb355112010-10-01 17:46:38 +0000656 return_type = g_arguments_data[i].arg_type;
657
658 return return_type;
659}
660
661static const char *
662BreakpointIDHelpTextCallback ()
663{
Greg Clayton9c236732011-10-26 00:56:27 +0000664 return "Breakpoint ID's consist major and minor numbers; the major number "
665 "corresponds to the single entity that was created with a 'breakpoint set' "
666 "command; the minor numbers correspond to all the locations that were actually "
667 "found/set based on the major breakpoint. A full breakpoint ID might look like "
668 "3.14, meaning the 14th location set for the 3rd breakpoint. You can specify "
669 "all the locations of a breakpoint by just indicating the major breakpoint "
670 "number. A valid breakpoint id consists either of just the major id number, "
671 "or the major number, a dot, and the location number (e.g. 3 or 3.2 could "
672 "both be valid breakpoint ids).";
Caroline Ticefb355112010-10-01 17:46:38 +0000673}
674
675static const char *
676BreakpointIDRangeHelpTextCallback ()
677{
Greg Clayton9c236732011-10-26 00:56:27 +0000678 return "A 'breakpoint id list' is a manner of specifying multiple breakpoints. "
679 "This can be done through several mechanisms. The easiest way is to just "
680 "enter a space-separated list of breakpoint ids. To specify all the "
681 "breakpoint locations under a major breakpoint, you can use the major "
682 "breakpoint number followed by '.*', eg. '5.*' means all the locations under "
683 "breakpoint 5. You can also indicate a range of breakpoints by using "
684 "<start-bp-id> - <end-bp-id>. The start-bp-id and end-bp-id for a range can "
685 "be any valid breakpoint ids. It is not legal, however, to specify a range "
686 "using specific locations that cross major breakpoint numbers. I.e. 3.2 - 3.7"
687 " is legal; 2 - 5 is legal; but 3.2 - 4.4 is not legal.";
Caroline Ticefb355112010-10-01 17:46:38 +0000688}
689
Enrico Granata886bc3e2011-07-02 00:25:22 +0000690static const char *
Greg Clayton9c236732011-10-26 00:56:27 +0000691GDBFormatHelpTextCallback ()
692{
Greg Clayton966096b2011-10-26 18:35:21 +0000693 return "A GDB format consists of a repeat count, a format letter and a size letter. "
694 "The repeat count is optional and defaults to 1. The format letter is optional "
695 "and defaults to the previous format that was used. The size letter is optional "
696 "and defaults to the previous size that was used.\n"
697 "\n"
698 "Format letters include:\n"
699 "o - octal\n"
700 "x - hexadecimal\n"
701 "d - decimal\n"
702 "u - unsigned decimal\n"
703 "t - binary\n"
704 "f - float\n"
705 "a - address\n"
706 "i - instruction\n"
707 "c - char\n"
708 "s - string\n"
709 "T - OSType\n"
710 "A - float as hex\n"
711 "\n"
712 "Size letters include:\n"
713 "b - 1 byte (byte)\n"
714 "h - 2 bytes (halfword)\n"
715 "w - 4 bytes (word)\n"
716 "g - 8 bytes (giant)\n"
717 "\n"
718 "Example formats:\n"
719 "32xb - show 32 1 byte hexadecimal integer values\n"
720 "16xh - show 16 2 byte hexadecimal integer values\n"
721 "64 - show 64 2 byte hexadecimal integer values (format and size from the last format)\n"
722 "dw - show 1 4 byte decimal integer value\n"
723 ;
Greg Clayton9c236732011-10-26 00:56:27 +0000724}
725
726static const char *
Enrico Granata886bc3e2011-07-02 00:25:22 +0000727FormatHelpTextCallback ()
728{
Enrico Granata1bba6e52011-07-07 00:38:40 +0000729
730 static char* help_text_ptr = NULL;
731
732 if (help_text_ptr)
733 return help_text_ptr;
734
Enrico Granata886bc3e2011-07-02 00:25:22 +0000735 StreamString sstr;
736 sstr << "One of the format names (or one-character names) that can be used to show a variable's value:\n";
737 for (Format f = eFormatDefault; f < kNumFormats; f = Format(f+1))
738 {
Enrico Granata1bba6e52011-07-07 00:38:40 +0000739 if (f != eFormatDefault)
740 sstr.PutChar('\n');
741
Enrico Granata886bc3e2011-07-02 00:25:22 +0000742 char format_char = FormatManager::GetFormatAsFormatChar(f);
743 if (format_char)
744 sstr.Printf("'%c' or ", format_char);
745
Enrico Granata1bba6e52011-07-07 00:38:40 +0000746 sstr.Printf ("\"%s\"", FormatManager::GetFormatAsCString(f));
Enrico Granata886bc3e2011-07-02 00:25:22 +0000747 }
748
749 sstr.Flush();
750
751 std::string data = sstr.GetString();
752
Enrico Granata1bba6e52011-07-07 00:38:40 +0000753 help_text_ptr = new char[data.length()+1];
Enrico Granata886bc3e2011-07-02 00:25:22 +0000754
Enrico Granata1bba6e52011-07-07 00:38:40 +0000755 data.copy(help_text_ptr, data.length());
Enrico Granata886bc3e2011-07-02 00:25:22 +0000756
Enrico Granata1bba6e52011-07-07 00:38:40 +0000757 return help_text_ptr;
Enrico Granata886bc3e2011-07-02 00:25:22 +0000758}
759
760static const char *
Enrico Granata1bba6e52011-07-07 00:38:40 +0000761SummaryStringHelpTextCallback()
Enrico Granata886bc3e2011-07-02 00:25:22 +0000762{
Enrico Granata1bba6e52011-07-07 00:38:40 +0000763 return
764 "A summary string is a way to extract information from variables in order to present them using a summary.\n"
765 "Summary strings contain static text, variables, scopes and control sequences:\n"
766 " - Static text can be any sequence of non-special characters, i.e. anything but '{', '}', '$', or '\\'.\n"
767 " - Variables are sequences of characters beginning with ${, ending with } and that contain symbols in the format described below.\n"
768 " - 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"
769 " - Control sequences are the usual C/C++ '\\a', '\\n', ..., plus '\\$', '\\{' and '\\}'.\n"
770 "A summary string works by copying static text verbatim, turning control sequences into their character counterpart, expanding variables and trying to expand scopes.\n"
771 "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"
772 "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"
773 " (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 +0000774 " ${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."
775 " 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 +0000776 "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."
777 "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"
778 " path refers to:\n"
779 " - 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"
780 " and displayed as an individual variable\n"
781 " - 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"
782 " 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 +0000783 "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"
784 "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"
785 " special symbols only allowed as part of a variable:\n"
786 " %V: show the value of the object by default\n"
787 " %S: show the summary of the object by default\n"
788 " %@: show the runtime-provided object description (for Objective-C, it calls NSPrintForDebugger; for C/C++ it does nothing)\n"
789 " %L: show the location of the object (memory address or a register name)\n"
790 " %#: show the number of children of the object\n"
791 " %T: show the type of the object\n"
792 "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"
793 " 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"
794 " count the number of actual elements stored in an std::list:\n"
795 "type summary add -s \"${svar%#}\" -x \"std::list<\"";
796}
797
798static const char *
799ExprPathHelpTextCallback()
800{
801 return
802 "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"
803 "For instance, given a class:\n"
804 " class foo {\n"
805 " int a;\n"
806 " int b; .\n"
807 " foo* next;\n"
808 " };\n"
809 "the expression to read item b in the item pointed to by next for foo aFoo would be aFoo.next->b.\n"
810 "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"
811 "Expression paths in LLDB include dot (.) and arrow (->) operators, and most commands using expression paths have ways to also accept the star (*) operator.\n"
812 "The meaning of these operators is the same as the usual one given to them by the C/C++ standards.\n"
813 "LLDB also has support for indexing ([ ]) in expression paths, and extends the traditional meaning of the square brackets operator to allow bitfield extraction:\n"
814 "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"
815 " 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"
816 " 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"
817 " meaning of array slicing (taking elements n thru m inside the array or pointed-to memory).";
Enrico Granata886bc3e2011-07-02 00:25:22 +0000818}
819
Johnny Chen0576c242011-09-21 01:00:02 +0000820void
Johnny Chencacedfb2011-09-22 22:34:09 +0000821CommandObject::AddIDsArgumentData(CommandArgumentEntry &arg, CommandArgumentType ID, CommandArgumentType IDRange)
Johnny Chen0576c242011-09-21 01:00:02 +0000822{
823 CommandArgumentData id_arg;
824 CommandArgumentData id_range_arg;
825
826 // Create the first variant for the first (and only) argument for this command.
Johnny Chencacedfb2011-09-22 22:34:09 +0000827 id_arg.arg_type = ID;
Johnny Chen0576c242011-09-21 01:00:02 +0000828 id_arg.arg_repetition = eArgRepeatOptional;
829
830 // Create the second variant for the first (and only) argument for this command.
Johnny Chencacedfb2011-09-22 22:34:09 +0000831 id_range_arg.arg_type = IDRange;
Johnny Chen0576c242011-09-21 01:00:02 +0000832 id_range_arg.arg_repetition = eArgRepeatOptional;
833
Johnny Chenf0734cc2011-09-21 01:04:49 +0000834 // The first (and only) argument for this command could be either an id or an id_range.
Johnny Chen0576c242011-09-21 01:00:02 +0000835 // Push both variants into the entry for the first argument for this command.
836 arg.push_back(id_arg);
837 arg.push_back(id_range_arg);
838}
839
Greg Claytonaa378b12011-02-20 02:15:07 +0000840const char *
841CommandObject::GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type)
842{
843 if (arg_type >=0 && arg_type < eArgTypeLastArg)
844 return g_arguments_data[arg_type].arg_name;
845 return NULL;
846
847}
848
849const char *
850CommandObject::GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type)
851{
852 if (arg_type >=0 && arg_type < eArgTypeLastArg)
853 return g_arguments_data[arg_type].help_text;
854 return NULL;
855}
856
Caroline Ticefb355112010-10-01 17:46:38 +0000857CommandObject::ArgumentTableEntry
858CommandObject::g_arguments_data[] =
859{
Enrico Granata9ae9fd32011-07-07 15:49:54 +0000860 { eArgTypeAddress, "address", CommandCompletions::eNoCompletion, { NULL, false }, "A valid address in the target program's execution space." },
861 { eArgTypeAliasName, "alias-name", CommandCompletions::eNoCompletion, { NULL, false }, "The name of an abbreviation (alias) for a debugger command." },
862 { 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.)" },
863 { eArgTypeArchitecture, "arch", CommandCompletions::eArchitectureCompletion, { NULL, false }, "The architecture name, e.g. i386 or x86_64." },
864 { eArgTypeBoolean, "boolean", CommandCompletions::eNoCompletion, { NULL, false }, "A Boolean value: 'true' or 'false'" },
865 { eArgTypeBreakpointID, "breakpt-id", CommandCompletions::eNoCompletion, { BreakpointIDHelpTextCallback, false }, NULL },
866 { eArgTypeBreakpointIDRange, "breakpt-id-list", CommandCompletions::eNoCompletion, { BreakpointIDRangeHelpTextCallback, false }, NULL },
867 { eArgTypeByteSize, "byte-size", CommandCompletions::eNoCompletion, { NULL, false }, "Number of bytes to use." },
868 { eArgTypeClassName, "class-name", CommandCompletions::eNoCompletion, { NULL, false }, "Then name of a class from the debug information in the program." },
869 { eArgTypeCommandName, "cmd-name", CommandCompletions::eNoCompletion, { NULL, false }, "A debugger command (may be multiple words), without any options or arguments." },
870 { eArgTypeCount, "count", CommandCompletions::eNoCompletion, { NULL, false }, "An unsigned integer." },
871 { eArgTypeEndAddress, "end-address", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." },
872 { eArgTypeExpression, "expr", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." },
Enrico Granata91544802011-09-06 19:20:51 +0000873 { eArgTypeExpressionPath, "expr-path", CommandCompletions::eNoCompletion, { ExprPathHelpTextCallback, true }, NULL },
Enrico Granata9ae9fd32011-07-07 15:49:54 +0000874 { eArgTypeExprFormat, "expression-format", CommandCompletions::eNoCompletion, { NULL, false }, "[ [bool|b] | [bin] | [char|c] | [oct|o] | [dec|i|d|u] | [hex|x] | [float|f] | [cstr|s] ]" },
875 { eArgTypeFilename, "filename", CommandCompletions::eDiskFileCompletion, { NULL, false }, "The name of a file (can include path)." },
876 { eArgTypeFormat, "format", CommandCompletions::eNoCompletion, { FormatHelpTextCallback, true }, NULL },
877 { eArgTypeFrameIndex, "frame-index", CommandCompletions::eNoCompletion, { NULL, false }, "Index into a thread's list of frames." },
878 { eArgTypeFullName, "fullname", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." },
879 { eArgTypeFunctionName, "function-name", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a function." },
Greg Clayton9c236732011-10-26 00:56:27 +0000880 { eArgTypeGDBFormat, "gdb-format", CommandCompletions::eNoCompletion, { GDBFormatHelpTextCallback, true }, NULL },
Enrico Granata9ae9fd32011-07-07 15:49:54 +0000881 { eArgTypeIndex, "index", CommandCompletions::eNoCompletion, { NULL, false }, "An index into a list." },
882 { eArgTypeLineNum, "linenum", CommandCompletions::eNoCompletion, { NULL, false }, "Line number in a source file." },
883 { 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." },
884 { 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)." },
885 { eArgTypeMethod, "method", CommandCompletions::eNoCompletion, { NULL, false }, "A C++ method name." },
886 { eArgTypeName, "name", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." },
887 { eArgTypeNewPathPrefix, "new-path-prefix", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." },
888 { eArgTypeNumLines, "num-lines", CommandCompletions::eNoCompletion, { NULL, false }, "The number of lines to use." },
889 { eArgTypeNumberPerLine, "number-per-line", CommandCompletions::eNoCompletion, { NULL, false }, "The number of items per line to display." },
890 { eArgTypeOffset, "offset", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." },
891 { eArgTypeOldPathPrefix, "old-path-prefix", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." },
892 { eArgTypeOneLiner, "one-line-command", CommandCompletions::eNoCompletion, { NULL, false }, "A command that is entered as a single line of text." },
893 { eArgTypePath, "path", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." },
894 { eArgTypePid, "pid", CommandCompletions::eNoCompletion, { NULL, false }, "The process ID number." },
895 { eArgTypePlugin, "plugin", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." },
896 { eArgTypeProcessName, "process-name", CommandCompletions::eNoCompletion, { NULL, false }, "The name of the process." },
Enrico Granata91544802011-09-06 19:20:51 +0000897 { eArgTypePythonClass, "python-class", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a Python class." },
898 { eArgTypePythonFunction, "python-function", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a Python function." },
899 { eArgTypePythonScript, "python-script", CommandCompletions::eNoCompletion, { NULL, false }, "Source code written in Python." },
Enrico Granata9ae9fd32011-07-07 15:49:54 +0000900 { eArgTypeQueueName, "queue-name", CommandCompletions::eNoCompletion, { NULL, false }, "The name of the thread queue." },
901 { eArgTypeRegisterName, "register-name", CommandCompletions::eNoCompletion, { NULL, false }, "A register name." },
902 { eArgTypeRegularExpression, "regular-expression", CommandCompletions::eNoCompletion, { NULL, false }, "A regular expression." },
903 { eArgTypeRunArgs, "run-args", CommandCompletions::eNoCompletion, { NULL, false }, "Arguments to be passed to the target program when it starts executing." },
904 { eArgTypeRunMode, "run-mode", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." },
Enrico Granata6010ace2011-11-07 22:57:04 +0000905 { 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 +0000906 { eArgTypeScriptLang, "script-language", CommandCompletions::eNoCompletion, { NULL, false }, "The scripting language to be used for script-based commands. Currently only Python is valid." },
907 { eArgTypeSearchWord, "search-word", CommandCompletions::eNoCompletion, { NULL, false }, "The word for which you wish to search for information about." },
908 { eArgTypeSelector, "selector", CommandCompletions::eNoCompletion, { NULL, false }, "An Objective-C selector name." },
909 { 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)." },
910 { 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)." },
911 { eArgTypeSettingPrefix, "setting-prefix", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a settable internal debugger variable up to a dot ('.'), e.g. 'target.process.'" },
912 { 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." },
913 { eArgTypeShlibName, "shlib-name", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a shared library." },
914 { eArgTypeSourceFile, "source-file", CommandCompletions::eSourceFileCompletion, { NULL, false }, "The name of a source file.." },
915 { eArgTypeSortOrder, "sort-order", CommandCompletions::eNoCompletion, { NULL, false }, "Specify a sort order when dumping lists." },
916 { eArgTypeStartAddress, "start-address", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." },
917 { eArgTypeSummaryString, "summary-string", CommandCompletions::eNoCompletion, { SummaryStringHelpTextCallback, true }, NULL },
918 { eArgTypeSymbol, "symbol", CommandCompletions::eSymbolCompletion, { NULL, false }, "Any symbol name (function name, variable, argument, etc.)" },
919 { eArgTypeThreadID, "thread-id", CommandCompletions::eNoCompletion, { NULL, false }, "Thread ID number." },
920 { eArgTypeThreadIndex, "thread-index", CommandCompletions::eNoCompletion, { NULL, false }, "Index into the process' list of threads." },
921 { eArgTypeThreadName, "thread-name", CommandCompletions::eNoCompletion, { NULL, false }, "The thread's name." },
Johnny Chen309c89d2011-07-14 22:20:12 +0000922 { eArgTypeUnsignedInteger, "unsigned-integer", CommandCompletions::eNoCompletion, { NULL, false }, "An unsigned integer." },
Enrico Granata9ae9fd32011-07-07 15:49:54 +0000923 { eArgTypeUnixSignal, "unix-signal", CommandCompletions::eNoCompletion, { NULL, false }, "A valid Unix signal name or number (e.g. SIGKILL, KILL or 9)." },
924 { eArgTypeVarName, "variable-name", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a variable in your program." },
925 { eArgTypeValue, "value", CommandCompletions::eNoCompletion, { NULL, false }, "A value could be anything, depending on where and how it is used." },
926 { eArgTypeWidth, "width", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." },
927 { eArgTypeNone, "none", CommandCompletions::eNoCompletion, { NULL, false }, "No help available for this." },
Johnny Chen58dba3c2011-09-09 23:25:26 +0000928 { 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 +0000929 { eArgTypeWatchpointID, "watchpt-id", CommandCompletions::eNoCompletion, { NULL, false }, "Watchpoint IDs are positive integers." },
930 { eArgTypeWatchpointIDRange, "watchpt-id-list", CommandCompletions::eNoCompletion, { NULL, false }, "For example, '1-3' or '1 to 3'." },
Johnny Chen34bbf852011-09-12 23:38:44 +0000931 { eArgTypeWatchType, "watch-type", CommandCompletions::eNoCompletion, { NULL, false }, "Specify the type for a watchpoint." }
Caroline Ticefb355112010-10-01 17:46:38 +0000932};
933
934const CommandObject::ArgumentTableEntry*
935CommandObject::GetArgumentTable ()
936{
Greg Claytonaa378b12011-02-20 02:15:07 +0000937 // If this assertion fires, then the table above is out of date with the CommandArgumentType enumeration
938 assert ((sizeof (CommandObject::g_arguments_data) / sizeof (CommandObject::ArgumentTableEntry)) == eArgTypeLastArg);
Caroline Ticefb355112010-10-01 17:46:38 +0000939 return CommandObject::g_arguments_data;
940}
941
942