LLDB mainline
CommandObjectBreakpoint.cpp
Go to the documentation of this file.
1//===-- CommandObjectBreakpoint.cpp ---------------------------------------===//
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
27#include "lldb/Target/Target.h"
31#include "llvm/Support/FormatAdapters.h"
32
33#include <memory>
34#include <optional>
35#include <vector>
36
37using namespace lldb;
38using namespace lldb_private;
39
42 s->IndentMore();
43 bp->GetDescription(s, level, true);
44 s->IndentLess();
45 s->EOL();
46}
47
48static bool GetDefaultFile(Target &target, StackFrame *cur_frame,
49 FileSpec &file, CommandReturnObject &result) {
50 // First use the Source Manager's default file. Then use the current stack
51 // frame's file.
52 if (auto maybe_file_and_line =
54 file = maybe_file_and_line->support_file_nsp->GetSpecOnly();
55 return true;
56 }
57
58 if (cur_frame == nullptr) {
59 result.AppendError("No selected frame to use to find the default file.");
60 return false;
61 }
62 if (!cur_frame->HasDebugInformation()) {
63 result.AppendError("Cannot use the selected frame to find the default "
64 "file, it has no debug info.");
65 return false;
66 }
67
68 const SymbolContext &sc =
69 cur_frame->GetSymbolContext(eSymbolContextLineEntry);
70 if (sc.line_entry.GetFile()) {
71 file = sc.line_entry.GetFile();
72 } else {
73 result.AppendError("Can't find the file for the selected frame to "
74 "use as the default file.");
75 return false;
76 }
77 return true;
78}
79
80// Modifiable Breakpoint Options
81#pragma mark Modify::CommandOptions
82#define LLDB_OPTIONS_breakpoint_modify
83#include "CommandOptions.inc"
84
86public:
88
89 ~BreakpointOptionGroup() override = default;
90
91 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
92 return llvm::ArrayRef(g_breakpoint_modify_options);
93 }
94
95 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
96 ExecutionContext *execution_context) override {
98 const int short_option =
99 g_breakpoint_modify_options[option_idx].short_option;
100 const char *long_option =
101 g_breakpoint_modify_options[option_idx].long_option;
102
103 switch (short_option) {
104 case 'c':
105 // Normally an empty breakpoint condition marks is as unset. But we need
106 // to say it was passed in.
107 m_bp_opts.GetCondition().SetText(option_arg.str());
109 break;
110 case 'C':
111 m_commands.push_back(std::string(option_arg));
112 break;
113 case 'd':
114 m_bp_opts.SetEnabled(false);
115 break;
116 case 'e':
117 m_bp_opts.SetEnabled(true);
118 break;
119 case 'G': {
120 bool value, success;
121 value = OptionArgParser::ToBoolean(option_arg, false, &success);
122 if (success)
123 m_bp_opts.SetAutoContinue(value);
124 else
126 CreateOptionParsingError(option_arg, short_option, long_option,
128 } break;
129 case 'i': {
130 uint32_t ignore_count;
131 if (option_arg.getAsInteger(0, ignore_count))
133 CreateOptionParsingError(option_arg, short_option, long_option,
135 else
136 m_bp_opts.SetIgnoreCount(ignore_count);
137 } break;
138 case 'o': {
139 bool value, success;
140 value = OptionArgParser::ToBoolean(option_arg, false, &success);
141 if (success) {
142 m_bp_opts.SetOneShot(value);
143 } else
145 CreateOptionParsingError(option_arg, short_option, long_option,
147 } break;
148 case 't': {
150 if (option_arg == "current") {
151 if (!execution_context) {
153 option_arg, short_option, long_option,
154 "No context to determine current thread"));
155 } else {
156 ThreadSP ctx_thread_sp = execution_context->GetThreadSP();
157 if (!ctx_thread_sp || !ctx_thread_sp->IsValid()) {
159 CreateOptionParsingError(option_arg, short_option, long_option,
160 "No currently selected thread"));
161 } else {
162 thread_id = ctx_thread_sp->GetID();
163 }
164 }
165 } else if (option_arg.getAsInteger(0, thread_id)) {
167 CreateOptionParsingError(option_arg, short_option, long_option,
169 }
170 if (thread_id != LLDB_INVALID_THREAD_ID)
171 m_bp_opts.SetThreadID(thread_id);
172 } break;
173 case 'T':
174 m_bp_opts.GetThreadSpec()->SetName(option_arg.str().c_str());
175 break;
176 case 'q':
177 m_bp_opts.GetThreadSpec()->SetQueueName(option_arg.str().c_str());
178 break;
179 case 'x': {
180 uint32_t thread_index = UINT32_MAX;
181 if (option_arg.getAsInteger(0, thread_index)) {
183 CreateOptionParsingError(option_arg, short_option, long_option,
185 } else {
186 m_bp_opts.GetThreadSpec()->SetIndex(thread_index);
187 }
188 } break;
189 case 'Y': {
191
192 LanguageSet languages_for_expressions =
194 if (language == eLanguageTypeUnknown)
196 option_arg, short_option, long_option, "invalid language"));
197 else if (!languages_for_expressions[language])
199 CreateOptionParsingError(option_arg, short_option, long_option,
200 "no expression support for language"));
201 else
202 m_bp_opts.GetCondition().SetLanguage(language);
203 } break;
204 default:
205 llvm_unreachable("Unimplemented option");
206 }
207
208 return error;
209 }
210
211 void OptionParsingStarting(ExecutionContext *execution_context) override {
212 m_bp_opts.Clear();
213 m_commands.clear();
214 }
215
216 Status OptionParsingFinished(ExecutionContext *execution_context) override {
217 if (!m_commands.empty()) {
218 auto cmd_data = std::make_unique<BreakpointOptions::CommandData>();
219
220 for (std::string &str : m_commands)
221 cmd_data->user_source.AppendString(str);
222
223 cmd_data->stop_on_error = true;
224 m_bp_opts.SetCommandDataCallback(cmd_data);
225 }
226 return Status();
227 }
228
230
231 std::vector<std::string> m_commands;
233};
234
235// This is the Breakpoint Names option group - used to add Names to breakpoints
236// while making them. Not to be confused with the "Breakpoint Name" option
237// group which is the common options of various "breakpoint name" commands.
238#define LLDB_OPTIONS_breakpoint_names
239#include "CommandOptions.inc"
240
242public:
244
245 ~BreakpointNamesOptionGroup() override = default;
246
247 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
248 return g_breakpoint_names_options;
249 }
250
251 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
252 ExecutionContext *execution_context) override {
254 const int short_option = GetDefinitions()[option_idx].short_option;
255 const char *long_option = GetDefinitions()[option_idx].long_option;
256
257 switch (short_option) {
258 case 'N':
260 m_breakpoint_names.push_back(std::string(option_value));
261 else
263 CreateOptionParsingError(option_value, short_option, long_option,
264 "Invalid breakpoint name"));
265 break;
266 }
267 return error;
268 }
269
270 void OptionParsingStarting(ExecutionContext *execution_context) override {
271 m_breakpoint_names.clear();
272 }
273
274 const std::vector<std::string> &GetBreakpointNames() {
275 return m_breakpoint_names;
276 }
277
278protected:
279 std::vector<std::string> m_breakpoint_names;
280};
281
282#define LLDB_OPTIONS_breakpoint_dummy
283#include "CommandOptions.inc"
284
286public:
288
289 ~BreakpointDummyOptionGroup() override = default;
290
291 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
292 return llvm::ArrayRef(g_breakpoint_dummy_options);
293 }
294
295 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
296 ExecutionContext *execution_context) override {
298 const int short_option =
299 g_breakpoint_dummy_options[option_idx].short_option;
300
301 switch (short_option) {
302 case 'D':
303 m_use_dummy = true;
304 break;
305 default:
306 llvm_unreachable("Unimplemented option");
307 }
308
309 return error;
310 }
311
312 void OptionParsingStarting(ExecutionContext *execution_context) override {
313 m_use_dummy = false;
314 }
315
317};
318
319#pragma mark AddAddress::CommandOptions
320#define LLDB_OPTIONS_breakpoint_add_address
321#include "CommandOptions.inc"
322
323#pragma mark Add Address
324
326 BreakpointOptionGroup &bp_opts,
327 const std::vector<std::string> &bp_names,
328 CommandReturnObject &result) {
329 assert(bp_sp && "CopyOverBreakpointOptions called with no breakpoint");
330
331 bp_sp->GetOptions().CopyOverSetOptions(bp_opts.GetBreakpointOptions());
332 Target &target = bp_sp->GetTarget();
333 if (!bp_names.empty()) {
334 Status name_error;
335 for (auto name : bp_names) {
336 target.AddNameToBreakpoint(bp_sp, name.c_str(), name_error);
337 if (name_error.Fail()) {
338 result.AppendErrorWithFormat("Invalid breakpoint name: %s",
339 name.c_str());
340 target.RemoveBreakpointByID(bp_sp->GetID());
341 return false;
342 }
343 }
344 }
345 return true;
346}
347
348static llvm::Expected<LanguageType>
349GetExceptionLanguageForLanguage(llvm::StringRef lang_name,
350 char short_option = '\0',
351 llvm::StringRef long_option = {}) {
352 llvm::Expected<LanguageType> exception_language =
354 if (!exception_language) {
355 std::string error_msg = llvm::toString(exception_language.takeError());
356 return CreateOptionParsingError(lang_name, short_option, long_option,
357 error_msg);
358 }
359 return exception_language;
360}
361
363 OptionValueFileColonLine &line_entry) {
365 uint32_t line_num = line_entry.GetLineNumber();
366 if (!line_entry.GetFileSpec()) {
367 FileSpec default_file_spec;
368 std::string error_msg;
369 Target *target = exe_ctx.GetTargetPtr();
370 if (!target) {
371 error.FromErrorString("Can't complete a line entry with no "
372 "target");
373 return error;
374 }
375 Debugger &dbg = target->GetDebugger();
376 CommandReturnObject result(dbg.GetUseColor());
377 if (!GetDefaultFile(*target, exe_ctx.GetFramePtr(), default_file_spec,
378 result)) {
379 error.FromErrorStringWithFormatv("{0}/nCouldn't get default file for "
380 "line {1}: {2}",
381 result.GetErrorString(), line_num,
382 error_msg);
383 return error;
384 }
385 line_entry.SetFile(default_file_spec);
386 }
387 return error;
388}
389
391public:
393 : CommandObjectParsed(interpreter, "breakpoint add address",
394 "Add breakpoints by raw address", nullptr,
395 eCommandAllowsDummyTarget) {
396 CommandArgumentData bp_id_arg;
397
398 // Define the first (and only) variant of this arg.
400 m_all_options.Append(&m_name_opts);
403 m_all_options.Finalize();
404
406 }
407
409
410 Options *GetOptions() override { return &m_all_options; }
411
413 public:
414 CommandOptions() = default;
415
416 ~CommandOptions() override = default;
417
418 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
419 ExecutionContext *execution_context) override {
421 const int short_option = GetDefinitions()[option_idx].short_option;
422 const char *long_option = GetDefinitions()[option_idx].long_option;
423
424 switch (short_option) {
425 case 'H':
426 m_hardware = true;
427 break;
428
429 case 's':
430 if (m_modules.GetSize() == 0)
431 m_modules.AppendIfUnique(FileSpec(option_arg));
432 else
434 CreateOptionParsingError(option_arg, short_option, long_option,
435 "Only one shared library can be "
436 "specified for address breakpoints."));
437 break;
438
439 default:
440 llvm_unreachable("Unimplemented option");
441 }
442
443 return error;
444 }
445
446 void OptionParsingStarting(ExecutionContext *execution_context) override {
447 m_hardware = false;
448 m_modules.Clear();
449 }
450
451 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
452 return llvm::ArrayRef(g_breakpoint_add_address_options);
453 }
454
455 // Instance variables to hold the values for command options.
456 bool m_hardware = false; // FIXME - this can go in the "modify" options.
458 };
459
460protected:
461 void DoExecute(Args &command, CommandReturnObject &result) override {
462 // We've already asserted that there can only be one entry in m_modules:
463 const ExecutionContext &exe_ctx = m_interpreter.GetExecutionContext();
464 // We don't set address breakpoints in the dummy target.
465 if (!exe_ctx.HasTargetScope() || exe_ctx.GetTargetPtr()->IsDummyTarget()) {
466 result.AppendError(
467 "can't set address breakpoints without a real target.");
468 return;
469 }
470 // Commands can't set internal breakpoints:
471 const bool internal = false;
472
473 Target &target = exe_ctx.GetTargetRef();
474
475 FileSpec module_spec;
476 bool has_module = false;
477 if (m_options.m_modules.GetSize() != 0) {
478 has_module = true;
479 module_spec = m_options.m_modules.GetFileSpecAtIndex(0);
480 }
481 BreakpointSP bp_sp;
482 // Let's process the arguments first so we can short-circuit if there are
483 // any errors:
484 std::vector<lldb::addr_t> bp_addrs;
485 for (const Args::ArgEntry &arg_entry : command) {
486 Address bp_address;
489 &exe_ctx, arg_entry.ref(), LLDB_INVALID_ADDRESS, &error);
490 if (error.Fail()) {
491 result.AppendErrorWithFormatv("invalid argument value '{0}': {1}",
492 arg_entry.ref(), error);
493 return;
494 }
495 bp_addrs.push_back(bp_load_addr);
496 }
497 for (auto bp_addr : bp_addrs) {
498 if (has_module)
499 bp_sp = target.CreateAddressInModuleBreakpoint(
500 bp_addr, internal, module_spec, m_options.m_hardware);
501 else
502 // ENHANCEMENT: we should see if bp_addr is in a single loaded module,
503 // and pass that module in if it is.
504 bp_sp =
505 target.CreateBreakpoint(bp_addr, internal, m_options.m_hardware);
506 }
507
508 if (bp_sp) {
510 m_name_opts.GetBreakpointNames(), result);
511 Stream &output_stream = result.GetOutputStream();
512 bp_sp->GetDescription(&output_stream, lldb::eDescriptionLevelInitial,
513 /*show_locations=*/false);
515 } else {
516 result.AppendError("Breakpoint creation failed: No breakpoint created.");
517 }
518 }
519
520private:
526};
527
528#pragma mark AddException::CommandOptions
529#define LLDB_OPTIONS_breakpoint_add_exception
530#include "CommandOptions.inc"
531
532#pragma mark Add Exception
533
535public:
538 interpreter, "breakpoint add exception",
539 "Add breakpoints on language exceptions. If no language is "
540 "specified, break on exceptions for all supported languages",
541 nullptr, eCommandAllowsDummyTarget) {
542 // Define the first (and only) variant of this arg.
544
545 // Next add all the options.
547 m_all_options.Append(&m_name_opts);
549 m_all_options.Append(&m_options);
550 m_all_options.Finalize();
551 }
552
554
555 Options *GetOptions() override { return &m_all_options; }
556
558 public:
559 CommandOptions() = default;
560
561 ~CommandOptions() override = default;
562
563 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
564 ExecutionContext *execution_context) override {
566 const int short_option = GetDefinitions()[option_idx].short_option;
567
568 switch (short_option) {
569 case 'E': {
570 uint32_t this_val = (uint32_t)OptionArgParser::ToOptionEnum(
571 option_arg, GetDefinitions()[option_idx].enum_values,
573 if (error.Fail())
574 return error;
575 m_exception_stage |= this_val;
576 } break;
577 case 'H':
578 m_hardware = true;
579 break;
580
581 case 'O':
582 m_exception_extra_args.AppendArgument("-O");
583 m_exception_extra_args.AppendArgument(option_arg);
584 break;
585
586 default:
587 llvm_unreachable("Unimplemented option");
588 }
589
590 return error;
591 }
592
593 void OptionParsingStarting(ExecutionContext *execution_context) override {
594 m_hardware = false;
597 }
598
599 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
600 return llvm::ArrayRef(g_breakpoint_add_exception_options);
601 }
602
603 // Instance variables to hold the values for command options.
604 bool m_hardware = false; // FIXME - this can go in the "modify" options.
607 };
608
609protected:
610 void DoExecute(Args &command, CommandReturnObject &result) override {
611 Target *target =
612 m_dummy_options.m_use_dummy ? &GetDummyTarget() : GetTarget();
613 BreakpointSP bp_sp;
614 LanguageType exception_language = eLanguageTypeUnknown;
615
616 if (command.size() == 0) {
617 result.AppendError("no languages specified");
618 } else if (command.size() > 1) {
619 result.AppendError(
620 "can only set exception breakpoints on one language at a time");
621 } else {
622 llvm::Expected<LanguageType> language =
623 GetExceptionLanguageForLanguage(command[0].ref());
624 if (language)
625 exception_language = *language;
626 else {
627 result.SetError(language.takeError());
628 return;
629 }
630 }
631 Status precond_error;
632 const bool internal = false;
633 bool catch_bp = (m_options.m_exception_stage & eExceptionStageCatch) != 0;
634 bool throw_bp = (m_options.m_exception_stage & eExceptionStageThrow) != 0;
635 bp_sp = target->CreateExceptionBreakpoint(
636 exception_language, catch_bp, throw_bp, internal,
637 &m_options.m_exception_extra_args, &precond_error);
638 if (precond_error.Fail()) {
640 "Error setting extra exception arguments: %s",
641 precond_error.AsCString());
642 target->RemoveBreakpointByID(bp_sp->GetID());
643 return;
644 }
645
646 if (bp_sp) {
648 m_name_opts.GetBreakpointNames(), result);
649 Stream &output_stream = result.GetOutputStream();
650 bp_sp->GetDescription(&output_stream, lldb::eDescriptionLevelInitial,
651 /*show_locations=*/false);
652 // Note, we don't print a "got no locations" warning for exception
653 // breakpoints. They can get set in the dummy target, and we won't know
654 // how to actually set the breakpoint till we know what version of the
655 // relevant LanguageRuntime gets loaded.
656 if (target == &GetDummyTarget())
657 output_stream.Printf("Breakpoint set in dummy target, will get copied "
658 "into future targets.\n");
660 } else {
661 result.AppendError("Breakpoint creation failed: No breakpoint created.");
662 }
663 }
664
665private:
671};
672
673#pragma mark AddFile::CommandOptions
674#define LLDB_OPTIONS_breakpoint_add_file
675#include "CommandOptions.inc"
676
677#pragma mark Add File
678
680public:
683 interpreter, "breakpoint add file",
684 "Add breakpoints on lines in specified source files", nullptr,
685 eCommandAllowsDummyTarget) {
687 CommandArgumentData linespec_arg;
688 CommandArgumentData no_arg;
689
690 // Any number of linespecs in group 1:
691 linespec_arg.arg_type = eArgTypeFileLineColumn;
692 linespec_arg.arg_repetition = eArgRepeatPlus;
694
695 arg1.push_back(linespec_arg);
696
697 // Leave arg2 empty, there are no arguments to this variant.
699 no_arg.arg_type = eArgTypeNone;
702
703 arg2.push_back(linespec_arg);
704
705 // Push the data for the first argument into the m_arguments vector.
706 m_arguments.push_back(arg1);
707 m_arguments.push_back(arg2);
708
709 // Define the first (and only) variant of this arg.
712 m_all_options.Append(&m_name_opts);
715 m_all_options.Append(&m_options);
716 m_all_options.Finalize();
717 }
718
720
721 Options *GetOptions() override { return &m_all_options; }
722
724 public:
725 CommandOptions() = default;
726
727 ~CommandOptions() override = default;
728
729 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
730 ExecutionContext *execution_context) override {
732 const int short_option = GetDefinitions()[option_idx].short_option;
733 const char *long_option = GetDefinitions()[option_idx].long_option;
734
735 switch (short_option) {
736 case 'f':
737 m_cur_value.SetFile(FileSpec(option_arg));
738 break;
739 case 'l':
740 uint32_t line_num;
741 if (option_arg.getAsInteger(0, line_num))
743 CreateOptionParsingError(option_arg, short_option, long_option,
745 else {
746 // The line number is the only required part of the options for a
747 // specifying the location - since we will fill in the file with the
748 // default file. So when we see a new line, the old line entry we
749 // were building is done. If we haven't gotten a file, try to fill
750 // in the default file, and then finish up this linespec and start
751 // the next one.
752 if (m_cur_value.GetLineNumber() != LLDB_INVALID_LINE_NUMBER) {
753 // FIXME: It should be possible to create a breakpoint with a list
754 // of file, line, column values. But for now we can only create
755 // one, so return an error here. The commented out code is what we
756 // will do when I come back to add that capability.
757 return Status::FromErrorString("Can only specify one file and line "
758 "pair at a time.");
759#if 0 // This code will be appropriate once we have a resolver that can take
760 // more than one linespec at a time.
761 error = CompleteLineEntry(*execution_context, m_cur_value);
762 if (error.Fail())
763 return error;
764
765 m_line_specs.push_back(m_cur_value);
766 m_cur_value.Clear();
767#endif
768 }
769 m_cur_value.SetLine(line_num);
770 }
771 break;
772 case 'u':
773 uint32_t column_num;
774 if (option_arg.getAsInteger(0, column_num))
776 CreateOptionParsingError(option_arg, short_option, long_option,
778 else
779 m_cur_value.SetColumn(column_num);
780 break;
781 case 'K': {
782 bool success;
783 bool value;
784 value = OptionArgParser::ToBoolean(option_arg, true, &success);
785 if (value)
787 else
789
790 if (!success)
792 CreateOptionParsingError(option_arg, short_option, long_option,
794 } break;
795 case 'm': {
796 bool success;
797 bool value;
798 value = OptionArgParser::ToBoolean(option_arg, true, &success);
799 if (value)
801 else
803
804 if (!success)
806 CreateOptionParsingError(option_arg, short_option, long_option,
808 } break;
809 case 's':
810 m_modules.AppendIfUnique(FileSpec(option_arg));
811 break;
812 case 'H':
813 m_hardware = true;
814 break;
815 case 'S': {
816 lldb::addr_t tmp_offset_addr;
817 tmp_offset_addr = OptionArgParser::ToAddress(execution_context,
818 option_arg, 0, &error);
819 if (error.Success())
820 m_offset_addr = tmp_offset_addr;
821 } break;
822
823 default:
824 llvm_unreachable("Unimplemented option");
825 }
826
827 return error;
828 }
829
830 void OptionParsingStarting(ExecutionContext *execution_context) override {
831 m_hardware = false;
832 m_line_specs.clear();
833 m_cur_value.Clear();
835 m_modules.Clear();
837 m_offset_addr = 0;
838 }
839
840 Status OptionParsingFinished(ExecutionContext *execution_context) override {
841 // We were supplied at least a line from the options, so fill in the
842 // default file if needed.
843 if (m_cur_value.GetLineNumber() != LLDB_INVALID_LINE_NUMBER) {
844 Status error = CompleteLineEntry(*execution_context, m_cur_value);
845 if (error.Fail())
846 return error;
847 m_line_specs.push_back(m_cur_value);
848 m_cur_value.Clear();
849 }
850 return {};
851 }
852
853 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
854 return llvm::ArrayRef(g_breakpoint_add_file_options);
855 }
856
857 // Instance variables to hold the values for command options.
858 bool m_hardware = false; // FIXME - this can go in the "modify" options.
859 std::vector<OptionValueFileColonLine> m_line_specs;
865 };
866
867protected:
868 void DoExecute(Args &command, CommandReturnObject &result) override {
869 bool internal = false;
870 Target *target =
871 m_dummy_options.m_use_dummy ? &GetDummyTarget() : GetTarget();
872 // FIXME: At present we can only make file & line breakpoints for one file
873 // and line pair. It wouldn't be hard to extend that, but I'm not adding
874 // features at this point so I'll leave that for a future patch. For now,
875 // flag this as an error.
876
877 // I'm leaving this as a loop since that's how it should be when we can
878 // do more than one linespec at a time.
879 FileSpec default_file;
880 for (const Args::ArgEntry &this_arg : command) {
882 uint32_t line_value = LLDB_INVALID_LINE_NUMBER;
883 if (!this_arg.ref().getAsInteger(0, line_value)) {
884 // The argument is a plain number. Treat that as a line number, and
885 // allow it if we can find a default file & line.
886 std::string error_msg;
887 if (!GetDefaultFile(*target, m_exe_ctx.GetFramePtr(), default_file,
888 result)) {
889 result.AppendErrorWithFormatv("Couldn't find default file for line "
890 "input: {0} - {1}",
891 line_value, error_msg);
892 return;
893 }
894 value.SetLine(line_value);
895 value.SetFile(default_file);
896 } else {
897 Status error = value.SetValueFromString(this_arg.c_str());
898 if (error.Fail()) {
899 result.AppendErrorWithFormatv("Failed to parse linespec: {0}", error);
900 return;
901 }
902 }
903 m_options.m_line_specs.push_back(value);
904 }
905
906 if (m_options.m_line_specs.size() != 1) {
907 result.AppendError("Can only make file and line breakpoints with one "
908 "specification at a time.");
909 return;
910 }
911
912 BreakpointSP bp_sp;
913 // Only check for inline functions if
914 LazyBool check_inlines = eLazyBoolCalculate;
915
916 OptionValueFileColonLine &this_spec = m_options.m_line_specs[0];
917 bp_sp = target->CreateBreakpoint(
918 &(m_options.m_modules), this_spec.GetFileSpec(),
919 this_spec.GetLineNumber(), this_spec.GetColumnNumber(),
920 m_options.m_offset_addr, check_inlines, m_options.m_skip_prologue,
921 internal, m_options.m_hardware, m_options.m_move_to_nearest_code);
922
923 if (bp_sp) {
925 m_name_opts.GetBreakpointNames(), result);
926 Stream &output_stream = result.GetOutputStream();
927 bp_sp->GetDescription(&output_stream, lldb::eDescriptionLevelInitial,
928 /*show_locations=*/false);
929 if (target == &GetDummyTarget())
930 output_stream.Printf("Breakpoint set in dummy target, will get copied "
931 "into future targets.\n");
932 else {
933 // Don't print out this warning for exception breakpoints. They can
934 // get set before the target is set, but we won't know how to actually
935 // set the breakpoint till we run.
936 if (bp_sp->GetNumLocations() == 0) {
937 output_stream.Printf("WARNING: Unable to resolve breakpoint to any "
938 "actual locations.\n");
939 }
940 }
942 } else {
943 result.AppendError("Breakpoint creation failed: No breakpoint created.");
944 }
945 }
946
947private:
953};
954
955#pragma mark AddName::CommandOptions
956#define LLDB_OPTIONS_breakpoint_add_name
957#include "CommandOptions.inc"
958
959#pragma mark Add Name
960
962public:
964 : CommandObjectParsed(interpreter, "breakpoint add name",
965 "Add breakpoints matching function or symbol names",
966 nullptr, eCommandAllowsDummyTarget) {
967 // FIXME: Add a completer that's aware of the name match style.
968 // Define the first (and only) variant of this arg.
970
971 // Now add all the options groups.
973 m_all_options.Append(&m_name_opts);
975 m_all_options.Append(&m_options);
976 m_all_options.Finalize();
977 }
978
980
981 Options *GetOptions() override { return &m_all_options; }
982
984 public:
985 CommandOptions() = default;
986
987 ~CommandOptions() override = default;
988
989 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
990 ExecutionContext *execution_context) override {
992 const int short_option = GetDefinitions()[option_idx].short_option;
993 const char *long_option = GetDefinitions()[option_idx].long_option;
994
995 switch (short_option) {
996 case 'f':
997 m_files.AppendIfUnique(FileSpec(option_arg));
998 break;
999 case 'K': {
1000 bool success;
1001 bool value;
1002 value = OptionArgParser::ToBoolean(option_arg, true, &success);
1003 if (!success)
1005 CreateOptionParsingError(option_arg, short_option, long_option,
1007 else {
1008 if (value)
1010 else
1012 }
1013 } break;
1014 case 'L': {
1018 CreateOptionParsingError(option_arg, short_option, long_option,
1020 } break;
1021 case 'm': {
1022 uint32_t this_val = (uint32_t)OptionArgParser::ToOptionEnum(
1023 option_arg, GetDefinitions()[option_idx].enum_values,
1025 if (error.Fail())
1026 return error;
1027 m_lookup_style = (NameMatchStyle)this_val;
1028 } break;
1029 case 's':
1030 m_modules.AppendIfUnique(FileSpec(option_arg));
1031 break;
1032 case 'H':
1033 m_hardware = true;
1034 break;
1035 case 'S': {
1036 lldb::addr_t tmp_offset_addr;
1037 tmp_offset_addr = OptionArgParser::ToAddress(execution_context,
1038 option_arg, 0, &error);
1039 if (error.Success())
1040 m_offset_addr = tmp_offset_addr;
1041 } break;
1042
1043 default:
1044 llvm_unreachable("Unimplemented option");
1045 }
1046
1047 return error;
1048 }
1049
1050 void OptionParsingStarting(ExecutionContext *execution_context) override {
1051 m_hardware = false;
1053 m_files.Clear();
1055 m_modules.Clear();
1056 m_offset_addr = 0;
1058 }
1059
1060 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
1061 return llvm::ArrayRef(g_breakpoint_add_name_options);
1062 }
1063
1064 // Instance variables to hold the values for command options.
1065 bool m_hardware = false; // FIXME - this can go in the "modify" options.
1073 };
1074
1075protected:
1076 void DoExecute(Args &command, CommandReturnObject &result) override {
1077 const bool internal = false;
1078 Target *target =
1079 m_dummy_options.m_use_dummy ? &GetDummyTarget() : GetTarget();
1080 // Parse the argument list - this is a simple list of names.
1081 std::vector<std::string> func_names;
1082 for (const Args::ArgEntry &this_arg : command) {
1083 func_names.push_back(this_arg.ref().str());
1084 }
1085 BreakpointSP bp_sp;
1086 if (!(m_options.m_lookup_style & eNameMatchStyleRegex))
1087 bp_sp = target->CreateBreakpoint(
1088 &m_options.m_modules, &m_options.m_files, func_names,
1089 (FunctionNameType)m_options.m_lookup_style, m_options.m_language,
1090 m_options.m_offset_addr, m_options.m_skip_prologue, internal,
1091 m_options.m_hardware);
1092 else {
1093 if (func_names.size() != 1) {
1094 result.AppendError("Can only set function regular expression "
1095 "breakpoints on one regex at a time.");
1096 return;
1097 }
1098 std::string &func_regexp = func_names[0];
1099 RegularExpression regexp(func_regexp);
1100 if (llvm::Error err = regexp.GetError()) {
1101 result.AppendErrorWithFormat(
1102 "Function name regular expression could not be compiled: %s",
1103 llvm::toString(std::move(err)).c_str());
1104 // Check if the incorrect regex looks like a globbing expression and
1105 // warn the user about it.
1106 if (!func_regexp.empty()) {
1107 if (func_regexp[0] == '*' || func_regexp[0] == '?')
1108 result.AppendWarning(
1109 "function name regex does not accept glob patterns");
1110 }
1111 return;
1112 }
1113
1114 bp_sp = target->CreateFuncRegexBreakpoint(
1115 &(m_options.m_modules), &(m_options.m_files), std::move(regexp),
1116 m_options.m_language, m_options.m_skip_prologue, internal,
1117 m_options.m_hardware);
1118 }
1119 if (bp_sp) {
1121 m_name_opts.GetBreakpointNames(), result);
1122 Stream &output_stream = result.GetOutputStream();
1123 bp_sp->GetDescription(&output_stream, lldb::eDescriptionLevelInitial,
1124 /*show_locations=*/false);
1125 if (target == &GetDummyTarget())
1126 output_stream.Printf("Breakpoint set in dummy target, will get copied "
1127 "into future targets.\n");
1128 else {
1129 if (bp_sp->GetNumLocations() == 0) {
1130 output_stream.Printf("WARNING: Unable to resolve breakpoint to any "
1131 "actual locations.\n");
1132 }
1133 }
1135 } else {
1136 result.AppendError("Breakpoint creation failed: No breakpoint created.");
1137 }
1138 }
1139
1140private:
1146};
1147
1148#pragma mark AddPattern::CommandOptions
1149#define LLDB_OPTIONS_breakpoint_add_pattern
1150#include "CommandOptions.inc"
1151
1152#pragma mark Add Pattern
1153
1155public:
1157 : CommandObjectRaw(interpreter, "breakpoint add pattern",
1158 "Add breakpoints matching patterns in the source text",
1159 "breakpoint add pattern [options] -- <pattern>",
1160 eCommandAllowsDummyTarget) {
1162 // Now add all the options groups.
1164 m_all_options.Append(&m_name_opts);
1166 m_all_options.Append(&m_options);
1167 m_all_options.Finalize();
1168 }
1169
1171
1172 Options *GetOptions() override { return &m_all_options; }
1173
1175 public:
1176 CommandOptions() = default;
1177
1178 ~CommandOptions() override = default;
1179
1180 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
1181 ExecutionContext *execution_context) override {
1182 Status error;
1183 const int short_option = GetDefinitions()[option_idx].short_option;
1184 const char *long_option = GetDefinitions()[option_idx].long_option;
1185
1186 switch (short_option) {
1187 case 'a': {
1188 bool success;
1189 bool value;
1190 value = OptionArgParser::ToBoolean(option_arg, true, &success);
1191 if (!success)
1193 CreateOptionParsingError(option_arg, short_option, long_option,
1195 else
1196 m_all_files = value;
1197 } break;
1198 case 'f':
1199 m_files.AppendIfUnique(FileSpec(option_arg));
1200 break;
1201 case 'm': {
1202 bool success;
1203 bool value;
1204 value = OptionArgParser::ToBoolean(option_arg, true, &success);
1205 if (!success)
1207 CreateOptionParsingError(option_arg, short_option, long_option,
1209 else {
1210 if (value)
1212 else
1214 }
1215 } break;
1216 case 'n':
1217 m_func_names.insert(option_arg.str());
1218 break;
1219 case 's':
1220 m_modules.AppendIfUnique(FileSpec(option_arg));
1221 break;
1222 case 'H':
1223 m_hardware = true;
1224 break;
1225 default:
1226 llvm_unreachable("Unimplemented option");
1227 }
1228
1229 return error;
1230 }
1231
1232 void OptionParsingStarting(ExecutionContext *execution_context) override {
1233 m_hardware = false;
1235 m_modules.Clear();
1236 m_files.Clear();
1237 m_func_names.clear();
1238 m_all_files = false;
1240 }
1241
1242 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
1243 return llvm::ArrayRef(g_breakpoint_add_pattern_options);
1244 }
1245
1246 // Instance variables to hold the values for command options.
1247 bool m_hardware = false; // FIXME - this can go in the "modify" options.
1251 std::unordered_set<std::string> m_func_names;
1252 bool m_all_files = false;
1254 };
1255
1256protected:
1257 void DoExecute(llvm::StringRef command,
1258 CommandReturnObject &result) override {
1259 const bool internal = false;
1261 m_all_options.NotifyOptionParsingStarting(&exe_ctx);
1262
1263 if (command.empty()) {
1264 result.AppendError("no pattern to seek.");
1265 return;
1266 }
1267
1268 OptionsWithRaw args(command);
1269
1270 if (args.HasArgs()) {
1271 if (!ParseOptionsAndNotify(args.GetArgs(), result, m_all_options,
1272 exe_ctx))
1273 return;
1274 }
1275 llvm::StringRef pattern = args.GetRawPart();
1276 if (pattern.empty()) {
1277 result.AppendError("no pattern to seek");
1278 return;
1279 }
1280
1281 Target *target =
1282 m_dummy_options.m_use_dummy ? &GetDummyTarget() : GetTarget();
1283
1284 BreakpointSP bp_sp;
1285 const size_t num_files = m_options.m_files.GetSize();
1286
1287 if (num_files == 0 && !m_options.m_all_files) {
1288 FileSpec file;
1289 if (!GetDefaultFile(*target, m_exe_ctx.GetFramePtr(), file, result)) {
1290 result.AppendError(
1291 "No files provided and could not find default file.");
1292 return;
1293 } else {
1294 m_options.m_files.Append(file);
1295 }
1296 }
1297
1298 RegularExpression regexp(pattern);
1299 if (llvm::Error err = regexp.GetError()) {
1300 result.AppendErrorWithFormat(
1301 "Source text regular expression could not be compiled: \"%s\"",
1302 llvm::toString(std::move(err)).c_str());
1303 return;
1304 }
1305 bp_sp = target->CreateSourceRegexBreakpoint(
1306 &(m_options.m_modules), &(m_options.m_files), m_options.m_func_names,
1307 std::move(regexp), internal, m_options.m_hardware,
1308 m_options.m_move_to_nearest_code);
1309
1310 if (bp_sp) {
1312 m_name_opts.GetBreakpointNames(), result);
1313 Stream &output_stream = result.GetOutputStream();
1314 bp_sp->GetDescription(&output_stream, lldb::eDescriptionLevelInitial,
1315 /*show_locations=*/false);
1316 if (target == &GetDummyTarget())
1317 output_stream.Printf("Breakpoint set in dummy target, will get copied "
1318 "into future targets.\n");
1319 else {
1320 // Don't print out this warning for exception breakpoints. They can
1321 // get set before the target is set, but we won't know how to actually
1322 // set the breakpoint till we run.
1323 if (bp_sp->GetNumLocations() == 0) {
1324 output_stream.Printf("WARNING: Unable to resolve breakpoint to any "
1325 "actual locations.\n");
1326 }
1327 }
1329 } else {
1330 result.AppendError("Breakpoint creation failed: No breakpoint created.");
1331 }
1332 }
1333
1334private:
1340};
1341
1342#pragma mark AddScripted::CommandOptions
1343#define LLDB_OPTIONS_breakpoint_add_scripted
1344#include "CommandOptions.inc"
1345
1346#pragma mark Add Scripted
1347
1349public:
1352 interpreter, "breakpoint add scripted",
1353 "Add breakpoints using a scripted breakpoint resolver.", nullptr,
1354 eCommandAllowsDummyTarget),
1355 m_python_class_options("scripted breakpoint", true, 'P') {
1356 // We're picking up all the normal options, commands and disable.
1359 // Define the first (and only) variant of this arg.
1361 m_all_options.Append(&m_name_opts);
1363 m_all_options.Append(&m_options);
1364 m_all_options.Finalize();
1365 }
1366
1368
1369 Options *GetOptions() override { return &m_all_options; }
1370
1372 public:
1373 CommandOptions() = default;
1374
1375 ~CommandOptions() override = default;
1376
1377 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
1378 ExecutionContext *execution_context) override {
1379 Status error;
1380 const int short_option = GetDefinitions()[option_idx].short_option;
1381
1382 switch (short_option) {
1383 case 'f':
1384 m_files.Append(FileSpec(option_arg));
1385 break;
1386 case 's':
1387 m_modules.AppendIfUnique(FileSpec(option_arg));
1388 break;
1389 case 'H':
1390 m_hardware = true;
1391 break;
1392
1393 default:
1394 llvm_unreachable("Unimplemented option");
1395 }
1396
1397 return error;
1398 }
1399
1400 void OptionParsingStarting(ExecutionContext *execution_context) override {
1401 m_hardware = false;
1402 m_files.Clear();
1403 m_modules.Clear();
1404 }
1405
1406 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
1407 return llvm::ArrayRef(g_breakpoint_add_scripted_options);
1408 }
1409
1410 // Instance variables to hold the values for command options.
1411 bool m_hardware = false; // FIXME - this can go in the "modify" options.
1414 };
1415
1416protected:
1417 void DoExecute(Args &command, CommandReturnObject &result) override {
1418 Target *target =
1419 m_dummy_options.m_use_dummy ? &GetDummyTarget() : GetTarget();
1420
1421 BreakpointSP bp_sp;
1422 Status error;
1423 bp_sp = target->CreateScriptedBreakpoint(
1424 m_python_class_options.GetName().c_str(), &(m_options.m_modules),
1425 &(m_options.m_files), false, m_options.m_hardware,
1426 m_python_class_options.GetStructuredData(), &error);
1427 if (error.Fail()) {
1428 result.AppendErrorWithFormat(
1429 "error setting extra exception arguments: %s", error.AsCString());
1430 target->RemoveBreakpointByID(bp_sp->GetID());
1431 return;
1432 }
1433
1434 if (bp_sp) {
1436 m_name_opts.GetBreakpointNames(), result);
1437 Stream &output_stream = result.GetOutputStream();
1438 bp_sp->GetDescription(&output_stream, lldb::eDescriptionLevelInitial,
1439 /*show_locations=*/false);
1440 if (target == &GetDummyTarget())
1441 output_stream.Printf("Breakpoint set in dummy target, will get copied "
1442 "into future targets.\n");
1443 else {
1444 // Don't print out this warning for exception breakpoints. They can
1445 // get set before the target is set, but we won't know how to actually
1446 // set the breakpoint till we run.
1447 if (bp_sp->GetNumLocations() == 0) {
1448 output_stream.Printf("WARNING: Unable to resolve breakpoint to any "
1449 "actual locations.\n");
1450 }
1451 }
1453 } else {
1454 result.AppendError("breakpoint creation failed: No breakpoint created.");
1455 }
1456 }
1457
1458private:
1465};
1466
1467#pragma mark Add::CommandOptions
1468#define LLDB_OPTIONS_breakpoint_add
1469#include "CommandOptions.inc"
1470
1471#pragma mark Add
1472
1474public:
1476 : CommandObjectMultiword(interpreter, "add",
1477 "Commands to add breakpoints of various types") {
1479 R"(
1480Access the breakpoint search kernels built into lldb. Along with specifying the
1481search kernel, each breakpoint add operation can specify a common set of
1482"reaction" options for each breakpoint. The reaction options can also be
1483modified after breakpoint creation using the "breakpoint modify" command.
1484 )");
1485 CommandObjectSP address_command_object(
1486 new CommandObjectBreakpointAddAddress(interpreter));
1487 CommandObjectSP exception_command_object(
1488 new CommandObjectBreakpointAddException(interpreter));
1489 CommandObjectSP file_command_object(
1490 new CommandObjectBreakpointAddFile(interpreter));
1491 CommandObjectSP name_command_object(
1492 new CommandObjectBreakpointAddName(interpreter));
1493 CommandObjectSP pattern_command_object(
1494 new CommandObjectBreakpointAddPattern(interpreter));
1495 CommandObjectSP scripted_command_object(
1496 new CommandObjectBreakpointAddScripted(interpreter));
1497
1498 LoadSubCommand("address", address_command_object);
1499 LoadSubCommand("exception", exception_command_object);
1500 LoadSubCommand("file", file_command_object);
1501 LoadSubCommand("name", name_command_object);
1502 LoadSubCommand("pattern", pattern_command_object);
1503 LoadSubCommand("scripted", scripted_command_object);
1504 }
1505};
1506
1507#define LLDB_OPTIONS_breakpoint_set
1508#include "CommandOptions.inc"
1509
1510// CommandObjectBreakpointSet
1511
1513public:
1524
1527 interpreter, "breakpoint set",
1528 "Sets a breakpoint or set of breakpoints in the executable.",
1529 "breakpoint set <cmd-options>", eCommandAllowsDummyTarget),
1530 m_python_class_options("scripted breakpoint", true, 'P') {
1531 // We're picking up all the normal options, commands and disable.
1534 m_all_options.Append(&m_bp_opts,
1538 m_all_options.Append(&m_options);
1539 m_all_options.Finalize();
1540 }
1541
1542 ~CommandObjectBreakpointSet() override = default;
1543
1544 Options *GetOptions() override { return &m_all_options; }
1545
1547 public:
1548 CommandOptions() = default;
1549
1550 ~CommandOptions() override = default;
1551
1552 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
1553 ExecutionContext *execution_context) override {
1554 Status error;
1555 const int short_option =
1556 g_breakpoint_set_options[option_idx].short_option;
1557 const char *long_option =
1558 g_breakpoint_set_options[option_idx].long_option;
1559
1560 switch (short_option) {
1561 case 'a': {
1562 m_load_addr = OptionArgParser::ToAddress(execution_context, option_arg,
1564 } break;
1565
1566 case 'A':
1567 m_all_files = true;
1568 break;
1569
1570 case 'b':
1571 m_func_names.push_back(std::string(option_arg));
1572 m_func_name_type_mask |= eFunctionNameTypeBase;
1573 break;
1574
1575 case 'u':
1576 if (option_arg.getAsInteger(0, m_column))
1578 CreateOptionParsingError(option_arg, short_option, long_option,
1580 break;
1581
1582 case 'E': {
1583 llvm::Expected<LanguageType> language = GetExceptionLanguageForLanguage(
1584 option_arg, short_option, long_option);
1585 if (language)
1586 m_exception_language = *language;
1587 else
1588 error = Status::FromError(language.takeError());
1589 } break;
1590
1591 case 'f':
1592 m_filenames.AppendIfUnique(FileSpec(option_arg));
1593 break;
1594
1595 case 'F':
1596 m_func_names.push_back(std::string(option_arg));
1597 m_func_name_type_mask |= eFunctionNameTypeFull;
1598 break;
1599
1600 case 'h': {
1601 bool success;
1602 m_catch_bp = OptionArgParser::ToBoolean(option_arg, true, &success);
1603 if (!success)
1605 CreateOptionParsingError(option_arg, short_option, long_option,
1607 } break;
1608
1609 case 'H':
1610 m_hardware = true;
1611 break;
1612
1613 case 'K': {
1614 bool success;
1615 bool value;
1616 value = OptionArgParser::ToBoolean(option_arg, true, &success);
1617 if (value)
1619 else
1621
1622 if (!success)
1624 CreateOptionParsingError(option_arg, short_option, long_option,
1626 } break;
1627
1628 case 'l':
1629 if (option_arg.getAsInteger(0, m_line_num))
1631 CreateOptionParsingError(option_arg, short_option, long_option,
1633 break;
1634
1635 case 'L':
1639 CreateOptionParsingError(option_arg, short_option, long_option,
1641 break;
1642
1643 case 'm': {
1644 bool success;
1645 bool value;
1646 value = OptionArgParser::ToBoolean(option_arg, true, &success);
1647 if (value)
1649 else
1651
1652 if (!success)
1654 CreateOptionParsingError(option_arg, short_option, long_option,
1656 break;
1657 }
1658
1659 case 'M':
1660 m_func_names.push_back(std::string(option_arg));
1661 m_func_name_type_mask |= eFunctionNameTypeMethod;
1662 break;
1663
1664 case 'n':
1665 m_func_names.push_back(std::string(option_arg));
1666 m_func_name_type_mask |= eFunctionNameTypeAuto;
1667 break;
1668
1669 case 'N': {
1671 m_breakpoint_names.push_back(std::string(option_arg));
1672 else
1674 CreateOptionParsingError(option_arg, short_option, long_option,
1675 "Invalid breakpoint name"));
1676 break;
1677 }
1678
1679 case 'R': {
1680 lldb::addr_t tmp_offset_addr;
1681 tmp_offset_addr = OptionArgParser::ToAddress(execution_context,
1682 option_arg, 0, &error);
1683 if (error.Success())
1684 m_offset_addr = tmp_offset_addr;
1685 } break;
1686
1687 case 'O':
1688 m_exception_extra_args.AppendArgument("-O");
1689 m_exception_extra_args.AppendArgument(option_arg);
1690 break;
1691
1692 case 'p':
1693 m_source_text_regexp.assign(std::string(option_arg));
1694 break;
1695
1696 case 'r':
1697 m_func_regexp.assign(std::string(option_arg));
1698 break;
1699
1700 case 's':
1701 m_modules.AppendIfUnique(FileSpec(option_arg));
1702 break;
1703
1704 case 'S':
1705 m_func_names.push_back(std::string(option_arg));
1706 m_func_name_type_mask |= eFunctionNameTypeSelector;
1707 break;
1708
1709 case 'w': {
1710 bool success;
1711 m_throw_bp = OptionArgParser::ToBoolean(option_arg, true, &success);
1712 if (!success)
1714 CreateOptionParsingError(option_arg, short_option, long_option,
1716 } break;
1717
1718 case 'X':
1719 m_source_regex_func_names.insert(std::string(option_arg));
1720 break;
1721
1722 case 'y':
1723 {
1725 Status fcl_err = value.SetValueFromString(option_arg);
1726 if (!fcl_err.Success()) {
1728 option_arg, short_option, long_option, fcl_err.AsCString()));
1729 } else {
1730 m_filenames.AppendIfUnique(value.GetFileSpec());
1731 m_line_num = value.GetLineNumber();
1732 m_column = value.GetColumnNumber();
1733 }
1734 } break;
1735
1736 default:
1737 llvm_unreachable("Unimplemented option");
1738 }
1739
1740 return error;
1741 }
1742
1743 void OptionParsingStarting(ExecutionContext *execution_context) override {
1744 m_filenames.Clear();
1745 m_line_num = 0;
1746 m_column = 0;
1747 m_func_names.clear();
1748 m_func_name_type_mask = eFunctionNameTypeNone;
1749 m_func_regexp.clear();
1750 m_source_text_regexp.clear();
1751 m_modules.Clear();
1753 m_offset_addr = 0;
1754 m_catch_bp = false;
1755 m_throw_bp = true;
1756 m_hardware = false;
1760 m_breakpoint_names.clear();
1761 m_all_files = false;
1762 m_exception_extra_args.Clear();
1765 m_current_key.clear();
1766 }
1767
1768 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
1769 return llvm::ArrayRef(g_breakpoint_set_options);
1770 }
1771
1772 // Instance variables to hold the values for command options.
1773
1774 std::string m_condition;
1776 uint32_t m_line_num = 0;
1777 uint32_t m_column = 0;
1778 std::vector<std::string> m_func_names;
1779 std::vector<std::string> m_breakpoint_names;
1780 lldb::FunctionNameType m_func_name_type_mask = eFunctionNameTypeNone;
1781 std::string m_func_regexp;
1786 bool m_catch_bp = false;
1787 bool m_throw_bp = true;
1788 bool m_hardware = false; // Request to use hardware breakpoints
1792 bool m_all_files = false;
1795 std::unordered_set<std::string> m_source_regex_func_names;
1796 std::string m_current_key;
1797 };
1798
1799protected:
1800 void DoExecute(Args &command, CommandReturnObject &result) override {
1801 Target *target =
1802 m_dummy_options.m_use_dummy ? &GetDummyTarget() : GetTarget();
1803
1804 // The following are the various types of breakpoints that could be set:
1805 // 1). -f -l -p [-s -g] (setting breakpoint by source location)
1806 // 2). -a [-s -g] (setting breakpoint by address)
1807 // 3). -n [-s -g] (setting breakpoint by function name)
1808 // 4). -r [-s -g] (setting breakpoint by function name regular
1809 // expression)
1810 // 5). -p -f (setting a breakpoint by comparing a reg-exp
1811 // to source text)
1812 // 6). -E [-w -h] (setting a breakpoint for exceptions for a
1813 // given language.)
1814
1816
1817 if (!m_python_class_options.GetName().empty())
1818 break_type = eSetTypeScripted;
1819 else if (m_options.m_line_num != 0)
1820 break_type = eSetTypeFileAndLine;
1821 else if (m_options.m_load_addr != LLDB_INVALID_ADDRESS)
1822 break_type = eSetTypeAddress;
1823 else if (!m_options.m_func_names.empty())
1824 break_type = eSetTypeFunctionName;
1825 else if (!m_options.m_func_regexp.empty())
1826 break_type = eSetTypeFunctionRegexp;
1827 else if (!m_options.m_source_text_regexp.empty())
1828 break_type = eSetTypeSourceRegexp;
1829 else if (m_options.m_exception_language != eLanguageTypeUnknown)
1830 break_type = eSetTypeException;
1831
1832 BreakpointSP bp_sp = nullptr;
1833 FileSpec module_spec;
1834 const bool internal = false;
1835
1836 // If the user didn't specify skip-prologue, having an offset should turn
1837 // that off.
1838 if (m_options.m_offset_addr != 0 &&
1839 m_options.m_skip_prologue == eLazyBoolCalculate)
1840 m_options.m_skip_prologue = eLazyBoolNo;
1841
1842 switch (break_type) {
1843 case eSetTypeFileAndLine: // Breakpoint by source position
1844 {
1845 FileSpec file;
1846 const size_t num_files = m_options.m_filenames.GetSize();
1847 if (num_files == 0) {
1848 if (!GetDefaultFile(*target, m_exe_ctx.GetFramePtr(), file, result)) {
1849 result.AppendError("no file supplied and no default file available.");
1850 return;
1851 }
1852 } else if (num_files > 1) {
1853 result.AppendError("only one file at a time is allowed for file and "
1854 "line breakpoints");
1855 return;
1856 } else
1857 file = m_options.m_filenames.GetFileSpecAtIndex(0);
1858
1859 // Only check for inline functions if
1860 LazyBool check_inlines = eLazyBoolCalculate;
1861
1862 bp_sp = target->CreateBreakpoint(
1863 &(m_options.m_modules), file, m_options.m_line_num,
1864 m_options.m_column, m_options.m_offset_addr, check_inlines,
1865 m_options.m_skip_prologue, internal, m_options.m_hardware,
1866 m_options.m_move_to_nearest_code);
1867 } break;
1868
1869 case eSetTypeAddress: // Breakpoint by address
1870 {
1871 // If a shared library has been specified, make an lldb_private::Address
1872 // with the library, and use that. That way the address breakpoint
1873 // will track the load location of the library.
1874 size_t num_modules_specified = m_options.m_modules.GetSize();
1875 if (num_modules_specified == 1) {
1876 const FileSpec &file_spec =
1877 m_options.m_modules.GetFileSpecAtIndex(0);
1878 bp_sp = target->CreateAddressInModuleBreakpoint(
1879 m_options.m_load_addr, internal, file_spec, m_options.m_hardware);
1880 } else if (num_modules_specified == 0) {
1881 bp_sp = target->CreateBreakpoint(m_options.m_load_addr, internal,
1882 m_options.m_hardware);
1883 } else {
1884 result.AppendError("Only one shared library can be specified for "
1885 "address breakpoints.");
1886 return;
1887 }
1888 break;
1889 }
1890 case eSetTypeFunctionName: // Breakpoint by function name
1891 {
1892 FunctionNameType name_type_mask = m_options.m_func_name_type_mask;
1893
1894 if (name_type_mask == 0)
1895 name_type_mask = eFunctionNameTypeAuto;
1896
1897 bp_sp = target->CreateBreakpoint(
1898 &(m_options.m_modules), &(m_options.m_filenames),
1899 m_options.m_func_names, name_type_mask, m_options.m_language,
1900 m_options.m_offset_addr, m_options.m_skip_prologue, internal,
1901 m_options.m_hardware);
1902 } break;
1903
1904 case eSetTypeFunctionRegexp: // Breakpoint by regular expression function
1905 // name
1906 {
1907 RegularExpression regexp(m_options.m_func_regexp);
1908 if (llvm::Error err = regexp.GetError()) {
1909 result.AppendErrorWithFormat(
1910 "Function name regular expression could not be compiled: %s",
1911 llvm::toString(std::move(err)).c_str());
1912 // Check if the incorrect regex looks like a globbing expression and
1913 // warn the user about it.
1914 if (!m_options.m_func_regexp.empty()) {
1915 if (m_options.m_func_regexp[0] == '*' ||
1916 m_options.m_func_regexp[0] == '?')
1917 result.AppendWarning(
1918 "function name regex does not accept glob patterns");
1919 }
1920 return;
1921 }
1922
1923 bp_sp = target->CreateFuncRegexBreakpoint(
1924 &(m_options.m_modules), &(m_options.m_filenames), std::move(regexp),
1925 m_options.m_language, m_options.m_skip_prologue, internal,
1926 m_options.m_hardware);
1927 } break;
1928 case eSetTypeSourceRegexp: // Breakpoint by regexp on source text.
1929 {
1930 const size_t num_files = m_options.m_filenames.GetSize();
1931
1932 if (num_files == 0 && !m_options.m_all_files) {
1933 FileSpec file;
1934 if (!GetDefaultFile(*target, m_exe_ctx.GetFramePtr(), file, result)) {
1935 result.AppendError(
1936 "No files provided and could not find default file.");
1937 return;
1938 } else {
1939 m_options.m_filenames.Append(file);
1940 }
1941 }
1942
1943 RegularExpression regexp(m_options.m_source_text_regexp);
1944 if (llvm::Error err = regexp.GetError()) {
1945 result.AppendErrorWithFormat(
1946 "Source text regular expression could not be compiled: \"%s\"",
1947 llvm::toString(std::move(err)).c_str());
1948 return;
1949 }
1950 bp_sp = target->CreateSourceRegexBreakpoint(
1951 &(m_options.m_modules), &(m_options.m_filenames),
1952 m_options.m_source_regex_func_names, std::move(regexp), internal,
1953 m_options.m_hardware, m_options.m_move_to_nearest_code);
1954 } break;
1955 case eSetTypeException: {
1956 Status precond_error;
1957 bp_sp = target->CreateExceptionBreakpoint(
1958 m_options.m_exception_language, m_options.m_catch_bp,
1959 m_options.m_throw_bp, internal, &m_options.m_exception_extra_args,
1960 &precond_error);
1961 if (precond_error.Fail()) {
1962 result.AppendErrorWithFormat(
1963 "Error setting extra exception arguments: %s",
1964 precond_error.AsCString());
1965 target->RemoveBreakpointByID(bp_sp->GetID());
1966 return;
1967 }
1968 } break;
1969 case eSetTypeScripted: {
1970
1971 Status error;
1972 bp_sp = target->CreateScriptedBreakpoint(
1973 m_python_class_options.GetName().c_str(), &(m_options.m_modules),
1974 &(m_options.m_filenames), false, m_options.m_hardware,
1975 m_python_class_options.GetStructuredData(), &error);
1976 if (error.Fail()) {
1977 result.AppendErrorWithFormat(
1978 "Error setting extra exception arguments: %s", error.AsCString());
1979 target->RemoveBreakpointByID(bp_sp->GetID());
1980 return;
1981 }
1982 } break;
1983 default:
1984 break;
1985 }
1986
1987 // Now set the various options that were passed in:
1988 if (bp_sp) {
1989 bp_sp->GetOptions().CopyOverSetOptions(m_bp_opts.GetBreakpointOptions());
1990
1991 if (!m_options.m_breakpoint_names.empty()) {
1992 Status name_error;
1993 for (auto name : m_options.m_breakpoint_names) {
1994 target->AddNameToBreakpoint(bp_sp, name.c_str(), name_error);
1995 if (name_error.Fail()) {
1996 result.AppendErrorWithFormat("Invalid breakpoint name: %s",
1997 name.c_str());
1998 target->RemoveBreakpointByID(bp_sp->GetID());
1999 return;
2000 }
2001 }
2002 }
2003 }
2004
2005 if (bp_sp) {
2006 Stream &output_stream = result.GetOutputStream();
2007 const bool show_locations = false;
2008 bp_sp->GetDescription(&output_stream, lldb::eDescriptionLevelInitial,
2009 show_locations);
2010 if (target == &GetDummyTarget())
2011 output_stream.Printf("Breakpoint set in dummy target, will get copied "
2012 "into future targets.\n");
2013 else {
2014 // Don't print out this warning for exception breakpoints. They can
2015 // get set before the target is set, but we won't know how to actually
2016 // set the breakpoint till we run.
2017 if (bp_sp->GetNumLocations() == 0 && break_type != eSetTypeException) {
2018 output_stream.Printf("WARNING: Unable to resolve breakpoint to any "
2019 "actual locations.\n");
2020 }
2021 }
2023 } else if (!bp_sp) {
2024 result.AppendError("breakpoint creation failed: no breakpoint created");
2025 }
2026 }
2027
2028private:
2034};
2035
2036// CommandObjectBreakpointModify
2037#pragma mark Modify
2038
2040public:
2042 : CommandObjectParsed(interpreter, "breakpoint modify",
2043 "Modify the options on a breakpoint or set of "
2044 "breakpoints in the executable. "
2045 "If no breakpoint is specified, acts on the last "
2046 "created breakpoint. "
2047 "With the exception of -e, -d and -i, passing an "
2048 "empty argument clears the modification.",
2049 nullptr, eCommandAllowsDummyTarget) {
2051
2052 m_options.Append(&m_bp_opts,
2056 m_options.Finalize();
2057 }
2058
2060
2061 void
2067
2068 Options *GetOptions() override { return &m_options; }
2069
2070protected:
2071 void DoExecute(Args &command, CommandReturnObject &result) override {
2072 Target *target = m_dummy_opts.m_use_dummy ? &GetDummyTarget() : GetTarget();
2073 assert(target && "target guaranteed by eCommandAllowsDummyTarget");
2074 std::unique_lock<std::recursive_mutex> lock;
2075 target->GetBreakpointList().GetListMutex(lock);
2076
2077 BreakpointIDList valid_bp_ids;
2078
2080 command, target, result, &valid_bp_ids,
2082
2083 if (result.Succeeded()) {
2084 const size_t count = valid_bp_ids.GetSize();
2085 for (size_t i = 0; i < count; ++i) {
2086 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex(i);
2087
2088 if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) {
2089 Breakpoint *bp =
2090 target->GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();
2091 if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) {
2092 BreakpointLocation *location =
2093 bp->FindLocationByID(cur_bp_id.GetLocationID()).get();
2094 if (location)
2096 m_bp_opts.GetBreakpointOptions());
2097 } else {
2099 m_bp_opts.GetBreakpointOptions());
2100 }
2101 }
2102 }
2103 }
2104 }
2105
2106private:
2110};
2111
2112// CommandObjectBreakpointEnable
2113#pragma mark Enable
2114
2116public:
2118 : CommandObjectParsed(interpreter, "enable",
2119 "Enable the specified disabled breakpoint(s). If "
2120 "no breakpoints are specified, enable all of them.",
2121 nullptr, eCommandAllowsDummyTarget) {
2123 }
2124
2126
2127 void
2133
2134protected:
2135 void DoExecute(Args &command, CommandReturnObject &result) override {
2136 Target *target = GetTarget();
2137 assert(target && "target guaranteed by eCommandAllowsDummyTarget");
2138 std::unique_lock<std::recursive_mutex> lock;
2139 target->GetBreakpointList().GetListMutex(lock);
2140
2141 const BreakpointList &breakpoints = target->GetBreakpointList();
2142
2143 size_t num_breakpoints = breakpoints.GetSize();
2144
2145 if (num_breakpoints == 0) {
2146 result.AppendError("no breakpoints exist to be enabled");
2147 return;
2148 }
2149
2150 if (command.empty()) {
2151 // No breakpoint selected; enable all currently set breakpoints.
2152 target->EnableAllowedBreakpoints();
2154 "All breakpoints enabled. ({0} breakpoints)", num_breakpoints);
2156 } else {
2157 // Particular breakpoint selected; enable that breakpoint.
2158 BreakpointIDList valid_bp_ids;
2160 command, m_exe_ctx, result, &valid_bp_ids,
2162
2163 if (result.Succeeded()) {
2164 int enable_count = 0;
2165 int loc_count = 0;
2166 const size_t count = valid_bp_ids.GetSize();
2167 for (size_t i = 0; i < count; ++i) {
2168 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex(i);
2169
2170 if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) {
2171 Breakpoint *breakpoint =
2172 target->GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();
2173 if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) {
2174 BreakpointLocation *location =
2175 breakpoint->FindLocationByID(cur_bp_id.GetLocationID()).get();
2176 if (location) {
2177 if (llvm::Error error = location->SetEnabled(true))
2179 "failed to enable breakpoint location: {0}",
2180 llvm::fmt_consume(std::move(error)));
2181 ++loc_count;
2182 }
2183 } else {
2184 breakpoint->SetEnabled(true);
2185 ++enable_count;
2186 }
2187 }
2188 }
2189 result.AppendMessageWithFormatv("{0} breakpoints enabled.",
2190 enable_count + loc_count);
2192 }
2193 }
2194 }
2195};
2196
2197// CommandObjectBreakpointDisable
2198#pragma mark Disable
2199
2201public:
2204 interpreter, "breakpoint disable",
2205 "Disable the specified breakpoint(s) without deleting "
2206 "them. If none are specified, disable all "
2207 "breakpoints.",
2208 nullptr, eCommandAllowsDummyTarget) {
2210 "Disable the specified breakpoint(s) without deleting them. \
2211If none are specified, disable all breakpoints."
2212 R"(
2213
2214)"
2215 "Note: disabling a breakpoint will cause none of its locations to be hit \
2216regardless of whether individual locations are enabled or disabled. After the sequence:"
2217 R"(
2218
2219 (lldb) break disable 1
2220 (lldb) break enable 1.1
2221
2222execution will NOT stop at location 1.1. To achieve that, type:
2223
2224 (lldb) break disable 1.*
2225 (lldb) break enable 1.1
2226
2227)"
2228 "The first command disables all locations for breakpoint 1, \
2229the second re-enables the first location.");
2230
2233
2234 ~CommandObjectBreakpointDisable() override = default;
2235
2236 void
2238 OptionElementVector &opt_element_vector) override {
2241 }
2242
2243protected:
2244 void DoExecute(Args &command, CommandReturnObject &result) override {
2245 Target *target = GetTarget();
2246 assert(target && "target guaranteed by eCommandAllowsDummyTarget");
2247 std::unique_lock<std::recursive_mutex> lock;
2248 target->GetBreakpointList().GetListMutex(lock);
2249
2250 const BreakpointList &breakpoints = target->GetBreakpointList();
2251 size_t num_breakpoints = breakpoints.GetSize();
2252
2253 if (num_breakpoints == 0) {
2254 result.AppendError("no breakpoints exist to be disabled");
2255 return;
2256 }
2257
2258 if (command.empty()) {
2259 // No breakpoint selected; disable all currently set breakpoints.
2260 target->DisableAllowedBreakpoints();
2262 "All breakpoints disabled. ({0} breakpoints)\n", num_breakpoints);
2264 } else {
2265 // Particular breakpoint selected; disable that breakpoint.
2266 BreakpointIDList valid_bp_ids;
2267
2269 command, m_exe_ctx, result, &valid_bp_ids,
2270 BreakpointName::Permissions::PermissionKinds::disablePerm);
2271
2272 if (result.Succeeded()) {
2273 int disable_count = 0;
2274 int loc_count = 0;
2275 const size_t count = valid_bp_ids.GetSize();
2276 for (size_t i = 0; i < count; ++i) {
2277 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex(i);
2278
2279 if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) {
2280 Breakpoint *breakpoint =
2281 target->GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();
2282 if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) {
2283 BreakpointLocation *location =
2284 breakpoint->FindLocationByID(cur_bp_id.GetLocationID()).get();
2285 if (location) {
2286 if (llvm::Error error = location->SetEnabled(false))
2288 "failed to disable breakpoint location: {0}",
2289 llvm::fmt_consume(std::move(error)));
2290 ++loc_count;
2291 }
2292 } else {
2293 breakpoint->SetEnabled(false);
2294 ++disable_count;
2295 }
2296 }
2297 }
2298 result.AppendMessageWithFormatv("{0} breakpoints disabled.",
2299 disable_count + loc_count);
2301 }
2302 }
2303 }
2304};
2305
2306// CommandObjectBreakpointList
2307
2308#pragma mark List::CommandOptions
2309#define LLDB_OPTIONS_breakpoint_list
2310#include "CommandOptions.inc"
2311
2312#pragma mark List
2313
2315public:
2318 interpreter, "breakpoint list",
2319 "List some or all breakpoints at configurable levels of detail.",
2320 nullptr, eCommandAllowsDummyTarget) {
2321
2322 // Define the first (and only) variant of this arg.
2324 }
2325
2326 ~CommandObjectBreakpointList() override = default;
2327
2328 Options *GetOptions() override { return &m_options; }
2329
2330 class CommandOptions : public Options {
2331 public:
2332 CommandOptions() = default;
2333
2334 ~CommandOptions() override = default;
2335
2336 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
2337 ExecutionContext *execution_context) override {
2338 Status error;
2339 const int short_option = m_getopt_table[option_idx].val;
2340
2341 switch (short_option) {
2342 case 'b':
2344 break;
2345 case 'D':
2346 m_use_dummy = true;
2347 break;
2348 case 'f':
2350 break;
2351 case 'v':
2353 break;
2354 case 'i':
2355 m_internal = true;
2356 break;
2357 default:
2358 llvm_unreachable("Unimplemented option");
2359 }
2360
2361 return error;
2362 }
2363
2364 void OptionParsingStarting(ExecutionContext *execution_context) override {
2366 m_internal = false;
2367 m_use_dummy = false;
2368 }
2369
2370 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
2371 return llvm::ArrayRef(g_breakpoint_list_options);
2372 }
2373
2374 // Instance variables to hold the values for command options.
2375
2377
2379 bool m_use_dummy = false;
2380 };
2381
2382protected:
2383 void DoExecute(Args &command, CommandReturnObject &result) override {
2384 Target *target = m_options.m_use_dummy ? &GetDummyTarget() : GetTarget();
2385 assert(target && "target guaranteed by eCommandAllowsDummyTarget");
2386 const BreakpointList &breakpoints =
2387 target->GetBreakpointList(m_options.m_internal);
2388 std::unique_lock<std::recursive_mutex> lock;
2389 target->GetBreakpointList(m_options.m_internal).GetListMutex(lock);
2390
2391 size_t num_breakpoints = breakpoints.GetSize();
2392
2393 if (num_breakpoints == 0) {
2394 result.AppendMessage("No breakpoints currently set.");
2396 return;
2397 }
2398
2399 Stream &output_stream = result.GetOutputStream();
2400
2401 if (command.empty()) {
2402 // No breakpoint selected; show info about all currently set breakpoints.
2403 result.AppendMessage("Current breakpoints:");
2404 for (size_t i = 0; i < num_breakpoints; ++i) {
2405 Breakpoint *breakpoint = breakpoints.GetBreakpointAtIndex(i).get();
2406 if (breakpoint->AllowList())
2407 AddBreakpointDescription(&output_stream, breakpoint,
2408 m_options.m_level);
2409 }
2411 } else {
2412 // Particular breakpoints selected; show info about that breakpoint.
2413 BreakpointIDList valid_bp_ids;
2415 command, target, result, &valid_bp_ids,
2417
2418 if (result.Succeeded()) {
2419 for (size_t i = 0; i < valid_bp_ids.GetSize(); ++i) {
2420 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex(i);
2421 Breakpoint *breakpoint =
2422 target->GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();
2423 AddBreakpointDescription(&output_stream, breakpoint,
2424 m_options.m_level);
2425 }
2427 } else {
2428 result.AppendError("invalid breakpoint ID");
2429 }
2430 }
2431 }
2432
2433private:
2435};
2436
2437// CommandObjectBreakpointClear
2438#pragma mark Clear::CommandOptions
2439
2440#define LLDB_OPTIONS_breakpoint_clear
2441#include "CommandOptions.inc"
2442
2443#pragma mark Clear
2444
2446public:
2448
2450 : CommandObjectParsed(interpreter, "breakpoint clear",
2451 "Delete or disable breakpoints matching the "
2452 "specified source file and line.",
2453 "breakpoint clear <cmd-options>",
2454 eCommandAllowsDummyTarget) {}
2455
2456 ~CommandObjectBreakpointClear() override = default;
2457
2458 Options *GetOptions() override { return &m_options; }
2459
2460 class CommandOptions : public Options {
2461 public:
2462 CommandOptions() = default;
2463
2464 ~CommandOptions() override = default;
2465
2466 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
2467 ExecutionContext *execution_context) override {
2468 Status error;
2469 const int short_option = m_getopt_table[option_idx].val;
2470
2471 switch (short_option) {
2472 case 'f':
2473 m_filename.assign(std::string(option_arg));
2474 break;
2475
2476 case 'l':
2477 option_arg.getAsInteger(0, m_line_num);
2478 break;
2479
2480 default:
2481 llvm_unreachable("Unimplemented option");
2482 }
2483
2484 return error;
2485 }
2486
2487 void OptionParsingStarting(ExecutionContext *execution_context) override {
2488 m_filename.clear();
2489 m_line_num = 0;
2490 }
2491
2492 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
2493 return llvm::ArrayRef(g_breakpoint_clear_options);
2494 }
2495
2496 // Instance variables to hold the values for command options.
2497
2498 std::string m_filename;
2499 uint32_t m_line_num = 0;
2500 };
2501
2502protected:
2503 void DoExecute(Args &command, CommandReturnObject &result) override {
2504 Target *target = GetTarget();
2505 assert(target && "target guaranteed by eCommandAllowsDummyTarget");
2506 // The following are the various types of breakpoints that could be
2507 // cleared:
2508 // 1). -f -l (clearing breakpoint by source location)
2509
2511
2512 if (m_options.m_line_num != 0)
2513 break_type = eClearTypeFileAndLine;
2514
2515 std::unique_lock<std::recursive_mutex> lock;
2516 target->GetBreakpointList().GetListMutex(lock);
2517
2518 BreakpointList &breakpoints = target->GetBreakpointList();
2519 size_t num_breakpoints = breakpoints.GetSize();
2520
2521 // Early return if there's no breakpoint at all.
2522 if (num_breakpoints == 0) {
2523 result.AppendError("breakpoint clear: no breakpoint cleared");
2524 return;
2525 }
2526
2527 // Find matching breakpoints and delete them.
2528
2529 // First create a copy of all the IDs.
2530 std::vector<break_id_t> BreakIDs;
2531 for (size_t i = 0; i < num_breakpoints; ++i)
2532 BreakIDs.push_back(breakpoints.GetBreakpointAtIndex(i)->GetID());
2533
2534 int num_cleared = 0;
2535 StreamString ss;
2536 switch (break_type) {
2537 case eClearTypeFileAndLine: // Breakpoint by source position
2538 {
2539 const ConstString filename(m_options.m_filename);
2541
2542 for (size_t i = 0; i < num_breakpoints; ++i) {
2543 Breakpoint *bp = breakpoints.FindBreakpointByID(BreakIDs[i]).get();
2544
2545 if (bp->GetMatchingFileLine(filename, m_options.m_line_num, loc_coll)) {
2546 // If the collection size is 0, it's a full match and we can just
2547 // remove the breakpoint.
2548 if (loc_coll.GetSize() == 0) {
2550 ss.EOL();
2551 target->RemoveBreakpointByID(bp->GetID());
2552 ++num_cleared;
2553 }
2554 }
2555 }
2556 } break;
2557
2558 default:
2559 break;
2560 }
2561
2562 if (num_cleared > 0) {
2563 Stream &output_stream = result.GetOutputStream();
2564 output_stream.Printf("%d breakpoints cleared:\n", num_cleared);
2565 output_stream << ss.GetString();
2566 output_stream.EOL();
2568 } else {
2569 result.AppendError("breakpoint clear: no breakpoint cleared");
2570 }
2571 }
2572
2573private:
2575};
2576
2577// CommandObjectBreakpointDelete
2578#define LLDB_OPTIONS_breakpoint_delete
2579#include "CommandOptions.inc"
2580
2581#pragma mark Delete
2582
2584public:
2586 : CommandObjectParsed(interpreter, "breakpoint delete",
2587 "Delete the specified breakpoint(s). If no "
2588 "breakpoints are specified, delete them all.",
2589 nullptr, eCommandAllowsDummyTarget) {
2591 }
2592
2594
2595 void
2601
2602 Options *GetOptions() override { return &m_options; }
2603
2604 class CommandOptions : public Options {
2605 public:
2606 CommandOptions() = default;
2607
2608 ~CommandOptions() override = default;
2609
2610 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
2611 ExecutionContext *execution_context) override {
2612 Status error;
2613 const int short_option = m_getopt_table[option_idx].val;
2614
2615 switch (short_option) {
2616 case 'f':
2617 m_force = true;
2618 break;
2619
2620 case 'D':
2621 m_use_dummy = true;
2622 break;
2623
2624 case 'd':
2625 m_delete_disabled = true;
2626 break;
2627
2628 default:
2629 llvm_unreachable("Unimplemented option");
2630 }
2631
2632 return error;
2633 }
2634
2635 void OptionParsingStarting(ExecutionContext *execution_context) override {
2636 m_use_dummy = false;
2637 m_force = false;
2638 m_delete_disabled = false;
2639 }
2640
2641 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
2642 return llvm::ArrayRef(g_breakpoint_delete_options);
2643 }
2644
2645 // Instance variables to hold the values for command options.
2646 bool m_use_dummy = false;
2647 bool m_force = false;
2648 bool m_delete_disabled = false;
2649 };
2650
2651protected:
2652 void DoExecute(Args &command, CommandReturnObject &result) override {
2653 Target *target = m_options.m_use_dummy ? &GetDummyTarget() : GetTarget();
2654 assert(target && "target guaranteed by eCommandAllowsDummyTarget");
2655 result.Clear();
2656
2657 std::unique_lock<std::recursive_mutex> lock;
2658 target->GetBreakpointList().GetListMutex(lock);
2659
2660 BreakpointList &breakpoints = target->GetBreakpointList();
2661
2662 size_t num_breakpoints = breakpoints.GetSize();
2663
2664 if (num_breakpoints == 0) {
2665 result.AppendError("no breakpoints exist to be deleted");
2666 return;
2667 }
2668
2669 // Handle the delete all breakpoints case:
2670 if (command.empty() && !m_options.m_delete_disabled) {
2671 if (!m_options.m_force &&
2672 !m_interpreter.Confirm(
2673 "About to delete all breakpoints, do you want to do that?",
2674 true)) {
2675 result.AppendMessage("Operation cancelled...");
2676 } else {
2677 target->RemoveAllowedBreakpoints();
2679 "All breakpoints removed. ({0} breakpoint{1})", num_breakpoints,
2680 num_breakpoints > 1 ? "s" : "");
2681 }
2683 return;
2684 }
2685
2686 // Either we have some kind of breakpoint specification(s),
2687 // or we are handling "break disable --deleted". Gather the list
2688 // of breakpoints to delete here, the we'll delete them below.
2689 BreakpointIDList valid_bp_ids;
2690
2691 if (m_options.m_delete_disabled) {
2692 BreakpointIDList excluded_bp_ids;
2693
2694 if (!command.empty()) {
2696 command, target, result, &excluded_bp_ids,
2698 if (!result.Succeeded())
2699 return;
2700 }
2701
2702 for (auto breakpoint_sp : breakpoints.Breakpoints()) {
2703 if (!breakpoint_sp->IsEnabled() && breakpoint_sp->AllowDelete()) {
2704 BreakpointID bp_id(breakpoint_sp->GetID());
2705 if (!excluded_bp_ids.Contains(bp_id))
2706 valid_bp_ids.AddBreakpointID(bp_id);
2707 }
2708 }
2709 if (valid_bp_ids.GetSize() == 0) {
2710 result.AppendError("no disabled breakpoints");
2711 return;
2712 }
2713 } else {
2715 command, m_exe_ctx, result, &valid_bp_ids,
2717 if (!result.Succeeded())
2718 return;
2719 }
2720
2721 int delete_count = 0;
2722 int disable_count = 0;
2723 const size_t count = valid_bp_ids.GetSize();
2724 for (size_t i = 0; i < count; ++i) {
2725 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex(i);
2726
2727 if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) {
2728 if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) {
2729 Breakpoint *breakpoint =
2730 target->GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();
2731 BreakpointLocation *location =
2732 breakpoint->FindLocationByID(cur_bp_id.GetLocationID()).get();
2733 // It makes no sense to try to delete individual locations, so we
2734 // disable them instead.
2735 if (location) {
2736 if (llvm::Error error = location->SetEnabled(false))
2738 "failed to disable breakpoint location: {0}",
2739 llvm::fmt_consume(std::move(error)));
2740 ++disable_count;
2741 }
2742 } else {
2743 target->RemoveBreakpointByID(cur_bp_id.GetBreakpointID());
2744 ++delete_count;
2745 }
2746 }
2747 }
2749 "{0} breakpoints deleted; {1} breakpoint locations disabled.",
2750 delete_count, disable_count);
2752 }
2753
2754private:
2756};
2757
2758// CommandObjectBreakpointName
2759#define LLDB_OPTIONS_breakpoint_name
2760#include "CommandOptions.inc"
2761
2763public:
2766
2767 ~BreakpointNameOptionGroup() override = default;
2768
2769 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
2770 return llvm::ArrayRef(g_breakpoint_name_options);
2771 }
2772
2773 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
2774 ExecutionContext *execution_context) override {
2775 Status error;
2776 const int short_option = g_breakpoint_name_options[option_idx].short_option;
2777 const char *long_option = g_breakpoint_name_options[option_idx].long_option;
2778
2779 switch (short_option) {
2780 case 'N':
2782 error.Success())
2783 m_name.SetValueFromString(option_arg);
2784 break;
2785 case 'B':
2786 if (m_breakpoint.SetValueFromString(option_arg).Fail())
2788 CreateOptionParsingError(option_arg, short_option, long_option,
2790 break;
2791 case 'D':
2792 if (m_use_dummy.SetValueFromString(option_arg).Fail())
2794 CreateOptionParsingError(option_arg, short_option, long_option,
2796 break;
2797 case 'H':
2798 m_help_string.SetValueFromString(option_arg);
2799 break;
2800
2801 default:
2802 llvm_unreachable("Unimplemented option");
2803 }
2804 return error;
2805 }
2806
2807 void OptionParsingStarting(ExecutionContext *execution_context) override {
2808 m_name.Clear();
2809 m_breakpoint.Clear();
2810 m_use_dummy.Clear();
2811 m_use_dummy.SetDefaultValue(false);
2812 m_help_string.Clear();
2813 }
2814
2819};
2820
2821#define LLDB_OPTIONS_breakpoint_access
2822#include "CommandOptions.inc"
2823
2825public:
2827
2828 ~BreakpointAccessOptionGroup() override = default;
2829
2830 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
2831 return llvm::ArrayRef(g_breakpoint_access_options);
2832 }
2833 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
2834 ExecutionContext *execution_context) override {
2835 Status error;
2836 const int short_option =
2837 g_breakpoint_access_options[option_idx].short_option;
2838 const char *long_option =
2839 g_breakpoint_access_options[option_idx].long_option;
2840
2841 switch (short_option) {
2842 case 'L': {
2843 bool value, success;
2844 value = OptionArgParser::ToBoolean(option_arg, false, &success);
2845 if (success) {
2846 m_permissions.SetAllowList(value);
2847 } else
2849 CreateOptionParsingError(option_arg, short_option, long_option,
2851 } break;
2852 case 'A': {
2853 bool value, success;
2854 value = OptionArgParser::ToBoolean(option_arg, false, &success);
2855 if (success) {
2856 m_permissions.SetAllowDisable(value);
2857 } else
2859 CreateOptionParsingError(option_arg, short_option, long_option,
2861 } break;
2862 case 'D': {
2863 bool value, success;
2864 value = OptionArgParser::ToBoolean(option_arg, false, &success);
2865 if (success) {
2866 m_permissions.SetAllowDelete(value);
2867 } else
2869 CreateOptionParsingError(option_arg, short_option, long_option,
2871 } break;
2872 default:
2873 llvm_unreachable("Unimplemented option");
2874 }
2875
2876 return error;
2877 }
2878
2879 void OptionParsingStarting(ExecutionContext *execution_context) override {}
2880
2882 return m_permissions;
2883 }
2885};
2886
2888public:
2891 interpreter, "configure",
2892 "Configure the options for the breakpoint"
2893 " name provided. "
2894 "If you provide a breakpoint id, the options will be copied from "
2895 "the breakpoint, otherwise only the options specified will be set "
2896 "on the name.",
2897 "breakpoint name configure <command-options> "
2898 "<breakpoint-name-list>",
2899 eCommandAllowsDummyTarget) {
2901
2907 m_option_group.Finalize();
2908 }
2909
2911
2912 Options *GetOptions() override { return &m_option_group; }
2913
2914protected:
2915 void DoExecute(Args &command, CommandReturnObject &result) override {
2916
2917 const size_t argc = command.GetArgumentCount();
2918 if (argc == 0) {
2919 result.AppendError("no names provided");
2920 return;
2921 }
2922
2923 Target *target = GetTarget();
2924 assert(target && "target guaranteed by eCommandAllowsDummyTarget");
2925 std::unique_lock<std::recursive_mutex> lock;
2926 target->GetBreakpointList().GetListMutex(lock);
2927
2928 // Make a pass through first to see that all the names are legal.
2929 for (auto &entry : command.entries()) {
2930 Status error;
2931 if (!BreakpointID::StringIsBreakpointName(entry.ref(), error)) {
2932 result.AppendErrorWithFormat("Invalid breakpoint name: %s - %s",
2933 entry.c_str(), error.AsCString());
2934 return;
2935 }
2936 }
2937 // Now configure them, we already pre-checked the names so we don't need to
2938 // check the error:
2939 BreakpointSP bp_sp;
2940 if (m_bp_id.m_breakpoint.OptionWasSet()) {
2941 lldb::break_id_t bp_id =
2942 m_bp_id.m_breakpoint.GetValueAs<uint64_t>().value_or(0);
2943 bp_sp = target->GetBreakpointByID(bp_id);
2944 if (!bp_sp) {
2945 result.AppendErrorWithFormatv("Could not find specified breakpoint {0}",
2946 bp_id);
2947 return;
2948 }
2949 }
2950
2951 Status error;
2952 for (auto &entry : command.entries()) {
2953 ConstString name(entry.c_str());
2954 BreakpointName *bp_name = target->FindBreakpointName(name, true, error);
2955 if (!bp_name)
2956 continue;
2957 if (m_bp_id.m_help_string.OptionWasSet())
2958 bp_name->SetHelp(m_bp_id.m_help_string.GetValueAs<llvm::StringRef>()
2959 .value_or("")
2960 .str()
2961 .c_str());
2962
2963 if (bp_sp)
2964 target->ConfigureBreakpointName(*bp_name, bp_sp->GetOptions(),
2965 m_access_options.GetPermissions());
2966 else
2967 target->ConfigureBreakpointName(*bp_name,
2968 m_bp_opts.GetBreakpointOptions(),
2969 m_access_options.GetPermissions());
2970 }
2972 }
2973
2974private:
2975 BreakpointNameOptionGroup m_bp_id; // Only using the id part of this.
2979};
2980
2982public:
2985 interpreter, "add", "Add a name to the breakpoints provided.",
2986 "breakpoint name add <command-options> <breakpoint-id-list>",
2987 eCommandAllowsDummyTarget) {
2989
2991 m_option_group.Finalize();
2992 }
2993
2995
2996 void
3002
3003 Options *GetOptions() override { return &m_option_group; }
3004
3005protected:
3006 void DoExecute(Args &command, CommandReturnObject &result) override {
3007 if (!m_name_options.m_name.OptionWasSet()) {
3008 result.AppendError("no name option provided");
3009 return;
3010 }
3011
3012 Target *target =
3013 m_name_options.m_use_dummy ? &GetDummyTarget() : GetTarget();
3014
3015 std::unique_lock<std::recursive_mutex> lock;
3016 target->GetBreakpointList().GetListMutex(lock);
3017
3018 const BreakpointList &breakpoints = target->GetBreakpointList();
3019
3020 size_t num_breakpoints = breakpoints.GetSize();
3021 if (num_breakpoints == 0) {
3022 result.AppendError("no breakpoints, cannot add names");
3023 return;
3024 }
3025
3026 // Particular breakpoint selected; disable that breakpoint.
3027 BreakpointIDList valid_bp_ids;
3029 command, target, result, &valid_bp_ids,
3031
3032 if (result.Succeeded()) {
3033 if (valid_bp_ids.GetSize() == 0) {
3034 result.AppendError("no breakpoints specified, cannot add names");
3035 return;
3036 }
3037 size_t num_valid_ids = valid_bp_ids.GetSize();
3038 const char *bp_name = m_name_options.m_name.GetCurrentValue();
3039 Status error; // This error reports illegal names, but we've already
3040 // checked that, so we don't need to check it again here.
3041 for (size_t index = 0; index < num_valid_ids; index++) {
3042 lldb::break_id_t bp_id =
3043 valid_bp_ids.GetBreakpointIDAtIndex(index).GetBreakpointID();
3044 BreakpointSP bp_sp = breakpoints.FindBreakpointByID(bp_id);
3045 target->AddNameToBreakpoint(bp_sp, bp_name, error);
3046 }
3047 }
3048 }
3049
3050private:
3053};
3054
3056public:
3059 interpreter, "delete",
3060 "Delete a name from the breakpoints provided.",
3061 "breakpoint name delete <command-options> <breakpoint-id-list>",
3062 eCommandAllowsDummyTarget) {
3064
3066 m_option_group.Finalize();
3067 }
3068
3070
3071 void
3077
3078 Options *GetOptions() override { return &m_option_group; }
3079
3080protected:
3081 void DoExecute(Args &command, CommandReturnObject &result) override {
3082 if (!m_name_options.m_name.OptionWasSet()) {
3083 result.AppendError("no name option provided");
3084 return;
3085 }
3086
3087 Target *target =
3088 m_name_options.m_use_dummy ? &GetDummyTarget() : GetTarget();
3089
3090 std::unique_lock<std::recursive_mutex> lock;
3091 target->GetBreakpointList().GetListMutex(lock);
3092
3093 const BreakpointList &breakpoints = target->GetBreakpointList();
3094
3095 size_t num_breakpoints = breakpoints.GetSize();
3096 if (num_breakpoints == 0) {
3097 result.AppendError("no breakpoints, cannot delete names");
3098 return;
3099 }
3100
3101 // Particular breakpoint selected; disable that breakpoint.
3102 BreakpointIDList valid_bp_ids;
3104 command, target, result, &valid_bp_ids,
3106
3107 if (result.Succeeded()) {
3108 if (valid_bp_ids.GetSize() == 0) {
3109 result.AppendError("no breakpoints specified, cannot delete names");
3110 return;
3111 }
3112 ConstString bp_name(m_name_options.m_name.GetCurrentValue());
3113 size_t num_valid_ids = valid_bp_ids.GetSize();
3114 for (size_t index = 0; index < num_valid_ids; index++) {
3115 lldb::break_id_t bp_id =
3116 valid_bp_ids.GetBreakpointIDAtIndex(index).GetBreakpointID();
3117 BreakpointSP bp_sp = breakpoints.FindBreakpointByID(bp_id);
3118 target->RemoveNameFromBreakpoint(bp_sp, bp_name);
3119 }
3120 }
3121 }
3122
3123private:
3126};
3127
3129public:
3131 : CommandObjectParsed(interpreter, "list",
3132 "List either the names for a breakpoint or info "
3133 "about a given name. With no arguments, lists all "
3134 "names",
3135 "breakpoint name list <command-options>",
3136 eCommandAllowsDummyTarget) {
3138 m_option_group.Finalize();
3139 }
3140
3142
3143 Options *GetOptions() override { return &m_option_group; }
3144
3145protected:
3146 void DoExecute(Args &command, CommandReturnObject &result) override {
3147 Target *target =
3148 m_name_options.m_use_dummy ? &GetDummyTarget() : GetTarget();
3149
3150 std::vector<std::string> name_list;
3151 if (command.empty()) {
3152 target->GetBreakpointNames(name_list);
3153 } else {
3154 for (const Args::ArgEntry &arg : command) {
3155 name_list.push_back(arg.c_str());
3156 }
3157 }
3158
3159 if (name_list.empty()) {
3160 result.AppendMessage("No breakpoint names found.");
3161 } else {
3162 for (const std::string &name : name_list) {
3163 // First print out the options for the name:
3164 Status error;
3165 BreakpointName *bp_name =
3166 target->FindBreakpointName(ConstString(name), false, error);
3167 if (bp_name) {
3168 StreamString s;
3169 result.AppendMessageWithFormatv("Name: {0}", name);
3170 if (bp_name->GetDescription(&s, eDescriptionLevelFull)) {
3171 result.AppendMessage(s.GetString());
3172 }
3173
3174 std::unique_lock<std::recursive_mutex> lock;
3175 target->GetBreakpointList().GetListMutex(lock);
3176
3177 BreakpointList &breakpoints = target->GetBreakpointList();
3178 bool any_set = false;
3179 for (BreakpointSP bp_sp : breakpoints.Breakpoints()) {
3180 if (bp_sp->MatchesName(name.c_str())) {
3181 StreamString s;
3182 any_set = true;
3183 bp_sp->GetDescription(&s, eDescriptionLevelBrief);
3184 s.EOL();
3185 result.AppendMessage(s.GetString());
3186 }
3187 }
3188 if (!any_set)
3189 result.AppendMessage("No breakpoints using this name.");
3190 } else {
3191 result.AppendMessageWithFormatv("Name: {0} not found.", name);
3192 }
3193 }
3194 }
3195 }
3196
3197private:
3200};
3201
3202// CommandObjectBreakpointName
3204public:
3207 interpreter, "name", "Commands to manage breakpoint names") {
3208
3209
3211 R"(
3212Breakpoint names provide a general tagging mechanism for breakpoints. Each
3213breakpoint name can be added to any number of breakpoints, and each breakpoint
3214can have any number of breakpoint names attached to it. For instance:
3215
3216 (lldb) break name add -N MyName 1-10
3217
3218adds the name MyName to breakpoints 1-10, and:
3219
3220 (lldb) break set -n myFunc -N Name1 -N Name2
3221
3222adds two names to the breakpoint set at myFunc.
3223
3224They have a number of interrelated uses:
3225
32261) They provide a stable way to refer to a breakpoint (e.g. in another
3227breakpoint's action). Using the breakpoint ID for this purpose is fragile, since
3228it depends on the order of breakpoint creation. Giving a name to the breakpoint
3229you want to act on, and then referring to it by name, is more robust:
3230
3231 (lldb) break set -n myFunc -N BKPT1
3232 (lldb) break set -n myOtherFunc -C "break disable BKPT1"
3233
32342) This is actually just a specific use of a more general feature of breakpoint
3235names. The <breakpt-id-list> argument type used to specify one or more
3236breakpoints in most of the commands that deal with breakpoints also accepts
3237breakpoint names. That allows you to refer to one breakpoint in a stable
3238manner, but also makes them a convenient grouping mechanism, allowing you to
3239easily act on a group of breakpoints by using their name, for instance disabling
3240them all in one action:
3241
3242 (lldb) break set -n myFunc -N Group1
3243 (lldb) break set -n myOtherFunc -N Group1
3244 (lldb) break disable Group1
3245
32463) But breakpoint names are also entities in their own right, and can be
3247configured with all the modifiable attributes of a breakpoint. Then when you
3248add a breakpoint name to a breakpoint, the breakpoint will be configured to
3249match the state of the breakpoint name. The link between the name and the
3250breakpoints sharing it remains live, so if you change the configuration on the
3251name, it will also change the configurations on the breakpoints:
3252
3253 (lldb) break name configure -i 10 IgnoreSome
3254 (lldb) break set -n myFunc -N IgnoreSome
3255 (lldb) break list IgnoreSome
3256 2: name = 'myFunc', locations = 0 (pending) Options: ignore: 10 enabled
3257 Names:
3258 IgnoreSome
3259 (lldb) break name configure -i 5 IgnoreSome
3260 (lldb) break list IgnoreSome
3261 2: name = 'myFunc', locations = 0 (pending) Options: ignore: 5 enabled
3262 Names:
3263 IgnoreSome
3264
3265Options that are not configured on a breakpoint name don't affect the value of
3266those options on the breakpoints they are added to. So for instance, if Name1
3267has the -i option configured and Name2 the -c option, adding both names to a
3268breakpoint will set the -i option from Name1 and the -c option from Name2, and
3269the other options will be unaltered.
3270
3271If you add multiple names to a breakpoint which have configured values for
3272the same option, the last name added's value wins.
3273
3274The "liveness" of these settings is one way, from name to breakpoint.
3275If you use "break modify" to change an option that is also configured on a name
3276which that breakpoint has, the "break modify" command will override the setting
3277for that breakpoint, but won't change the value configured in the name or on the
3278other breakpoints sharing that name.
3279
32804) Breakpoint names are also a convenient way to copy option sets from one
3281breakpoint to another. Using the -B option to "breakpoint name configure" makes
3282a name configured with all the options of the original breakpoint. Then
3283adding that name to another breakpoint copies over all the values from the
3284original breakpoint to the new one.
3285
32865) You can also use breakpoint names to hide breakpoints from the breakpoint
3287operations that act on all breakpoints: "break delete", "break disable" and
3288"break list". You do that by specifying a "false" value for the
3289--allow-{list,delete,disable} options to "breakpoint name configure" and then
3290adding that name to a breakpoint.
3291
3292This won't keep the breakpoint from being deleted or disabled if you refer to it
3293specifically by ID. The point of the feature is to make sure users don't
3294inadvertently delete or disable useful breakpoints (e.g. ones an IDE is using
3295for its own purposes) as part of a "delete all" or "disable all" operation. The
3296list hiding is because it's confusing for people to see breakpoints they
3297didn't set.
3298
3299)");
3300 CommandObjectSP add_command_object(
3301 new CommandObjectBreakpointNameAdd(interpreter));
3302 CommandObjectSP delete_command_object(
3303 new CommandObjectBreakpointNameDelete(interpreter));
3304 CommandObjectSP list_command_object(
3305 new CommandObjectBreakpointNameList(interpreter));
3306 CommandObjectSP configure_command_object(
3307 new CommandObjectBreakpointNameConfigure(interpreter));
3308
3309 LoadSubCommand("add", add_command_object);
3310 LoadSubCommand("delete", delete_command_object);
3311 LoadSubCommand("list", list_command_object);
3312 LoadSubCommand("configure", configure_command_object);
3313 }
3314
3315 ~CommandObjectBreakpointName() override = default;
3316};
3317
3318// CommandObjectBreakpointRead
3319#pragma mark Read::CommandOptions
3320#define LLDB_OPTIONS_breakpoint_read
3321#include "CommandOptions.inc"
3322
3323#pragma mark Read
3324
3326public:
3328 : CommandObjectParsed(interpreter, "breakpoint read",
3329 "Read and set the breakpoints previously saved to "
3330 "a file with \"breakpoint write\". ",
3331 nullptr, eCommandAllowsDummyTarget) {}
3332
3333 ~CommandObjectBreakpointRead() override = default;
3334
3335 Options *GetOptions() override { return &m_options; }
3336
3337 class CommandOptions : public Options {
3338 public:
3339 CommandOptions() = default;
3340
3341 ~CommandOptions() override = default;
3342
3343 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
3344 ExecutionContext *execution_context) override {
3345 Status error;
3346 const int short_option = m_getopt_table[option_idx].val;
3347 const char *long_option =
3348 m_getopt_table[option_idx].definition->long_option;
3349
3350 switch (short_option) {
3351 case 'f':
3352 m_filename.assign(std::string(option_arg));
3353 break;
3354 case 'N': {
3355 Status name_error;
3356 if (!BreakpointID::StringIsBreakpointName(llvm::StringRef(option_arg),
3357 name_error)) {
3359 option_arg, short_option, long_option, name_error.AsCString()));
3360 }
3361 m_names.push_back(std::string(option_arg));
3362 break;
3363 }
3364 default:
3365 llvm_unreachable("Unimplemented option");
3366 }
3367
3368 return error;
3369 }
3370
3371 void OptionParsingStarting(ExecutionContext *execution_context) override {
3372 m_filename.clear();
3373 m_names.clear();
3374 }
3375
3376 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
3377 return llvm::ArrayRef(g_breakpoint_read_options);
3378 }
3379
3381 CompletionRequest &request, OptionElementVector &opt_element_vector,
3382 int opt_element_index, CommandInterpreter &interpreter) override {
3383 int opt_arg_pos = opt_element_vector[opt_element_index].opt_arg_pos;
3384 int opt_defs_index = opt_element_vector[opt_element_index].opt_defs_index;
3385
3386 switch (GetDefinitions()[opt_defs_index].short_option) {
3387 case 'f':
3389 interpreter, lldb::eDiskFileCompletion, request, nullptr);
3390 break;
3391
3392 case 'N':
3393 std::optional<FileSpec> file_spec;
3394 const llvm::StringRef dash_f("-f");
3395 for (int arg_idx = 0; arg_idx < opt_arg_pos; arg_idx++) {
3396 if (dash_f == request.GetParsedLine().GetArgumentAtIndex(arg_idx)) {
3397 file_spec.emplace(
3398 request.GetParsedLine().GetArgumentAtIndex(arg_idx + 1));
3399 break;
3400 }
3401 }
3402 if (!file_spec)
3403 return;
3404
3405 FileSystem::Instance().Resolve(*file_spec);
3406 Status error;
3407 StructuredData::ObjectSP input_data_sp =
3409 if (!error.Success())
3410 return;
3411
3412 StructuredData::Array *bkpt_array = input_data_sp->GetAsArray();
3413 if (!bkpt_array)
3414 return;
3415
3416 const size_t num_bkpts = bkpt_array->GetSize();
3417 for (size_t i = 0; i < num_bkpts; i++) {
3418 StructuredData::ObjectSP bkpt_object_sp =
3419 bkpt_array->GetItemAtIndex(i);
3420 if (!bkpt_object_sp)
3421 return;
3422
3423 StructuredData::Dictionary *bkpt_dict =
3424 bkpt_object_sp->GetAsDictionary();
3425 if (!bkpt_dict)
3426 return;
3427
3428 StructuredData::ObjectSP bkpt_data_sp =
3430 if (!bkpt_data_sp)
3431 return;
3432
3433 bkpt_dict = bkpt_data_sp->GetAsDictionary();
3434 if (!bkpt_dict)
3435 return;
3436
3437 StructuredData::Array *names_array;
3438
3439 if (!bkpt_dict->GetValueForKeyAsArray("Names", names_array))
3440 return;
3441
3442 size_t num_names = names_array->GetSize();
3443
3444 for (size_t i = 0; i < num_names; i++) {
3445 if (std::optional<llvm::StringRef> maybe_name =
3446 names_array->GetItemAtIndexAsString(i))
3447 request.TryCompleteCurrentArg(*maybe_name);
3448 }
3449 }
3450 }
3451 }
3452
3453 std::string m_filename;
3454 std::vector<std::string> m_names;
3455 };
3456
3457protected:
3458 void DoExecute(Args &command, CommandReturnObject &result) override {
3459 Target *target = GetTarget();
3460 assert(target && "target guaranteed by eCommandAllowsDummyTarget");
3461 std::unique_lock<std::recursive_mutex> lock;
3462 target->GetBreakpointList().GetListMutex(lock);
3463
3464 FileSpec input_spec(m_options.m_filename);
3465 FileSystem::Instance().Resolve(input_spec);
3466 BreakpointIDList new_bps;
3468 input_spec, m_options.m_names, new_bps);
3469
3470 if (!error.Success()) {
3471 result.AppendError(error.AsCString());
3472 return;
3473 }
3474
3475 Stream &output_stream = result.GetOutputStream();
3476
3477 size_t num_breakpoints = new_bps.GetSize();
3478 if (num_breakpoints == 0) {
3479 result.AppendMessage("No breakpoints added.");
3480 } else {
3481 // No breakpoint selected; show info about all currently set breakpoints.
3482 result.AppendMessage("New breakpoints:");
3483 for (size_t i = 0; i < num_breakpoints; ++i) {
3484 BreakpointID bp_id = new_bps.GetBreakpointIDAtIndex(i);
3485 Breakpoint *bp = target->GetBreakpointList()
3487 .get();
3488 if (bp)
3490 false);
3491 }
3492 }
3493 }
3494
3495private:
3497};
3498
3499// CommandObjectBreakpointWrite
3500#pragma mark Write::CommandOptions
3501#define LLDB_OPTIONS_breakpoint_write
3502#include "CommandOptions.inc"
3503
3504#pragma mark Write
3506public:
3508 : CommandObjectParsed(interpreter, "breakpoint write",
3509 "Write the breakpoints listed to a file that can "
3510 "be read in with \"breakpoint read\". "
3511 "If given no arguments, writes all breakpoints.",
3512 nullptr, eCommandAllowsDummyTarget) {
3514 }
3515
3516 ~CommandObjectBreakpointWrite() override = default;
3517
3518 void
3524
3525 Options *GetOptions() override { return &m_options; }
3526
3527 class CommandOptions : public Options {
3528 public:
3529 CommandOptions() = default;
3530
3531 ~CommandOptions() override = default;
3532
3533 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
3534 ExecutionContext *execution_context) override {
3535 Status error;
3536 const int short_option = m_getopt_table[option_idx].val;
3537
3538 switch (short_option) {
3539 case 'f':
3540 m_filename.assign(std::string(option_arg));
3541 break;
3542 case 'a':
3543 m_append = true;
3544 break;
3545 default:
3546 llvm_unreachable("Unimplemented option");
3547 }
3548
3549 return error;
3550 }
3551
3552 void OptionParsingStarting(ExecutionContext *execution_context) override {
3553 m_filename.clear();
3554 m_append = false;
3555 }
3556
3557 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
3558 return llvm::ArrayRef(g_breakpoint_write_options);
3559 }
3560
3561 // Instance variables to hold the values for command options.
3562
3563 std::string m_filename;
3564 bool m_append = false;
3565 };
3566
3567protected:
3568 void DoExecute(Args &command, CommandReturnObject &result) override {
3569 Target *target = GetTarget();
3570 assert(target && "target guaranteed by eCommandAllowsDummyTarget");
3571 std::unique_lock<std::recursive_mutex> lock;
3572 target->GetBreakpointList().GetListMutex(lock);
3573
3574 BreakpointIDList valid_bp_ids;
3575 if (!command.empty()) {
3577 command, m_exe_ctx, result, &valid_bp_ids,
3579
3580 if (!result.Succeeded()) {
3582 return;
3583 }
3584 }
3585 FileSpec file_spec(m_options.m_filename);
3586 FileSystem::Instance().Resolve(file_spec);
3587 Status error = target->SerializeBreakpointsToFile(file_spec, valid_bp_ids,
3588 m_options.m_append);
3589 if (!error.Success()) {
3590 result.AppendErrorWithFormat("error serializing breakpoints: %s",
3591 error.AsCString());
3592 }
3593 }
3594
3595private:
3597};
3598
3599#pragma mark override add
3600#define LLDB_OPTIONS_breakpoint_override_add
3601#include "CommandOptions.inc"
3602
3604public:
3606 : CommandObjectParsed(interpreter, "breakpoint override add",
3607 "Add a scripted breakpoint override resolver.",
3608 nullptr, eCommandAllowsDummyTarget),
3609 m_python_class_options("breakpoint override resolver", true, 'P') {
3610 // We're picking up all the normal options, commands and disable.
3614 m_all_options.Append(&m_options, llvm::ArrayRef<llvm::StringRef>());
3615 m_all_options.Finalize();
3616 }
3617
3619
3621 public:
3622 CommandOptions() = default;
3623
3624 ~CommandOptions() override = default;
3625
3626 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
3627 ExecutionContext *execution_context) override {
3628 Status error;
3629 const int short_option = GetDefinitions()[option_idx].short_option;
3630
3631 switch (short_option) {
3632 case 'd':
3633 m_description.assign(std::string(option_arg));
3634 break;
3635 default:
3636 llvm_unreachable("Unimplemented option");
3637 }
3638
3639 return error;
3640 }
3641
3642 void OptionParsingStarting(ExecutionContext *execution_context) override {
3643 m_description.clear();
3644 }
3645
3646 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
3647 return llvm::ArrayRef(g_breakpoint_override_add_options);
3648 }
3649
3650 // Instance variables to hold the values for command options.
3651
3652 std::string m_description;
3653 };
3654 Options *GetOptions() override { return &m_all_options; }
3655
3656protected:
3657 void DoExecute(Args &command, CommandReturnObject &result) override {
3658 Target *target =
3659 m_dummy_options.m_use_dummy ? &GetDummyTarget() : GetTarget();
3660 llvm::Expected<lldb::user_id_t> id = target->AddBreakpointResolverOverride(
3661 m_python_class_options.GetName(),
3662 m_python_class_options.GetStructuredData(), m_options.m_description);
3663 if (id) {
3664 result.AppendMessageWithFormatv("{0}", *id);
3666 } else {
3667 result.AppendErrorWithFormatv("could not add resolver: {0}.",
3668 llvm::toString(id.takeError()));
3669 }
3670 }
3671
3672private:
3677};
3678
3680public:
3682 : CommandObjectParsed(interpreter, "breakpoint override delete",
3683 "Delete a scripted breakpoint override resolver.",
3684 nullptr, eCommandAllowsDummyTarget) {
3687 m_all_options.Finalize();
3688 }
3689
3691
3692 Options *GetOptions() override { return &m_all_options; }
3693
3694protected:
3695 void DoExecute(Args &command, CommandReturnObject &result) override {
3696 Target *target =
3697 m_dummy_options.m_use_dummy ? &GetDummyTarget() : GetTarget();
3698
3699 const size_t argc = command.GetArgumentCount();
3700 if (argc == 0) {
3701 if (m_interpreter.Confirm("Delete all breakpoint overrides?", false)) {
3703 }
3705 return;
3706 }
3707
3708 for (auto &entry : command.entries()) {
3709 uint64_t id;
3710 bool success;
3711 if (!entry.ref().getAsInteger(0, id))
3712 success = target->RemoveBreakpointResolverOverride(id);
3713 else {
3714 result.AppendErrorWithFormatv("Index not an integer: {0}", entry.ref());
3716 return;
3717 }
3718 if (!success) {
3719 result.AppendErrorWithFormatv("Cannot delete override: {0}", id);
3721 return;
3722 }
3723 }
3725 }
3726
3727private:
3730};
3731
3733public:
3736 interpreter, "breakpoint override list",
3737 "List the current scripted breakpoint override resolvers.", nullptr,
3738 eCommandAllowsDummyTarget) {
3741 m_all_options.Finalize();
3742 }
3743
3745
3746 Options *GetOptions() override { return &m_all_options; }
3747
3748protected:
3749 void DoExecute(Args &command, CommandReturnObject &result) override {
3750 Target *target =
3751 m_dummy_options.m_use_dummy ? &GetDummyTarget() : GetTarget();
3752
3753 const size_t argc = command.GetArgumentCount();
3754 std::vector<uint64_t> idxs;
3755 if (argc != 0) {
3756 for (auto &entry : command.entries()) {
3757 uint64_t id;
3758 if (!entry.ref().getAsInteger(0, id)) {
3759 idxs.push_back(id);
3760 } else {
3761 result.AppendErrorWithFormatv("Index not an integer: {0}",
3762 entry.ref());
3764 return;
3765 }
3766 }
3767 }
3768 target->DescribeBreakpointOverrides(result.GetOutputStream(), idxs);
3769 if (idxs.empty()) {
3771 } else {
3773 Stream &error_strm = result.GetErrorStream();
3774 if (idxs.size() == 1) {
3775 error_strm << llvm::formatv("error: invalid index: {0}", idxs[0]);
3776 return;
3777 }
3778 error_strm << "error: invalid indices: ";
3779 auto begin = idxs.begin();
3780 error_strm << llvm::formatv("{0}", *begin);
3781 idxs.erase(begin);
3782 for (auto elem : idxs)
3783 error_strm << llvm::formatv(", {0}", elem);
3784 }
3785 }
3786
3787private:
3790};
3792public:
3795 interpreter, "override",
3796 "Commands to manage breakpoint override resolvers") {
3797
3799 R"(
3800Breakpoint override resolvers allow you to intercept breakpoint requests and
3801re-implement them using a custom breakpoint resolver. Override resolvers are
3802implemented by a scripted breakpoint resolver that implements the
3803'overrides_resolver' interface. It takes an SBStructuredData with the
3804serialized form of the original breakpoint resolver. If it returns true, then
3805the provided resolver will be substituted for the one lldb would have produced
3806by default.
3807
3808Add new override resolvers using:
3809
3810 (lldb) breakpoint override add -c class_name
3811
3812This returns the ID of the resolver you added.
3813
3814List the currently added override resolvers using:
3815
3816 (lldb) breakpoint override list
3817
3818Delete an added resolver using:
3819
3820 (lldb) breakpoint override delete <id>
3821
3822)");
3823 CommandObjectSP add_command_object(
3824 new CommandObjectBreakpointOverrideAdd(interpreter));
3825 CommandObjectSP delete_command_object(
3826 new CommandObjectBreakpointOverrideDelete(interpreter));
3827 CommandObjectSP list_command_object(
3828 new CommandObjectBreakpointOverrideList(interpreter));
3829
3830 LoadSubCommand("add", add_command_object);
3831 LoadSubCommand("delete", delete_command_object);
3832 LoadSubCommand("list", list_command_object);
3833 }
3834
3835 ~CommandObjectBreakpointOverride() override = default;
3836};
3837
3838// CommandObjectMultiwordBreakpoint
3839#pragma mark MultiwordBreakpoint
3840
3842 CommandInterpreter &interpreter)
3844 interpreter, "breakpoint",
3845 "Commands for operating on breakpoints (see 'help b' for shorthand.)",
3846 "breakpoint <subcommand> [<command-options>]") {
3847 CommandObjectSP list_command_object(
3848 new CommandObjectBreakpointList(interpreter));
3849 CommandObjectSP enable_command_object(
3850 new CommandObjectBreakpointEnable(interpreter));
3851 CommandObjectSP disable_command_object(
3852 new CommandObjectBreakpointDisable(interpreter));
3853 CommandObjectSP clear_command_object(
3854 new CommandObjectBreakpointClear(interpreter));
3855 CommandObjectSP delete_command_object(
3856 new CommandObjectBreakpointDelete(interpreter));
3857 CommandObjectSP set_command_object(
3858 new CommandObjectBreakpointSet(interpreter));
3859 CommandObjectSP add_command_object(
3860 new CommandObjectBreakpointAdd(interpreter));
3861 CommandObjectSP command_command_object(
3862 new CommandObjectBreakpointCommand(interpreter));
3863 CommandObjectSP modify_command_object(
3864 new CommandObjectBreakpointModify(interpreter));
3865 CommandObjectSP name_command_object(
3866 new CommandObjectBreakpointName(interpreter));
3867 CommandObjectSP write_command_object(
3868 new CommandObjectBreakpointWrite(interpreter));
3869 CommandObjectSP read_command_object(
3870 new CommandObjectBreakpointRead(interpreter));
3871 CommandObjectSP override_command_object(
3872 new CommandObjectBreakpointOverride(interpreter));
3873
3874 list_command_object->SetCommandName("breakpoint list");
3875 enable_command_object->SetCommandName("breakpoint enable");
3876 disable_command_object->SetCommandName("breakpoint disable");
3877 clear_command_object->SetCommandName("breakpoint clear");
3878 delete_command_object->SetCommandName("breakpoint delete");
3879 set_command_object->SetCommandName("breakpoint set");
3880 add_command_object->SetCommandName("breakpoint add");
3881 command_command_object->SetCommandName("breakpoint command");
3882 modify_command_object->SetCommandName("breakpoint modify");
3883 name_command_object->SetCommandName("breakpoint name");
3884 write_command_object->SetCommandName("breakpoint write");
3885 read_command_object->SetCommandName("breakpoint read");
3886 override_command_object->SetCommandName("breakpoint override");
3887
3888 LoadSubCommand("list", list_command_object);
3889 LoadSubCommand("enable", enable_command_object);
3890 LoadSubCommand("disable", disable_command_object);
3891 LoadSubCommand("clear", clear_command_object);
3892 LoadSubCommand("delete", delete_command_object);
3893 LoadSubCommand("set", set_command_object);
3894 LoadSubCommand("add", add_command_object);
3895 LoadSubCommand("command", command_command_object);
3896 LoadSubCommand("modify", modify_command_object);
3897 LoadSubCommand("name", name_command_object);
3898 LoadSubCommand("write", write_command_object);
3899 LoadSubCommand("read", read_command_object);
3900 LoadSubCommand("override", override_command_object);
3901}
3902
3904
3906 Args &args, const ExecutionContext &exe_ctx, bool allow_locations,
3907 CommandReturnObject &result, BreakpointIDList *valid_ids,
3908 BreakpointName::Permissions ::PermissionKinds purpose) {
3909 // args can be strings representing 1). integers (for breakpoint ids)
3910 // 2). the full breakpoint & location
3911 // canonical representation
3912 // 3). the word "to" or a hyphen,
3913 // representing a range (in which case there
3914 // had *better* be an entry both before &
3915 // after of one of the first two types.
3916 // 4). A breakpoint name
3917 // If args is empty, we will use the last created breakpoint (if there is
3918 // one.)
3919
3920 Target &target = exe_ctx.GetTargetRef();
3921 Args temp_args;
3922
3923 if (args.empty()) {
3924 if (target.GetLastCreatedBreakpoint()) {
3925 valid_ids->AddBreakpointID(BreakpointID(
3928 } else {
3929 result.AppendError(
3930 "No breakpoint specified and no last created breakpoint.");
3931 }
3932 return;
3933 }
3934
3935 // Create a new Args variable to use; copy any non-breakpoint-id-ranges stuff
3936 // directly from the old ARGS to the new TEMP_ARGS. Do not copy breakpoint
3937 // id range strings over; instead generate a list of strings for all the
3938 // breakpoint ids in the range, and shove all of those breakpoint id strings
3939 // into TEMP_ARGS.
3940
3941 if (llvm::Error err = BreakpointIDList::FindAndReplaceIDRanges(
3942 args, exe_ctx, allow_locations, purpose, temp_args)) {
3943 result.SetError(std::move(err));
3944 return;
3945 }
3947
3948 // NOW, convert the list of breakpoint id strings in TEMP_ARGS into an actual
3949 // BreakpointIDList:
3950
3951 for (llvm::StringRef temp_arg : temp_args.GetArgumentArrayRef())
3952 if (auto bp_id = BreakpointID::ParseCanonicalReference(temp_arg))
3953 valid_ids->AddBreakpointID(*bp_id);
3954
3955 // At this point, all of the breakpoint ids that the user passed in have
3956 // been converted to breakpoint IDs and put into valid_ids.
3957
3958 // Now that we've converted everything from args into a list of breakpoint
3959 // ids, go through our tentative list of breakpoint id's and verify that
3960 // they correspond to valid/currently set breakpoints.
3961
3962 const size_t count = valid_ids->GetSize();
3963 for (size_t i = 0; i < count; ++i) {
3964 BreakpointID cur_bp_id = valid_ids->GetBreakpointIDAtIndex(i);
3965 Breakpoint *breakpoint =
3966 target.GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();
3967 if (breakpoint != nullptr) {
3968 lldb::break_id_t cur_loc_id = cur_bp_id.GetLocationID();
3969 // GetLocationID returns 0 when the location isn't specified.
3970 if (cur_loc_id != 0 && !breakpoint->FindLocationByID(cur_loc_id)) {
3971 StreamString id_str;
3973 &id_str, cur_bp_id.GetBreakpointID(), cur_bp_id.GetLocationID());
3974 i = valid_ids->GetSize() + 1;
3975 result.AppendErrorWithFormat(
3976 "'%s' is not a currently valid breakpoint/location id",
3977 id_str.GetData());
3978 }
3979 } else {
3980 i = valid_ids->GetSize() + 1;
3981 result.AppendErrorWithFormat(
3982 "'%d' is not a currently valid breakpoint ID",
3983 cur_bp_id.GetBreakpointID());
3984 }
3985 }
3986}
static bool GetDefaultFile(Target &target, StackFrame *cur_frame, FileSpec &file, CommandReturnObject &result)
static bool CopyOverBreakpointOptions(BreakpointSP bp_sp, BreakpointOptionGroup &bp_opts, const std::vector< std::string > &bp_names, CommandReturnObject &result)
static llvm::Expected< LanguageType > GetExceptionLanguageForLanguage(llvm::StringRef lang_name, char short_option='\0', llvm::StringRef long_option={})
static void AddBreakpointDescription(Stream *s, Breakpoint *bp, lldb::DescriptionLevel level)
static Status CompleteLineEntry(ExecutionContext &exe_ctx, OptionValueFileColonLine &line_entry)
static llvm::raw_ostream & error(Stream &strm)
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
const BreakpointName::Permissions & GetPermissions() const
~BreakpointAccessOptionGroup() override=default
BreakpointName::Permissions m_permissions
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
void OptionParsingStarting(ExecutionContext *execution_context) override
BreakpointDummyOptionGroup()=default
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
void OptionParsingStarting(ExecutionContext *execution_context) override
~BreakpointDummyOptionGroup() override=default
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
~BreakpointNameOptionGroup() override=default
void OptionParsingStarting(ExecutionContext *execution_context) override
void OptionParsingStarting(ExecutionContext *execution_context) override
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
const std::vector< std::string > & GetBreakpointNames()
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, ExecutionContext *execution_context) override
~BreakpointNamesOptionGroup() override=default
std::vector< std::string > m_breakpoint_names
BreakpointNamesOptionGroup()=default
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
void OptionParsingStarting(ExecutionContext *execution_context) override
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectBreakpointAddAddress(CommandInterpreter &interpreter)
~CommandObjectBreakpointAddAddress() override=default
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
void OptionParsingStarting(ExecutionContext *execution_context) override
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
~CommandObjectBreakpointAddException() override=default
CommandObjectBreakpointAddException(CommandInterpreter &interpreter)
void DoExecute(Args &command, CommandReturnObject &result) override
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Status OptionParsingFinished(ExecutionContext *execution_context) override
void OptionParsingStarting(ExecutionContext *execution_context) override
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
std::vector< OptionValueFileColonLine > m_line_specs
CommandObjectBreakpointAddFile(CommandInterpreter &interpreter)
void DoExecute(Args &command, CommandReturnObject &result) override
~CommandObjectBreakpointAddFile() override=default
BreakpointDummyOptionGroup m_dummy_options
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
void OptionParsingStarting(ExecutionContext *execution_context) override
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
BreakpointDummyOptionGroup m_dummy_options
~CommandObjectBreakpointAddName() override=default
CommandObjectBreakpointAddName(CommandInterpreter &interpreter)
void DoExecute(Args &command, CommandReturnObject &result) override
void OptionParsingStarting(ExecutionContext *execution_context) override
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
void DoExecute(llvm::StringRef command, CommandReturnObject &result) override
~CommandObjectBreakpointAddPattern() override=default
CommandObjectBreakpointAddPattern(CommandInterpreter &interpreter)
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
void OptionParsingStarting(ExecutionContext *execution_context) override
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
~CommandObjectBreakpointAddScripted() override=default
CommandObjectBreakpointAddScripted(CommandInterpreter &interpreter)
void DoExecute(Args &command, CommandReturnObject &result) override
OptionGroupPythonClassWithDict m_python_class_options
CommandObjectBreakpointAdd(CommandInterpreter &interpreter)
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
void OptionParsingStarting(ExecutionContext *execution_context) override
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectBreakpointClear(CommandInterpreter &interpreter)
~CommandObjectBreakpointClear() override=default
void OptionParsingStarting(ExecutionContext *execution_context) override
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
CommandObjectBreakpointDelete(CommandInterpreter &interpreter)
~CommandObjectBreakpointDelete() override=default
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
void DoExecute(Args &command, CommandReturnObject &result) override
~CommandObjectBreakpointDisable() override=default
CommandObjectBreakpointDisable(CommandInterpreter &interpreter)
void DoExecute(Args &command, CommandReturnObject &result) override
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
~CommandObjectBreakpointEnable() override=default
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
CommandObjectBreakpointEnable(CommandInterpreter &interpreter)
void DoExecute(Args &command, CommandReturnObject &result) override
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
void OptionParsingStarting(ExecutionContext *execution_context) override
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
~CommandObjectBreakpointList() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectBreakpointList(CommandInterpreter &interpreter)
void DoExecute(Args &command, CommandReturnObject &result) override
BreakpointDummyOptionGroup m_dummy_opts
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
CommandObjectBreakpointModify(CommandInterpreter &interpreter)
~CommandObjectBreakpointModify() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectBreakpointNameAdd(CommandInterpreter &interpreter)
~CommandObjectBreakpointNameAdd() override=default
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
~CommandObjectBreakpointNameConfigure() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectBreakpointNameConfigure(CommandInterpreter &interpreter)
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
CommandObjectBreakpointNameDelete(CommandInterpreter &interpreter)
void DoExecute(Args &command, CommandReturnObject &result) override
~CommandObjectBreakpointNameDelete() override=default
CommandObjectBreakpointNameList(CommandInterpreter &interpreter)
void DoExecute(Args &command, CommandReturnObject &result) override
~CommandObjectBreakpointNameList() override=default
~CommandObjectBreakpointName() override=default
CommandObjectBreakpointName(CommandInterpreter &interpreter)
void OptionParsingStarting(ExecutionContext *execution_context) override
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
CommandObjectBreakpointOverrideAdd(CommandInterpreter &interpreter)
~CommandObjectBreakpointOverrideAdd() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
OptionGroupPythonClassWithDict m_python_class_options
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectBreakpointOverrideDelete(CommandInterpreter &interpreter)
~CommandObjectBreakpointOverrideDelete() override=default
CommandObjectBreakpointOverrideList(CommandInterpreter &interpreter)
~CommandObjectBreakpointOverrideList() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectBreakpointOverride(CommandInterpreter &interpreter)
~CommandObjectBreakpointOverride() override=default
void HandleOptionArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector, int opt_element_index, CommandInterpreter &interpreter) override
Handles the generic bits of figuring out whether we are in an option, and if so completing it.
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
void OptionParsingStarting(ExecutionContext *execution_context) override
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectBreakpointRead(CommandInterpreter &interpreter)
~CommandObjectBreakpointRead() override=default
void OptionParsingStarting(ExecutionContext *execution_context) override
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
std::unordered_set< std::string > m_source_regex_func_names
~CommandObjectBreakpointSet() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
OptionGroupPythonClassWithDict m_python_class_options
CommandObjectBreakpointSet(CommandInterpreter &interpreter)
BreakpointDummyOptionGroup m_dummy_options
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
void OptionParsingStarting(ExecutionContext *execution_context) override
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
void DoExecute(Args &command, CommandReturnObject &result) override
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
CommandObjectBreakpointWrite(CommandInterpreter &interpreter)
~CommandObjectBreakpointWrite() override=default
A section + offset based address class.
Definition Address.h:62
A command line argument class.
Definition Args.h:33
llvm::ArrayRef< const char * > GetArgumentArrayRef() const
Gets the argument as an ArrayRef.
Definition Args.h:173
size_t GetArgumentCount() const
Gets the number of arguments left in this command object.
Definition Args.h:120
llvm::ArrayRef< ArgEntry > entries() const
Definition Args.h:132
size_t size() const
Definition Args.h:139
const char * GetArgumentAtIndex(size_t idx) const
Gets the NULL terminated C string argument pointer for the argument at index idx.
Definition Args.cpp:273
bool empty() const
Definition Args.h:122
bool Contains(BreakpointID bp_id) const
bool AddBreakpointID(BreakpointID bp_id)
static llvm::Error FindAndReplaceIDRanges(Args &old_args, const ExecutionContext &exe_ctx, bool allow_locations, BreakpointName::Permissions ::PermissionKinds purpose, Args &new_args)
BreakpointID GetBreakpointIDAtIndex(size_t index) const
static std::optional< BreakpointID > ParseCanonicalReference(llvm::StringRef input)
Takes an input string containing the description of a breakpoint or breakpoint and location and retur...
lldb::break_id_t GetBreakpointID() const
lldb::break_id_t GetLocationID() const
static void GetCanonicalReference(Stream *s, lldb::break_id_t break_id, lldb::break_id_t break_loc_id)
Takes a breakpoint ID and the breakpoint location id and returns a string containing the canonical de...
static bool StringIsBreakpointName(llvm::StringRef str, Status &error)
Takes an input string and checks to see whether it is a breakpoint name.
General Outline: Allows adding and removing breakpoints and find by ID and index.
BreakpointIterable Breakpoints()
lldb::BreakpointSP FindBreakpointByID(lldb::break_id_t breakID) const
Returns a shared pointer to the breakpoint with id breakID.
void GetListMutex(std::unique_lock< std::recursive_mutex > &lock)
Sets the passed in Locker to hold the Breakpoint List mutex.
size_t GetSize() const
Returns the number of elements in this breakpoint list.
lldb::BreakpointSP GetBreakpointAtIndex(size_t i) const
Returns a shared pointer to the breakpoint with index i.
size_t GetSize() const
Returns the number of elements in this breakpoint location list.
General Outline: A breakpoint location is defined by the breakpoint that produces it,...
llvm::Error SetEnabled(bool enabled)
If enabled is true, enable the breakpoint, if false disable it.
BreakpointOptions & GetLocationOptions()
Use this to set location specific breakpoint options.
bool GetDescription(Stream *s, lldb::DescriptionLevel level)
void SetHelp(const char *description)
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Status OptionParsingFinished(ExecutionContext *execution_context) override
const BreakpointOptions & GetBreakpointOptions()
~BreakpointOptionGroup() override=default
void OptionParsingStarting(ExecutionContext *execution_context) override
"lldb/Breakpoint/BreakpointOptions.h" Class that manages the options on a breakpoint or breakpoint lo...
void CopyOverSetOptions(const BreakpointOptions &rhs)
Copy over only the options set in the incoming BreakpointOptions.
General Outline: A breakpoint has four main parts, a filter, a resolver, the list of breakpoint locat...
Definition Breakpoint.h:81
lldb::BreakpointLocationSP FindLocationByID(lldb::break_id_t bp_loc_id, bool use_facade=true)
Find a breakpoint location for a given breakpoint location ID.
void GetDescription(Stream *s, lldb::DescriptionLevel level, bool show_locations=false)
Put a description of this breakpoint into the stream s.
BreakpointOptions & GetOptions()
Returns the BreakpointOptions structure set at the breakpoint level.
static const char * GetSerializationKey()
Definition Breakpoint.h:160
bool GetMatchingFileLine(ConstString filename, uint32_t line_number, BreakpointLocationCollection &loc_coll)
Find breakpoint locations which match the (filename, line_number) description.
void SetEnabled(bool enable) override
If enable is true, enable the breakpoint, if false disable it.
static bool InvokeCommonCompletionCallbacks(CommandInterpreter &interpreter, uint32_t completion_mask, lldb_private::CompletionRequest &request, SearchFilter *searcher)
ExecutionContext GetExecutionContext(bool adopt_dummy_target=true) const
Returns the execution context the interpreter should run a command in.
static void VerifyIDs(Args &args, const ExecutionContext &exe_ctx, bool allow_locations, CommandReturnObject &result, BreakpointIDList *valid_ids, BreakpointName::Permissions::PermissionKinds purpose)
CommandObjectMultiwordBreakpoint(CommandInterpreter &interpreter)
static void VerifyBreakpointOrLocationIDs(Args &args, const ExecutionContext &exe_ctx, CommandReturnObject &result, BreakpointIDList *valid_ids, BreakpointName::Permissions ::PermissionKinds purpose)
static void VerifyBreakpointIDs(Args &args, const ExecutionContext &exe_ctx, CommandReturnObject &result, BreakpointIDList *valid_ids, BreakpointName::Permissions::PermissionKinds purpose)
bool LoadSubCommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj) override
CommandObjectMultiword(CommandInterpreter &interpreter, const char *name, const char *help=nullptr, const char *syntax=nullptr, uint32_t flags=0)
CommandObjectParsed(CommandInterpreter &interpreter, const char *name, const char *help=nullptr, const char *syntax=nullptr, uint32_t flags=0)
CommandObjectRaw(CommandInterpreter &interpreter, llvm::StringRef name, llvm::StringRef help="", llvm::StringRef syntax="", uint32_t flags=0)
std::vector< CommandArgumentData > CommandArgumentEntry
virtual void SetHelpLong(llvm::StringRef str)
void AddSimpleArgumentList(lldb::CommandArgumentType arg_type, ArgumentRepetitionType repetition_type=eArgRepeatPlain)
bool ParseOptionsAndNotify(Args &args, CommandReturnObject &result, OptionGroupOptions &group_options, ExecutionContext &exe_ctx)
std::vector< CommandArgumentEntry > m_arguments
void AddIDsArgumentData(IDType type)
CommandInterpreter & GetCommandInterpreter()
CommandInterpreter & m_interpreter
Target * GetTarget()
Get the target this command should operate on.
void AppendMessage(llvm::StringRef in_string)
void AppendError(llvm::StringRef in_string)
std::string GetErrorString(bool with_diagnostics=true) const
Return the errors as a string.
void SetStatus(lldb::ReturnStatus status)
void AppendErrorWithFormat(const char *format,...) __attribute__((format(printf
void void AppendMessageWithFormatv(const char *format, Args &&...args)
void AppendWarning(llvm::StringRef in_string)
void AppendErrorWithFormatv(const char *format, Args &&...args)
"lldb/Utility/ArgCompletionRequest.h"
void TryCompleteCurrentArg(llvm::StringRef completion, llvm::StringRef description="")
Adds a possible completion string if the completion would complete the current argument.
A uniqued constant string class.
Definition ConstString.h:40
A class to manage flag bits.
Definition Debugger.h:100
bool GetUseColor() const
Definition Debugger.cpp:525
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
StackFrame * GetFramePtr() const
Returns a pointer to the frame object.
Target * GetTargetPtr() const
Returns a pointer to the target object.
const lldb::ThreadSP & GetThreadSP() const
Get accessor to get the thread shared pointer.
bool HasTargetScope() const
Returns true the ExecutionContext object contains a valid target.
Target & GetTargetRef() const
Returns a reference to the target object.
A file collection class.
A file utility class.
Definition FileSpec.h:57
static FileSystem & Instance()
void Resolve(llvm::SmallVectorImpl< char > &path, bool force_make_absolute=false)
Resolve path to make it canonical.
static llvm::Expected< lldb::LanguageType > GetExceptionLanguageForLanguage(llvm::StringRef lang_name)
Definition Language.cpp:159
static LanguageSet GetLanguagesSupportingTypeSystemsForExpressions()
Definition Language.cpp:471
static lldb::LanguageType GetLanguageTypeFromString(const char *string)=delete
Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign) override
A pair of an option list with a 'raw' string as a suffix.
Definition Args.h:319
bool HasArgs() const
Returns true if there are any arguments before the raw suffix.
Definition Args.h:330
Args & GetArgs()
Returns the list of arguments.
Definition Args.h:335
const std::string & GetRawPart() const
Returns the raw suffix part of the parsed string.
Definition Args.h:368
A command line option parsing protocol class.
Definition Options.h:58
std::vector< Option > m_getopt_table
Definition Options.h:198
llvm::Error GetError() const
Return an error if the regular expression failed to compile.
std::optional< SupportFileAndLine > GetDefaultFileAndLine()
This base class provides an interface to stack frames.
Definition StackFrame.h:44
virtual const SymbolContext & GetSymbolContext(lldb::SymbolContextItem resolve_scope)
Provide a SymbolContext for this StackFrame's current pc value.
virtual bool HasDebugInformation()
Determine whether this StackFrame has debug information available or not.
An error handling class.
Definition Status.h:118
static Status FromErrorString(const char *str)
Definition Status.h:141
bool Fail() const
Test for error condition.
Definition Status.cpp:293
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
Definition Status.cpp:194
static Status FromError(llvm::Error error)
Avoid using this in new code. Migrate APIs to llvm::Expected instead.
Definition Status.cpp:136
bool Success() const
Test for success condition.
Definition Status.cpp:303
lldb::break_id_t GetID() const
Definition Stoppoint.cpp:22
const char * GetData() const
llvm::StringRef GetString() const
A stream class that can stream formatted output to a file.
Definition Stream.h:28
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition Stream.cpp:134
size_t EOL()
Output and End of Line character to the stream.
Definition Stream.cpp:155
void IndentLess(unsigned amount=2)
Decrement the current indentation level.
Definition Stream.cpp:204
void IndentMore(unsigned amount=2)
Increment the current indentation level.
Definition Stream.cpp:201
ObjectSP GetItemAtIndex(size_t idx) const
std::optional< llvm::StringRef > GetItemAtIndexAsString(size_t idx) const
ObjectSP GetValueForKey(llvm::StringRef key) const
bool GetValueForKeyAsArray(llvm::StringRef key, Array *&result) const
std::shared_ptr< Object > ObjectSP
static ObjectSP ParseJSONFromFile(const FileSpec &file, Status &error)
Defines a symbol context baton that can be handed other debug core functions.
LineEntry line_entry
The LineEntry for a given query.
void DescribeBreakpointOverrides(Stream &stream, std::vector< lldb::user_id_t > &idxs)
Describe the breakpoint overrides.
Definition Target.cpp:974
lldb::BreakpointSP CreateScriptedBreakpoint(const llvm::StringRef class_name, const FileSpecList *containingModules, const FileSpecList *containingSourceFiles, bool internal, bool request_hardware, StructuredData::ObjectSP extra_args_sp, Status *creation_error=nullptr)
Definition Target.cpp:776
lldb::BreakpointSP CreateFuncRegexBreakpoint(const FileSpecList *containingModules, const FileSpecList *containingSourceFiles, RegularExpression func_regexp, lldb::LanguageType requested_language, LazyBool skip_prologue, bool internal, bool request_hardware)
Definition Target.cpp:742
lldb::BreakpointSP GetBreakpointByID(lldb::break_id_t break_id)
Definition Target.cpp:437
BreakpointList & GetBreakpointList(bool internal=false)
Definition Target.cpp:423
SourceManager & GetSourceManager()
Definition Target.cpp:3110
lldb::user_id_t AddBreakpointResolverOverride(BreakpointResolverOverrideUP override_up)
Add a breakpoint override resolver. This version can't fail.
Definition Target.h:1039
Debugger & GetDebugger() const
Definition Target.h:1324
void AddNameToBreakpoint(BreakpointID &id, llvm::StringRef name, Status &error)
Definition Target.cpp:853
void DisableAllowedBreakpoints()
Definition Target.cpp:1151
bool RemoveBreakpointByID(lldb::break_id_t break_id)
Definition Target.cpp:1175
BreakpointName * FindBreakpointName(ConstString name, bool can_create, Status &error)
Definition Target.cpp:885
void ClearBreakpointResolverOverrides()
Definition Target.h:1057
bool RemoveBreakpointResolverOverride(lldb::user_id_t override_id)
Definition Target.h:1052
void ConfigureBreakpointName(BreakpointName &bp_name, const BreakpointOptions &options, const BreakpointName::Permissions &permissions)
Definition Target.cpp:923
Status SerializeBreakpointsToFile(const FileSpec &file, const BreakpointIDList &bp_ids, bool append)
Definition Target.cpp:1236
lldb::BreakpointSP CreateExceptionBreakpoint(enum lldb::LanguageType language, bool catch_bp, bool throw_bp, bool internal, Args *additional_args=nullptr, Status *additional_args_error=nullptr)
Definition Target.cpp:759
void EnableAllowedBreakpoints()
Definition Target.cpp:1168
void RemoveAllowedBreakpoints()
Definition Target.cpp:1120
lldb::BreakpointSP CreateAddressInModuleBreakpoint(lldb::addr_t file_addr, bool internal, const FileSpec &file_spec, bool request_hardware)
Definition Target.cpp:593
lldb::BreakpointSP CreateBreakpoint(const FileSpecList *containingModules, const FileSpec &file, uint32_t line_no, uint32_t column, lldb::addr_t offset, LazyBool check_inlines, LazyBool skip_prologue, bool internal, bool request_hardware, LazyBool move_to_nearest_code)
Definition Target.cpp:504
lldb::BreakpointSP CreateSourceRegexBreakpoint(const FileSpecList *containingModules, const FileSpecList *source_file_list, const std::unordered_set< std::string > &function_names, RegularExpression source_regex, bool internal, bool request_hardware, LazyBool move_to_nearest_code)
Definition Target.cpp:487
void GetBreakpointNames(std::vector< std::string > &names)
Definition Target.cpp:946
bool IsDummyTarget() const
Definition Target.h:671
Status CreateBreakpointsFromFile(const FileSpec &file, BreakpointIDList &new_bps)
Definition Target.cpp:1328
void RemoveNameFromBreakpoint(lldb::BreakpointSP &bp_sp, ConstString name)
Definition Target.cpp:918
lldb::BreakpointSP GetLastCreatedBreakpoint()
Definition Target.h:843
#define LLDB_OPT_SET_1
#define LLDB_OPT_SET_2
#define LLDB_INVALID_BREAK_ID
#define LLDB_INVALID_LINE_NUMBER
#define LLDB_INVALID_THREAD_ID
#define LLDB_OPT_SET_ALL
#define LLDB_OPT_SET_3
#define LLDB_OPT_SET_11
#define LLDB_INVALID_ADDRESS
#define UINT32_MAX
#define LLDB_OPT_SET_4
A class that represents a running process on the host machine.
std::vector< OptionArgElement > OptionElementVector
Definition Options.h:43
static constexpr llvm::StringLiteral g_bool_parsing_error_message
Definition Options.h:367
static constexpr llvm::StringLiteral g_int_parsing_error_message
Definition Options.h:369
llvm::Error CreateOptionParsingError(llvm::StringRef option_arg, const char short_option, llvm::StringRef long_option={}, llvm::StringRef additional_context={})
Creates an error that represents the failure to parse an command line option argument.
Definition Options.cpp:1374
static constexpr llvm::StringLiteral g_language_parsing_error_message
Definition Options.h:371
@ eBreakpointCompletion
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
@ eDescriptionLevelBrief
@ eDescriptionLevelInitial
@ eDescriptionLevelFull
@ eDescriptionLevelVerbose
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::CommandObject > CommandObjectSP
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
std::shared_ptr< lldb_private::Breakpoint > BreakpointSP
int32_t break_id_t
Definition lldb-types.h:87
@ eReturnStatusFailed
@ eReturnStatusSuccessFinishResult
@ eReturnStatusSuccessFinishNoResult
@ eArgTypeBreakpointID
@ eArgTypeFileLineColumn
@ eArgTypeFunctionOrSymbol
@ eArgTypeBreakpointName
@ eArgTypeRegularExpression
uint64_t addr_t
Definition lldb-types.h:80
uint64_t tid_t
Definition lldb-types.h:84
Used to build individual command argument lists.
uint32_t arg_opt_set_association
This arg might be associated only with some particular option set(s).
A SmallBitVector that represents a set of source languages (lldb::LanguageType).
Definition Type.h:38
const FileSpec & GetFile() const
Helper to access the file.
Definition LineEntry.h:134
static int64_t ToOptionEnum(llvm::StringRef s, const OptionEnumValues &enum_values, int32_t fail_value, Status &error)
static lldb::addr_t ToAddress(const ExecutionContext *exe_ctx, llvm::StringRef s, lldb::addr_t fail_value, Status *error_ptr)
Try to parse an address.
static bool ToBoolean(llvm::StringRef s, bool fail_value, bool *success_ptr)