1 //===-- 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/lldb-python.h"
11 
12 #include "lldb/Interpreter/CommandObject.h"
13 
14 #include <string>
15 #include <map>
16 
17 #include <stdlib.h>
18 #include <ctype.h>
19 
20 #include "lldb/Core/Address.h"
21 #include "lldb/Core/ArchSpec.h"
22 #include "lldb/Interpreter/Options.h"
23 
24 // These are for the Sourcename completers.
25 // FIXME: Make a separate file for the completers.
26 #include "lldb/Host/FileSpec.h"
27 #include "lldb/Core/FileSpecList.h"
28 #include "lldb/Target/Process.h"
29 #include "lldb/Target/Target.h"
30 
31 #include "lldb/Interpreter/CommandInterpreter.h"
32 #include "lldb/Interpreter/CommandReturnObject.h"
33 #include "lldb/Interpreter/ScriptInterpreter.h"
34 #include "lldb/Interpreter/ScriptInterpreterPython.h"
35 
36 using namespace lldb;
37 using namespace lldb_private;
38 
39 //-------------------------------------------------------------------------
40 // CommandObject
41 //-------------------------------------------------------------------------
42 
43 CommandObject::CommandObject
44 (
45     CommandInterpreter &interpreter,
46     const char *name,
47     const char *help,
48     const char *syntax,
49     uint32_t flags
50 ) :
51     m_interpreter (interpreter),
52     m_cmd_name (name),
53     m_cmd_help_short (),
54     m_cmd_help_long (),
55     m_cmd_syntax (),
56     m_is_alias (false),
57     m_flags (flags),
58     m_arguments(),
59     m_deprecated_command_override_callback (nullptr),
60     m_command_override_callback (nullptr),
61     m_command_override_baton (nullptr)
62 {
63     if (help && help[0])
64         m_cmd_help_short = help;
65     if (syntax && syntax[0])
66         m_cmd_syntax = syntax;
67 }
68 
69 CommandObject::~CommandObject ()
70 {
71 }
72 
73 const char *
74 CommandObject::GetHelp ()
75 {
76     return m_cmd_help_short.c_str();
77 }
78 
79 const char *
80 CommandObject::GetHelpLong ()
81 {
82     return m_cmd_help_long.c_str();
83 }
84 
85 const char *
86 CommandObject::GetSyntax ()
87 {
88     if (m_cmd_syntax.length() == 0)
89     {
90         StreamString syntax_str;
91         syntax_str.Printf ("%s", GetCommandName());
92         if (GetOptions() != nullptr)
93             syntax_str.Printf (" <cmd-options>");
94         if (m_arguments.size() > 0)
95         {
96             syntax_str.Printf (" ");
97             if (WantsRawCommandString() && GetOptions() && GetOptions()->NumCommandOptions())
98                 syntax_str.Printf("-- ");
99             GetFormattedCommandArguments (syntax_str);
100         }
101         m_cmd_syntax = syntax_str.GetData ();
102     }
103 
104     return m_cmd_syntax.c_str();
105 }
106 
107 const char *
108 CommandObject::GetCommandName ()
109 {
110     return m_cmd_name.c_str();
111 }
112 
113 void
114 CommandObject::SetCommandName (const char *name)
115 {
116     m_cmd_name = name;
117 }
118 
119 void
120 CommandObject::SetHelp (const char *cstr)
121 {
122     m_cmd_help_short = cstr;
123 }
124 
125 void
126 CommandObject::SetHelpLong (const char *cstr)
127 {
128     m_cmd_help_long = cstr;
129 }
130 
131 void
132 CommandObject::SetHelpLong (std::string str)
133 {
134     m_cmd_help_long = str;
135 }
136 
137 void
138 CommandObject::SetSyntax (const char *cstr)
139 {
140     m_cmd_syntax = cstr;
141 }
142 
143 Options *
144 CommandObject::GetOptions ()
145 {
146     // By default commands don't have options unless this virtual function
147     // is overridden by base classes.
148     return nullptr;
149 }
150 
151 bool
152 CommandObject::ParseOptions
153 (
154     Args& args,
155     CommandReturnObject &result
156 )
157 {
158     // See if the subclass has options?
159     Options *options = GetOptions();
160     if (options != nullptr)
161     {
162         Error error;
163         options->NotifyOptionParsingStarting();
164 
165         // ParseOptions calls getopt_long_only, which always skips the zero'th item in the array and starts at position 1,
166         // so we need to push a dummy value into position zero.
167         args.Unshift("dummy_string");
168         error = args.ParseOptions (*options);
169 
170         // The "dummy_string" will have already been removed by ParseOptions,
171         // so no need to remove it.
172 
173         if (error.Success())
174             error = options->NotifyOptionParsingFinished();
175 
176         if (error.Success())
177         {
178             if (options->VerifyOptions (result))
179                 return true;
180         }
181         else
182         {
183             const char *error_cstr = error.AsCString();
184             if (error_cstr)
185             {
186                 // We got an error string, lets use that
187                 result.AppendError(error_cstr);
188             }
189             else
190             {
191                 // No error string, output the usage information into result
192                 options->GenerateOptionUsage (result.GetErrorStream(), this);
193             }
194         }
195         result.SetStatus (eReturnStatusFailed);
196         return false;
197     }
198     return true;
199 }
200 
201 
202 
203 bool
204 CommandObject::CheckRequirements (CommandReturnObject &result)
205 {
206 #ifdef LLDB_CONFIGURATION_DEBUG
207     // Nothing should be stored in m_exe_ctx between running commands as m_exe_ctx
208     // has shared pointers to the target, process, thread and frame and we don't
209     // want any CommandObject instances to keep any of these objects around
210     // longer than for a single command. Every command should call
211     // CommandObject::Cleanup() after it has completed
212     assert (m_exe_ctx.GetTargetPtr() == NULL);
213     assert (m_exe_ctx.GetProcessPtr() == NULL);
214     assert (m_exe_ctx.GetThreadPtr() == NULL);
215     assert (m_exe_ctx.GetFramePtr() == NULL);
216 #endif
217 
218     // Lock down the interpreter's execution context prior to running the
219     // command so we guarantee the selected target, process, thread and frame
220     // can't go away during the execution
221     m_exe_ctx = m_interpreter.GetExecutionContext();
222 
223     const uint32_t flags = GetFlags().Get();
224     if (flags & (eFlagRequiresTarget   |
225                  eFlagRequiresProcess  |
226                  eFlagRequiresThread   |
227                  eFlagRequiresFrame    |
228                  eFlagTryTargetAPILock ))
229     {
230 
231         if ((flags & eFlagRequiresTarget) && !m_exe_ctx.HasTargetScope())
232         {
233             result.AppendError (GetInvalidTargetDescription());
234             return false;
235         }
236 
237         if ((flags & eFlagRequiresProcess) && !m_exe_ctx.HasProcessScope())
238         {
239             result.AppendError (GetInvalidProcessDescription());
240             return false;
241         }
242 
243         if ((flags & eFlagRequiresThread) && !m_exe_ctx.HasThreadScope())
244         {
245             result.AppendError (GetInvalidThreadDescription());
246             return false;
247         }
248 
249         if ((flags & eFlagRequiresFrame) && !m_exe_ctx.HasFrameScope())
250         {
251             result.AppendError (GetInvalidFrameDescription());
252             return false;
253         }
254 
255         if ((flags & eFlagRequiresRegContext) && (m_exe_ctx.GetRegisterContext() == nullptr))
256         {
257             result.AppendError (GetInvalidRegContextDescription());
258             return false;
259         }
260 
261         if (flags & eFlagTryTargetAPILock)
262         {
263             Target *target = m_exe_ctx.GetTargetPtr();
264             if (target)
265                 m_api_locker.Lock (target->GetAPIMutex());
266         }
267     }
268 
269     if (GetFlags().AnySet (CommandObject::eFlagProcessMustBeLaunched | CommandObject::eFlagProcessMustBePaused))
270     {
271         Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
272         if (process == nullptr)
273         {
274             // A process that is not running is considered paused.
275             if (GetFlags().Test(CommandObject::eFlagProcessMustBeLaunched))
276             {
277                 result.AppendError ("Process must exist.");
278                 result.SetStatus (eReturnStatusFailed);
279                 return false;
280             }
281         }
282         else
283         {
284             StateType state = process->GetState();
285             switch (state)
286             {
287             case eStateInvalid:
288             case eStateSuspended:
289             case eStateCrashed:
290             case eStateStopped:
291                 break;
292 
293             case eStateConnected:
294             case eStateAttaching:
295             case eStateLaunching:
296             case eStateDetached:
297             case eStateExited:
298             case eStateUnloaded:
299                 if (GetFlags().Test(CommandObject::eFlagProcessMustBeLaunched))
300                 {
301                     result.AppendError ("Process must be launched.");
302                     result.SetStatus (eReturnStatusFailed);
303                     return false;
304                 }
305                 break;
306 
307             case eStateRunning:
308             case eStateStepping:
309                 if (GetFlags().Test(CommandObject::eFlagProcessMustBePaused))
310                 {
311                     result.AppendError ("Process is running.  Use 'process interrupt' to pause execution.");
312                     result.SetStatus (eReturnStatusFailed);
313                     return false;
314                 }
315             }
316         }
317     }
318     return true;
319 }
320 
321 void
322 CommandObject::Cleanup ()
323 {
324     m_exe_ctx.Clear();
325     m_api_locker.Unlock();
326 }
327 
328 
329 class CommandDictCommandPartialMatch
330 {
331     public:
332         CommandDictCommandPartialMatch (const char *match_str)
333         {
334             m_match_str = match_str;
335         }
336         bool operator() (const std::pair<std::string, lldb::CommandObjectSP> map_element) const
337         {
338             // A NULL or empty string matches everything.
339             if (m_match_str == nullptr || *m_match_str == '\0')
340                 return true;
341 
342             return map_element.first.find (m_match_str, 0) == 0;
343         }
344 
345     private:
346         const char *m_match_str;
347 };
348 
349 int
350 CommandObject::AddNamesMatchingPartialString (CommandObject::CommandMap &in_map, const char *cmd_str,
351                                               StringList &matches)
352 {
353     int number_added = 0;
354     CommandDictCommandPartialMatch matcher(cmd_str);
355 
356     CommandObject::CommandMap::iterator matching_cmds = std::find_if (in_map.begin(), in_map.end(), matcher);
357 
358     while (matching_cmds != in_map.end())
359     {
360         ++number_added;
361         matches.AppendString((*matching_cmds).first.c_str());
362         matching_cmds = std::find_if (++matching_cmds, in_map.end(), matcher);;
363     }
364     return number_added;
365 }
366 
367 int
368 CommandObject::HandleCompletion
369 (
370     Args &input,
371     int &cursor_index,
372     int &cursor_char_position,
373     int match_start_point,
374     int max_return_elements,
375     bool &word_complete,
376     StringList &matches
377 )
378 {
379     // Default implmentation of WantsCompletion() is !WantsRawCommandString().
380     // Subclasses who want raw command string but desire, for example,
381     // argument completion should override WantsCompletion() to return true,
382     // instead.
383     if (WantsRawCommandString() && !WantsCompletion())
384     {
385         // FIXME: Abstract telling the completion to insert the completion character.
386         matches.Clear();
387         return -1;
388     }
389     else
390     {
391         // Can we do anything generic with the options?
392         Options *cur_options = GetOptions();
393         CommandReturnObject result;
394         OptionElementVector opt_element_vector;
395 
396         if (cur_options != nullptr)
397         {
398             // Re-insert the dummy command name string which will have been
399             // stripped off:
400             input.Unshift ("dummy-string");
401             cursor_index++;
402 
403 
404             // I stick an element on the end of the input, because if the last element is
405             // option that requires an argument, getopt_long_only will freak out.
406 
407             input.AppendArgument ("<FAKE-VALUE>");
408 
409             input.ParseArgsForCompletion (*cur_options, opt_element_vector, cursor_index);
410 
411             input.DeleteArgumentAtIndex(input.GetArgumentCount() - 1);
412 
413             bool handled_by_options;
414             handled_by_options = cur_options->HandleOptionCompletion (input,
415                                                                       opt_element_vector,
416                                                                       cursor_index,
417                                                                       cursor_char_position,
418                                                                       match_start_point,
419                                                                       max_return_elements,
420                                                                       word_complete,
421                                                                       matches);
422             if (handled_by_options)
423                 return matches.GetSize();
424         }
425 
426         // If we got here, the last word is not an option or an option argument.
427         return HandleArgumentCompletion (input,
428                                          cursor_index,
429                                          cursor_char_position,
430                                          opt_element_vector,
431                                          match_start_point,
432                                          max_return_elements,
433                                          word_complete,
434                                          matches);
435     }
436 }
437 
438 bool
439 CommandObject::HelpTextContainsWord (const char *search_word)
440 {
441     std::string options_usage_help;
442 
443     bool found_word = false;
444 
445     const char *short_help = GetHelp();
446     const char *long_help = GetHelpLong();
447     const char *syntax_help = GetSyntax();
448 
449     if (short_help && strcasestr (short_help, search_word))
450         found_word = true;
451     else if (long_help && strcasestr (long_help, search_word))
452         found_word = true;
453     else if (syntax_help && strcasestr (syntax_help, search_word))
454         found_word = true;
455 
456     if (!found_word
457         && GetOptions() != nullptr)
458     {
459         StreamString usage_help;
460         GetOptions()->GenerateOptionUsage (usage_help, this);
461         if (usage_help.GetSize() > 0)
462         {
463             const char *usage_text = usage_help.GetData();
464             if (strcasestr (usage_text, search_word))
465               found_word = true;
466         }
467     }
468 
469     return found_word;
470 }
471 
472 int
473 CommandObject::GetNumArgumentEntries  ()
474 {
475     return m_arguments.size();
476 }
477 
478 CommandObject::CommandArgumentEntry *
479 CommandObject::GetArgumentEntryAtIndex (int idx)
480 {
481     if (static_cast<size_t>(idx) < m_arguments.size())
482         return &(m_arguments[idx]);
483 
484     return nullptr;
485 }
486 
487 CommandObject::ArgumentTableEntry *
488 CommandObject::FindArgumentDataByType (CommandArgumentType arg_type)
489 {
490     const ArgumentTableEntry *table = CommandObject::GetArgumentTable();
491 
492     for (int i = 0; i < eArgTypeLastArg; ++i)
493         if (table[i].arg_type == arg_type)
494             return (ArgumentTableEntry *) &(table[i]);
495 
496     return nullptr;
497 }
498 
499 void
500 CommandObject::GetArgumentHelp (Stream &str, CommandArgumentType arg_type, CommandInterpreter &interpreter)
501 {
502     const ArgumentTableEntry* table = CommandObject::GetArgumentTable();
503     ArgumentTableEntry *entry = (ArgumentTableEntry *) &(table[arg_type]);
504 
505     // The table is *supposed* to be kept in arg_type order, but someone *could* have messed it up...
506 
507     if (entry->arg_type != arg_type)
508         entry = CommandObject::FindArgumentDataByType (arg_type);
509 
510     if (!entry)
511         return;
512 
513     StreamString name_str;
514     name_str.Printf ("<%s>", entry->arg_name);
515 
516     if (entry->help_function)
517     {
518         const char* help_text = entry->help_function();
519         if (!entry->help_function.self_formatting)
520         {
521             interpreter.OutputFormattedHelpText (str, name_str.GetData(), "--", help_text,
522                                                  name_str.GetSize());
523         }
524         else
525         {
526             interpreter.OutputHelpText(str, name_str.GetData(), "--", help_text,
527                                        name_str.GetSize());
528         }
529     }
530     else
531         interpreter.OutputFormattedHelpText (str, name_str.GetData(), "--", entry->help_text, name_str.GetSize());
532 }
533 
534 const char *
535 CommandObject::GetArgumentName (CommandArgumentType arg_type)
536 {
537     ArgumentTableEntry *entry = (ArgumentTableEntry *) &(CommandObject::GetArgumentTable()[arg_type]);
538 
539     // The table is *supposed* to be kept in arg_type order, but someone *could* have messed it up...
540 
541     if (entry->arg_type != arg_type)
542         entry = CommandObject::FindArgumentDataByType (arg_type);
543 
544     if (entry)
545         return entry->arg_name;
546 
547     StreamString str;
548     str << "Arg name for type (" << arg_type << ") not in arg table!";
549     return str.GetData();
550 }
551 
552 bool
553 CommandObject::IsPairType (ArgumentRepetitionType arg_repeat_type)
554 {
555     if ((arg_repeat_type == eArgRepeatPairPlain)
556         ||  (arg_repeat_type == eArgRepeatPairOptional)
557         ||  (arg_repeat_type == eArgRepeatPairPlus)
558         ||  (arg_repeat_type == eArgRepeatPairStar)
559         ||  (arg_repeat_type == eArgRepeatPairRange)
560         ||  (arg_repeat_type == eArgRepeatPairRangeOptional))
561         return true;
562 
563     return false;
564 }
565 
566 static CommandObject::CommandArgumentEntry
567 OptSetFiltered(uint32_t opt_set_mask, CommandObject::CommandArgumentEntry &cmd_arg_entry)
568 {
569     CommandObject::CommandArgumentEntry ret_val;
570     for (unsigned i = 0; i < cmd_arg_entry.size(); ++i)
571         if (opt_set_mask & cmd_arg_entry[i].arg_opt_set_association)
572             ret_val.push_back(cmd_arg_entry[i]);
573     return ret_val;
574 }
575 
576 // Default parameter value of opt_set_mask is LLDB_OPT_SET_ALL, which means take
577 // all the argument data into account.  On rare cases where some argument sticks
578 // with certain option sets, this function returns the option set filtered args.
579 void
580 CommandObject::GetFormattedCommandArguments (Stream &str, uint32_t opt_set_mask)
581 {
582     int num_args = m_arguments.size();
583     for (int i = 0; i < num_args; ++i)
584     {
585         if (i > 0)
586             str.Printf (" ");
587         CommandArgumentEntry arg_entry =
588             opt_set_mask == LLDB_OPT_SET_ALL ? m_arguments[i]
589                                              : OptSetFiltered(opt_set_mask, m_arguments[i]);
590         int num_alternatives = arg_entry.size();
591 
592         if ((num_alternatives == 2)
593             && IsPairType (arg_entry[0].arg_repetition))
594         {
595             const char *first_name = GetArgumentName (arg_entry[0].arg_type);
596             const char *second_name = GetArgumentName (arg_entry[1].arg_type);
597             switch (arg_entry[0].arg_repetition)
598             {
599                 case eArgRepeatPairPlain:
600                     str.Printf ("<%s> <%s>", first_name, second_name);
601                     break;
602                 case eArgRepeatPairOptional:
603                     str.Printf ("[<%s> <%s>]", first_name, second_name);
604                     break;
605                 case eArgRepeatPairPlus:
606                     str.Printf ("<%s> <%s> [<%s> <%s> [...]]", first_name, second_name, first_name, second_name);
607                     break;
608                 case eArgRepeatPairStar:
609                     str.Printf ("[<%s> <%s> [<%s> <%s> [...]]]", first_name, second_name, first_name, second_name);
610                     break;
611                 case eArgRepeatPairRange:
612                     str.Printf ("<%s_1> <%s_1> ... <%s_n> <%s_n>", first_name, second_name, first_name, second_name);
613                     break;
614                 case eArgRepeatPairRangeOptional:
615                     str.Printf ("[<%s_1> <%s_1> ... <%s_n> <%s_n>]", first_name, second_name, first_name, second_name);
616                     break;
617                 // Explicitly test for all the rest of the cases, so if new types get added we will notice the
618                 // missing case statement(s).
619                 case eArgRepeatPlain:
620                 case eArgRepeatOptional:
621                 case eArgRepeatPlus:
622                 case eArgRepeatStar:
623                 case eArgRepeatRange:
624                     // These should not be reached, as they should fail the IsPairType test above.
625                     break;
626             }
627         }
628         else
629         {
630             StreamString names;
631             for (int j = 0; j < num_alternatives; ++j)
632             {
633                 if (j > 0)
634                     names.Printf (" | ");
635                 names.Printf ("%s", GetArgumentName (arg_entry[j].arg_type));
636             }
637             switch (arg_entry[0].arg_repetition)
638             {
639                 case eArgRepeatPlain:
640                     str.Printf ("<%s>", names.GetData());
641                     break;
642                 case eArgRepeatPlus:
643                     str.Printf ("<%s> [<%s> [...]]", names.GetData(), names.GetData());
644                     break;
645                 case eArgRepeatStar:
646                     str.Printf ("[<%s> [<%s> [...]]]", names.GetData(), names.GetData());
647                     break;
648                 case eArgRepeatOptional:
649                     str.Printf ("[<%s>]", names.GetData());
650                     break;
651                 case eArgRepeatRange:
652                     str.Printf ("<%s_1> .. <%s_n>", names.GetData(), names.GetData());
653                     break;
654                 // Explicitly test for all the rest of the cases, so if new types get added we will notice the
655                 // missing case statement(s).
656                 case eArgRepeatPairPlain:
657                 case eArgRepeatPairOptional:
658                 case eArgRepeatPairPlus:
659                 case eArgRepeatPairStar:
660                 case eArgRepeatPairRange:
661                 case eArgRepeatPairRangeOptional:
662                     // These should not be hit, as they should pass the IsPairType test above, and control should
663                     // have gone into the other branch of the if statement.
664                     break;
665             }
666         }
667     }
668 }
669 
670 CommandArgumentType
671 CommandObject::LookupArgumentName (const char *arg_name)
672 {
673     CommandArgumentType return_type = eArgTypeLastArg;
674 
675     std::string arg_name_str (arg_name);
676     size_t len = arg_name_str.length();
677     if (arg_name[0] == '<'
678         && arg_name[len-1] == '>')
679         arg_name_str = arg_name_str.substr (1, len-2);
680 
681     const ArgumentTableEntry *table = GetArgumentTable();
682     for (int i = 0; i < eArgTypeLastArg; ++i)
683         if (arg_name_str.compare (table[i].arg_name) == 0)
684             return_type = g_arguments_data[i].arg_type;
685 
686     return return_type;
687 }
688 
689 static const char *
690 RegisterNameHelpTextCallback ()
691 {
692     return "Register names can be specified using the architecture specific names.  "
693     "They can also be specified using generic names.  Not all generic entities have "
694     "registers backing them on all architectures.  When they don't the generic name "
695     "will return an error.\n"
696     "The generic names defined in lldb are:\n"
697     "\n"
698     "pc       - program counter register\n"
699     "ra       - return address register\n"
700     "fp       - frame pointer register\n"
701     "sp       - stack pointer register\n"
702     "flags    - the flags register\n"
703     "arg{1-6} - integer argument passing registers.\n";
704 }
705 
706 static const char *
707 BreakpointIDHelpTextCallback ()
708 {
709     return "Breakpoint ID's consist major and minor numbers;  the major number "
710     "corresponds to the single entity that was created with a 'breakpoint set' "
711     "command; the minor numbers correspond to all the locations that were actually "
712     "found/set based on the major breakpoint.  A full breakpoint ID might look like "
713     "3.14, meaning the 14th location set for the 3rd breakpoint.  You can specify "
714     "all the locations of a breakpoint by just indicating the major breakpoint "
715     "number. A valid breakpoint id consists either of just the major id number, "
716     "or the major number, a dot, and the location number (e.g. 3 or 3.2 could "
717     "both be valid breakpoint ids).";
718 }
719 
720 static const char *
721 BreakpointIDRangeHelpTextCallback ()
722 {
723     return "A 'breakpoint id list' is a manner of specifying multiple breakpoints. "
724     "This can be done  through several mechanisms.  The easiest way is to just "
725     "enter a space-separated list of breakpoint ids.  To specify all the "
726     "breakpoint locations under a major breakpoint, you can use the major "
727     "breakpoint number followed by '.*', eg. '5.*' means all the locations under "
728     "breakpoint 5.  You can also indicate a range of breakpoints by using "
729     "<start-bp-id> - <end-bp-id>.  The start-bp-id and end-bp-id for a range can "
730     "be any valid breakpoint ids.  It is not legal, however, to specify a range "
731     "using specific locations that cross major breakpoint numbers.  I.e. 3.2 - 3.7"
732     " is legal; 2 - 5 is legal; but 3.2 - 4.4 is not legal.";
733 }
734 
735 static const char *
736 GDBFormatHelpTextCallback ()
737 {
738     return "A GDB format consists of a repeat count, a format letter and a size letter. "
739     "The repeat count is optional and defaults to 1. The format letter is optional "
740     "and defaults to the previous format that was used. The size letter is optional "
741     "and defaults to the previous size that was used.\n"
742     "\n"
743     "Format letters include:\n"
744     "o - octal\n"
745     "x - hexadecimal\n"
746     "d - decimal\n"
747     "u - unsigned decimal\n"
748     "t - binary\n"
749     "f - float\n"
750     "a - address\n"
751     "i - instruction\n"
752     "c - char\n"
753     "s - string\n"
754     "T - OSType\n"
755     "A - float as hex\n"
756     "\n"
757     "Size letters include:\n"
758     "b - 1 byte  (byte)\n"
759     "h - 2 bytes (halfword)\n"
760     "w - 4 bytes (word)\n"
761     "g - 8 bytes (giant)\n"
762     "\n"
763     "Example formats:\n"
764     "32xb - show 32 1 byte hexadecimal integer values\n"
765     "16xh - show 16 2 byte hexadecimal integer values\n"
766     "64   - show 64 2 byte hexadecimal integer values (format and size from the last format)\n"
767     "dw   - show 1 4 byte decimal integer value\n"
768     ;
769 }
770 
771 static const char *
772 FormatHelpTextCallback ()
773 {
774 
775     static char* help_text_ptr = nullptr;
776 
777     if (help_text_ptr)
778         return help_text_ptr;
779 
780     StreamString sstr;
781     sstr << "One of the format names (or one-character names) that can be used to show a variable's value:\n";
782     for (Format f = eFormatDefault; f < kNumFormats; f = Format(f+1))
783     {
784         if (f != eFormatDefault)
785             sstr.PutChar('\n');
786 
787         char format_char = FormatManager::GetFormatAsFormatChar(f);
788         if (format_char)
789             sstr.Printf("'%c' or ", format_char);
790 
791         sstr.Printf ("\"%s\"", FormatManager::GetFormatAsCString(f));
792     }
793 
794     sstr.Flush();
795 
796     std::string data = sstr.GetString();
797 
798     help_text_ptr = new char[data.length()+1];
799 
800     data.copy(help_text_ptr, data.length());
801 
802     return help_text_ptr;
803 }
804 
805 static const char *
806 LanguageTypeHelpTextCallback ()
807 {
808     static char* help_text_ptr = nullptr;
809 
810     if (help_text_ptr)
811         return help_text_ptr;
812 
813     StreamString sstr;
814     sstr << "One of the following languages:\n";
815 
816     for (unsigned int l = eLanguageTypeUnknown; l < eNumLanguageTypes; ++l)
817     {
818         sstr << "  " << LanguageRuntime::GetNameForLanguageType(static_cast<LanguageType>(l)) << "\n";
819     }
820 
821     sstr.Flush();
822 
823     std::string data = sstr.GetString();
824 
825     help_text_ptr = new char[data.length()+1];
826 
827     data.copy(help_text_ptr, data.length());
828 
829     return help_text_ptr;
830 }
831 
832 static const char *
833 SummaryStringHelpTextCallback()
834 {
835     return
836         "A summary string is a way to extract information from variables in order to present them using a summary.\n"
837         "Summary strings contain static text, variables, scopes and control sequences:\n"
838         "  - Static text can be any sequence of non-special characters, i.e. anything but '{', '}', '$', or '\\'.\n"
839         "  - Variables are sequences of characters beginning with ${, ending with } and that contain symbols in the format described below.\n"
840         "  - 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"
841         "  - Control sequences are the usual C/C++ '\\a', '\\n', ..., plus '\\$', '\\{' and '\\}'.\n"
842         "A summary string works by copying static text verbatim, turning control sequences into their character counterpart, expanding variables and trying to expand scopes.\n"
843         "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"
844         "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"
845         " (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"
846         " ${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."
847         " 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"
848         "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."
849         "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"
850         " path refers to:\n"
851         "  - 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"
852         " and displayed as an individual variable\n"
853         "  - 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"
854         " 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"
855         "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"
856         "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"
857         " special symbols only allowed as part of a variable:\n"
858         "    %V: show the value of the object by default\n"
859         "    %S: show the summary of the object by default\n"
860         "    %@: show the runtime-provided object description (for Objective-C, it calls NSPrintForDebugger; for C/C++ it does nothing)\n"
861         "    %L: show the location of the object (memory address or a register name)\n"
862         "    %#: show the number of children of the object\n"
863         "    %T: show the type of the object\n"
864         "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"
865         " 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"
866         " count the number of actual elements stored in an std::list:\n"
867         "type summary add -s \"${svar%#}\" -x \"std::list<\"";
868 }
869 
870 static const char *
871 ExprPathHelpTextCallback()
872 {
873     return
874     "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"
875     "For instance, given a class:\n"
876     "  class foo {\n"
877     "      int a;\n"
878     "      int b; .\n"
879     "      foo* next;\n"
880     "  };\n"
881     "the expression to read item b in the item pointed to by next for foo aFoo would be aFoo.next->b.\n"
882     "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"
883     "Expression paths in LLDB include dot (.) and arrow (->) operators, and most commands using expression paths have ways to also accept the star (*) operator.\n"
884     "The meaning of these operators is the same as the usual one given to them by the C/C++ standards.\n"
885     "LLDB also has support for indexing ([ ]) in expression paths, and extends the traditional meaning of the square brackets operator to allow bitfield extraction:\n"
886     "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"
887     " 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"
888     " 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"
889     " meaning of array slicing (taking elements n thru m inside the array or pointed-to memory).";
890 }
891 
892 void
893 CommandObject::GenerateHelpText (CommandReturnObject &result)
894 {
895     GenerateHelpText(result.GetOutputStream());
896 
897     result.SetStatus (eReturnStatusSuccessFinishNoResult);
898 }
899 
900 void
901 CommandObject::GenerateHelpText (Stream &output_strm)
902 {
903     CommandInterpreter& interpreter = GetCommandInterpreter();
904     if (GetOptions() != nullptr)
905     {
906         if (WantsRawCommandString())
907         {
908             std::string help_text (GetHelp());
909             help_text.append ("  This command takes 'raw' input (no need to quote stuff).");
910             interpreter.OutputFormattedHelpText (output_strm, "", "", help_text.c_str(), 1);
911         }
912         else
913             interpreter.OutputFormattedHelpText (output_strm, "", "", GetHelp(), 1);
914         output_strm.Printf ("\nSyntax: %s\n", GetSyntax());
915         GetOptions()->GenerateOptionUsage (output_strm, this);
916         const char *long_help = GetHelpLong();
917         if ((long_help != nullptr)
918             && (strlen (long_help) > 0))
919             output_strm.Printf ("\n%s", long_help);
920         if (WantsRawCommandString() && !WantsCompletion())
921         {
922             // Emit the message about using ' -- ' between the end of the command options and the raw input
923             // conditionally, i.e., only if the command object does not want completion.
924             interpreter.OutputFormattedHelpText (output_strm, "", "",
925                                                  "\nIMPORTANT NOTE:  Because this command takes 'raw' input, if you use any command options"
926                                                  " you must use ' -- ' between the end of the command options and the beginning of the raw input.", 1);
927         }
928         else if (GetNumArgumentEntries() > 0
929                  && GetOptions()
930                  && GetOptions()->NumCommandOptions() > 0)
931         {
932             // Also emit a warning about using "--" in case you are using a command that takes options and arguments.
933             interpreter.OutputFormattedHelpText (output_strm, "", "",
934                                                  "\nThis command takes options and free-form arguments.  If your arguments resemble"
935                                                  " option specifiers (i.e., they start with a - or --), you must use ' -- ' between"
936                                                  " the end of the command options and the beginning of the arguments.", 1);
937         }
938     }
939     else if (IsMultiwordObject())
940     {
941         if (WantsRawCommandString())
942         {
943             std::string help_text (GetHelp());
944             help_text.append ("  This command takes 'raw' input (no need to quote stuff).");
945             interpreter.OutputFormattedHelpText (output_strm, "", "", help_text.c_str(), 1);
946         }
947         else
948             interpreter.OutputFormattedHelpText (output_strm, "", "", GetHelp(), 1);
949         GenerateHelpText (output_strm);
950     }
951     else
952     {
953         const char *long_help = GetHelpLong();
954         if ((long_help != nullptr)
955             && (strlen (long_help) > 0))
956             output_strm.Printf ("%s", long_help);
957         else if (WantsRawCommandString())
958         {
959             std::string help_text (GetHelp());
960             help_text.append ("  This command takes 'raw' input (no need to quote stuff).");
961             interpreter.OutputFormattedHelpText (output_strm, "", "", help_text.c_str(), 1);
962         }
963         else
964             interpreter.OutputFormattedHelpText (output_strm, "", "", GetHelp(), 1);
965         output_strm.Printf ("\nSyntax: %s\n", GetSyntax());
966     }
967 }
968 
969 void
970 CommandObject::AddIDsArgumentData(CommandArgumentEntry &arg, CommandArgumentType ID, CommandArgumentType IDRange)
971 {
972     CommandArgumentData id_arg;
973     CommandArgumentData id_range_arg;
974 
975     // Create the first variant for the first (and only) argument for this command.
976     id_arg.arg_type = ID;
977     id_arg.arg_repetition = eArgRepeatOptional;
978 
979     // Create the second variant for the first (and only) argument for this command.
980     id_range_arg.arg_type = IDRange;
981     id_range_arg.arg_repetition = eArgRepeatOptional;
982 
983     // The first (and only) argument for this command could be either an id or an id_range.
984     // Push both variants into the entry for the first argument for this command.
985     arg.push_back(id_arg);
986     arg.push_back(id_range_arg);
987 }
988 
989 const char *
990 CommandObject::GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type)
991 {
992     if (arg_type >=0 && arg_type < eArgTypeLastArg)
993         return g_arguments_data[arg_type].arg_name;
994     return nullptr;
995 
996 }
997 
998 const char *
999 CommandObject::GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type)
1000 {
1001     if (arg_type >=0 && arg_type < eArgTypeLastArg)
1002         return g_arguments_data[arg_type].help_text;
1003     return nullptr;
1004 }
1005 
1006 bool
1007 CommandObjectParsed::Execute (const char *args_string, CommandReturnObject &result)
1008 {
1009     bool handled = false;
1010     Args cmd_args (args_string);
1011     if (HasOverrideCallback())
1012     {
1013         Args full_args (GetCommandName ());
1014         full_args.AppendArguments(cmd_args);
1015         handled = InvokeOverrideCallback (full_args.GetConstArgumentVector(), result);
1016     }
1017     if (!handled)
1018     {
1019         for (size_t i = 0; i < cmd_args.GetArgumentCount();  ++i)
1020         {
1021             const char *tmp_str = cmd_args.GetArgumentAtIndex (i);
1022             if (tmp_str[0] == '`')  // back-quote
1023                 cmd_args.ReplaceArgumentAtIndex (i, m_interpreter.ProcessEmbeddedScriptCommands (tmp_str));
1024         }
1025 
1026         if (CheckRequirements(result))
1027         {
1028             if (ParseOptions (cmd_args, result))
1029             {
1030                 // Call the command-specific version of 'Execute', passing it the already processed arguments.
1031                 handled = DoExecute (cmd_args, result);
1032             }
1033         }
1034 
1035         Cleanup();
1036     }
1037     return handled;
1038 }
1039 
1040 bool
1041 CommandObjectRaw::Execute (const char *args_string, CommandReturnObject &result)
1042 {
1043     bool handled = false;
1044     if (HasOverrideCallback())
1045     {
1046         std::string full_command (GetCommandName ());
1047         full_command += ' ';
1048         full_command += args_string;
1049         const char *argv[2] = { nullptr, nullptr };
1050         argv[0] = full_command.c_str();
1051         handled = InvokeOverrideCallback (argv, result);
1052     }
1053     if (!handled)
1054     {
1055         if (CheckRequirements(result))
1056             handled = DoExecute (args_string, result);
1057 
1058         Cleanup();
1059     }
1060     return handled;
1061 }
1062 
1063 static
1064 const char *arch_helper()
1065 {
1066     static StreamString g_archs_help;
1067     if (g_archs_help.Empty())
1068     {
1069         StringList archs;
1070         ArchSpec::AutoComplete(nullptr, archs);
1071         g_archs_help.Printf("These are the supported architecture names:\n");
1072         archs.Join("\n", g_archs_help);
1073     }
1074     return g_archs_help.GetData();
1075 }
1076 
1077 CommandObject::ArgumentTableEntry
1078 CommandObject::g_arguments_data[] =
1079 {
1080     { eArgTypeAddress, "address", CommandCompletions::eNoCompletion, { nullptr, false }, "A valid address in the target program's execution space." },
1081     { eArgTypeAddressOrExpression, "address-expression", CommandCompletions::eNoCompletion, { nullptr, false }, "An expression that resolves to an address." },
1082     { eArgTypeAliasName, "alias-name", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of an abbreviation (alias) for a debugger command." },
1083     { eArgTypeAliasOptions, "options-for-aliased-command", CommandCompletions::eNoCompletion, { nullptr, false }, "Command options to be used as part of an alias (abbreviation) definition.  (See 'help commands alias' for more information.)" },
1084     { eArgTypeArchitecture, "arch", CommandCompletions::eArchitectureCompletion, { arch_helper, true }, "The architecture name, e.g. i386 or x86_64." },
1085     { eArgTypeBoolean, "boolean", CommandCompletions::eNoCompletion, { nullptr, false }, "A Boolean value: 'true' or 'false'" },
1086     { eArgTypeBreakpointID, "breakpt-id", CommandCompletions::eNoCompletion, { BreakpointIDHelpTextCallback, false }, nullptr },
1087     { eArgTypeBreakpointIDRange, "breakpt-id-list", CommandCompletions::eNoCompletion, { BreakpointIDRangeHelpTextCallback, false }, nullptr },
1088     { eArgTypeByteSize, "byte-size", CommandCompletions::eNoCompletion, { nullptr, false }, "Number of bytes to use." },
1089     { eArgTypeClassName, "class-name", CommandCompletions::eNoCompletion, { nullptr, false }, "Then name of a class from the debug information in the program." },
1090     { eArgTypeCommandName, "cmd-name", CommandCompletions::eNoCompletion, { nullptr, false }, "A debugger command (may be multiple words), without any options or arguments." },
1091     { eArgTypeCount, "count", CommandCompletions::eNoCompletion, { nullptr, false }, "An unsigned integer." },
1092     { eArgTypeDirectoryName, "directory", CommandCompletions::eDiskDirectoryCompletion, { nullptr, false }, "A directory name." },
1093     { eArgTypeDisassemblyFlavor, "disassembly-flavor", CommandCompletions::eNoCompletion, { nullptr, false }, "A disassembly flavor recognized by your disassembly plugin.  Currently the only valid options are \"att\" and \"intel\" for Intel targets" },
1094     { eArgTypeDescriptionVerbosity, "description-verbosity", CommandCompletions::eNoCompletion, { nullptr, false }, "How verbose the output of 'po' should be." },
1095     { eArgTypeEndAddress, "end-address", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." },
1096     { eArgTypeExpression, "expr", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." },
1097     { eArgTypeExpressionPath, "expr-path", CommandCompletions::eNoCompletion, { ExprPathHelpTextCallback, true }, nullptr },
1098     { eArgTypeExprFormat, "expression-format", CommandCompletions::eNoCompletion, { nullptr, false }, "[ [bool|b] | [bin] | [char|c] | [oct|o] | [dec|i|d|u] | [hex|x] | [float|f] | [cstr|s] ]" },
1099     { eArgTypeFilename, "filename", CommandCompletions::eDiskFileCompletion, { nullptr, false }, "The name of a file (can include path)." },
1100     { eArgTypeFormat, "format", CommandCompletions::eNoCompletion, { FormatHelpTextCallback, true }, nullptr },
1101     { eArgTypeFrameIndex, "frame-index", CommandCompletions::eNoCompletion, { nullptr, false }, "Index into a thread's list of frames." },
1102     { eArgTypeFullName, "fullname", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." },
1103     { eArgTypeFunctionName, "function-name", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a function." },
1104     { eArgTypeFunctionOrSymbol, "function-or-symbol", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a function or symbol." },
1105     { eArgTypeGDBFormat, "gdb-format", CommandCompletions::eNoCompletion, { GDBFormatHelpTextCallback, true }, nullptr },
1106     { eArgTypeIndex, "index", CommandCompletions::eNoCompletion, { nullptr, false }, "An index into a list." },
1107     { eArgTypeLanguage, "language", CommandCompletions::eNoCompletion, { LanguageTypeHelpTextCallback, true }, nullptr },
1108     { eArgTypeLineNum, "linenum", CommandCompletions::eNoCompletion, { nullptr, false }, "Line number in a source file." },
1109     { eArgTypeLogCategory, "log-category", CommandCompletions::eNoCompletion, { nullptr, 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." },
1110     { eArgTypeLogChannel, "log-channel", CommandCompletions::eNoCompletion, { nullptr, 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)." },
1111     { eArgTypeMethod, "method", CommandCompletions::eNoCompletion, { nullptr, false }, "A C++ method name." },
1112     { eArgTypeName, "name", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." },
1113     { eArgTypeNewPathPrefix, "new-path-prefix", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." },
1114     { eArgTypeNumLines, "num-lines", CommandCompletions::eNoCompletion, { nullptr, false }, "The number of lines to use." },
1115     { eArgTypeNumberPerLine, "number-per-line", CommandCompletions::eNoCompletion, { nullptr, false }, "The number of items per line to display." },
1116     { eArgTypeOffset, "offset", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." },
1117     { eArgTypeOldPathPrefix, "old-path-prefix", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." },
1118     { eArgTypeOneLiner, "one-line-command", CommandCompletions::eNoCompletion, { nullptr, false }, "A command that is entered as a single line of text." },
1119     { eArgTypePath, "path", CommandCompletions::eDiskFileCompletion, { nullptr, false }, "Path." },
1120     { eArgTypePermissionsNumber, "perms-numeric", CommandCompletions::eNoCompletion, { nullptr, false }, "Permissions given as an octal number (e.g. 755)." },
1121     { eArgTypePermissionsString, "perms=string", CommandCompletions::eNoCompletion, { nullptr, false }, "Permissions given as a string value (e.g. rw-r-xr--)." },
1122     { eArgTypePid, "pid", CommandCompletions::eNoCompletion, { nullptr, false }, "The process ID number." },
1123     { eArgTypePlugin, "plugin", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." },
1124     { eArgTypeProcessName, "process-name", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of the process." },
1125     { eArgTypePythonClass, "python-class", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a Python class." },
1126     { eArgTypePythonFunction, "python-function", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a Python function." },
1127     { eArgTypePythonScript, "python-script", CommandCompletions::eNoCompletion, { nullptr, false }, "Source code written in Python." },
1128     { eArgTypeQueueName, "queue-name", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of the thread queue." },
1129     { eArgTypeRegisterName, "register-name", CommandCompletions::eNoCompletion, { RegisterNameHelpTextCallback, true }, nullptr },
1130     { eArgTypeRegularExpression, "regular-expression", CommandCompletions::eNoCompletion, { nullptr, false }, "A regular expression." },
1131     { eArgTypeRunArgs, "run-args", CommandCompletions::eNoCompletion, { nullptr, false }, "Arguments to be passed to the target program when it starts executing." },
1132     { eArgTypeRunMode, "run-mode", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." },
1133     { eArgTypeScriptedCommandSynchronicity, "script-cmd-synchronicity", CommandCompletions::eNoCompletion, { nullptr, false }, "The synchronicity to use to run scripted commands with regard to LLDB event system." },
1134     { eArgTypeScriptLang, "script-language", CommandCompletions::eNoCompletion, { nullptr, false }, "The scripting language to be used for script-based commands.  Currently only Python is valid." },
1135     { eArgTypeSearchWord, "search-word", CommandCompletions::eNoCompletion, { nullptr, false }, "The word for which you wish to search for information about." },
1136     { eArgTypeSelector, "selector", CommandCompletions::eNoCompletion, { nullptr, false }, "An Objective-C selector name." },
1137     { eArgTypeSettingIndex, "setting-index", CommandCompletions::eNoCompletion, { nullptr, false }, "An index into a settings variable that is an array (try 'settings list' to see all the possible settings variables and their types)." },
1138     { eArgTypeSettingKey, "setting-key", CommandCompletions::eNoCompletion, { nullptr, false }, "A key into a settings variables that is a dictionary (try 'settings list' to see all the possible settings variables and their types)." },
1139     { eArgTypeSettingPrefix, "setting-prefix", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a settable internal debugger variable up to a dot ('.'), e.g. 'target.process.'" },
1140     { eArgTypeSettingVariableName, "setting-variable-name", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a settable internal debugger variable.  Type 'settings list' to see a complete list of such variables." },
1141     { eArgTypeShlibName, "shlib-name", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a shared library." },
1142     { eArgTypeSourceFile, "source-file", CommandCompletions::eSourceFileCompletion, { nullptr, false }, "The name of a source file.." },
1143     { eArgTypeSortOrder, "sort-order", CommandCompletions::eNoCompletion, { nullptr, false }, "Specify a sort order when dumping lists." },
1144     { eArgTypeStartAddress, "start-address", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." },
1145     { eArgTypeSummaryString, "summary-string", CommandCompletions::eNoCompletion, { SummaryStringHelpTextCallback, true }, nullptr },
1146     { eArgTypeSymbol, "symbol", CommandCompletions::eSymbolCompletion, { nullptr, false }, "Any symbol name (function name, variable, argument, etc.)" },
1147     { eArgTypeThreadID, "thread-id", CommandCompletions::eNoCompletion, { nullptr, false }, "Thread ID number." },
1148     { eArgTypeThreadIndex, "thread-index", CommandCompletions::eNoCompletion, { nullptr, false }, "Index into the process' list of threads." },
1149     { eArgTypeThreadName, "thread-name", CommandCompletions::eNoCompletion, { nullptr, false }, "The thread's name." },
1150     { eArgTypeUnsignedInteger, "unsigned-integer", CommandCompletions::eNoCompletion, { nullptr, false }, "An unsigned integer." },
1151     { eArgTypeUnixSignal, "unix-signal", CommandCompletions::eNoCompletion, { nullptr, false }, "A valid Unix signal name or number (e.g. SIGKILL, KILL or 9)." },
1152     { eArgTypeVarName, "variable-name", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a variable in your program." },
1153     { eArgTypeValue, "value", CommandCompletions::eNoCompletion, { nullptr, false }, "A value could be anything, depending on where and how it is used." },
1154     { eArgTypeWidth, "width", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." },
1155     { eArgTypeNone, "none", CommandCompletions::eNoCompletion, { nullptr, false }, "No help available for this." },
1156     { eArgTypePlatform, "platform-name", CommandCompletions::ePlatformPluginCompletion, { nullptr, false }, "The name of an installed platform plug-in . Type 'platform list' to see a complete list of installed platforms." },
1157     { eArgTypeWatchpointID, "watchpt-id", CommandCompletions::eNoCompletion, { nullptr, false }, "Watchpoint IDs are positive integers." },
1158     { eArgTypeWatchpointIDRange, "watchpt-id-list", CommandCompletions::eNoCompletion, { nullptr, false }, "For example, '1-3' or '1 to 3'." },
1159     { eArgTypeWatchType, "watch-type", CommandCompletions::eNoCompletion, { nullptr, false }, "Specify the type for a watchpoint." }
1160 };
1161 
1162 const CommandObject::ArgumentTableEntry*
1163 CommandObject::GetArgumentTable ()
1164 {
1165     // If this assertion fires, then the table above is out of date with the CommandArgumentType enumeration
1166     assert ((sizeof (CommandObject::g_arguments_data) / sizeof (CommandObject::ArgumentTableEntry)) == eArgTypeLastArg);
1167     return CommandObject::g_arguments_data;
1168 }
1169 
1170 
1171