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