1c9af18a5SGreg Clayton //===-- CommandCompletions.cpp ----------------------------------*- C++ -*-===//
2c9af18a5SGreg Clayton //
3c9af18a5SGreg Clayton //                     The LLVM Compiler Infrastructure
4c9af18a5SGreg Clayton //
5c9af18a5SGreg Clayton // This file is distributed under the University of Illinois Open Source
6c9af18a5SGreg Clayton // License. See LICENSE.TXT for details.
7c9af18a5SGreg Clayton //
8c9af18a5SGreg Clayton //===----------------------------------------------------------------------===//
9c9af18a5SGreg Clayton 
1093a64300SDaniel Malea #include "lldb/lldb-python.h"
11c9af18a5SGreg Clayton 
12c9af18a5SGreg Clayton // C Includes
13558ce124SJim Ingham #include <sys/stat.h>
14fd18426eSGreg Clayton #if defined(__APPLE__) || defined(__linux__)
157cc478b9SJim Ingham #include <pwd.h>
16fd18426eSGreg Clayton #endif
17558ce124SJim Ingham 
18c9af18a5SGreg Clayton // C++ Includes
19c9af18a5SGreg Clayton // Other libraries and framework includes
20c9af18a5SGreg Clayton // Project includes
2153239f00SGreg Clayton #include "lldb/Host/FileSpec.h"
229b62fd2fSGreg Clayton #include "lldb/Core/FileSpecList.h"
23ab65b34fSGreg Clayton #include "lldb/Core/PluginManager.h"
241f746071SGreg Clayton #include "lldb/Core/Module.h"
259b62fd2fSGreg Clayton #include "lldb/Interpreter/Args.h"
269b62fd2fSGreg Clayton #include "lldb/Interpreter/CommandCompletions.h"
279b62fd2fSGreg Clayton #include "lldb/Interpreter/CommandInterpreter.h"
281f746071SGreg Clayton #include "lldb/Symbol/CompileUnit.h"
29f21feadcSGreg Clayton #include "lldb/Symbol/Variable.h"
309b62fd2fSGreg Clayton #include "lldb/Target/Target.h"
319b62fd2fSGreg Clayton #include "lldb/Utility/CleanUp.h"
32c9af18a5SGreg Clayton 
33c9af18a5SGreg Clayton using namespace lldb_private;
34c9af18a5SGreg Clayton 
35c9af18a5SGreg Clayton CommandCompletions::CommonCompletionElement
36c9af18a5SGreg Clayton CommandCompletions::g_common_completions[] =
37c9af18a5SGreg Clayton {
38c9af18a5SGreg Clayton     {eCustomCompletion,          NULL},
39c9af18a5SGreg Clayton     {eSourceFileCompletion,      CommandCompletions::SourceFiles},
40558ce124SJim Ingham     {eDiskFileCompletion,        CommandCompletions::DiskFiles},
41558ce124SJim Ingham     {eDiskDirectoryCompletion,   CommandCompletions::DiskDirectories},
42c9af18a5SGreg Clayton     {eSymbolCompletion,          CommandCompletions::Symbols},
43c9af18a5SGreg Clayton     {eModuleCompletion,          CommandCompletions::Modules},
443df9a8dfSCaroline Tice     {eSettingsNameCompletion,    CommandCompletions::SettingsNames},
45ab65b34fSGreg Clayton     {ePlatformPluginCompletion,  CommandCompletions::PlatformPluginNames},
46ab65b34fSGreg Clayton     {eArchitectureCompletion,    CommandCompletions::ArchitectureNames},
47f21feadcSGreg Clayton     {eVariablePathCompletion,    CommandCompletions::VariablePath},
48c9af18a5SGreg Clayton     {eNoCompletion,              NULL}      // This one has to be last in the list.
49c9af18a5SGreg Clayton };
50c9af18a5SGreg Clayton 
51c9af18a5SGreg Clayton bool
526611103cSGreg Clayton CommandCompletions::InvokeCommonCompletionCallbacks
536611103cSGreg Clayton (
546611103cSGreg Clayton     CommandInterpreter &interpreter,
556611103cSGreg Clayton     uint32_t completion_mask,
56c9af18a5SGreg Clayton     const char *completion_str,
57c9af18a5SGreg Clayton     int match_start_point,
58c9af18a5SGreg Clayton     int max_return_elements,
59c9af18a5SGreg Clayton     SearchFilter *searcher,
60558ce124SJim Ingham     bool &word_complete,
616611103cSGreg Clayton     StringList &matches
626611103cSGreg Clayton )
63c9af18a5SGreg Clayton {
64c9af18a5SGreg Clayton     bool handled = false;
65c9af18a5SGreg Clayton 
66c9af18a5SGreg Clayton     if (completion_mask & eCustomCompletion)
67c9af18a5SGreg Clayton         return false;
68c9af18a5SGreg Clayton 
69c9af18a5SGreg Clayton     for (int i = 0; ; i++)
70c9af18a5SGreg Clayton     {
71c9af18a5SGreg Clayton         if (g_common_completions[i].type == eNoCompletion)
72c9af18a5SGreg Clayton             break;
73c9af18a5SGreg Clayton          else if ((g_common_completions[i].type & completion_mask) == g_common_completions[i].type
74c9af18a5SGreg Clayton                    && g_common_completions[i].callback != NULL)
75c9af18a5SGreg Clayton          {
76c9af18a5SGreg Clayton             handled = true;
776611103cSGreg Clayton             g_common_completions[i].callback (interpreter,
786611103cSGreg Clayton                                               completion_str,
79c9af18a5SGreg Clayton                                               match_start_point,
80c9af18a5SGreg Clayton                                               max_return_elements,
81c9af18a5SGreg Clayton                                               searcher,
82558ce124SJim Ingham                                               word_complete,
83c9af18a5SGreg Clayton                                               matches);
84c9af18a5SGreg Clayton         }
85c9af18a5SGreg Clayton     }
86c9af18a5SGreg Clayton     return handled;
87c9af18a5SGreg Clayton }
88c9af18a5SGreg Clayton 
89c9af18a5SGreg Clayton int
906611103cSGreg Clayton CommandCompletions::SourceFiles
916611103cSGreg Clayton (
926611103cSGreg Clayton     CommandInterpreter &interpreter,
936611103cSGreg Clayton     const char *partial_file_name,
94c9af18a5SGreg Clayton     int match_start_point,
95c9af18a5SGreg Clayton     int max_return_elements,
96c9af18a5SGreg Clayton     SearchFilter *searcher,
97558ce124SJim Ingham     bool &word_complete,
986611103cSGreg Clayton     StringList &matches
996611103cSGreg Clayton )
100c9af18a5SGreg Clayton {
101558ce124SJim Ingham     word_complete = true;
102c9af18a5SGreg Clayton     // Find some way to switch "include support files..."
1036611103cSGreg Clayton     SourceFileCompleter completer (interpreter,
1046611103cSGreg Clayton                                    false,
1056611103cSGreg Clayton                                    partial_file_name,
1066611103cSGreg Clayton                                    match_start_point,
1076611103cSGreg Clayton                                    max_return_elements,
108c9af18a5SGreg Clayton                                    matches);
109c9af18a5SGreg Clayton 
110c9af18a5SGreg Clayton     if (searcher == NULL)
111c9af18a5SGreg Clayton     {
1122976d00aSJim Ingham         lldb::TargetSP target_sp = interpreter.GetDebugger().GetSelectedTarget();
113c9af18a5SGreg Clayton         SearchFilter null_searcher (target_sp);
114c9af18a5SGreg Clayton         completer.DoCompletion (&null_searcher);
115c9af18a5SGreg Clayton     }
116c9af18a5SGreg Clayton     else
117c9af18a5SGreg Clayton     {
118c9af18a5SGreg Clayton         completer.DoCompletion (searcher);
119c9af18a5SGreg Clayton     }
120c9af18a5SGreg Clayton     return matches.GetSize();
121c9af18a5SGreg Clayton }
122c9af18a5SGreg Clayton 
123b2f1fb29SVirgile Bello typedef struct DiskFilesOrDirectoriesBaton
124b2f1fb29SVirgile Bello {
125b2f1fb29SVirgile Bello     const char *remainder;
126b2f1fb29SVirgile Bello     char *partial_name_copy;
127b2f1fb29SVirgile Bello     bool only_directories;
128b2f1fb29SVirgile Bello     bool *saw_directory;
129b2f1fb29SVirgile Bello     StringList *matches;
130b2f1fb29SVirgile Bello     char *end_ptr;
131b2f1fb29SVirgile Bello     size_t baselen;
132*0b5e5f43SMichael Sartain } DiskFilesOrDirectoriesBaton;
133b2f1fb29SVirgile Bello 
134b2f1fb29SVirgile Bello FileSpec::EnumerateDirectoryResult DiskFilesOrDirectoriesCallback(void *baton, FileSpec::FileType file_type, const FileSpec &spec)
135b2f1fb29SVirgile Bello {
136b2f1fb29SVirgile Bello     const char *name = spec.GetFilename().AsCString();
137b2f1fb29SVirgile Bello 
138b2f1fb29SVirgile Bello     const DiskFilesOrDirectoriesBaton *parameters = (DiskFilesOrDirectoriesBaton*)baton;
139b2f1fb29SVirgile Bello     char *end_ptr = parameters->end_ptr;
140b2f1fb29SVirgile Bello     char *partial_name_copy = parameters->partial_name_copy;
141b2f1fb29SVirgile Bello     const char *remainder = parameters->remainder;
142b2f1fb29SVirgile Bello 
143b2f1fb29SVirgile Bello     // Omit ".", ".." and any . files if the match string doesn't start with .
144b2f1fb29SVirgile Bello     if (name[0] == '.')
145b2f1fb29SVirgile Bello     {
146b2f1fb29SVirgile Bello         if (name[1] == '\0')
147b2f1fb29SVirgile Bello             return FileSpec::eEnumerateDirectoryResultNext;
148b2f1fb29SVirgile Bello         else if (name[1] == '.' && name[2] == '\0')
149b2f1fb29SVirgile Bello             return FileSpec::eEnumerateDirectoryResultNext;
150b2f1fb29SVirgile Bello         else if (remainder[0] != '.')
151b2f1fb29SVirgile Bello             return FileSpec::eEnumerateDirectoryResultNext;
152b2f1fb29SVirgile Bello     }
153b2f1fb29SVirgile Bello 
154b2f1fb29SVirgile Bello     // If we found a directory, we put a "/" at the end of the name.
155b2f1fb29SVirgile Bello 
156b2f1fb29SVirgile Bello     if (remainder[0] == '\0' || strstr(name, remainder) == name)
157b2f1fb29SVirgile Bello     {
158b2f1fb29SVirgile Bello         if (strlen(name) + parameters->baselen >= PATH_MAX)
159b2f1fb29SVirgile Bello             return FileSpec::eEnumerateDirectoryResultNext;
160b2f1fb29SVirgile Bello 
161b2f1fb29SVirgile Bello         strcpy(end_ptr, name);
162b2f1fb29SVirgile Bello 
163b2f1fb29SVirgile Bello         bool isa_directory = false;
164b2f1fb29SVirgile Bello         if (file_type == FileSpec::eFileTypeDirectory)
165b2f1fb29SVirgile Bello             isa_directory = true;
166b2f1fb29SVirgile Bello         else if (file_type == FileSpec::eFileTypeSymbolicLink)
167b2f1fb29SVirgile Bello         {
168b2f1fb29SVirgile Bello             struct stat stat_buf;
169b2f1fb29SVirgile Bello             if ((stat(partial_name_copy, &stat_buf) == 0) && S_ISDIR(stat_buf.st_mode))
170b2f1fb29SVirgile Bello                 isa_directory = true;
171b2f1fb29SVirgile Bello         }
172b2f1fb29SVirgile Bello 
173b2f1fb29SVirgile Bello         if (isa_directory)
174b2f1fb29SVirgile Bello         {
175b2f1fb29SVirgile Bello             *parameters->saw_directory = true;
176b2f1fb29SVirgile Bello             size_t len = strlen(parameters->partial_name_copy);
177b2f1fb29SVirgile Bello             partial_name_copy[len] = '/';
178b2f1fb29SVirgile Bello             partial_name_copy[len + 1] = '\0';
179b2f1fb29SVirgile Bello         }
180b2f1fb29SVirgile Bello         if (parameters->only_directories && !isa_directory)
181b2f1fb29SVirgile Bello             return FileSpec::eEnumerateDirectoryResultNext;
182b2f1fb29SVirgile Bello         parameters->matches->AppendString(partial_name_copy);
183b2f1fb29SVirgile Bello     }
184b2f1fb29SVirgile Bello 
185b2f1fb29SVirgile Bello     return FileSpec::eEnumerateDirectoryResultNext;
186b2f1fb29SVirgile Bello }
187b2f1fb29SVirgile Bello 
188558ce124SJim Ingham static int
189558ce124SJim Ingham DiskFilesOrDirectories
190558ce124SJim Ingham (
191558ce124SJim Ingham     const char *partial_file_name,
192558ce124SJim Ingham     bool only_directories,
193558ce124SJim Ingham     bool &saw_directory,
194558ce124SJim Ingham     StringList &matches
195558ce124SJim Ingham )
196558ce124SJim Ingham {
197558ce124SJim Ingham     // I'm going to  use the "glob" function with GLOB_TILDE for user directory expansion.
198558ce124SJim Ingham     // If it is not defined on your host system, you'll need to implement it yourself...
199558ce124SJim Ingham 
200c7bece56SGreg Clayton     size_t partial_name_len = strlen(partial_file_name);
201558ce124SJim Ingham 
202558ce124SJim Ingham     if (partial_name_len >= PATH_MAX)
203558ce124SJim Ingham         return matches.GetSize();
204558ce124SJim Ingham 
205558ce124SJim Ingham     // This copy of the string will be cut up into the directory part, and the remainder.  end_ptr
206558ce124SJim Ingham     // below will point to the place of the remainder in this string.  Then when we've resolved the
207558ce124SJim Ingham     // containing directory, and opened it, we'll read the directory contents and overwrite the
208558ce124SJim Ingham     // partial_name_copy starting from end_ptr with each of the matches.  Thus we will preserve
209558ce124SJim Ingham     // the form the user originally typed.
210558ce124SJim Ingham 
211558ce124SJim Ingham     char partial_name_copy[PATH_MAX];
212021b605dSBenjamin Kramer     memcpy(partial_name_copy, partial_file_name, partial_name_len);
213558ce124SJim Ingham     partial_name_copy[partial_name_len] = '\0';
214558ce124SJim Ingham 
215710dd5aeSGreg Clayton     // We'll need to save a copy of the remainder for comparison, which we do here.
216558ce124SJim Ingham     char remainder[PATH_MAX];
217558ce124SJim Ingham 
218558ce124SJim Ingham     // end_ptr will point past the last / in partial_name_copy, or if there is no slash to the beginning of the string.
219558ce124SJim Ingham     char *end_ptr;
220558ce124SJim Ingham 
221558ce124SJim Ingham     end_ptr = strrchr(partial_name_copy, '/');
222558ce124SJim Ingham 
223558ce124SJim Ingham     // This will store the resolved form of the containing directory
224558ce124SJim Ingham     char containing_part[PATH_MAX];
225558ce124SJim Ingham 
226558ce124SJim Ingham     if (end_ptr == NULL)
227558ce124SJim Ingham     {
228558ce124SJim Ingham         // There's no directory.  If the thing begins with a "~" then this is a bare
229558ce124SJim Ingham         // user name.
230558ce124SJim Ingham         if (*partial_name_copy == '~')
231558ce124SJim Ingham         {
232558ce124SJim Ingham             // Nothing here but the user name.  We could just put a slash on the end,
2337cc478b9SJim Ingham             // but for completeness sake we'll resolve the user name and only put a slash
234558ce124SJim Ingham             // on the end if it exists.
2357cc478b9SJim Ingham             char resolved_username[PATH_MAX];
236c982c768SGreg Clayton             size_t resolved_username_len = FileSpec::ResolveUsername (partial_name_copy, resolved_username,
2377cc478b9SJim Ingham                                                           sizeof (resolved_username));
2387cc478b9SJim Ingham 
2397cc478b9SJim Ingham            // Not sure how this would happen, a username longer than PATH_MAX?  Still...
2407cc478b9SJim Ingham             if (resolved_username_len >= sizeof (resolved_username))
241558ce124SJim Ingham                 return matches.GetSize();
24284363078SJim Ingham             else if (resolved_username_len == 0)
2437cc478b9SJim Ingham             {
2447cc478b9SJim Ingham                 // The user name didn't resolve, let's look in the password database for matches.
2457cc478b9SJim Ingham                 // The user name database contains duplicates, and is not in alphabetical order, so
2467cc478b9SJim Ingham                 // we'll use a set to manage that for us.
24784363078SJim Ingham                 FileSpec::ResolvePartialUsername (partial_name_copy, matches);
24884363078SJim Ingham                 if (matches.GetSize() > 0)
2497cc478b9SJim Ingham                     saw_directory = true;
2507cc478b9SJim Ingham                 return matches.GetSize();
2517cc478b9SJim Ingham             }
25284363078SJim Ingham             else
25384363078SJim Ingham             {
254558ce124SJim Ingham                 //The thing exists, put a '/' on the end, and return it...
255558ce124SJim Ingham                 // FIXME: complete user names here:
256558ce124SJim Ingham                 partial_name_copy[partial_name_len] = '/';
257558ce124SJim Ingham                 partial_name_copy[partial_name_len+1] = '\0';
258558ce124SJim Ingham                 matches.AppendString(partial_name_copy);
259021b605dSBenjamin Kramer                 saw_directory = true;
260558ce124SJim Ingham                 return matches.GetSize();
261558ce124SJim Ingham             }
26284363078SJim Ingham         }
263558ce124SJim Ingham         else
264558ce124SJim Ingham         {
265558ce124SJim Ingham             // The containing part is the CWD, and the whole string is the remainder.
266558ce124SJim Ingham             containing_part[0] = '.';
267558ce124SJim Ingham             containing_part[1] = '\0';
268558ce124SJim Ingham             strcpy(remainder, partial_name_copy);
269558ce124SJim Ingham             end_ptr = partial_name_copy;
270558ce124SJim Ingham         }
271558ce124SJim Ingham     }
272558ce124SJim Ingham     else
273558ce124SJim Ingham     {
274558ce124SJim Ingham         if (end_ptr == partial_name_copy)
275558ce124SJim Ingham         {
276558ce124SJim Ingham             // We're completing a file or directory in the root volume.
277558ce124SJim Ingham             containing_part[0] = '/';
278558ce124SJim Ingham             containing_part[1] = '\0';
279558ce124SJim Ingham         }
280558ce124SJim Ingham         else
281558ce124SJim Ingham         {
282558ce124SJim Ingham             size_t len = end_ptr - partial_name_copy;
283558ce124SJim Ingham             memcpy(containing_part, partial_name_copy, len);
284558ce124SJim Ingham             containing_part[len] = '\0';
285558ce124SJim Ingham         }
286558ce124SJim Ingham         // Push end_ptr past the final "/" and set remainder.
287558ce124SJim Ingham         end_ptr++;
288558ce124SJim Ingham         strcpy(remainder, end_ptr);
289558ce124SJim Ingham     }
290558ce124SJim Ingham 
2917cc478b9SJim Ingham     // Look for a user name in the containing part, and if it's there, resolve it and stick the
292558ce124SJim Ingham     // result back into the containing_part:
293558ce124SJim Ingham 
294558ce124SJim Ingham     if (*partial_name_copy == '~')
295558ce124SJim Ingham     {
29684363078SJim Ingham         size_t resolved_username_len = FileSpec::ResolveUsername(containing_part,
29784363078SJim Ingham                                                                  containing_part,
29884363078SJim Ingham                                                                  sizeof (containing_part));
299558ce124SJim Ingham         // User name doesn't exist, we're not getting any further...
300a0807356SGreg Clayton         if (resolved_username_len == 0 || resolved_username_len >= sizeof (containing_part))
301558ce124SJim Ingham             return matches.GetSize();
302558ce124SJim Ingham     }
303558ce124SJim Ingham 
304558ce124SJim Ingham     // Okay, containing_part is now the directory we want to open and look for files:
305558ce124SJim Ingham 
306558ce124SJim Ingham     size_t baselen = end_ptr - partial_name_copy;
307558ce124SJim Ingham 
308b2f1fb29SVirgile Bello     DiskFilesOrDirectoriesBaton parameters;
309b2f1fb29SVirgile Bello     parameters.remainder = remainder;
310b2f1fb29SVirgile Bello     parameters.partial_name_copy = partial_name_copy;
311b2f1fb29SVirgile Bello     parameters.only_directories = only_directories;
312b2f1fb29SVirgile Bello     parameters.saw_directory = &saw_directory;
313b2f1fb29SVirgile Bello     parameters.matches = &matches;
314b2f1fb29SVirgile Bello     parameters.end_ptr = end_ptr;
315b2f1fb29SVirgile Bello     parameters.baselen = baselen;
316558ce124SJim Ingham 
317b2f1fb29SVirgile Bello     FileSpec::EnumerateDirectory(containing_part, true, true, true, DiskFilesOrDirectoriesCallback, &parameters);
318558ce124SJim Ingham 
319558ce124SJim Ingham     return matches.GetSize();
320558ce124SJim Ingham }
321558ce124SJim Ingham 
322558ce124SJim Ingham int
323558ce124SJim Ingham CommandCompletions::DiskFiles
324558ce124SJim Ingham (
325558ce124SJim Ingham     CommandInterpreter &interpreter,
326558ce124SJim Ingham     const char *partial_file_name,
327558ce124SJim Ingham     int match_start_point,
328558ce124SJim Ingham     int max_return_elements,
329558ce124SJim Ingham     SearchFilter *searcher,
330558ce124SJim Ingham     bool &word_complete,
331558ce124SJim Ingham     StringList &matches
332558ce124SJim Ingham )
333558ce124SJim Ingham {
334558ce124SJim Ingham 
335558ce124SJim Ingham     int ret_val = DiskFilesOrDirectories (partial_file_name,
336558ce124SJim Ingham                                           false,
337558ce124SJim Ingham                                           word_complete,
338558ce124SJim Ingham                                           matches);
339558ce124SJim Ingham     word_complete = !word_complete;
340558ce124SJim Ingham     return ret_val;
341558ce124SJim Ingham }
342558ce124SJim Ingham 
343558ce124SJim Ingham int
344558ce124SJim Ingham CommandCompletions::DiskDirectories
345558ce124SJim Ingham (
346558ce124SJim Ingham     CommandInterpreter &interpreter,
347558ce124SJim Ingham     const char *partial_file_name,
348558ce124SJim Ingham     int match_start_point,
349558ce124SJim Ingham     int max_return_elements,
350558ce124SJim Ingham     SearchFilter *searcher,
351558ce124SJim Ingham     bool &word_complete,
352558ce124SJim Ingham     StringList &matches
353558ce124SJim Ingham )
354558ce124SJim Ingham {
355558ce124SJim Ingham     int ret_val =  DiskFilesOrDirectories (partial_file_name,
356558ce124SJim Ingham                                            true,
357558ce124SJim Ingham                                            word_complete,
358558ce124SJim Ingham                                            matches);
359558ce124SJim Ingham     word_complete = false;
360558ce124SJim Ingham     return ret_val;
361558ce124SJim Ingham }
362558ce124SJim Ingham 
363c9af18a5SGreg Clayton int
3646611103cSGreg Clayton CommandCompletions::Modules
3656611103cSGreg Clayton (
3666611103cSGreg Clayton     CommandInterpreter &interpreter,
3676611103cSGreg Clayton     const char *partial_file_name,
368c9af18a5SGreg Clayton     int match_start_point,
369c9af18a5SGreg Clayton     int max_return_elements,
370c9af18a5SGreg Clayton     SearchFilter *searcher,
371558ce124SJim Ingham     bool &word_complete,
3726611103cSGreg Clayton     StringList &matches
3736611103cSGreg Clayton )
374c9af18a5SGreg Clayton {
375558ce124SJim Ingham     word_complete = true;
3766611103cSGreg Clayton     ModuleCompleter completer (interpreter,
3776611103cSGreg Clayton                                partial_file_name,
3786611103cSGreg Clayton                                match_start_point,
3796611103cSGreg Clayton                                max_return_elements,
3806611103cSGreg Clayton                                matches);
381c9af18a5SGreg Clayton 
382c9af18a5SGreg Clayton     if (searcher == NULL)
383c9af18a5SGreg Clayton     {
3842976d00aSJim Ingham         lldb::TargetSP target_sp = interpreter.GetDebugger().GetSelectedTarget();
385c9af18a5SGreg Clayton         SearchFilter null_searcher (target_sp);
386c9af18a5SGreg Clayton         completer.DoCompletion (&null_searcher);
387c9af18a5SGreg Clayton     }
388c9af18a5SGreg Clayton     else
389c9af18a5SGreg Clayton     {
390c9af18a5SGreg Clayton         completer.DoCompletion (searcher);
391c9af18a5SGreg Clayton     }
392c9af18a5SGreg Clayton     return matches.GetSize();
393c9af18a5SGreg Clayton }
394c9af18a5SGreg Clayton 
395c9af18a5SGreg Clayton int
3966611103cSGreg Clayton CommandCompletions::Symbols
3976611103cSGreg Clayton (
3986611103cSGreg Clayton     CommandInterpreter &interpreter,
3996611103cSGreg Clayton     const char *partial_file_name,
400c9af18a5SGreg Clayton     int match_start_point,
401c9af18a5SGreg Clayton     int max_return_elements,
402c9af18a5SGreg Clayton     SearchFilter *searcher,
403558ce124SJim Ingham     bool &word_complete,
4046611103cSGreg Clayton     StringList &matches)
405c9af18a5SGreg Clayton {
406558ce124SJim Ingham     word_complete = true;
4076611103cSGreg Clayton     SymbolCompleter completer (interpreter,
4086611103cSGreg Clayton                                partial_file_name,
4096611103cSGreg Clayton                                match_start_point,
4106611103cSGreg Clayton                                max_return_elements,
4116611103cSGreg Clayton                                matches);
412c9af18a5SGreg Clayton 
413c9af18a5SGreg Clayton     if (searcher == NULL)
414c9af18a5SGreg Clayton     {
4152976d00aSJim Ingham         lldb::TargetSP target_sp = interpreter.GetDebugger().GetSelectedTarget();
416c9af18a5SGreg Clayton         SearchFilter null_searcher (target_sp);
417c9af18a5SGreg Clayton         completer.DoCompletion (&null_searcher);
418c9af18a5SGreg Clayton     }
419c9af18a5SGreg Clayton     else
420c9af18a5SGreg Clayton     {
421c9af18a5SGreg Clayton         completer.DoCompletion (searcher);
422c9af18a5SGreg Clayton     }
423c9af18a5SGreg Clayton     return matches.GetSize();
424c9af18a5SGreg Clayton }
425c9af18a5SGreg Clayton 
4263df9a8dfSCaroline Tice int
4273df9a8dfSCaroline Tice CommandCompletions::SettingsNames (CommandInterpreter &interpreter,
4283df9a8dfSCaroline Tice                                    const char *partial_setting_name,
4293df9a8dfSCaroline Tice                                    int match_start_point,
4303df9a8dfSCaroline Tice                                    int max_return_elements,
4313df9a8dfSCaroline Tice                                    SearchFilter *searcher,
4323df9a8dfSCaroline Tice                                    bool &word_complete,
4333df9a8dfSCaroline Tice                                    StringList &matches)
4343df9a8dfSCaroline Tice {
43567cc0636SGreg Clayton     // Cache the full setting name list
43667cc0636SGreg Clayton     static StringList g_property_names;
43767cc0636SGreg Clayton     if (g_property_names.GetSize() == 0)
43867cc0636SGreg Clayton     {
43967cc0636SGreg Clayton         // Generate the full setting name list on demand
44067cc0636SGreg Clayton         lldb::OptionValuePropertiesSP properties_sp (interpreter.GetDebugger().GetValueProperties());
44167cc0636SGreg Clayton         if (properties_sp)
44267cc0636SGreg Clayton         {
44367cc0636SGreg Clayton             StreamString strm;
44467cc0636SGreg Clayton             properties_sp->DumpValue(NULL, strm, OptionValue::eDumpOptionName);
44567cc0636SGreg Clayton             const std::string &str = strm.GetString();
44667cc0636SGreg Clayton             g_property_names.SplitIntoLines(str.c_str(), str.size());
44767cc0636SGreg Clayton         }
44867cc0636SGreg Clayton     }
4493df9a8dfSCaroline Tice 
45067cc0636SGreg Clayton     size_t exact_matches_idx = SIZE_MAX;
45167cc0636SGreg Clayton     const size_t num_matches = g_property_names.AutoComplete (partial_setting_name, matches, exact_matches_idx);
45267cc0636SGreg Clayton     word_complete = exact_matches_idx != SIZE_MAX;
45367cc0636SGreg Clayton     return num_matches;
4543df9a8dfSCaroline Tice }
4553df9a8dfSCaroline Tice 
456ab65b34fSGreg Clayton 
457ab65b34fSGreg Clayton int
458ab65b34fSGreg Clayton CommandCompletions::PlatformPluginNames (CommandInterpreter &interpreter,
459ab65b34fSGreg Clayton                                          const char *partial_name,
460ab65b34fSGreg Clayton                                          int match_start_point,
461ab65b34fSGreg Clayton                                          int max_return_elements,
462ab65b34fSGreg Clayton                                          SearchFilter *searcher,
463ab65b34fSGreg Clayton                                          bool &word_complete,
464ab65b34fSGreg Clayton                                          lldb_private::StringList &matches)
465ab65b34fSGreg Clayton {
466ab65b34fSGreg Clayton     const uint32_t num_matches = PluginManager::AutoCompletePlatformName(partial_name, matches);
467ab65b34fSGreg Clayton     word_complete = num_matches == 1;
468ab65b34fSGreg Clayton     return num_matches;
469ab65b34fSGreg Clayton }
470ab65b34fSGreg Clayton 
471ab65b34fSGreg Clayton int
472ab65b34fSGreg Clayton CommandCompletions::ArchitectureNames (CommandInterpreter &interpreter,
473ab65b34fSGreg Clayton                                        const char *partial_name,
474ab65b34fSGreg Clayton                                        int match_start_point,
475ab65b34fSGreg Clayton                                        int max_return_elements,
476ab65b34fSGreg Clayton                                        SearchFilter *searcher,
477ab65b34fSGreg Clayton                                        bool &word_complete,
478ab65b34fSGreg Clayton                                        lldb_private::StringList &matches)
479ab65b34fSGreg Clayton {
480ab65b34fSGreg Clayton     const uint32_t num_matches = ArchSpec::AutoComplete (partial_name, matches);
481ab65b34fSGreg Clayton     word_complete = num_matches == 1;
482ab65b34fSGreg Clayton     return num_matches;
483ab65b34fSGreg Clayton }
484ab65b34fSGreg Clayton 
485ab65b34fSGreg Clayton 
486f21feadcSGreg Clayton int
487f21feadcSGreg Clayton CommandCompletions::VariablePath (CommandInterpreter &interpreter,
488f21feadcSGreg Clayton                                   const char *partial_name,
489f21feadcSGreg Clayton                                   int match_start_point,
490f21feadcSGreg Clayton                                   int max_return_elements,
491f21feadcSGreg Clayton                                   SearchFilter *searcher,
492f21feadcSGreg Clayton                                   bool &word_complete,
493f21feadcSGreg Clayton                                   lldb_private::StringList &matches)
494f21feadcSGreg Clayton {
495f21feadcSGreg Clayton     return Variable::AutoComplete (interpreter.GetExecutionContext(), partial_name, matches, word_complete);
496f21feadcSGreg Clayton }
497f21feadcSGreg Clayton 
498f21feadcSGreg Clayton 
4996611103cSGreg Clayton CommandCompletions::Completer::Completer
5006611103cSGreg Clayton (
5016611103cSGreg Clayton     CommandInterpreter &interpreter,
502c9af18a5SGreg Clayton     const char *completion_str,
503c9af18a5SGreg Clayton     int match_start_point,
504c9af18a5SGreg Clayton     int max_return_elements,
505c9af18a5SGreg Clayton     StringList &matches
506c9af18a5SGreg Clayton ) :
5076611103cSGreg Clayton     m_interpreter (interpreter),
508c9af18a5SGreg Clayton     m_completion_str (completion_str),
509c9af18a5SGreg Clayton     m_match_start_point (match_start_point),
510c9af18a5SGreg Clayton     m_max_return_elements (max_return_elements),
511c9af18a5SGreg Clayton     m_matches (matches)
512c9af18a5SGreg Clayton {
513c9af18a5SGreg Clayton }
514c9af18a5SGreg Clayton 
515c9af18a5SGreg Clayton CommandCompletions::Completer::~Completer ()
516c9af18a5SGreg Clayton {
517c9af18a5SGreg Clayton 
518c9af18a5SGreg Clayton }
519c9af18a5SGreg Clayton 
520c9af18a5SGreg Clayton //----------------------------------------------------------------------
521c9af18a5SGreg Clayton // SourceFileCompleter
522c9af18a5SGreg Clayton //----------------------------------------------------------------------
523c9af18a5SGreg Clayton 
5246611103cSGreg Clayton CommandCompletions::SourceFileCompleter::SourceFileCompleter
5256611103cSGreg Clayton (
5266611103cSGreg Clayton     CommandInterpreter &interpreter,
527c9af18a5SGreg Clayton     bool include_support_files,
528c9af18a5SGreg Clayton     const char *completion_str,
529c9af18a5SGreg Clayton     int match_start_point,
530c9af18a5SGreg Clayton     int max_return_elements,
531c9af18a5SGreg Clayton     StringList &matches
532c9af18a5SGreg Clayton ) :
5336611103cSGreg Clayton     CommandCompletions::Completer (interpreter, completion_str, match_start_point, max_return_elements, matches),
534c9af18a5SGreg Clayton     m_include_support_files (include_support_files),
535c9af18a5SGreg Clayton     m_matching_files()
536c9af18a5SGreg Clayton {
537274060b6SGreg Clayton     FileSpec partial_spec (m_completion_str.c_str(), false);
538c9af18a5SGreg Clayton     m_file_name = partial_spec.GetFilename().GetCString();
539c9af18a5SGreg Clayton     m_dir_name = partial_spec.GetDirectory().GetCString();
540c9af18a5SGreg Clayton }
541c9af18a5SGreg Clayton 
542c9af18a5SGreg Clayton Searcher::Depth
543c9af18a5SGreg Clayton CommandCompletions::SourceFileCompleter::GetDepth()
544c9af18a5SGreg Clayton {
545c9af18a5SGreg Clayton     return eDepthCompUnit;
546c9af18a5SGreg Clayton }
547c9af18a5SGreg Clayton 
548c9af18a5SGreg Clayton Searcher::CallbackReturn
549c9af18a5SGreg Clayton CommandCompletions::SourceFileCompleter::SearchCallback (
550c9af18a5SGreg Clayton     SearchFilter &filter,
551c9af18a5SGreg Clayton     SymbolContext &context,
552c9af18a5SGreg Clayton     Address *addr,
553c9af18a5SGreg Clayton     bool complete
554c9af18a5SGreg Clayton )
555c9af18a5SGreg Clayton {
556c9af18a5SGreg Clayton     if (context.comp_unit != NULL)
557c9af18a5SGreg Clayton     {
558c9af18a5SGreg Clayton         if (m_include_support_files)
559c9af18a5SGreg Clayton         {
560c9af18a5SGreg Clayton             FileSpecList supporting_files = context.comp_unit->GetSupportFiles();
561c9af18a5SGreg Clayton             for (size_t sfiles = 0; sfiles < supporting_files.GetSize(); sfiles++)
562c9af18a5SGreg Clayton             {
563c9af18a5SGreg Clayton                 const FileSpec &sfile_spec = supporting_files.GetFileSpecAtIndex(sfiles);
564c9af18a5SGreg Clayton                 const char *sfile_file_name = sfile_spec.GetFilename().GetCString();
565c9af18a5SGreg Clayton                 const char *sfile_dir_name = sfile_spec.GetFilename().GetCString();
566c9af18a5SGreg Clayton                 bool match = false;
567c9af18a5SGreg Clayton                 if (m_file_name && sfile_file_name
568c9af18a5SGreg Clayton                     && strstr (sfile_file_name, m_file_name) == sfile_file_name)
569c9af18a5SGreg Clayton                     match = true;
570c9af18a5SGreg Clayton                 if (match && m_dir_name && sfile_dir_name
571c9af18a5SGreg Clayton                     && strstr (sfile_dir_name, m_dir_name) != sfile_dir_name)
572c9af18a5SGreg Clayton                     match = false;
573c9af18a5SGreg Clayton 
574c9af18a5SGreg Clayton                 if (match)
575c9af18a5SGreg Clayton                 {
576c9af18a5SGreg Clayton                     m_matching_files.AppendIfUnique(sfile_spec);
577c9af18a5SGreg Clayton                 }
578c9af18a5SGreg Clayton             }
579c9af18a5SGreg Clayton 
580c9af18a5SGreg Clayton         }
581c9af18a5SGreg Clayton         else
582c9af18a5SGreg Clayton         {
583c9af18a5SGreg Clayton             const char *cur_file_name = context.comp_unit->GetFilename().GetCString();
584c9af18a5SGreg Clayton             const char *cur_dir_name = context.comp_unit->GetDirectory().GetCString();
585c9af18a5SGreg Clayton 
586c9af18a5SGreg Clayton             bool match = false;
587c9af18a5SGreg Clayton             if (m_file_name && cur_file_name
588c9af18a5SGreg Clayton                 && strstr (cur_file_name, m_file_name) == cur_file_name)
589c9af18a5SGreg Clayton                 match = true;
590c9af18a5SGreg Clayton 
591c9af18a5SGreg Clayton             if (match && m_dir_name && cur_dir_name
592c9af18a5SGreg Clayton                 && strstr (cur_dir_name, m_dir_name) != cur_dir_name)
593c9af18a5SGreg Clayton                 match = false;
594c9af18a5SGreg Clayton 
595c9af18a5SGreg Clayton             if (match)
596c9af18a5SGreg Clayton             {
597c9af18a5SGreg Clayton                 m_matching_files.AppendIfUnique(context.comp_unit);
598c9af18a5SGreg Clayton             }
599c9af18a5SGreg Clayton         }
600c9af18a5SGreg Clayton     }
601c9af18a5SGreg Clayton     return Searcher::eCallbackReturnContinue;
602c9af18a5SGreg Clayton }
603c9af18a5SGreg Clayton 
604c9af18a5SGreg Clayton size_t
605c9af18a5SGreg Clayton CommandCompletions::SourceFileCompleter::DoCompletion (SearchFilter *filter)
606c9af18a5SGreg Clayton {
607c9af18a5SGreg Clayton     filter->Search (*this);
608c9af18a5SGreg Clayton     // Now convert the filelist to completions:
609c9af18a5SGreg Clayton     for (size_t i = 0; i < m_matching_files.GetSize(); i++)
610c9af18a5SGreg Clayton     {
611c9af18a5SGreg Clayton         m_matches.AppendString (m_matching_files.GetFileSpecAtIndex(i).GetFilename().GetCString());
612c9af18a5SGreg Clayton     }
613c9af18a5SGreg Clayton     return m_matches.GetSize();
614c9af18a5SGreg Clayton 
615c9af18a5SGreg Clayton }
616c9af18a5SGreg Clayton 
617c9af18a5SGreg Clayton //----------------------------------------------------------------------
618c9af18a5SGreg Clayton // SymbolCompleter
619c9af18a5SGreg Clayton //----------------------------------------------------------------------
620c9af18a5SGreg Clayton 
621c9af18a5SGreg Clayton static bool
622c9af18a5SGreg Clayton regex_chars (const char comp)
623c9af18a5SGreg Clayton {
624649f8b9bSGreg Clayton     if (comp == '[' || comp == ']' ||
625649f8b9bSGreg Clayton         comp == '(' || comp == ')' ||
626649f8b9bSGreg Clayton         comp == '{' || comp == '}' ||
627649f8b9bSGreg Clayton         comp == '+' ||
628649f8b9bSGreg Clayton         comp == '.' ||
629649f8b9bSGreg Clayton         comp == '*' ||
630649f8b9bSGreg Clayton         comp == '|' ||
631649f8b9bSGreg Clayton         comp == '^' ||
632649f8b9bSGreg Clayton         comp == '$' ||
633649f8b9bSGreg Clayton         comp == '\\' ||
634649f8b9bSGreg Clayton         comp == '?')
635c9af18a5SGreg Clayton         return true;
636c9af18a5SGreg Clayton     else
637c9af18a5SGreg Clayton         return false;
638c9af18a5SGreg Clayton }
6396611103cSGreg Clayton CommandCompletions::SymbolCompleter::SymbolCompleter
6406611103cSGreg Clayton (
6416611103cSGreg Clayton     CommandInterpreter &interpreter,
642c9af18a5SGreg Clayton     const char *completion_str,
643c9af18a5SGreg Clayton     int match_start_point,
644c9af18a5SGreg Clayton     int max_return_elements,
645c9af18a5SGreg Clayton     StringList &matches
646c9af18a5SGreg Clayton ) :
6476611103cSGreg Clayton     CommandCompletions::Completer (interpreter, completion_str, match_start_point, max_return_elements, matches)
648c9af18a5SGreg Clayton {
649649f8b9bSGreg Clayton     std::string regex_str;
650649f8b9bSGreg Clayton     if (completion_str && completion_str[0])
651649f8b9bSGreg Clayton     {
652649f8b9bSGreg Clayton         regex_str.append("^");
653c9af18a5SGreg Clayton         regex_str.append(completion_str);
654649f8b9bSGreg Clayton     }
655649f8b9bSGreg Clayton     else
656649f8b9bSGreg Clayton     {
657649f8b9bSGreg Clayton         // Match anything since the completion string is empty
658649f8b9bSGreg Clayton         regex_str.append(".");
659649f8b9bSGreg Clayton     }
660649f8b9bSGreg Clayton     std::string::iterator pos = find_if(regex_str.begin() + 1, regex_str.end(), regex_chars);
661649f8b9bSGreg Clayton     while (pos < regex_str.end())
662649f8b9bSGreg Clayton     {
663c9af18a5SGreg Clayton         pos = regex_str.insert(pos, '\\');
664649f8b9bSGreg Clayton         pos = find_if(pos + 2, regex_str.end(), regex_chars);
665c9af18a5SGreg Clayton     }
666c9af18a5SGreg Clayton     m_regex.Compile(regex_str.c_str());
667c9af18a5SGreg Clayton }
668c9af18a5SGreg Clayton 
669c9af18a5SGreg Clayton Searcher::Depth
670c9af18a5SGreg Clayton CommandCompletions::SymbolCompleter::GetDepth()
671c9af18a5SGreg Clayton {
672c9af18a5SGreg Clayton     return eDepthModule;
673c9af18a5SGreg Clayton }
674c9af18a5SGreg Clayton 
675c9af18a5SGreg Clayton Searcher::CallbackReturn
676c9af18a5SGreg Clayton CommandCompletions::SymbolCompleter::SearchCallback (
677c9af18a5SGreg Clayton     SearchFilter &filter,
678c9af18a5SGreg Clayton     SymbolContext &context,
679c9af18a5SGreg Clayton     Address *addr,
680c9af18a5SGreg Clayton     bool complete
681c9af18a5SGreg Clayton )
682c9af18a5SGreg Clayton {
683c9af18a5SGreg Clayton     if (context.module_sp)
684c9af18a5SGreg Clayton     {
685931180e6SGreg Clayton         SymbolContextList sc_list;
686931180e6SGreg Clayton         const bool include_symbols = true;
6879df05fbbSSean Callanan         const bool include_inlines = true;
688931180e6SGreg Clayton         const bool append = true;
6899df05fbbSSean Callanan         context.module_sp->FindFunctions (m_regex, include_symbols, include_inlines, append, sc_list);
690c9af18a5SGreg Clayton 
691c9af18a5SGreg Clayton         SymbolContext sc;
692c9af18a5SGreg Clayton         // Now add the functions & symbols to the list - only add if unique:
693931180e6SGreg Clayton         for (uint32_t i = 0; i < sc_list.GetSize(); i++)
694c9af18a5SGreg Clayton         {
695931180e6SGreg Clayton             if (sc_list.GetContextAtIndex(i, sc))
696c9af18a5SGreg Clayton             {
697530a413cSJim Ingham                 ConstString func_name = sc.GetFunctionName(Mangled::ePreferDemangled);
698530a413cSJim Ingham                 if (!func_name.IsEmpty())
699530a413cSJim Ingham                     m_match_set.insert (func_name);
700c9af18a5SGreg Clayton             }
701c9af18a5SGreg Clayton         }
702c9af18a5SGreg Clayton     }
703c9af18a5SGreg Clayton     return Searcher::eCallbackReturnContinue;
704c9af18a5SGreg Clayton }
705c9af18a5SGreg Clayton 
706c9af18a5SGreg Clayton size_t
707c9af18a5SGreg Clayton CommandCompletions::SymbolCompleter::DoCompletion (SearchFilter *filter)
708c9af18a5SGreg Clayton {
709c9af18a5SGreg Clayton     filter->Search (*this);
710c9af18a5SGreg Clayton     collection::iterator pos = m_match_set.begin(), end = m_match_set.end();
711c9af18a5SGreg Clayton     for (pos = m_match_set.begin(); pos != end; pos++)
712c9af18a5SGreg Clayton         m_matches.AppendString((*pos).GetCString());
713c9af18a5SGreg Clayton 
714c9af18a5SGreg Clayton     return m_matches.GetSize();
715c9af18a5SGreg Clayton }
716c9af18a5SGreg Clayton 
717c9af18a5SGreg Clayton //----------------------------------------------------------------------
718c9af18a5SGreg Clayton // ModuleCompleter
719c9af18a5SGreg Clayton //----------------------------------------------------------------------
7206611103cSGreg Clayton CommandCompletions::ModuleCompleter::ModuleCompleter
7216611103cSGreg Clayton (
7226611103cSGreg Clayton     CommandInterpreter &interpreter,
723c9af18a5SGreg Clayton     const char *completion_str,
724c9af18a5SGreg Clayton     int match_start_point,
725c9af18a5SGreg Clayton     int max_return_elements,
726c9af18a5SGreg Clayton     StringList &matches
727c9af18a5SGreg Clayton ) :
7286611103cSGreg Clayton     CommandCompletions::Completer (interpreter, completion_str, match_start_point, max_return_elements, matches)
729c9af18a5SGreg Clayton {
730274060b6SGreg Clayton     FileSpec partial_spec (m_completion_str.c_str(), false);
731c9af18a5SGreg Clayton     m_file_name = partial_spec.GetFilename().GetCString();
732c9af18a5SGreg Clayton     m_dir_name = partial_spec.GetDirectory().GetCString();
733c9af18a5SGreg Clayton }
734c9af18a5SGreg Clayton 
735c9af18a5SGreg Clayton Searcher::Depth
736c9af18a5SGreg Clayton CommandCompletions::ModuleCompleter::GetDepth()
737c9af18a5SGreg Clayton {
738c9af18a5SGreg Clayton     return eDepthModule;
739c9af18a5SGreg Clayton }
740c9af18a5SGreg Clayton 
741c9af18a5SGreg Clayton Searcher::CallbackReturn
742c9af18a5SGreg Clayton CommandCompletions::ModuleCompleter::SearchCallback (
743c9af18a5SGreg Clayton     SearchFilter &filter,
744c9af18a5SGreg Clayton     SymbolContext &context,
745c9af18a5SGreg Clayton     Address *addr,
746c9af18a5SGreg Clayton     bool complete
747c9af18a5SGreg Clayton )
748c9af18a5SGreg Clayton {
749747bcb03SGreg Clayton     if (context.module_sp)
750c9af18a5SGreg Clayton     {
751c9af18a5SGreg Clayton         const char *cur_file_name = context.module_sp->GetFileSpec().GetFilename().GetCString();
752c9af18a5SGreg Clayton         const char *cur_dir_name = context.module_sp->GetFileSpec().GetDirectory().GetCString();
753c9af18a5SGreg Clayton 
754c9af18a5SGreg Clayton         bool match = false;
755c9af18a5SGreg Clayton         if (m_file_name && cur_file_name
756c9af18a5SGreg Clayton             && strstr (cur_file_name, m_file_name) == cur_file_name)
757c9af18a5SGreg Clayton             match = true;
758c9af18a5SGreg Clayton 
759c9af18a5SGreg Clayton         if (match && m_dir_name && cur_dir_name
760c9af18a5SGreg Clayton             && strstr (cur_dir_name, m_dir_name) != cur_dir_name)
761c9af18a5SGreg Clayton             match = false;
762c9af18a5SGreg Clayton 
763c9af18a5SGreg Clayton         if (match)
764c9af18a5SGreg Clayton         {
765c9af18a5SGreg Clayton             m_matches.AppendString (cur_file_name);
766c9af18a5SGreg Clayton         }
767c9af18a5SGreg Clayton     }
768c9af18a5SGreg Clayton     return Searcher::eCallbackReturnContinue;
769c9af18a5SGreg Clayton }
770c9af18a5SGreg Clayton 
771c9af18a5SGreg Clayton size_t
772c9af18a5SGreg Clayton CommandCompletions::ModuleCompleter::DoCompletion (SearchFilter *filter)
773c9af18a5SGreg Clayton {
774c9af18a5SGreg Clayton     filter->Search (*this);
775c9af18a5SGreg Clayton     return m_matches.GetSize();
776c9af18a5SGreg Clayton }
777