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