Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 1 | //===-- CommandObjectWatchpointCommand.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 | // C Includes |
| 11 | // C++ Includes |
Eugene Zelenko | 49bcfd8 | 2016-02-23 01:43:44 +0000 | [diff] [blame] | 12 | #include <vector> |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 13 | |
Eugene Zelenko | 49bcfd8 | 2016-02-23 01:43:44 +0000 | [diff] [blame] | 14 | // Other libraries and framework includes |
| 15 | // Project includes |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 16 | #include "CommandObjectWatchpoint.h" |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 17 | #include "CommandObjectWatchpointCommand.h" |
| 18 | #include "lldb/Breakpoint/StoppointCallbackContext.h" |
| 19 | #include "lldb/Breakpoint/Watchpoint.h" |
Greg Clayton | 44d9378 | 2014-01-27 23:43:24 +0000 | [diff] [blame] | 20 | #include "lldb/Core/IOHandler.h" |
Zachary Turner | 3eb2b44 | 2017-03-22 23:33:16 +0000 | [diff] [blame] | 21 | #include "lldb/Host/OptionParser.h" |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 22 | #include "lldb/Interpreter/CommandInterpreter.h" |
| 23 | #include "lldb/Interpreter/CommandReturnObject.h" |
Pavel Labath | 47cbf4a | 2018-04-10 09:03:59 +0000 | [diff] [blame] | 24 | #include "lldb/Interpreter/OptionArgParser.h" |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 25 | #include "lldb/Target/Target.h" |
| 26 | #include "lldb/Target/Thread.h" |
Pavel Labath | d821c99 | 2018-08-07 11:07:21 +0000 | [diff] [blame] | 27 | #include "lldb/Utility/State.h" |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 28 | |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 29 | using namespace lldb; |
| 30 | using namespace lldb_private; |
| 31 | |
| 32 | //------------------------------------------------------------------------- |
| 33 | // CommandObjectWatchpointCommandAdd |
| 34 | //------------------------------------------------------------------------- |
| 35 | |
Zachary Turner | 1f0f5b5 | 2016-09-22 20:22:55 +0000 | [diff] [blame] | 36 | // FIXME: "script-type" needs to have its contents determined dynamically, so |
| 37 | // somebody can add a new scripting |
| 38 | // language to lldb and have it pickable here without having to change this |
| 39 | // enumeration by hand and rebuild lldb proper. |
| 40 | |
Tatyana Krasnukha | 8fe53c49 | 2018-09-26 18:50:19 +0000 | [diff] [blame^] | 41 | static constexpr OptionEnumValueElement g_script_option_enumeration[] = { |
Zachary Turner | 1f0f5b5 | 2016-09-22 20:22:55 +0000 | [diff] [blame] | 42 | {eScriptLanguageNone, "command", |
| 43 | "Commands are in the lldb command interpreter language"}, |
| 44 | {eScriptLanguagePython, "python", "Commands are in the Python language."}, |
| 45 | {eSortOrderByName, "default-script", |
Tatyana Krasnukha | 8fe53c49 | 2018-09-26 18:50:19 +0000 | [diff] [blame^] | 46 | "Commands are in the default scripting language."} }; |
Zachary Turner | 1f0f5b5 | 2016-09-22 20:22:55 +0000 | [diff] [blame] | 47 | |
Tatyana Krasnukha | 8fe53c49 | 2018-09-26 18:50:19 +0000 | [diff] [blame^] | 48 | static constexpr OptionEnumValues ScriptOptionEnum() { |
| 49 | return OptionEnumValues(g_script_option_enumeration); |
| 50 | } |
| 51 | |
| 52 | static constexpr OptionDefinition g_watchpoint_command_add_options[] = { |
Zachary Turner | 1f0f5b5 | 2016-09-22 20:22:55 +0000 | [diff] [blame] | 53 | // clang-format off |
Tatyana Krasnukha | 8fe53c49 | 2018-09-26 18:50:19 +0000 | [diff] [blame^] | 54 | { LLDB_OPT_SET_1, false, "one-liner", 'o', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeOneLiner, "Specify a one-line watchpoint command inline. Be sure to surround it with quotes." }, |
| 55 | { LLDB_OPT_SET_ALL, false, "stop-on-error", 'e', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Specify whether watchpoint command execution should terminate on error." }, |
| 56 | { LLDB_OPT_SET_ALL, false, "script-type", 's', OptionParser::eRequiredArgument, nullptr, ScriptOptionEnum(), 0, eArgTypeNone, "Specify the language for the commands - if none is specified, the lldb command interpreter will be used." }, |
| 57 | { LLDB_OPT_SET_2, false, "python-function", 'F', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePythonFunction, "Give the name of a Python function to run as command for this watchpoint. Be sure to give a module name if appropriate." } |
Zachary Turner | 1f0f5b5 | 2016-09-22 20:22:55 +0000 | [diff] [blame] | 58 | // clang-format on |
| 59 | }; |
| 60 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 61 | class CommandObjectWatchpointCommandAdd : public CommandObjectParsed, |
| 62 | public IOHandlerDelegateMultiline { |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 63 | public: |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 64 | CommandObjectWatchpointCommandAdd(CommandInterpreter &interpreter) |
| 65 | : CommandObjectParsed(interpreter, "add", |
| 66 | "Add a set of LLDB commands to a watchpoint, to be " |
| 67 | "executed whenever the watchpoint is hit.", |
| 68 | nullptr), |
| 69 | IOHandlerDelegateMultiline("DONE", |
| 70 | IOHandlerDelegate::Completion::LLDBCommand), |
| 71 | m_options() { |
| 72 | SetHelpLong( |
| 73 | R"( |
Kate Stone | ea671fb | 2015-07-14 05:48:36 +0000 | [diff] [blame] | 74 | General information about entering watchpoint commands |
| 75 | ------------------------------------------------------ |
| 76 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 77 | )" |
| 78 | "This command will prompt for commands to be executed when the specified \ |
Kate Stone | ea671fb | 2015-07-14 05:48:36 +0000 | [diff] [blame] | 79 | watchpoint is hit. Each command is typed on its own line following the '> ' \ |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 80 | prompt until 'DONE' is entered." |
| 81 | R"( |
Kate Stone | ea671fb | 2015-07-14 05:48:36 +0000 | [diff] [blame] | 82 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 83 | )" |
| 84 | "Syntactic errors may not be detected when initially entered, and many \ |
Kate Stone | ea671fb | 2015-07-14 05:48:36 +0000 | [diff] [blame] | 85 | malformed commands can silently fail when executed. If your watchpoint commands \ |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 86 | do not appear to be executing, double-check the command syntax." |
| 87 | R"( |
Kate Stone | ea671fb | 2015-07-14 05:48:36 +0000 | [diff] [blame] | 88 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 89 | )" |
| 90 | "Note: You may enter any debugger command exactly as you would at the debugger \ |
Kate Stone | ea671fb | 2015-07-14 05:48:36 +0000 | [diff] [blame] | 91 | prompt. There is no limit to the number of commands supplied, but do NOT enter \ |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 92 | more than one command per line." |
| 93 | R"( |
Kate Stone | ea671fb | 2015-07-14 05:48:36 +0000 | [diff] [blame] | 94 | |
| 95 | Special information about PYTHON watchpoint commands |
| 96 | ---------------------------------------------------- |
| 97 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 98 | )" |
| 99 | "You may enter either one or more lines of Python, including function \ |
Kate Stone | ea671fb | 2015-07-14 05:48:36 +0000 | [diff] [blame] | 100 | definitions or calls to functions that will have been imported by the time \ |
| 101 | the code executes. Single line watchpoint commands will be interpreted 'as is' \ |
| 102 | when the watchpoint is hit. Multiple lines of Python will be wrapped in a \ |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 103 | generated function, and a call to the function will be attached to the watchpoint." |
| 104 | R"( |
Kate Stone | ea671fb | 2015-07-14 05:48:36 +0000 | [diff] [blame] | 105 | |
| 106 | This auto-generated function is passed in three arguments: |
| 107 | |
| 108 | frame: an lldb.SBFrame object for the frame which hit the watchpoint. |
| 109 | |
| 110 | wp: the watchpoint that was hit. |
| 111 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 112 | )" |
| 113 | "When specifying a python function with the --python-function option, you need \ |
| 114 | to supply the function name prepended by the module name:" |
| 115 | R"( |
Kate Stone | ea671fb | 2015-07-14 05:48:36 +0000 | [diff] [blame] | 116 | |
| 117 | --python-function myutils.watchpoint_callback |
| 118 | |
| 119 | The function itself must have the following prototype: |
| 120 | |
| 121 | def watchpoint_callback(frame, wp): |
| 122 | # Your code goes here |
| 123 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 124 | )" |
| 125 | "The arguments are the same as the arguments passed to generated functions as \ |
Kate Stone | ea671fb | 2015-07-14 05:48:36 +0000 | [diff] [blame] | 126 | described above. Note that the global variable 'lldb.frame' will NOT be updated when \ |
| 127 | this function is called, so be sure to use the 'frame' argument. The 'frame' argument \ |
| 128 | can get you to the thread via frame.GetThread(), the thread can get you to the \ |
| 129 | process via thread.GetProcess(), and the process can get you back to the target \ |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 130 | via process.GetTarget()." |
| 131 | R"( |
Kate Stone | ea671fb | 2015-07-14 05:48:36 +0000 | [diff] [blame] | 132 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 133 | )" |
| 134 | "Important Note: As Python code gets collected into functions, access to global \ |
Kate Stone | ea671fb | 2015-07-14 05:48:36 +0000 | [diff] [blame] | 135 | variables requires explicit scoping using the 'global' keyword. Be sure to use correct \ |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 136 | Python syntax, including indentation, when entering Python watchpoint commands." |
| 137 | R"( |
Kate Stone | ea671fb | 2015-07-14 05:48:36 +0000 | [diff] [blame] | 138 | |
| 139 | Example Python one-line watchpoint command: |
| 140 | |
| 141 | (lldb) watchpoint command add -s python 1 |
| 142 | Enter your Python command(s). Type 'DONE' to end. |
| 143 | > print "Hit this watchpoint!" |
| 144 | > DONE |
| 145 | |
| 146 | As a convenience, this also works for a short Python one-liner: |
| 147 | |
| 148 | (lldb) watchpoint command add -s python 1 -o 'import time; print time.asctime()' |
| 149 | (lldb) run |
| 150 | Launching '.../a.out' (x86_64) |
| 151 | (lldb) Fri Sep 10 12:17:45 2010 |
| 152 | Process 21778 Stopped |
| 153 | * thread #1: tid = 0x2e03, 0x0000000100000de8 a.out`c + 7 at main.c:39, stop reason = watchpoint 1.1, queue = com.apple.main-thread |
| 154 | 36 |
| 155 | 37 int c(int val) |
| 156 | 38 { |
| 157 | 39 -> return val + 3; |
| 158 | 40 } |
| 159 | 41 |
| 160 | 42 int main (int argc, char const *argv[]) |
| 161 | |
| 162 | Example multiple line Python watchpoint command, using function definition: |
| 163 | |
| 164 | (lldb) watchpoint command add -s python 1 |
| 165 | Enter your Python command(s). Type 'DONE' to end. |
| 166 | > def watchpoint_output (wp_no): |
| 167 | > out_string = "Hit watchpoint number " + repr (wp_no) |
| 168 | > print out_string |
| 169 | > return True |
| 170 | > watchpoint_output (1) |
| 171 | > DONE |
| 172 | |
| 173 | Example multiple line Python watchpoint command, using 'loose' Python: |
| 174 | |
| 175 | (lldb) watchpoint command add -s p 1 |
| 176 | Enter your Python command(s). Type 'DONE' to end. |
| 177 | > global wp_count |
| 178 | > wp_count = wp_count + 1 |
| 179 | > print "Hit this watchpoint " + repr(wp_count) + " times!" |
| 180 | > DONE |
| 181 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 182 | )" |
| 183 | "In this case, since there is a reference to a global variable, \ |
Kate Stone | ea671fb | 2015-07-14 05:48:36 +0000 | [diff] [blame] | 184 | 'wp_count', you will also need to make sure 'wp_count' exists and is \ |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 185 | initialized:" |
| 186 | R"( |
Kate Stone | ea671fb | 2015-07-14 05:48:36 +0000 | [diff] [blame] | 187 | |
| 188 | (lldb) script |
| 189 | >>> wp_count = 0 |
| 190 | >>> quit() |
| 191 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 192 | )" |
| 193 | "Final Note: A warning that no watchpoint command was generated when there \ |
| 194 | are no syntax errors may indicate that a function was declared but never called."); |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 195 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 196 | CommandArgumentEntry arg; |
| 197 | CommandArgumentData wp_id_arg; |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 198 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 199 | // Define the first (and only) variant of this arg. |
| 200 | wp_id_arg.arg_type = eArgTypeWatchpointID; |
| 201 | wp_id_arg.arg_repetition = eArgRepeatPlain; |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 202 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 203 | // There is only one variant this argument could be; put it into the |
| 204 | // argument entry. |
| 205 | arg.push_back(wp_id_arg); |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 206 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 207 | // Push the data for the first argument into the m_arguments vector. |
| 208 | m_arguments.push_back(arg); |
| 209 | } |
| 210 | |
| 211 | ~CommandObjectWatchpointCommandAdd() override = default; |
| 212 | |
| 213 | Options *GetOptions() override { return &m_options; } |
| 214 | |
| 215 | void IOHandlerActivated(IOHandler &io_handler) override { |
| 216 | StreamFileSP output_sp(io_handler.GetOutputStreamFile()); |
| 217 | if (output_sp) { |
| 218 | output_sp->PutCString( |
| 219 | "Enter your debugger command(s). Type 'DONE' to end.\n"); |
| 220 | output_sp->Flush(); |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | void IOHandlerInputComplete(IOHandler &io_handler, |
| 225 | std::string &line) override { |
| 226 | io_handler.SetIsDone(true); |
| 227 | |
| 228 | // The WatchpointOptions object is owned by the watchpoint or watchpoint |
| 229 | // location |
| 230 | WatchpointOptions *wp_options = |
| 231 | (WatchpointOptions *)io_handler.GetUserData(); |
| 232 | if (wp_options) { |
| 233 | std::unique_ptr<WatchpointOptions::CommandData> data_ap( |
| 234 | new WatchpointOptions::CommandData()); |
| 235 | if (data_ap) { |
| 236 | data_ap->user_source.SplitIntoLines(line); |
Zachary Turner | 4e4fbe8 | 2016-09-13 17:53:38 +0000 | [diff] [blame] | 237 | auto baton_sp = std::make_shared<WatchpointOptions::CommandBaton>( |
| 238 | std::move(data_ap)); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 239 | wp_options->SetCallback(WatchpointOptionsCallbackFunction, baton_sp); |
| 240 | } |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | void CollectDataForWatchpointCommandCallback(WatchpointOptions *wp_options, |
| 245 | CommandReturnObject &result) { |
| 246 | m_interpreter.GetLLDBCommandsFromIOHandler( |
| 247 | "> ", // Prompt |
| 248 | *this, // IOHandlerDelegate |
| 249 | true, // Run IOHandler in async mode |
| 250 | wp_options); // Baton for the "io_handler" that will be passed back into |
| 251 | // our IOHandlerDelegate functions |
| 252 | } |
| 253 | |
| 254 | /// Set a one-liner as the callback for the watchpoint. |
| 255 | void SetWatchpointCommandCallback(WatchpointOptions *wp_options, |
| 256 | const char *oneliner) { |
| 257 | std::unique_ptr<WatchpointOptions::CommandData> data_ap( |
| 258 | new WatchpointOptions::CommandData()); |
| 259 | |
Adrian Prantl | 0509724 | 2018-04-30 16:49:04 +0000 | [diff] [blame] | 260 | // It's necessary to set both user_source and script_source to the |
| 261 | // oneliner. The former is used to generate callback description (as in |
| 262 | // watchpoint command list) while the latter is used for Python to |
| 263 | // interpret during the actual callback. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 264 | data_ap->user_source.AppendString(oneliner); |
| 265 | data_ap->script_source.assign(oneliner); |
| 266 | data_ap->stop_on_error = m_options.m_stop_on_error; |
| 267 | |
Zachary Turner | 4e4fbe8 | 2016-09-13 17:53:38 +0000 | [diff] [blame] | 268 | auto baton_sp = |
| 269 | std::make_shared<WatchpointOptions::CommandBaton>(std::move(data_ap)); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 270 | wp_options->SetCallback(WatchpointOptionsCallbackFunction, baton_sp); |
| 271 | } |
| 272 | |
| 273 | static bool |
| 274 | WatchpointOptionsCallbackFunction(void *baton, |
| 275 | StoppointCallbackContext *context, |
| 276 | lldb::user_id_t watch_id) { |
| 277 | bool ret_value = true; |
| 278 | if (baton == nullptr) |
| 279 | return true; |
| 280 | |
| 281 | WatchpointOptions::CommandData *data = |
| 282 | (WatchpointOptions::CommandData *)baton; |
| 283 | StringList &commands = data->user_source; |
| 284 | |
| 285 | if (commands.GetSize() > 0) { |
| 286 | ExecutionContext exe_ctx(context->exe_ctx_ref); |
| 287 | Target *target = exe_ctx.GetTargetPtr(); |
| 288 | if (target) { |
| 289 | CommandReturnObject result; |
| 290 | Debugger &debugger = target->GetDebugger(); |
| 291 | // Rig up the results secondary output stream to the debugger's, so the |
Adrian Prantl | 0509724 | 2018-04-30 16:49:04 +0000 | [diff] [blame] | 292 | // output will come out synchronously if the debugger is set up that |
| 293 | // way. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 294 | |
| 295 | StreamSP output_stream(debugger.GetAsyncOutputStream()); |
| 296 | StreamSP error_stream(debugger.GetAsyncErrorStream()); |
| 297 | result.SetImmediateOutputStream(output_stream); |
| 298 | result.SetImmediateErrorStream(error_stream); |
| 299 | |
| 300 | CommandInterpreterRunOptions options; |
| 301 | options.SetStopOnContinue(true); |
| 302 | options.SetStopOnError(data->stop_on_error); |
| 303 | options.SetEchoCommands(false); |
| 304 | options.SetPrintResults(true); |
| 305 | options.SetAddToHistory(false); |
| 306 | |
| 307 | debugger.GetCommandInterpreter().HandleCommands(commands, &exe_ctx, |
| 308 | options, result); |
| 309 | result.GetImmediateOutputStream()->Flush(); |
| 310 | result.GetImmediateErrorStream()->Flush(); |
| 311 | } |
| 312 | } |
| 313 | return ret_value; |
| 314 | } |
| 315 | |
| 316 | class CommandOptions : public Options { |
| 317 | public: |
| 318 | CommandOptions() |
| 319 | : Options(), m_use_commands(false), m_use_script_language(false), |
| 320 | m_script_language(eScriptLanguageNone), m_use_one_liner(false), |
| 321 | m_one_liner(), m_function_name() {} |
| 322 | |
| 323 | ~CommandOptions() override = default; |
| 324 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 325 | Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, |
| 326 | ExecutionContext *execution_context) override { |
| 327 | Status error; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 328 | const int short_option = m_getopt_table[option_idx].val; |
| 329 | |
| 330 | switch (short_option) { |
| 331 | case 'o': |
| 332 | m_use_one_liner = true; |
| 333 | m_one_liner = option_arg; |
| 334 | break; |
| 335 | |
| 336 | case 's': |
Pavel Labath | 47cbf4a | 2018-04-10 09:03:59 +0000 | [diff] [blame] | 337 | m_script_language = (lldb::ScriptLanguage)OptionArgParser::ToOptionEnum( |
Zachary Turner | fe11483 | 2016-11-12 16:56:47 +0000 | [diff] [blame] | 338 | option_arg, GetDefinitions()[option_idx].enum_values, |
| 339 | eScriptLanguageNone, error); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 340 | |
| 341 | m_use_script_language = (m_script_language == eScriptLanguagePython || |
| 342 | m_script_language == eScriptLanguageDefault); |
| 343 | break; |
| 344 | |
| 345 | case 'e': { |
| 346 | bool success = false; |
Pavel Labath | 47cbf4a | 2018-04-10 09:03:59 +0000 | [diff] [blame] | 347 | m_stop_on_error = |
| 348 | OptionArgParser::ToBoolean(option_arg, false, &success); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 349 | if (!success) |
| 350 | error.SetErrorStringWithFormat( |
Zachary Turner | fe11483 | 2016-11-12 16:56:47 +0000 | [diff] [blame] | 351 | "invalid value for stop-on-error: \"%s\"", |
| 352 | option_arg.str().c_str()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 353 | } break; |
| 354 | |
| 355 | case 'F': |
| 356 | m_use_one_liner = false; |
| 357 | m_use_script_language = true; |
| 358 | m_function_name.assign(option_arg); |
| 359 | break; |
| 360 | |
| 361 | default: |
| 362 | break; |
| 363 | } |
| 364 | return error; |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 365 | } |
| 366 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 367 | void OptionParsingStarting(ExecutionContext *execution_context) override { |
| 368 | m_use_commands = true; |
| 369 | m_use_script_language = false; |
| 370 | m_script_language = eScriptLanguageNone; |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 371 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 372 | m_use_one_liner = false; |
| 373 | m_stop_on_error = true; |
| 374 | m_one_liner.clear(); |
| 375 | m_function_name.clear(); |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 376 | } |
| 377 | |
Zachary Turner | 1f0f5b5 | 2016-09-22 20:22:55 +0000 | [diff] [blame] | 378 | llvm::ArrayRef<OptionDefinition> GetDefinitions() override { |
Zachary Turner | 7060243 | 2016-09-22 21:06:13 +0000 | [diff] [blame] | 379 | return llvm::makeArrayRef(g_watchpoint_command_add_options); |
Zachary Turner | 1f0f5b5 | 2016-09-22 20:22:55 +0000 | [diff] [blame] | 380 | } |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 381 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 382 | // Instance variables to hold the values for command options. |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 383 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 384 | bool m_use_commands; |
| 385 | bool m_use_script_language; |
| 386 | lldb::ScriptLanguage m_script_language; |
Eugene Zelenko | 49bcfd8 | 2016-02-23 01:43:44 +0000 | [diff] [blame] | 387 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 388 | // Instance variables to hold the values for one_liner options. |
| 389 | bool m_use_one_liner; |
| 390 | std::string m_one_liner; |
| 391 | bool m_stop_on_error; |
| 392 | std::string m_function_name; |
| 393 | }; |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 394 | |
| 395 | protected: |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 396 | bool DoExecute(Args &command, CommandReturnObject &result) override { |
| 397 | Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 398 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 399 | if (target == nullptr) { |
| 400 | result.AppendError("There is not a current executable; there are no " |
| 401 | "watchpoints to which to add commands"); |
| 402 | result.SetStatus(eReturnStatusFailed); |
| 403 | return false; |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 404 | } |
| 405 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 406 | const WatchpointList &watchpoints = target->GetWatchpointList(); |
| 407 | size_t num_watchpoints = watchpoints.GetSize(); |
| 408 | |
| 409 | if (num_watchpoints == 0) { |
| 410 | result.AppendError("No watchpoints exist to have commands added"); |
| 411 | result.SetStatus(eReturnStatusFailed); |
| 412 | return false; |
| 413 | } |
| 414 | |
| 415 | if (!m_options.m_use_script_language && |
| 416 | !m_options.m_function_name.empty()) { |
| 417 | result.AppendError("need to enable scripting to have a function run as a " |
| 418 | "watchpoint command"); |
| 419 | result.SetStatus(eReturnStatusFailed); |
| 420 | return false; |
| 421 | } |
| 422 | |
| 423 | std::vector<uint32_t> valid_wp_ids; |
| 424 | if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(target, command, |
| 425 | valid_wp_ids)) { |
| 426 | result.AppendError("Invalid watchpoints specification."); |
| 427 | result.SetStatus(eReturnStatusFailed); |
| 428 | return false; |
| 429 | } |
| 430 | |
| 431 | result.SetStatus(eReturnStatusSuccessFinishNoResult); |
| 432 | const size_t count = valid_wp_ids.size(); |
| 433 | for (size_t i = 0; i < count; ++i) { |
| 434 | uint32_t cur_wp_id = valid_wp_ids.at(i); |
| 435 | if (cur_wp_id != LLDB_INVALID_WATCH_ID) { |
| 436 | Watchpoint *wp = target->GetWatchpointList().FindByID(cur_wp_id).get(); |
| 437 | // Sanity check wp first. |
| 438 | if (wp == nullptr) |
| 439 | continue; |
| 440 | |
| 441 | WatchpointOptions *wp_options = wp->GetOptions(); |
| 442 | // Skip this watchpoint if wp_options is not good. |
| 443 | if (wp_options == nullptr) |
| 444 | continue; |
| 445 | |
Adrian Prantl | 0509724 | 2018-04-30 16:49:04 +0000 | [diff] [blame] | 446 | // If we are using script language, get the script interpreter in order |
| 447 | // to set or collect command callback. Otherwise, call the methods |
| 448 | // associated with this object. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 449 | if (m_options.m_use_script_language) { |
| 450 | // Special handling for one-liner specified inline. |
| 451 | if (m_options.m_use_one_liner) { |
| 452 | m_interpreter.GetScriptInterpreter()->SetWatchpointCommandCallback( |
| 453 | wp_options, m_options.m_one_liner.c_str()); |
| 454 | } |
Adrian Prantl | 0509724 | 2018-04-30 16:49:04 +0000 | [diff] [blame] | 455 | // Special handling for using a Python function by name instead of |
| 456 | // extending the watchpoint callback data structures, we just |
| 457 | // automatize what the user would do manually: make their watchpoint |
| 458 | // command be a function call |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 459 | else if (!m_options.m_function_name.empty()) { |
| 460 | std::string oneliner(m_options.m_function_name); |
| 461 | oneliner += "(frame, wp, internal_dict)"; |
| 462 | m_interpreter.GetScriptInterpreter()->SetWatchpointCommandCallback( |
| 463 | wp_options, oneliner.c_str()); |
| 464 | } else { |
| 465 | m_interpreter.GetScriptInterpreter() |
| 466 | ->CollectDataForWatchpointCommandCallback(wp_options, result); |
| 467 | } |
| 468 | } else { |
| 469 | // Special handling for one-liner specified inline. |
| 470 | if (m_options.m_use_one_liner) |
| 471 | SetWatchpointCommandCallback(wp_options, |
| 472 | m_options.m_one_liner.c_str()); |
| 473 | else |
| 474 | CollectDataForWatchpointCommandCallback(wp_options, result); |
| 475 | } |
| 476 | } |
| 477 | } |
| 478 | |
| 479 | return result.Succeeded(); |
| 480 | } |
| 481 | |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 482 | private: |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 483 | CommandOptions m_options; |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 484 | }; |
| 485 | |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 486 | //------------------------------------------------------------------------- |
| 487 | // CommandObjectWatchpointCommandDelete |
| 488 | //------------------------------------------------------------------------- |
| 489 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 490 | class CommandObjectWatchpointCommandDelete : public CommandObjectParsed { |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 491 | public: |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 492 | CommandObjectWatchpointCommandDelete(CommandInterpreter &interpreter) |
| 493 | : CommandObjectParsed(interpreter, "delete", |
Eugene Zelenko | 49bcfd8 | 2016-02-23 01:43:44 +0000 | [diff] [blame] | 494 | "Delete the set of commands from a watchpoint.", |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 495 | nullptr) { |
| 496 | CommandArgumentEntry arg; |
| 497 | CommandArgumentData wp_id_arg; |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 498 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 499 | // Define the first (and only) variant of this arg. |
| 500 | wp_id_arg.arg_type = eArgTypeWatchpointID; |
| 501 | wp_id_arg.arg_repetition = eArgRepeatPlain; |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 502 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 503 | // There is only one variant this argument could be; put it into the |
| 504 | // argument entry. |
| 505 | arg.push_back(wp_id_arg); |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 506 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 507 | // Push the data for the first argument into the m_arguments vector. |
| 508 | m_arguments.push_back(arg); |
| 509 | } |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 510 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 511 | ~CommandObjectWatchpointCommandDelete() override = default; |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 512 | |
| 513 | protected: |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 514 | bool DoExecute(Args &command, CommandReturnObject &result) override { |
| 515 | Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 516 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 517 | if (target == nullptr) { |
| 518 | result.AppendError("There is not a current executable; there are no " |
| 519 | "watchpoints from which to delete commands"); |
| 520 | result.SetStatus(eReturnStatusFailed); |
| 521 | return false; |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 522 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 523 | |
| 524 | const WatchpointList &watchpoints = target->GetWatchpointList(); |
| 525 | size_t num_watchpoints = watchpoints.GetSize(); |
| 526 | |
| 527 | if (num_watchpoints == 0) { |
| 528 | result.AppendError("No watchpoints exist to have commands deleted"); |
| 529 | result.SetStatus(eReturnStatusFailed); |
| 530 | return false; |
| 531 | } |
| 532 | |
| 533 | if (command.GetArgumentCount() == 0) { |
| 534 | result.AppendError( |
| 535 | "No watchpoint specified from which to delete the commands"); |
| 536 | result.SetStatus(eReturnStatusFailed); |
| 537 | return false; |
| 538 | } |
| 539 | |
| 540 | std::vector<uint32_t> valid_wp_ids; |
| 541 | if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(target, command, |
| 542 | valid_wp_ids)) { |
| 543 | result.AppendError("Invalid watchpoints specification."); |
| 544 | result.SetStatus(eReturnStatusFailed); |
| 545 | return false; |
| 546 | } |
| 547 | |
| 548 | result.SetStatus(eReturnStatusSuccessFinishNoResult); |
| 549 | const size_t count = valid_wp_ids.size(); |
| 550 | for (size_t i = 0; i < count; ++i) { |
| 551 | uint32_t cur_wp_id = valid_wp_ids.at(i); |
| 552 | if (cur_wp_id != LLDB_INVALID_WATCH_ID) { |
| 553 | Watchpoint *wp = target->GetWatchpointList().FindByID(cur_wp_id).get(); |
| 554 | if (wp) |
| 555 | wp->ClearCallback(); |
| 556 | } else { |
| 557 | result.AppendErrorWithFormat("Invalid watchpoint ID: %u.\n", cur_wp_id); |
| 558 | result.SetStatus(eReturnStatusFailed); |
| 559 | return false; |
| 560 | } |
| 561 | } |
| 562 | return result.Succeeded(); |
| 563 | } |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 564 | }; |
| 565 | |
| 566 | //------------------------------------------------------------------------- |
| 567 | // CommandObjectWatchpointCommandList |
| 568 | //------------------------------------------------------------------------- |
| 569 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 570 | class CommandObjectWatchpointCommandList : public CommandObjectParsed { |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 571 | public: |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 572 | CommandObjectWatchpointCommandList(CommandInterpreter &interpreter) |
| 573 | : CommandObjectParsed(interpreter, "list", "List the script or set of " |
| 574 | "commands to be executed when " |
| 575 | "the watchpoint is hit.", |
| 576 | nullptr) { |
| 577 | CommandArgumentEntry arg; |
| 578 | CommandArgumentData wp_id_arg; |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 579 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 580 | // Define the first (and only) variant of this arg. |
| 581 | wp_id_arg.arg_type = eArgTypeWatchpointID; |
| 582 | wp_id_arg.arg_repetition = eArgRepeatPlain; |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 583 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 584 | // There is only one variant this argument could be; put it into the |
| 585 | // argument entry. |
| 586 | arg.push_back(wp_id_arg); |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 587 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 588 | // Push the data for the first argument into the m_arguments vector. |
| 589 | m_arguments.push_back(arg); |
| 590 | } |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 591 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 592 | ~CommandObjectWatchpointCommandList() override = default; |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 593 | |
| 594 | protected: |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 595 | bool DoExecute(Args &command, CommandReturnObject &result) override { |
| 596 | Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 597 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 598 | if (target == nullptr) { |
| 599 | result.AppendError("There is not a current executable; there are no " |
| 600 | "watchpoints for which to list commands"); |
| 601 | result.SetStatus(eReturnStatusFailed); |
| 602 | return false; |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 603 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 604 | |
| 605 | const WatchpointList &watchpoints = target->GetWatchpointList(); |
| 606 | size_t num_watchpoints = watchpoints.GetSize(); |
| 607 | |
| 608 | if (num_watchpoints == 0) { |
| 609 | result.AppendError("No watchpoints exist for which to list commands"); |
| 610 | result.SetStatus(eReturnStatusFailed); |
| 611 | return false; |
| 612 | } |
| 613 | |
| 614 | if (command.GetArgumentCount() == 0) { |
| 615 | result.AppendError( |
| 616 | "No watchpoint specified for which to list the commands"); |
| 617 | result.SetStatus(eReturnStatusFailed); |
| 618 | return false; |
| 619 | } |
| 620 | |
| 621 | std::vector<uint32_t> valid_wp_ids; |
| 622 | if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(target, command, |
| 623 | valid_wp_ids)) { |
| 624 | result.AppendError("Invalid watchpoints specification."); |
| 625 | result.SetStatus(eReturnStatusFailed); |
| 626 | return false; |
| 627 | } |
| 628 | |
| 629 | result.SetStatus(eReturnStatusSuccessFinishNoResult); |
| 630 | const size_t count = valid_wp_ids.size(); |
| 631 | for (size_t i = 0; i < count; ++i) { |
| 632 | uint32_t cur_wp_id = valid_wp_ids.at(i); |
| 633 | if (cur_wp_id != LLDB_INVALID_WATCH_ID) { |
| 634 | Watchpoint *wp = target->GetWatchpointList().FindByID(cur_wp_id).get(); |
| 635 | |
| 636 | if (wp) { |
| 637 | const WatchpointOptions *wp_options = wp->GetOptions(); |
| 638 | if (wp_options) { |
| 639 | // Get the callback baton associated with the current watchpoint. |
| 640 | const Baton *baton = wp_options->GetBaton(); |
| 641 | if (baton) { |
| 642 | result.GetOutputStream().Printf("Watchpoint %u:\n", cur_wp_id); |
| 643 | result.GetOutputStream().IndentMore(); |
| 644 | baton->GetDescription(&result.GetOutputStream(), |
| 645 | eDescriptionLevelFull); |
| 646 | result.GetOutputStream().IndentLess(); |
| 647 | } else { |
| 648 | result.AppendMessageWithFormat( |
| 649 | "Watchpoint %u does not have an associated command.\n", |
| 650 | cur_wp_id); |
| 651 | } |
| 652 | } |
| 653 | result.SetStatus(eReturnStatusSuccessFinishResult); |
| 654 | } else { |
| 655 | result.AppendErrorWithFormat("Invalid watchpoint ID: %u.\n", |
| 656 | cur_wp_id); |
| 657 | result.SetStatus(eReturnStatusFailed); |
| 658 | } |
| 659 | } |
| 660 | } |
| 661 | |
| 662 | return result.Succeeded(); |
| 663 | } |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 664 | }; |
| 665 | |
| 666 | //------------------------------------------------------------------------- |
| 667 | // CommandObjectWatchpointCommand |
| 668 | //------------------------------------------------------------------------- |
| 669 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 670 | CommandObjectWatchpointCommand::CommandObjectWatchpointCommand( |
| 671 | CommandInterpreter &interpreter) |
| 672 | : CommandObjectMultiword( |
| 673 | interpreter, "command", |
| 674 | "Commands for adding, removing and examining LLDB commands " |
Bruce Mitchener | 4ebdee0 | 2018-05-29 09:10:46 +0000 | [diff] [blame] | 675 | "executed when the watchpoint is hit (watchpoint 'commands').", |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 676 | "command <sub-command> [<sub-command-options>] <watchpoint-id>") { |
| 677 | CommandObjectSP add_command_object( |
| 678 | new CommandObjectWatchpointCommandAdd(interpreter)); |
| 679 | CommandObjectSP delete_command_object( |
| 680 | new CommandObjectWatchpointCommandDelete(interpreter)); |
| 681 | CommandObjectSP list_command_object( |
| 682 | new CommandObjectWatchpointCommandList(interpreter)); |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 683 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 684 | add_command_object->SetCommandName("watchpoint command add"); |
| 685 | delete_command_object->SetCommandName("watchpoint command delete"); |
| 686 | list_command_object->SetCommandName("watchpoint command list"); |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 687 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 688 | LoadSubCommand("add", add_command_object); |
| 689 | LoadSubCommand("delete", delete_command_object); |
| 690 | LoadSubCommand("list", list_command_object); |
Johnny Chen | e9a5627 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 691 | } |
| 692 | |
Eugene Zelenko | 49bcfd8 | 2016-02-23 01:43:44 +0000 | [diff] [blame] | 693 | CommandObjectWatchpointCommand::~CommandObjectWatchpointCommand() = default; |