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 case 'Z': {
205 auto condition_mode =
207 option_arg, GetDefinitions()[option_idx].enum_values,
209 m_bp_opts.GetCondition().SetMode(condition_mode);
210 } break;
211 default:
212 llvm_unreachable("Unimplemented option");
213 }
214
215 return error;
216 }
217
218 void OptionParsingStarting(ExecutionContext *execution_context) override {
219 m_bp_opts.Clear();
220 m_commands.clear();
221 }
222
223 Status OptionParsingFinished(ExecutionContext *execution_context) override {
224 if (!m_commands.empty()) {
225 auto cmd_data = std::make_unique<BreakpointOptions::CommandData>();
226
227 for (std::string &str : m_commands)
228 cmd_data->user_source.AppendString(str);
229
230 cmd_data->stop_on_error = true;
231 m_bp_opts.SetCommandDataCallback(cmd_data);
232 }
233 return Status();
234 }
235
237
238 std::vector<std::string> m_commands;
240};
241
242// This is the Breakpoint Names option group - used to add Names to breakpoints
243// while making them. Not to be confused with the "Breakpoint Name" option
244// group which is the common options of various "breakpoint name" commands.
245#define LLDB_OPTIONS_breakpoint_names
246#include "CommandOptions.inc"
247
249public:
251
252 ~BreakpointNamesOptionGroup() override = default;
253
254 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
255 return g_breakpoint_names_options;
256 }
257
258 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
259 ExecutionContext *execution_context) override {
261 const int short_option = GetDefinitions()[option_idx].short_option;
262 const char *long_option = GetDefinitions()[option_idx].long_option;
263
264 switch (short_option) {
265 case 'N':
267 m_breakpoint_names.push_back(std::string(option_value));
268 else
270 CreateOptionParsingError(option_value, short_option, long_option,
271 "Invalid breakpoint name"));
272 break;
273 }
274 return error;
275 }
276
277 void OptionParsingStarting(ExecutionContext *execution_context) override {
278 m_breakpoint_names.clear();
279 }
280
281 const std::vector<std::string> &GetBreakpointNames() {
282 return m_breakpoint_names;
283 }
284
285protected:
286 std::vector<std::string> m_breakpoint_names;
287};
288
289#define LLDB_OPTIONS_breakpoint_dummy
290#include "CommandOptions.inc"
291
293public:
295
296 ~BreakpointDummyOptionGroup() override = default;
297
298 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
299 return llvm::ArrayRef(g_breakpoint_dummy_options);
300 }
301
302 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
303 ExecutionContext *execution_context) override {
305 const int short_option =
306 g_breakpoint_dummy_options[option_idx].short_option;
307
308 switch (short_option) {
309 case 'D':
310 m_use_dummy = true;
311 break;
312 default:
313 llvm_unreachable("Unimplemented option");
314 }
315
316 return error;
317 }
318
319 void OptionParsingStarting(ExecutionContext *execution_context) override {
320 m_use_dummy = false;
321 }
322
324};
325
326#pragma mark AddAddress::CommandOptions
327#define LLDB_OPTIONS_breakpoint_add_address
328#include "CommandOptions.inc"
329
330#pragma mark Add Address
331
333 BreakpointOptionGroup &bp_opts,
334 const std::vector<std::string> &bp_names,
335 CommandReturnObject &result) {
336 assert(bp_sp && "CopyOverBreakpointOptions called with no breakpoint");
337
338 bp_sp->GetOptions().CopyOverSetOptions(bp_opts.GetBreakpointOptions());
339 Target &target = bp_sp->GetTarget();
340 if (!bp_names.empty()) {
341 Status name_error;
342 for (auto name : bp_names) {
343 target.AddNameToBreakpoint(bp_sp, name.c_str(), name_error);
344 if (name_error.Fail()) {
345 result.AppendErrorWithFormat("Invalid breakpoint name: %s",
346 name.c_str());
347 target.RemoveBreakpointByID(bp_sp->GetID());
348 return false;
349 }
350 }
351 }
352 return true;
353}
354
355static llvm::Expected<LanguageType>
356GetExceptionLanguageForLanguage(llvm::StringRef lang_name,
357 char short_option = '\0',
358 llvm::StringRef long_option = {}) {
359 llvm::Expected<LanguageType> exception_language =
361 if (!exception_language) {
362 std::string error_msg = llvm::toString(exception_language.takeError());
363 return CreateOptionParsingError(lang_name, short_option, long_option,
364 error_msg);
365 }
366 return exception_language;
367}
368
370 OptionValueFileColonLine &line_entry) {
372 uint32_t line_num = line_entry.GetLineNumber();
373 if (!line_entry.GetFileSpec()) {
374 FileSpec default_file_spec;
375 std::string error_msg;
376 Target *target = exe_ctx.GetTargetPtr();
377 if (!target) {
378 error.FromErrorString("Can't complete a line entry with no "
379 "target");
380 return error;
381 }
382 Debugger &dbg = target->GetDebugger();
383 CommandReturnObject result(dbg.GetUseColor());
384 if (!GetDefaultFile(*target, exe_ctx.GetFramePtr(), default_file_spec,
385 result)) {
386 error.FromErrorStringWithFormatv("{0}/nCouldn't get default file for "
387 "line {1}: {2}",
388 result.GetErrorString(), line_num,
389 error_msg);
390 return error;
391 }
392 line_entry.SetFile(default_file_spec);
393 }
394 return error;
395}
396
398public:
400 : CommandObjectParsed(interpreter, "breakpoint add address",
401 "Add breakpoints by raw address", nullptr,
402 eCommandAllowsDummyTarget) {
403 CommandArgumentData bp_id_arg;
404
405 // Define the first (and only) variant of this arg.
407 m_all_options.Append(&m_name_opts);
410 m_all_options.Finalize();
411
413 }
414
416
417 Options *GetOptions() override { return &m_all_options; }
418
420 public:
421 CommandOptions() = default;
422
423 ~CommandOptions() override = default;
424
425 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
426 ExecutionContext *execution_context) override {
428 const int short_option = GetDefinitions()[option_idx].short_option;
429 const char *long_option = GetDefinitions()[option_idx].long_option;
430
431 switch (short_option) {
432 case 'H':
433 m_hardware = true;
434 break;
435
436 case 's':
437 if (m_modules.GetSize() == 0)
438 m_modules.AppendIfUnique(FileSpec(option_arg));
439 else
441 CreateOptionParsingError(option_arg, short_option, long_option,
442 "Only one shared library can be "
443 "specified for address breakpoints."));
444 break;
445
446 default:
447 llvm_unreachable("Unimplemented option");
448 }
449
450 return error;
451 }
452
453 void OptionParsingStarting(ExecutionContext *execution_context) override {
454 m_hardware = false;
455 m_modules.Clear();
456 }
457
458 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
459 return llvm::ArrayRef(g_breakpoint_add_address_options);
460 }
461
462 // Instance variables to hold the values for command options.
463 bool m_hardware = false; // FIXME - this can go in the "modify" options.
465 };
466
467protected:
468 void DoExecute(Args &command, CommandReturnObject &result) override {
469 // We've already asserted that there can only be one entry in m_modules:
470 const ExecutionContext &exe_ctx = m_interpreter.GetExecutionContext();
471 // We don't set address breakpoints in the dummy target.
472 if (!exe_ctx.HasTargetScope() || exe_ctx.GetTargetPtr()->IsDummyTarget()) {
473 result.AppendError(
474 "can't set address breakpoints without a real target.");
475 return;
476 }
477 // Commands can't set internal breakpoints:
478 const bool internal = false;
479
480 Target &target = exe_ctx.GetTargetRef();
481
482 FileSpec module_spec;
483 bool has_module = false;
484 if (m_options.m_modules.GetSize() != 0) {
485 has_module = true;
486 module_spec = m_options.m_modules.GetFileSpecAtIndex(0);
487 }
488 BreakpointSP bp_sp;
489 // Let's process the arguments first so we can short-circuit if there are
490 // any errors:
491 std::vector<lldb::addr_t> bp_addrs;
492 for (const Args::ArgEntry &arg_entry : command) {
493 Address bp_address;
496 &exe_ctx, arg_entry.ref(), LLDB_INVALID_ADDRESS, &error);
497 if (error.Fail()) {
498 result.AppendErrorWithFormatv("invalid argument value '{0}': {1}",
499 arg_entry.ref(), error);
500 return;
501 }
502 bp_addrs.push_back(bp_load_addr);
503 }
504 for (auto bp_addr : bp_addrs) {
505 if (has_module)
506 bp_sp = target.CreateAddressInModuleBreakpoint(
507 bp_addr, internal, module_spec, m_options.m_hardware);
508 else
509 // ENHANCEMENT: we should see if bp_addr is in a single loaded module,
510 // and pass that module in if it is.
511 bp_sp =
512 target.CreateBreakpoint(bp_addr, internal, m_options.m_hardware);
513 }
514
515 if (bp_sp) {
517 m_name_opts.GetBreakpointNames(), result);
518 Stream &output_stream = result.GetOutputStream();
519 bp_sp->GetDescription(&output_stream, lldb::eDescriptionLevelInitial,
520 /*show_locations=*/false);
522 } else {
523 result.AppendError("Breakpoint creation failed: No breakpoint created.");
524 }
525 }
526
527private:
533};
534
535#pragma mark AddException::CommandOptions
536#define LLDB_OPTIONS_breakpoint_add_exception
537#include "CommandOptions.inc"
538
539#pragma mark Add Exception
540
542public:
545 interpreter, "breakpoint add exception",
546 "Add breakpoints on language exceptions. If no language is "
547 "specified, break on exceptions for all supported languages",
548 nullptr, eCommandAllowsDummyTarget) {
549 // Define the first (and only) variant of this arg.
551
552 // Next add all the options.
554 m_all_options.Append(&m_name_opts);
556 m_all_options.Append(&m_options);
557 m_all_options.Finalize();
558 }
559
561
562 Options *GetOptions() override { return &m_all_options; }
563
565 public:
566 CommandOptions() = default;
567
568 ~CommandOptions() override = default;
569
570 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
571 ExecutionContext *execution_context) override {
573 const int short_option = GetDefinitions()[option_idx].short_option;
574
575 switch (short_option) {
576 case 'E': {
577 uint32_t this_val = (uint32_t)OptionArgParser::ToOptionEnum(
578 option_arg, GetDefinitions()[option_idx].enum_values,
580 if (error.Fail())
581 return error;
582 m_exception_stage |= this_val;
583 } break;
584 case 'H':
585 m_hardware = true;
586 break;
587
588 case 'O':
589 m_exception_extra_args.AppendArgument("-O");
590 m_exception_extra_args.AppendArgument(option_arg);
591 break;
592
593 default:
594 llvm_unreachable("Unimplemented option");
595 }
596
597 return error;
598 }
599
600 void OptionParsingStarting(ExecutionContext *execution_context) override {
601 m_hardware = false;
604 }
605
606 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
607 return llvm::ArrayRef(g_breakpoint_add_exception_options);
608 }
609
610 // Instance variables to hold the values for command options.
611 bool m_hardware = false; // FIXME - this can go in the "modify" options.
614 };
615
616protected:
617 void DoExecute(Args &command, CommandReturnObject &result) override {
618 Target *target =
619 m_dummy_options.m_use_dummy ? &GetDummyTarget() : GetTarget();
620 BreakpointSP bp_sp;
621 LanguageType exception_language = eLanguageTypeUnknown;
622
623 if (command.size() == 0) {
624 result.AppendError("no languages specified");
625 } else if (command.size() > 1) {
626 result.AppendError(
627 "can only set exception breakpoints on one language at a time");
628 } else {
629 llvm::Expected<LanguageType> language =
630 GetExceptionLanguageForLanguage(command[0].ref());
631 if (language)
632 exception_language = *language;
633 else {
634 result.SetError(language.takeError());
635 return;
636 }
637 }
638 Status precond_error;
639 const bool internal = false;
640 bool catch_bp = (m_options.m_exception_stage & eExceptionStageCatch) != 0;
641 bool throw_bp = (m_options.m_exception_stage & eExceptionStageThrow) != 0;
642 bp_sp = target->CreateExceptionBreakpoint(
643 exception_language, catch_bp, throw_bp, internal,
644 &m_options.m_exception_extra_args, &precond_error);
645 if (precond_error.Fail()) {
647 "Error setting extra exception arguments: %s",
648 precond_error.AsCString());
649 target->RemoveBreakpointByID(bp_sp->GetID());
650 return;
651 }
652
653 if (bp_sp) {
655 m_name_opts.GetBreakpointNames(), result);
656 Stream &output_stream = result.GetOutputStream();
657 bp_sp->GetDescription(&output_stream, lldb::eDescriptionLevelInitial,
658 /*show_locations=*/false);
659 // Note, we don't print a "got no locations" warning for exception
660 // breakpoints. They can get set in the dummy target, and we won't know
661 // how to actually set the breakpoint till we know what version of the
662 // relevant LanguageRuntime gets loaded.
663 if (target == &GetDummyTarget())
664 output_stream.Printf("Breakpoint set in dummy target, will get copied "
665 "into future targets.\n");
667 } else {
668 result.AppendError("Breakpoint creation failed: No breakpoint created.");
669 }
670 }
671
672private:
678};
679
680#pragma mark AddFile::CommandOptions
681#define LLDB_OPTIONS_breakpoint_add_file
682#include "CommandOptions.inc"
683
684#pragma mark Add File
685
687public:
690 interpreter, "breakpoint add file",
691 "Add breakpoints on lines in specified source files", nullptr,
692 eCommandAllowsDummyTarget) {
694 CommandArgumentData linespec_arg;
695 CommandArgumentData no_arg;
696
697 // Any number of linespecs in group 1:
698 linespec_arg.arg_type = eArgTypeFileLineColumn;
699 linespec_arg.arg_repetition = eArgRepeatPlus;
701
702 arg1.push_back(linespec_arg);
703
704 // Leave arg2 empty, there are no arguments to this variant.
706 no_arg.arg_type = eArgTypeNone;
709
710 arg2.push_back(linespec_arg);
711
712 // Push the data for the first argument into the m_arguments vector.
713 m_arguments.push_back(arg1);
714 m_arguments.push_back(arg2);
715
716 // Define the first (and only) variant of this arg.
719 m_all_options.Append(&m_name_opts);
722 m_all_options.Append(&m_options);
723 m_all_options.Finalize();
724 }
725
727
728 Options *GetOptions() override { return &m_all_options; }
729
731 public:
732 CommandOptions() = default;
733
734 ~CommandOptions() override = default;
735
736 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
737 ExecutionContext *execution_context) override {
739 const int short_option = GetDefinitions()[option_idx].short_option;
740 const char *long_option = GetDefinitions()[option_idx].long_option;
741
742 switch (short_option) {
743 case 'f':
744 m_cur_value.SetFile(FileSpec(option_arg));
745 break;
746 case 'l':
747 uint32_t line_num;
748 if (option_arg.getAsInteger(0, line_num))
750 CreateOptionParsingError(option_arg, short_option, long_option,
752 else {
753 // The line number is the only required part of the options for a
754 // specifying the location - since we will fill in the file with the
755 // default file. So when we see a new line, the old line entry we
756 // were building is done. If we haven't gotten a file, try to fill
757 // in the default file, and then finish up this linespec and start
758 // the next one.
759 if (m_cur_value.GetLineNumber() != LLDB_INVALID_LINE_NUMBER) {
760 // FIXME: It should be possible to create a breakpoint with a list
761 // of file, line, column values. But for now we can only create
762 // one, so return an error here. The commented out code is what we
763 // will do when I come back to add that capability.
764 return Status::FromErrorString("Can only specify one file and line "
765 "pair at a time.");
766#if 0 // This code will be appropriate once we have a resolver that can take
767 // more than one linespec at a time.
768 error = CompleteLineEntry(*execution_context, m_cur_value);
769 if (error.Fail())
770 return error;
771
772 m_line_specs.push_back(m_cur_value);
773 m_cur_value.Clear();
774#endif
775 }
776 m_cur_value.SetLine(line_num);
777 }
778 break;
779 case 'u':
780 uint32_t column_num;
781 if (option_arg.getAsInteger(0, column_num))
783 CreateOptionParsingError(option_arg, short_option, long_option,
785 else
786 m_cur_value.SetColumn(column_num);
787 break;
788 case 'K': {
789 bool success;
790 bool value;
791 value = OptionArgParser::ToBoolean(option_arg, true, &success);
792 if (value)
794 else
796
797 if (!success)
799 CreateOptionParsingError(option_arg, short_option, long_option,
801 } break;
802 case 'm': {
803 bool success;
804 bool value;
805 value = OptionArgParser::ToBoolean(option_arg, true, &success);
806 if (value)
808 else
810
811 if (!success)
813 CreateOptionParsingError(option_arg, short_option, long_option,
815 } break;
816 case 's':
817 m_modules.AppendIfUnique(FileSpec(option_arg));
818 break;
819 case 'H':
820 m_hardware = true;
821 break;
822 case 'S': {
823 lldb::addr_t tmp_offset_addr;
824 tmp_offset_addr = OptionArgParser::ToAddress(execution_context,
825 option_arg, 0, &error);
826 if (error.Success())
827 m_offset_addr = tmp_offset_addr;
828 } break;
829
830 default:
831 llvm_unreachable("Unimplemented option");
832 }
833
834 return error;
835 }
836
837 void OptionParsingStarting(ExecutionContext *execution_context) override {
838 m_hardware = false;
839 m_line_specs.clear();
840 m_cur_value.Clear();
842 m_modules.Clear();
844 m_offset_addr = 0;
845 }
846
847 Status OptionParsingFinished(ExecutionContext *execution_context) override {
848 // We were supplied at least a line from the options, so fill in the
849 // default file if needed.
850 if (m_cur_value.GetLineNumber() != LLDB_INVALID_LINE_NUMBER) {
851 Status error = CompleteLineEntry(*execution_context, m_cur_value);
852 if (error.Fail())
853 return error;
854 m_line_specs.push_back(m_cur_value);
855 m_cur_value.Clear();
856 }
857 return {};
858 }
859
860 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
861 return llvm::ArrayRef(g_breakpoint_add_file_options);
862 }
863
864 // Instance variables to hold the values for command options.
865 bool m_hardware = false; // FIXME - this can go in the "modify" options.
866 std::vector<OptionValueFileColonLine> m_line_specs;
872 };
873
874protected:
875 void DoExecute(Args &command, CommandReturnObject &result) override {
876 bool internal = false;
877 Target *target =
878 m_dummy_options.m_use_dummy ? &GetDummyTarget() : GetTarget();
879 // FIXME: At present we can only make file & line breakpoints for one file
880 // and line pair. It wouldn't be hard to extend that, but I'm not adding
881 // features at this point so I'll leave that for a future patch. For now,
882 // flag this as an error.
883
884 // I'm leaving this as a loop since that's how it should be when we can
885 // do more than one linespec at a time.
886 FileSpec default_file;
887 for (const Args::ArgEntry &this_arg : command) {
889 uint32_t line_value = LLDB_INVALID_LINE_NUMBER;
890 if (!this_arg.ref().getAsInteger(0, line_value)) {
891 // The argument is a plain number. Treat that as a line number, and
892 // allow it if we can find a default file & line.
893 std::string error_msg;
894 if (!GetDefaultFile(*target, m_exe_ctx.GetFramePtr(), default_file,
895 result)) {
896 result.AppendErrorWithFormatv("Couldn't find default file for line "
897 "input: {0} - {1}",
898 line_value, error_msg);
899 return;
900 }
901 value.SetLine(line_value);
902 value.SetFile(default_file);
903 } else {
904 Status error = value.SetValueFromString(this_arg.c_str());
905 if (error.Fail()) {
906 result.AppendErrorWithFormatv("Failed to parse linespec: {0}", error);
907 return;
908 }
909 }
910 m_options.m_line_specs.push_back(value);
911 }
912
913 if (m_options.m_line_specs.size() != 1) {
914 result.AppendError("Can only make file and line breakpoints with one "
915 "specification at a time.");
916 return;
917 }
918
919 BreakpointSP bp_sp;
920 // Only check for inline functions if
921 LazyBool check_inlines = eLazyBoolCalculate;
922
923 OptionValueFileColonLine &this_spec = m_options.m_line_specs[0];
924 bp_sp = target->CreateBreakpoint(
925 &(m_options.m_modules), this_spec.GetFileSpec(),
926 this_spec.GetLineNumber(), this_spec.GetColumnNumber(),
927 m_options.m_offset_addr, check_inlines, m_options.m_skip_prologue,
928 internal, m_options.m_hardware, m_options.m_move_to_nearest_code);
929
930 if (bp_sp) {
932 m_name_opts.GetBreakpointNames(), result);
933 Stream &output_stream = result.GetOutputStream();
934 bp_sp->GetDescription(&output_stream, lldb::eDescriptionLevelInitial,
935 /*show_locations=*/false);
936 if (target == &GetDummyTarget())
937 output_stream.Printf("Breakpoint set in dummy target, will get copied "
938 "into future targets.\n");
939 else {
940 // Don't print out this warning for exception breakpoints. They can
941 // get set before the target is set, but we won't know how to actually
942 // set the breakpoint till we run.
943 if (bp_sp->GetNumLocations() == 0) {
944 output_stream.Printf("WARNING: Unable to resolve breakpoint to any "
945 "actual locations.\n");
946 }
947 }
949 } else {
950 result.AppendError("Breakpoint creation failed: No breakpoint created.");
951 }
952 }
953
954private:
960};
961
962#pragma mark AddName::CommandOptions
963#define LLDB_OPTIONS_breakpoint_add_name
964#include "CommandOptions.inc"
965
966#pragma mark Add Name
967
969public:
971 : CommandObjectParsed(interpreter, "breakpoint add name",
972 "Add breakpoints matching function or symbol names",
973 nullptr, eCommandAllowsDummyTarget) {
974 // FIXME: Add a completer that's aware of the name match style.
975 // Define the first (and only) variant of this arg.
977
978 // Now add all the options groups.
980 m_all_options.Append(&m_name_opts);
982 m_all_options.Append(&m_options);
983 m_all_options.Finalize();
984 }
985
987
988 Options *GetOptions() override { return &m_all_options; }
989
991 public:
992 CommandOptions() = default;
993
994 ~CommandOptions() override = default;
995
996 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
997 ExecutionContext *execution_context) override {
999 const int short_option = GetDefinitions()[option_idx].short_option;
1000 const char *long_option = GetDefinitions()[option_idx].long_option;
1001
1002 switch (short_option) {
1003 case 'f':
1004 m_files.AppendIfUnique(FileSpec(option_arg));
1005 break;
1006 case 'K': {
1007 bool success;
1008 bool value;
1009 value = OptionArgParser::ToBoolean(option_arg, true, &success);
1010 if (!success)
1012 CreateOptionParsingError(option_arg, short_option, long_option,
1014 else {
1015 if (value)
1017 else
1019 }
1020 } break;
1021 case 'L': {
1025 CreateOptionParsingError(option_arg, short_option, long_option,
1027 } break;
1028 case 'm': {
1029 uint32_t this_val = (uint32_t)OptionArgParser::ToOptionEnum(
1030 option_arg, GetDefinitions()[option_idx].enum_values,
1032 if (error.Fail())
1033 return error;
1034 m_lookup_style = (NameMatchStyle)this_val;
1035 } break;
1036 case 's':
1037 m_modules.AppendIfUnique(FileSpec(option_arg));
1038 break;
1039 case 'H':
1040 m_hardware = true;
1041 break;
1042 case 'S': {
1043 lldb::addr_t tmp_offset_addr;
1044 tmp_offset_addr = OptionArgParser::ToAddress(execution_context,
1045 option_arg, 0, &error);
1046 if (error.Success())
1047 m_offset_addr = tmp_offset_addr;
1048 } break;
1049
1050 default:
1051 llvm_unreachable("Unimplemented option");
1052 }
1053
1054 return error;
1055 }
1056
1057 void OptionParsingStarting(ExecutionContext *execution_context) override {
1058 m_hardware = false;
1060 m_files.Clear();
1062 m_modules.Clear();
1063 m_offset_addr = 0;
1065 }
1066
1067 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
1068 return llvm::ArrayRef(g_breakpoint_add_name_options);
1069 }
1070
1071 // Instance variables to hold the values for command options.
1072 bool m_hardware = false; // FIXME - this can go in the "modify" options.
1080 };
1081
1082protected:
1083 void DoExecute(Args &command, CommandReturnObject &result) override {
1084 const bool internal = false;
1085 Target *target =
1086 m_dummy_options.m_use_dummy ? &GetDummyTarget() : GetTarget();
1087 // Parse the argument list - this is a simple list of names.
1088 std::vector<std::string> func_names;
1089 for (const Args::ArgEntry &this_arg : command) {
1090 func_names.push_back(this_arg.ref().str());
1091 }
1092 BreakpointSP bp_sp;
1093 if (!(m_options.m_lookup_style & eNameMatchStyleRegex))
1094 bp_sp = target->CreateBreakpoint(
1095 &m_options.m_modules, &m_options.m_files, func_names,
1096 (FunctionNameType)m_options.m_lookup_style, m_options.m_language,
1097 m_options.m_offset_addr, m_options.m_skip_prologue, internal,
1098 m_options.m_hardware);
1099 else {
1100 if (func_names.size() != 1) {
1101 result.AppendError("Can only set function regular expression "
1102 "breakpoints on one regex at a time.");
1103 return;
1104 }
1105 std::string &func_regexp = func_names[0];
1106 RegularExpression regexp(func_regexp);
1107 if (llvm::Error err = regexp.GetError()) {
1108 result.AppendErrorWithFormat(
1109 "Function name regular expression could not be compiled: %s",
1110 llvm::toString(std::move(err)).c_str());
1111 // Check if the incorrect regex looks like a globbing expression and
1112 // warn the user about it.
1113 if (!func_regexp.empty()) {
1114 if (func_regexp[0] == '*' || func_regexp[0] == '?')
1115 result.AppendWarning(
1116 "function name regex does not accept glob patterns");
1117 }
1118 return;
1119 }
1120
1121 bp_sp = target->CreateFuncRegexBreakpoint(
1122 &(m_options.m_modules), &(m_options.m_files), std::move(regexp),
1123 m_options.m_language, m_options.m_skip_prologue, internal,
1124 m_options.m_hardware);
1125 }
1126 if (bp_sp) {
1128 m_name_opts.GetBreakpointNames(), result);
1129 Stream &output_stream = result.GetOutputStream();
1130 bp_sp->GetDescription(&output_stream, lldb::eDescriptionLevelInitial,
1131 /*show_locations=*/false);
1132 if (target == &GetDummyTarget())
1133 output_stream.Printf("Breakpoint set in dummy target, will get copied "
1134 "into future targets.\n");
1135 else {
1136 if (bp_sp->GetNumLocations() == 0) {
1137 output_stream.Printf("WARNING: Unable to resolve breakpoint to any "
1138 "actual locations.\n");
1139 }
1140 }
1142 } else {
1143 result.AppendError("Breakpoint creation failed: No breakpoint created.");
1144 }
1145 }
1146
1147private:
1153};
1154
1155#pragma mark AddPattern::CommandOptions
1156#define LLDB_OPTIONS_breakpoint_add_pattern
1157#include "CommandOptions.inc"
1158
1159#pragma mark Add Pattern
1160
1162public:
1164 : CommandObjectRaw(interpreter, "breakpoint add pattern",
1165 "Add breakpoints matching patterns in the source text",
1166 "breakpoint add pattern [options] -- <pattern>",
1167 eCommandAllowsDummyTarget) {
1169 // Now add all the options groups.
1171 m_all_options.Append(&m_name_opts);
1173 m_all_options.Append(&m_options);
1174 m_all_options.Finalize();
1175 }
1176
1178
1179 Options *GetOptions() override { return &m_all_options; }
1180
1182 public:
1183 CommandOptions() = default;
1184
1185 ~CommandOptions() override = default;
1186
1187 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
1188 ExecutionContext *execution_context) override {
1189 Status error;
1190 const int short_option = GetDefinitions()[option_idx].short_option;
1191 const char *long_option = GetDefinitions()[option_idx].long_option;
1192
1193 switch (short_option) {
1194 case 'a': {
1195 bool success;
1196 bool value;
1197 value = OptionArgParser::ToBoolean(option_arg, true, &success);
1198 if (!success)
1200 CreateOptionParsingError(option_arg, short_option, long_option,
1202 else
1203 m_all_files = value;
1204 } break;
1205 case 'f':
1206 m_files.AppendIfUnique(FileSpec(option_arg));
1207 break;
1208 case 'm': {
1209 bool success;
1210 bool value;
1211 value = OptionArgParser::ToBoolean(option_arg, true, &success);
1212 if (!success)
1214 CreateOptionParsingError(option_arg, short_option, long_option,
1216 else {
1217 if (value)
1219 else
1221 }
1222 } break;
1223 case 'n':
1224 m_func_names.insert(option_arg.str());
1225 break;
1226 case 's':
1227 m_modules.AppendIfUnique(FileSpec(option_arg));
1228 break;
1229 case 'H':
1230 m_hardware = true;
1231 break;
1232 default:
1233 llvm_unreachable("Unimplemented option");
1234 }
1235
1236 return error;
1237 }
1238
1239 void OptionParsingStarting(ExecutionContext *execution_context) override {
1240 m_hardware = false;
1242 m_modules.Clear();
1243 m_files.Clear();
1244 m_func_names.clear();
1245 m_all_files = false;
1247 }
1248
1249 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
1250 return llvm::ArrayRef(g_breakpoint_add_pattern_options);
1251 }
1252
1253 // Instance variables to hold the values for command options.
1254 bool m_hardware = false; // FIXME - this can go in the "modify" options.
1258 std::unordered_set<std::string> m_func_names;
1259 bool m_all_files = false;
1261 };
1262
1263protected:
1264 void DoExecute(llvm::StringRef command,
1265 CommandReturnObject &result) override {
1266 const bool internal = false;
1268 m_all_options.NotifyOptionParsingStarting(&exe_ctx);
1269
1270 if (command.empty()) {
1271 result.AppendError("no pattern to seek.");
1272 return;
1273 }
1274
1275 OptionsWithRaw args(command);
1276
1277 if (args.HasArgs()) {
1278 if (!ParseOptionsAndNotify(args.GetArgs(), result, m_all_options,
1279 exe_ctx))
1280 return;
1281 }
1282 llvm::StringRef pattern = args.GetRawPart();
1283 if (pattern.empty()) {
1284 result.AppendError("no pattern to seek");
1285 return;
1286 }
1287
1288 Target *target =
1289 m_dummy_options.m_use_dummy ? &GetDummyTarget() : GetTarget();
1290
1291 BreakpointSP bp_sp;
1292 const size_t num_files = m_options.m_files.GetSize();
1293
1294 if (num_files == 0 && !m_options.m_all_files) {
1295 FileSpec file;
1296 if (!GetDefaultFile(*target, m_exe_ctx.GetFramePtr(), file, result)) {
1297 result.AppendError(
1298 "No files provided and could not find default file.");
1299 return;
1300 } else {
1301 m_options.m_files.Append(file);
1302 }
1303 }
1304
1305 RegularExpression regexp(pattern);
1306 if (llvm::Error err = regexp.GetError()) {
1307 result.AppendErrorWithFormat(
1308 "Source text regular expression could not be compiled: \"%s\"",
1309 llvm::toString(std::move(err)).c_str());
1310 return;
1311 }
1312 bp_sp = target->CreateSourceRegexBreakpoint(
1313 &(m_options.m_modules), &(m_options.m_files), m_options.m_func_names,
1314 std::move(regexp), internal, m_options.m_hardware,
1315 m_options.m_move_to_nearest_code);
1316
1317 if (bp_sp) {
1319 m_name_opts.GetBreakpointNames(), result);
1320 Stream &output_stream = result.GetOutputStream();
1321 bp_sp->GetDescription(&output_stream, lldb::eDescriptionLevelInitial,
1322 /*show_locations=*/false);
1323 if (target == &GetDummyTarget())
1324 output_stream.Printf("Breakpoint set in dummy target, will get copied "
1325 "into future targets.\n");
1326 else {
1327 // Don't print out this warning for exception breakpoints. They can
1328 // get set before the target is set, but we won't know how to actually
1329 // set the breakpoint till we run.
1330 if (bp_sp->GetNumLocations() == 0) {
1331 output_stream.Printf("WARNING: Unable to resolve breakpoint to any "
1332 "actual locations.\n");
1333 }
1334 }
1336 } else {
1337 result.AppendError("Breakpoint creation failed: No breakpoint created.");
1338 }
1339 }
1340
1341private:
1347};
1348
1349#pragma mark AddScripted::CommandOptions
1350#define LLDB_OPTIONS_breakpoint_add_scripted
1351#include "CommandOptions.inc"
1352
1353#pragma mark Add Scripted
1354
1356public:
1359 interpreter, "breakpoint add scripted",
1360 "Add breakpoints using a scripted breakpoint resolver.", nullptr,
1361 eCommandAllowsDummyTarget),
1362 m_python_class_options("scripted breakpoint", true, 'P') {
1363 // We're picking up all the normal options, commands and disable.
1366 // Define the first (and only) variant of this arg.
1368 m_all_options.Append(&m_name_opts);
1370 m_all_options.Append(&m_options);
1371 m_all_options.Finalize();
1372 }
1373
1375
1376 Options *GetOptions() override { return &m_all_options; }
1377
1379 public:
1380 CommandOptions() = default;
1381
1382 ~CommandOptions() override = default;
1383
1384 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
1385 ExecutionContext *execution_context) override {
1386 Status error;
1387 const int short_option = GetDefinitions()[option_idx].short_option;
1388
1389 switch (short_option) {
1390 case 'f':
1391 m_files.Append(FileSpec(option_arg));
1392 break;
1393 case 's':
1394 m_modules.AppendIfUnique(FileSpec(option_arg));
1395 break;
1396 case 'H':
1397 m_hardware = true;
1398 break;
1399
1400 default:
1401 llvm_unreachable("Unimplemented option");
1402 }
1403
1404 return error;
1405 }
1406
1407 void OptionParsingStarting(ExecutionContext *execution_context) override {
1408 m_hardware = false;
1409 m_files.Clear();
1410 m_modules.Clear();
1411 }
1412
1413 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
1414 return llvm::ArrayRef(g_breakpoint_add_scripted_options);
1415 }
1416
1417 // Instance variables to hold the values for command options.
1418 bool m_hardware = false; // FIXME - this can go in the "modify" options.
1421 };
1422
1423protected:
1424 void DoExecute(Args &command, CommandReturnObject &result) override {
1425 Target *target =
1426 m_dummy_options.m_use_dummy ? &GetDummyTarget() : GetTarget();
1427
1428 BreakpointSP bp_sp;
1429 Status error;
1430 bp_sp = target->CreateScriptedBreakpoint(
1431 m_python_class_options.GetName().c_str(), &(m_options.m_modules),
1432 &(m_options.m_files), false, m_options.m_hardware,
1433 m_python_class_options.GetStructuredData(), &error);
1434 if (error.Fail()) {
1435 result.AppendErrorWithFormat(
1436 "error setting extra exception arguments: %s", error.AsCString());
1437 target->RemoveBreakpointByID(bp_sp->GetID());
1438 return;
1439 }
1440
1441 if (bp_sp) {
1443 m_name_opts.GetBreakpointNames(), result);
1444 Stream &output_stream = result.GetOutputStream();
1445 bp_sp->GetDescription(&output_stream, lldb::eDescriptionLevelInitial,
1446 /*show_locations=*/false);
1447 if (target == &GetDummyTarget())
1448 output_stream.Printf("Breakpoint set in dummy target, will get copied "
1449 "into future targets.\n");
1450 else {
1451 // Don't print out this warning for exception breakpoints. They can
1452 // get set before the target is set, but we won't know how to actually
1453 // set the breakpoint till we run.
1454 if (bp_sp->GetNumLocations() == 0) {
1455 output_stream.Printf("WARNING: Unable to resolve breakpoint to any "
1456 "actual locations.\n");
1457 }
1458 }
1460 } else {
1461 result.AppendError("breakpoint creation failed: No breakpoint created.");
1462 }
1463 }
1464
1465private:
1472};
1473
1474#pragma mark Add::CommandOptions
1475#define LLDB_OPTIONS_breakpoint_add
1476#include "CommandOptions.inc"
1477
1478#pragma mark Add
1479
1481public:
1483 : CommandObjectMultiword(interpreter, "add",
1484 "Commands to add breakpoints of various types") {
1486 R"(
1487Access the breakpoint search kernels built into lldb. Along with specifying the
1488search kernel, each breakpoint add operation can specify a common set of
1489"reaction" options for each breakpoint. The reaction options can also be
1490modified after breakpoint creation using the "breakpoint modify" command.
1491 )");
1492 CommandObjectSP address_command_object(
1493 new CommandObjectBreakpointAddAddress(interpreter));
1494 CommandObjectSP exception_command_object(
1495 new CommandObjectBreakpointAddException(interpreter));
1496 CommandObjectSP file_command_object(
1497 new CommandObjectBreakpointAddFile(interpreter));
1498 CommandObjectSP name_command_object(
1499 new CommandObjectBreakpointAddName(interpreter));
1500 CommandObjectSP pattern_command_object(
1501 new CommandObjectBreakpointAddPattern(interpreter));
1502 CommandObjectSP scripted_command_object(
1503 new CommandObjectBreakpointAddScripted(interpreter));
1504
1505 LoadSubCommand("address", address_command_object);
1506 LoadSubCommand("exception", exception_command_object);
1507 LoadSubCommand("file", file_command_object);
1508 LoadSubCommand("name", name_command_object);
1509 LoadSubCommand("pattern", pattern_command_object);
1510 LoadSubCommand("scripted", scripted_command_object);
1511 }
1512};
1513
1514#define LLDB_OPTIONS_breakpoint_set
1515#include "CommandOptions.inc"
1516
1517// CommandObjectBreakpointSet
1518
1520public:
1531
1534 interpreter, "breakpoint set",
1535 "Sets a breakpoint or set of breakpoints in the executable.",
1536 "breakpoint set <cmd-options>", eCommandAllowsDummyTarget),
1537 m_python_class_options("scripted breakpoint", true, 'P') {
1538 // We're picking up all the normal options, commands and disable.
1541 m_all_options.Append(&m_bp_opts,
1545 m_all_options.Append(&m_options);
1546 m_all_options.Finalize();
1547 }
1548
1549 ~CommandObjectBreakpointSet() override = default;
1550
1551 Options *GetOptions() override { return &m_all_options; }
1552
1554 public:
1555 CommandOptions() = default;
1556
1557 ~CommandOptions() override = default;
1558
1559 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
1560 ExecutionContext *execution_context) override {
1561 Status error;
1562 const int short_option =
1563 g_breakpoint_set_options[option_idx].short_option;
1564 const char *long_option =
1565 g_breakpoint_set_options[option_idx].long_option;
1566
1567 switch (short_option) {
1568 case 'a': {
1569 m_load_addr = OptionArgParser::ToAddress(execution_context, option_arg,
1571 } break;
1572
1573 case 'A':
1574 m_all_files = true;
1575 break;
1576
1577 case 'b':
1578 m_func_names.push_back(std::string(option_arg));
1579 m_func_name_type_mask |= eFunctionNameTypeBase;
1580 break;
1581
1582 case 'u':
1583 if (option_arg.getAsInteger(0, m_column))
1585 CreateOptionParsingError(option_arg, short_option, long_option,
1587 break;
1588
1589 case 'E': {
1590 llvm::Expected<LanguageType> language = GetExceptionLanguageForLanguage(
1591 option_arg, short_option, long_option);
1592 if (language)
1593 m_exception_language = *language;
1594 else
1595 error = Status::FromError(language.takeError());
1596 } break;
1597
1598 case 'f':
1599 m_filenames.AppendIfUnique(FileSpec(option_arg));
1600 break;
1601
1602 case 'F':
1603 m_func_names.push_back(std::string(option_arg));
1604 m_func_name_type_mask |= eFunctionNameTypeFull;
1605 break;
1606
1607 case 'h': {
1608 bool success;
1609 m_catch_bp = OptionArgParser::ToBoolean(option_arg, true, &success);
1610 if (!success)
1612 CreateOptionParsingError(option_arg, short_option, long_option,
1614 } break;
1615
1616 case 'H':
1617 m_hardware = true;
1618 break;
1619
1620 case 'K': {
1621 bool success;
1622 bool value;
1623 value = OptionArgParser::ToBoolean(option_arg, true, &success);
1624 if (value)
1626 else
1628
1629 if (!success)
1631 CreateOptionParsingError(option_arg, short_option, long_option,
1633 } break;
1634
1635 case 'l':
1636 if (option_arg.getAsInteger(0, m_line_num))
1638 CreateOptionParsingError(option_arg, short_option, long_option,
1640 break;
1641
1642 case 'L':
1646 CreateOptionParsingError(option_arg, short_option, long_option,
1648 break;
1649
1650 case 'm': {
1651 bool success;
1652 bool value;
1653 value = OptionArgParser::ToBoolean(option_arg, true, &success);
1654 if (value)
1656 else
1658
1659 if (!success)
1661 CreateOptionParsingError(option_arg, short_option, long_option,
1663 break;
1664 }
1665
1666 case 'M':
1667 m_func_names.push_back(std::string(option_arg));
1668 m_func_name_type_mask |= eFunctionNameTypeMethod;
1669 break;
1670
1671 case 'n':
1672 m_func_names.push_back(std::string(option_arg));
1673 m_func_name_type_mask |= eFunctionNameTypeAuto;
1674 break;
1675
1676 case 'N': {
1678 m_breakpoint_names.push_back(std::string(option_arg));
1679 else
1681 CreateOptionParsingError(option_arg, short_option, long_option,
1682 "Invalid breakpoint name"));
1683 break;
1684 }
1685
1686 case 'R': {
1687 lldb::addr_t tmp_offset_addr;
1688 tmp_offset_addr = OptionArgParser::ToAddress(execution_context,
1689 option_arg, 0, &error);
1690 if (error.Success())
1691 m_offset_addr = tmp_offset_addr;
1692 } break;
1693
1694 case 'O':
1695 m_exception_extra_args.AppendArgument("-O");
1696 m_exception_extra_args.AppendArgument(option_arg);
1697 break;
1698
1699 case 'p':
1700 m_source_text_regexp.assign(std::string(option_arg));
1701 break;
1702
1703 case 'r':
1704 m_func_regexp.assign(std::string(option_arg));
1705 break;
1706
1707 case 's':
1708 m_modules.AppendIfUnique(FileSpec(option_arg));
1709 break;
1710
1711 case 'S':
1712 m_func_names.push_back(std::string(option_arg));
1713 m_func_name_type_mask |= eFunctionNameTypeSelector;
1714 break;
1715
1716 case 'w': {
1717 bool success;
1718 m_throw_bp = OptionArgParser::ToBoolean(option_arg, true, &success);
1719 if (!success)
1721 CreateOptionParsingError(option_arg, short_option, long_option,
1723 } break;
1724
1725 case 'X':
1726 m_source_regex_func_names.insert(std::string(option_arg));
1727 break;
1728
1729 case 'y':
1730 {
1732 Status fcl_err = value.SetValueFromString(option_arg);
1733 if (!fcl_err.Success()) {
1735 option_arg, short_option, long_option, fcl_err.AsCString()));
1736 } else {
1737 m_filenames.AppendIfUnique(value.GetFileSpec());
1738 m_line_num = value.GetLineNumber();
1739 m_column = value.GetColumnNumber();
1740 }
1741 } break;
1742
1743 default:
1744 llvm_unreachable("Unimplemented option");
1745 }
1746
1747 return error;
1748 }
1749
1750 void OptionParsingStarting(ExecutionContext *execution_context) override {
1751 m_filenames.Clear();
1752 m_line_num = 0;
1753 m_column = 0;
1754 m_func_names.clear();
1755 m_func_name_type_mask = eFunctionNameTypeNone;
1756 m_func_regexp.clear();
1757 m_source_text_regexp.clear();
1758 m_modules.Clear();
1760 m_offset_addr = 0;
1761 m_catch_bp = false;
1762 m_throw_bp = true;
1763 m_hardware = false;
1767 m_breakpoint_names.clear();
1768 m_all_files = false;
1769 m_exception_extra_args.Clear();
1772 m_current_key.clear();
1773 }
1774
1775 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
1776 return llvm::ArrayRef(g_breakpoint_set_options);
1777 }
1778
1779 // Instance variables to hold the values for command options.
1780
1781 std::string m_condition;
1783 uint32_t m_line_num = 0;
1784 uint32_t m_column = 0;
1785 std::vector<std::string> m_func_names;
1786 std::vector<std::string> m_breakpoint_names;
1787 lldb::FunctionNameType m_func_name_type_mask = eFunctionNameTypeNone;
1788 std::string m_func_regexp;
1793 bool m_catch_bp = false;
1794 bool m_throw_bp = true;
1795 bool m_hardware = false; // Request to use hardware breakpoints
1799 bool m_all_files = false;
1802 std::unordered_set<std::string> m_source_regex_func_names;
1803 std::string m_current_key;
1804 };
1805
1806protected:
1807 void DoExecute(Args &command, CommandReturnObject &result) override {
1808 Target *target =
1809 m_dummy_options.m_use_dummy ? &GetDummyTarget() : GetTarget();
1810
1811 // The following are the various types of breakpoints that could be set:
1812 // 1). -f -l -p [-s -g] (setting breakpoint by source location)
1813 // 2). -a [-s -g] (setting breakpoint by address)
1814 // 3). -n [-s -g] (setting breakpoint by function name)
1815 // 4). -r [-s -g] (setting breakpoint by function name regular
1816 // expression)
1817 // 5). -p -f (setting a breakpoint by comparing a reg-exp
1818 // to source text)
1819 // 6). -E [-w -h] (setting a breakpoint for exceptions for a
1820 // given language.)
1821
1823
1824 if (!m_python_class_options.GetName().empty())
1825 break_type = eSetTypeScripted;
1826 else if (m_options.m_line_num != 0)
1827 break_type = eSetTypeFileAndLine;
1828 else if (m_options.m_load_addr != LLDB_INVALID_ADDRESS)
1829 break_type = eSetTypeAddress;
1830 else if (!m_options.m_func_names.empty())
1831 break_type = eSetTypeFunctionName;
1832 else if (!m_options.m_func_regexp.empty())
1833 break_type = eSetTypeFunctionRegexp;
1834 else if (!m_options.m_source_text_regexp.empty())
1835 break_type = eSetTypeSourceRegexp;
1836 else if (m_options.m_exception_language != eLanguageTypeUnknown)
1837 break_type = eSetTypeException;
1838
1839 BreakpointSP bp_sp = nullptr;
1840 FileSpec module_spec;
1841 const bool internal = false;
1842
1843 // If the user didn't specify skip-prologue, having an offset should turn
1844 // that off.
1845 if (m_options.m_offset_addr != 0 &&
1846 m_options.m_skip_prologue == eLazyBoolCalculate)
1847 m_options.m_skip_prologue = eLazyBoolNo;
1848
1849 switch (break_type) {
1850 case eSetTypeFileAndLine: // Breakpoint by source position
1851 {
1852 FileSpec file;
1853 const size_t num_files = m_options.m_filenames.GetSize();
1854 if (num_files == 0) {
1855 if (!GetDefaultFile(*target, m_exe_ctx.GetFramePtr(), file, result)) {
1856 result.AppendError("no file supplied and no default file available.");
1857 return;
1858 }
1859 } else if (num_files > 1) {
1860 result.AppendError("only one file at a time is allowed for file and "
1861 "line breakpoints");
1862 return;
1863 } else
1864 file = m_options.m_filenames.GetFileSpecAtIndex(0);
1865
1866 // Only check for inline functions if
1867 LazyBool check_inlines = eLazyBoolCalculate;
1868
1869 bp_sp = target->CreateBreakpoint(
1870 &(m_options.m_modules), file, m_options.m_line_num,
1871 m_options.m_column, m_options.m_offset_addr, check_inlines,
1872 m_options.m_skip_prologue, internal, m_options.m_hardware,
1873 m_options.m_move_to_nearest_code);
1874 } break;
1875
1876 case eSetTypeAddress: // Breakpoint by address
1877 {
1878 // If a shared library has been specified, make an lldb_private::Address
1879 // with the library, and use that. That way the address breakpoint
1880 // will track the load location of the library.
1881 size_t num_modules_specified = m_options.m_modules.GetSize();
1882 if (num_modules_specified == 1) {
1883 const FileSpec &file_spec =
1884 m_options.m_modules.GetFileSpecAtIndex(0);
1885 bp_sp = target->CreateAddressInModuleBreakpoint(
1886 m_options.m_load_addr, internal, file_spec, m_options.m_hardware);
1887 } else if (num_modules_specified == 0) {
1888 bp_sp = target->CreateBreakpoint(m_options.m_load_addr, internal,
1889 m_options.m_hardware);
1890 } else {
1891 result.AppendError("Only one shared library can be specified for "
1892 "address breakpoints.");
1893 return;
1894 }
1895 break;
1896 }
1897 case eSetTypeFunctionName: // Breakpoint by function name
1898 {
1899 FunctionNameType name_type_mask = m_options.m_func_name_type_mask;
1900
1901 if (name_type_mask == 0)
1902 name_type_mask = eFunctionNameTypeAuto;
1903
1904 bp_sp = target->CreateBreakpoint(
1905 &(m_options.m_modules), &(m_options.m_filenames),
1906 m_options.m_func_names, name_type_mask, m_options.m_language,
1907 m_options.m_offset_addr, m_options.m_skip_prologue, internal,
1908 m_options.m_hardware);
1909 } break;
1910
1911 case eSetTypeFunctionRegexp: // Breakpoint by regular expression function
1912 // name
1913 {
1914 RegularExpression regexp(m_options.m_func_regexp);
1915 if (llvm::Error err = regexp.GetError()) {
1916 result.AppendErrorWithFormat(
1917 "Function name regular expression could not be compiled: %s",
1918 llvm::toString(std::move(err)).c_str());
1919 // Check if the incorrect regex looks like a globbing expression and
1920 // warn the user about it.
1921 if (!m_options.m_func_regexp.empty()) {
1922 if (m_options.m_func_regexp[0] == '*' ||
1923 m_options.m_func_regexp[0] == '?')
1924 result.AppendWarning(
1925 "function name regex does not accept glob patterns");
1926 }
1927 return;
1928 }
1929
1930 bp_sp = target->CreateFuncRegexBreakpoint(
1931 &(m_options.m_modules), &(m_options.m_filenames), std::move(regexp),
1932 m_options.m_language, m_options.m_skip_prologue, internal,
1933 m_options.m_hardware);
1934 } break;
1935 case eSetTypeSourceRegexp: // Breakpoint by regexp on source text.
1936 {
1937 const size_t num_files = m_options.m_filenames.GetSize();
1938
1939 if (num_files == 0 && !m_options.m_all_files) {
1940 FileSpec file;
1941 if (!GetDefaultFile(*target, m_exe_ctx.GetFramePtr(), file, result)) {
1942 result.AppendError(
1943 "No files provided and could not find default file.");
1944 return;
1945 } else {
1946 m_options.m_filenames.Append(file);
1947 }
1948 }
1949
1950 RegularExpression regexp(m_options.m_source_text_regexp);
1951 if (llvm::Error err = regexp.GetError()) {
1952 result.AppendErrorWithFormat(
1953 "Source text regular expression could not be compiled: \"%s\"",
1954 llvm::toString(std::move(err)).c_str());
1955 return;
1956 }
1957 bp_sp = target->CreateSourceRegexBreakpoint(
1958 &(m_options.m_modules), &(m_options.m_filenames),
1959 m_options.m_source_regex_func_names, std::move(regexp), internal,
1960 m_options.m_hardware, m_options.m_move_to_nearest_code);
1961 } break;
1962 case eSetTypeException: {
1963 Status precond_error;
1964 bp_sp = target->CreateExceptionBreakpoint(
1965 m_options.m_exception_language, m_options.m_catch_bp,
1966 m_options.m_throw_bp, internal, &m_options.m_exception_extra_args,
1967 &precond_error);
1968 if (precond_error.Fail()) {
1969 result.AppendErrorWithFormat(
1970 "Error setting extra exception arguments: %s",
1971 precond_error.AsCString());
1972 target->RemoveBreakpointByID(bp_sp->GetID());
1973 return;
1974 }
1975 } break;
1976 case eSetTypeScripted: {
1977
1978 Status error;
1979 bp_sp = target->CreateScriptedBreakpoint(
1980 m_python_class_options.GetName().c_str(), &(m_options.m_modules),
1981 &(m_options.m_filenames), false, m_options.m_hardware,
1982 m_python_class_options.GetStructuredData(), &error);
1983 if (error.Fail()) {
1984 result.AppendErrorWithFormat(
1985 "Error setting extra exception arguments: %s", error.AsCString());
1986 target->RemoveBreakpointByID(bp_sp->GetID());
1987 return;
1988 }
1989 } break;
1990 default:
1991 break;
1992 }
1993
1994 // Now set the various options that were passed in:
1995 if (bp_sp) {
1996 bp_sp->GetOptions().CopyOverSetOptions(m_bp_opts.GetBreakpointOptions());
1997
1998 if (!m_options.m_breakpoint_names.empty()) {
1999 Status name_error;
2000 for (auto name : m_options.m_breakpoint_names) {
2001 target->AddNameToBreakpoint(bp_sp, name.c_str(), name_error);
2002 if (name_error.Fail()) {
2003 result.AppendErrorWithFormat("Invalid breakpoint name: %s",
2004 name.c_str());
2005 target->RemoveBreakpointByID(bp_sp->GetID());
2006 return;
2007 }
2008 }
2009 }
2010 }
2011
2012 if (bp_sp) {
2013 Stream &output_stream = result.GetOutputStream();
2014 const bool show_locations = false;
2015 bp_sp->GetDescription(&output_stream, lldb::eDescriptionLevelInitial,
2016 show_locations);
2017 if (target == &GetDummyTarget())
2018 output_stream.Printf("Breakpoint set in dummy target, will get copied "
2019 "into future targets.\n");
2020 else {
2021 // Don't print out this warning for exception breakpoints. They can
2022 // get set before the target is set, but we won't know how to actually
2023 // set the breakpoint till we run.
2024 if (bp_sp->GetNumLocations() == 0 && break_type != eSetTypeException) {
2025 output_stream.Printf("WARNING: Unable to resolve breakpoint to any "
2026 "actual locations.\n");
2027 }
2028 }
2030 } else if (!bp_sp) {
2031 result.AppendError("breakpoint creation failed: no breakpoint created");
2032 }
2033 }
2034
2035private:
2041};
2042
2043// CommandObjectBreakpointModify
2044#pragma mark Modify
2045
2047public:
2049 : CommandObjectParsed(interpreter, "breakpoint modify",
2050 "Modify the options on a breakpoint or set of "
2051 "breakpoints in the executable. "
2052 "If no breakpoint is specified, acts on the last "
2053 "created breakpoint. "
2054 "With the exception of -e, -d and -i, passing an "
2055 "empty argument clears the modification.",
2056 nullptr, eCommandAllowsDummyTarget) {
2058
2059 m_options.Append(&m_bp_opts,
2063 m_options.Finalize();
2064 }
2065
2067
2068 void
2074
2075 Options *GetOptions() override { return &m_options; }
2076
2077protected:
2078 void DoExecute(Args &command, CommandReturnObject &result) override {
2079 Target *target = m_dummy_opts.m_use_dummy ? &GetDummyTarget() : GetTarget();
2080 assert(target && "target guaranteed by eCommandAllowsDummyTarget");
2081 std::unique_lock<std::recursive_mutex> lock;
2082 target->GetBreakpointList().GetListMutex(lock);
2083
2084 BreakpointIDList valid_bp_ids;
2085
2087 command, target, result, &valid_bp_ids,
2089
2090 if (result.Succeeded()) {
2091 const size_t count = valid_bp_ids.GetSize();
2092 for (size_t i = 0; i < count; ++i) {
2093 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex(i);
2094
2095 if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) {
2096 Breakpoint *bp =
2097 target->GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();
2098 if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) {
2099 BreakpointLocation *location =
2100 bp->FindLocationByID(cur_bp_id.GetLocationID()).get();
2101 if (location)
2103 m_bp_opts.GetBreakpointOptions());
2104 } else {
2106 m_bp_opts.GetBreakpointOptions());
2107 }
2108 }
2109 }
2110 }
2111 }
2112
2113private:
2117};
2118
2119// CommandObjectBreakpointEnable
2120#pragma mark Enable
2121
2123public:
2125 : CommandObjectParsed(interpreter, "enable",
2126 "Enable the specified disabled breakpoint(s). If "
2127 "no breakpoints are specified, enable all of them.",
2128 nullptr, eCommandAllowsDummyTarget) {
2130 }
2131
2133
2134 void
2140
2141protected:
2142 void DoExecute(Args &command, CommandReturnObject &result) override {
2143 Target *target = GetTarget();
2144 assert(target && "target guaranteed by eCommandAllowsDummyTarget");
2145 std::unique_lock<std::recursive_mutex> lock;
2146 target->GetBreakpointList().GetListMutex(lock);
2147
2148 const BreakpointList &breakpoints = target->GetBreakpointList();
2149
2150 size_t num_breakpoints = breakpoints.GetSize();
2151
2152 if (num_breakpoints == 0) {
2153 result.AppendError("no breakpoints exist to be enabled");
2154 return;
2155 }
2156
2157 if (command.empty()) {
2158 // No breakpoint selected; enable all currently set breakpoints.
2159 target->EnableAllowedBreakpoints();
2161 "All breakpoints enabled. ({0} breakpoints)", num_breakpoints);
2163 } else {
2164 // Particular breakpoint selected; enable that breakpoint.
2165 BreakpointIDList valid_bp_ids;
2167 command, m_exe_ctx, result, &valid_bp_ids,
2169
2170 if (result.Succeeded()) {
2171 int enable_count = 0;
2172 int loc_count = 0;
2173 const size_t count = valid_bp_ids.GetSize();
2174 for (size_t i = 0; i < count; ++i) {
2175 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex(i);
2176
2177 if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) {
2178 Breakpoint *breakpoint =
2179 target->GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();
2180 if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) {
2181 BreakpointLocation *location =
2182 breakpoint->FindLocationByID(cur_bp_id.GetLocationID()).get();
2183 if (location) {
2184 if (llvm::Error error = location->SetEnabled(true))
2186 "failed to enable breakpoint location: {0}",
2187 llvm::fmt_consume(std::move(error)));
2188 ++loc_count;
2189 }
2190 } else {
2191 breakpoint->SetEnabled(true);
2192 ++enable_count;
2193 }
2194 }
2195 }
2196 result.AppendMessageWithFormatv("{0} breakpoints enabled.",
2197 enable_count + loc_count);
2199 }
2200 }
2201 }
2202};
2203
2204// CommandObjectBreakpointDisable
2205#pragma mark Disable
2206
2208public:
2211 interpreter, "breakpoint disable",
2212 "Disable the specified breakpoint(s) without deleting "
2213 "them. If none are specified, disable all "
2214 "breakpoints.",
2215 nullptr, eCommandAllowsDummyTarget) {
2217 "Disable the specified breakpoint(s) without deleting them. \
2218If none are specified, disable all breakpoints."
2219 R"(
2220
2221)"
2222 "Note: disabling a breakpoint will cause none of its locations to be hit \
2223regardless of whether individual locations are enabled or disabled. After the sequence:"
2224 R"(
2225
2226 (lldb) break disable 1
2227 (lldb) break enable 1.1
2228
2229execution will NOT stop at location 1.1. To achieve that, type:
2230
2231 (lldb) break disable 1.*
2232 (lldb) break enable 1.1
2233
2234)"
2235 "The first command disables all locations for breakpoint 1, \
2236the second re-enables the first location.");
2237
2240
2241 ~CommandObjectBreakpointDisable() override = default;
2242
2243 void
2245 OptionElementVector &opt_element_vector) override {
2248 }
2249
2250protected:
2251 void DoExecute(Args &command, CommandReturnObject &result) override {
2252 Target *target = GetTarget();
2253 assert(target && "target guaranteed by eCommandAllowsDummyTarget");
2254 std::unique_lock<std::recursive_mutex> lock;
2255 target->GetBreakpointList().GetListMutex(lock);
2256
2257 const BreakpointList &breakpoints = target->GetBreakpointList();
2258 size_t num_breakpoints = breakpoints.GetSize();
2259
2260 if (num_breakpoints == 0) {
2261 result.AppendError("no breakpoints exist to be disabled");
2262 return;
2263 }
2264
2265 if (command.empty()) {
2266 // No breakpoint selected; disable all currently set breakpoints.
2267 target->DisableAllowedBreakpoints();
2269 "All breakpoints disabled. ({0} breakpoints)\n", num_breakpoints);
2271 } else {
2272 // Particular breakpoint selected; disable that breakpoint.
2273 BreakpointIDList valid_bp_ids;
2274
2276 command, m_exe_ctx, result, &valid_bp_ids,
2277 BreakpointName::Permissions::PermissionKinds::disablePerm);
2278
2279 if (result.Succeeded()) {
2280 int disable_count = 0;
2281 int loc_count = 0;
2282 const size_t count = valid_bp_ids.GetSize();
2283 for (size_t i = 0; i < count; ++i) {
2284 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex(i);
2285
2286 if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) {
2287 Breakpoint *breakpoint =
2288 target->GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();
2289 if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) {
2290 BreakpointLocation *location =
2291 breakpoint->FindLocationByID(cur_bp_id.GetLocationID()).get();
2292 if (location) {
2293 if (llvm::Error error = location->SetEnabled(false))
2295 "failed to disable breakpoint location: {0}",
2296 llvm::fmt_consume(std::move(error)));
2297 ++loc_count;
2298 }
2299 } else {
2300 breakpoint->SetEnabled(false);
2301 ++disable_count;
2302 }
2303 }
2304 }
2305 result.AppendMessageWithFormatv("{0} breakpoints disabled.",
2306 disable_count + loc_count);
2308 }
2309 }
2310 }
2311};
2312
2313// CommandObjectBreakpointList
2314
2315#pragma mark List::CommandOptions
2316#define LLDB_OPTIONS_breakpoint_list
2317#include "CommandOptions.inc"
2318
2319#pragma mark List
2320
2322public:
2325 interpreter, "breakpoint list",
2326 "List some or all breakpoints at configurable levels of detail.",
2327 nullptr, eCommandAllowsDummyTarget) {
2328
2329 // Define the first (and only) variant of this arg.
2331 }
2332
2333 ~CommandObjectBreakpointList() override = default;
2334
2335 Options *GetOptions() override { return &m_options; }
2336
2337 class CommandOptions : public Options {
2338 public:
2339 CommandOptions() = default;
2340
2341 ~CommandOptions() override = default;
2342
2343 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
2344 ExecutionContext *execution_context) override {
2345 Status error;
2346 const int short_option = m_getopt_table[option_idx].val;
2347
2348 switch (short_option) {
2349 case 'b':
2351 break;
2352 case 'D':
2353 m_use_dummy = true;
2354 break;
2355 case 'f':
2357 break;
2358 case 'v':
2360 break;
2361 case 'i':
2362 m_internal = true;
2363 break;
2364 default:
2365 llvm_unreachable("Unimplemented option");
2366 }
2367
2368 return error;
2369 }
2370
2371 void OptionParsingStarting(ExecutionContext *execution_context) override {
2373 m_internal = false;
2374 m_use_dummy = false;
2375 }
2376
2377 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
2378 return llvm::ArrayRef(g_breakpoint_list_options);
2379 }
2380
2381 // Instance variables to hold the values for command options.
2382
2384
2386 bool m_use_dummy = false;
2387 };
2388
2389protected:
2390 void DoExecute(Args &command, CommandReturnObject &result) override {
2391 Target *target = m_options.m_use_dummy ? &GetDummyTarget() : GetTarget();
2392 assert(target && "target guaranteed by eCommandAllowsDummyTarget");
2393 const BreakpointList &breakpoints =
2394 target->GetBreakpointList(m_options.m_internal);
2395 std::unique_lock<std::recursive_mutex> lock;
2396 target->GetBreakpointList(m_options.m_internal).GetListMutex(lock);
2397
2398 size_t num_breakpoints = breakpoints.GetSize();
2399
2400 if (num_breakpoints == 0) {
2401 result.AppendMessage("No breakpoints currently set.");
2403 return;
2404 }
2405
2406 Stream &output_stream = result.GetOutputStream();
2407
2408 if (command.empty()) {
2409 // No breakpoint selected; show info about all currently set breakpoints.
2410 result.AppendMessage("Current breakpoints:");
2411 for (size_t i = 0; i < num_breakpoints; ++i) {
2412 Breakpoint *breakpoint = breakpoints.GetBreakpointAtIndex(i).get();
2413 if (breakpoint->AllowList())
2414 AddBreakpointDescription(&output_stream, breakpoint,
2415 m_options.m_level);
2416 }
2418 } else {
2419 // Particular breakpoints selected; show info about that breakpoint.
2420 BreakpointIDList valid_bp_ids;
2422 command, target, result, &valid_bp_ids,
2424
2425 if (result.Succeeded()) {
2426 for (size_t i = 0; i < valid_bp_ids.GetSize(); ++i) {
2427 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex(i);
2428 Breakpoint *breakpoint =
2429 target->GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();
2430 AddBreakpointDescription(&output_stream, breakpoint,
2431 m_options.m_level);
2432 }
2434 } else {
2435 result.AppendError("invalid breakpoint ID");
2436 }
2437 }
2438 }
2439
2440private:
2442};
2443
2444// CommandObjectBreakpointClear
2445#pragma mark Clear::CommandOptions
2446
2447#define LLDB_OPTIONS_breakpoint_clear
2448#include "CommandOptions.inc"
2449
2450#pragma mark Clear
2451
2453public:
2455
2457 : CommandObjectParsed(interpreter, "breakpoint clear",
2458 "Delete or disable breakpoints matching the "
2459 "specified source file and line.",
2460 "breakpoint clear <cmd-options>",
2461 eCommandAllowsDummyTarget) {}
2462
2463 ~CommandObjectBreakpointClear() override = default;
2464
2465 Options *GetOptions() override { return &m_options; }
2466
2467 class CommandOptions : public Options {
2468 public:
2469 CommandOptions() = default;
2470
2471 ~CommandOptions() override = default;
2472
2473 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
2474 ExecutionContext *execution_context) override {
2475 Status error;
2476 const int short_option = m_getopt_table[option_idx].val;
2477
2478 switch (short_option) {
2479 case 'f':
2480 m_filename.assign(std::string(option_arg));
2481 break;
2482
2483 case 'l':
2484 option_arg.getAsInteger(0, m_line_num);
2485 break;
2486
2487 default:
2488 llvm_unreachable("Unimplemented option");
2489 }
2490
2491 return error;
2492 }
2493
2494 void OptionParsingStarting(ExecutionContext *execution_context) override {
2495 m_filename.clear();
2496 m_line_num = 0;
2497 }
2498
2499 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
2500 return llvm::ArrayRef(g_breakpoint_clear_options);
2501 }
2502
2503 // Instance variables to hold the values for command options.
2504
2505 std::string m_filename;
2506 uint32_t m_line_num = 0;
2507 };
2508
2509protected:
2510 void DoExecute(Args &command, CommandReturnObject &result) override {
2511 Target *target = GetTarget();
2512 assert(target && "target guaranteed by eCommandAllowsDummyTarget");
2513 // The following are the various types of breakpoints that could be
2514 // cleared:
2515 // 1). -f -l (clearing breakpoint by source location)
2516
2518
2519 if (m_options.m_line_num != 0)
2520 break_type = eClearTypeFileAndLine;
2521
2522 std::unique_lock<std::recursive_mutex> lock;
2523 target->GetBreakpointList().GetListMutex(lock);
2524
2525 BreakpointList &breakpoints = target->GetBreakpointList();
2526 size_t num_breakpoints = breakpoints.GetSize();
2527
2528 // Early return if there's no breakpoint at all.
2529 if (num_breakpoints == 0) {
2530 result.AppendError("breakpoint clear: no breakpoint cleared");
2531 return;
2532 }
2533
2534 // Find matching breakpoints and delete them.
2535
2536 // First create a copy of all the IDs.
2537 std::vector<break_id_t> BreakIDs;
2538 for (size_t i = 0; i < num_breakpoints; ++i)
2539 BreakIDs.push_back(breakpoints.GetBreakpointAtIndex(i)->GetID());
2540
2541 int num_cleared = 0;
2542 StreamString ss;
2543 switch (break_type) {
2544 case eClearTypeFileAndLine: // Breakpoint by source position
2545 {
2546 llvm::StringRef filename(m_options.m_filename);
2548
2549 for (size_t i = 0; i < num_breakpoints; ++i) {
2550 Breakpoint *bp = breakpoints.FindBreakpointByID(BreakIDs[i]).get();
2551
2552 if (bp->GetMatchingFileLine(filename, m_options.m_line_num, loc_coll)) {
2553 // If the collection size is 0, it's a full match and we can just
2554 // remove the breakpoint.
2555 if (loc_coll.GetSize() == 0) {
2557 ss.EOL();
2558 target->RemoveBreakpointByID(bp->GetID());
2559 ++num_cleared;
2560 }
2561 }
2562 }
2563 } break;
2564
2565 default:
2566 break;
2567 }
2568
2569 if (num_cleared > 0) {
2570 Stream &output_stream = result.GetOutputStream();
2571 output_stream.Printf("%d breakpoints cleared:\n", num_cleared);
2572 output_stream << ss.GetString();
2573 output_stream.EOL();
2575 } else {
2576 result.AppendError("breakpoint clear: no breakpoint cleared");
2577 }
2578 }
2579
2580private:
2582};
2583
2584// CommandObjectBreakpointDelete
2585#define LLDB_OPTIONS_breakpoint_delete
2586#include "CommandOptions.inc"
2587
2588#pragma mark Delete
2589
2591public:
2593 : CommandObjectParsed(interpreter, "breakpoint delete",
2594 "Delete the specified breakpoint(s). If no "
2595 "breakpoints are specified, delete them all.",
2596 nullptr, eCommandAllowsDummyTarget) {
2598 }
2599
2601
2602 void
2608
2609 Options *GetOptions() override { return &m_options; }
2610
2611 class CommandOptions : public Options {
2612 public:
2613 CommandOptions() = default;
2614
2615 ~CommandOptions() override = default;
2616
2617 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
2618 ExecutionContext *execution_context) override {
2619 Status error;
2620 const int short_option = m_getopt_table[option_idx].val;
2621
2622 switch (short_option) {
2623 case 'f':
2624 m_force = true;
2625 break;
2626
2627 case 'D':
2628 m_use_dummy = true;
2629 break;
2630
2631 case 'd':
2632 m_delete_disabled = true;
2633 break;
2634
2635 default:
2636 llvm_unreachable("Unimplemented option");
2637 }
2638
2639 return error;
2640 }
2641
2642 void OptionParsingStarting(ExecutionContext *execution_context) override {
2643 m_use_dummy = false;
2644 m_force = false;
2645 m_delete_disabled = false;
2646 }
2647
2648 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
2649 return llvm::ArrayRef(g_breakpoint_delete_options);
2650 }
2651
2652 // Instance variables to hold the values for command options.
2653 bool m_use_dummy = false;
2654 bool m_force = false;
2655 bool m_delete_disabled = false;
2656 };
2657
2658protected:
2659 void DoExecute(Args &command, CommandReturnObject &result) override {
2660 Target *target = m_options.m_use_dummy ? &GetDummyTarget() : GetTarget();
2661 assert(target && "target guaranteed by eCommandAllowsDummyTarget");
2662 result.Clear();
2663
2664 std::unique_lock<std::recursive_mutex> lock;
2665 target->GetBreakpointList().GetListMutex(lock);
2666
2667 BreakpointList &breakpoints = target->GetBreakpointList();
2668
2669 size_t num_breakpoints = breakpoints.GetSize();
2670
2671 if (num_breakpoints == 0) {
2672 result.AppendError("no breakpoints exist to be deleted");
2673 return;
2674 }
2675
2676 // Handle the delete all breakpoints case:
2677 if (command.empty() && !m_options.m_delete_disabled) {
2678 if (!m_options.m_force &&
2679 !m_interpreter.Confirm(
2680 "About to delete all breakpoints, do you want to do that?",
2681 true)) {
2682 result.AppendMessage("Operation cancelled...");
2683 } else {
2684 target->RemoveAllowedBreakpoints();
2686 "All breakpoints removed. ({0} breakpoint{1})", num_breakpoints,
2687 num_breakpoints > 1 ? "s" : "");
2688 }
2690 return;
2691 }
2692
2693 // Either we have some kind of breakpoint specification(s),
2694 // or we are handling "break disable --deleted". Gather the list
2695 // of breakpoints to delete here, the we'll delete them below.
2696 BreakpointIDList valid_bp_ids;
2697
2698 if (m_options.m_delete_disabled) {
2699 BreakpointIDList excluded_bp_ids;
2700
2701 if (!command.empty()) {
2703 command, target, result, &excluded_bp_ids,
2705 if (!result.Succeeded())
2706 return;
2707 }
2708
2709 for (auto breakpoint_sp : breakpoints.Breakpoints()) {
2710 if (!breakpoint_sp->IsEnabled() && breakpoint_sp->AllowDelete()) {
2711 BreakpointID bp_id(breakpoint_sp->GetID());
2712 if (!excluded_bp_ids.Contains(bp_id))
2713 valid_bp_ids.AddBreakpointID(bp_id);
2714 }
2715 }
2716 if (valid_bp_ids.GetSize() == 0) {
2717 result.AppendError("no disabled breakpoints");
2718 return;
2719 }
2720 } else {
2722 command, m_exe_ctx, result, &valid_bp_ids,
2724 if (!result.Succeeded())
2725 return;
2726 }
2727
2728 int delete_count = 0;
2729 int disable_count = 0;
2730 const size_t count = valid_bp_ids.GetSize();
2731 for (size_t i = 0; i < count; ++i) {
2732 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex(i);
2733
2734 if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) {
2735 if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) {
2736 Breakpoint *breakpoint =
2737 target->GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();
2738 BreakpointLocation *location =
2739 breakpoint->FindLocationByID(cur_bp_id.GetLocationID()).get();
2740 // It makes no sense to try to delete individual locations, so we
2741 // disable them instead.
2742 if (location) {
2743 if (llvm::Error error = location->SetEnabled(false))
2745 "failed to disable breakpoint location: {0}",
2746 llvm::fmt_consume(std::move(error)));
2747 ++disable_count;
2748 }
2749 } else {
2750 target->RemoveBreakpointByID(cur_bp_id.GetBreakpointID());
2751 ++delete_count;
2752 }
2753 }
2754 }
2756 "{0} breakpoints deleted; {1} breakpoint locations disabled.",
2757 delete_count, disable_count);
2759 }
2760
2761private:
2763};
2764
2765// CommandObjectBreakpointName
2766#define LLDB_OPTIONS_breakpoint_name
2767#include "CommandOptions.inc"
2768
2770public:
2773
2774 ~BreakpointNameOptionGroup() override = default;
2775
2776 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
2777 return llvm::ArrayRef(g_breakpoint_name_options);
2778 }
2779
2780 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
2781 ExecutionContext *execution_context) override {
2782 Status error;
2783 const int short_option = g_breakpoint_name_options[option_idx].short_option;
2784 const char *long_option = g_breakpoint_name_options[option_idx].long_option;
2785
2786 switch (short_option) {
2787 case 'N':
2789 error.Success())
2790 m_name.SetValueFromString(option_arg);
2791 break;
2792 case 'B':
2793 if (m_breakpoint.SetValueFromString(option_arg).Fail())
2795 CreateOptionParsingError(option_arg, short_option, long_option,
2797 break;
2798 case 'D':
2799 if (m_use_dummy.SetValueFromString(option_arg).Fail())
2801 CreateOptionParsingError(option_arg, short_option, long_option,
2803 break;
2804 case 'H':
2805 m_help_string.SetValueFromString(option_arg);
2806 break;
2807
2808 default:
2809 llvm_unreachable("Unimplemented option");
2810 }
2811 return error;
2812 }
2813
2814 void OptionParsingStarting(ExecutionContext *execution_context) override {
2815 m_name.Clear();
2816 m_breakpoint.Clear();
2817 m_use_dummy.Clear();
2818 m_use_dummy.SetDefaultValue(false);
2819 m_help_string.Clear();
2820 }
2821
2826};
2827
2828#define LLDB_OPTIONS_breakpoint_access
2829#include "CommandOptions.inc"
2830
2832public:
2834
2835 ~BreakpointAccessOptionGroup() override = default;
2836
2837 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
2838 return llvm::ArrayRef(g_breakpoint_access_options);
2839 }
2840 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
2841 ExecutionContext *execution_context) override {
2842 Status error;
2843 const int short_option =
2844 g_breakpoint_access_options[option_idx].short_option;
2845 const char *long_option =
2846 g_breakpoint_access_options[option_idx].long_option;
2847
2848 switch (short_option) {
2849 case 'L': {
2850 bool value, success;
2851 value = OptionArgParser::ToBoolean(option_arg, false, &success);
2852 if (success) {
2853 m_permissions.SetAllowList(value);
2854 } else
2856 CreateOptionParsingError(option_arg, short_option, long_option,
2858 } break;
2859 case 'A': {
2860 bool value, success;
2861 value = OptionArgParser::ToBoolean(option_arg, false, &success);
2862 if (success) {
2863 m_permissions.SetAllowDisable(value);
2864 } else
2866 CreateOptionParsingError(option_arg, short_option, long_option,
2868 } break;
2869 case 'D': {
2870 bool value, success;
2871 value = OptionArgParser::ToBoolean(option_arg, false, &success);
2872 if (success) {
2873 m_permissions.SetAllowDelete(value);
2874 } else
2876 CreateOptionParsingError(option_arg, short_option, long_option,
2878 } break;
2879 default:
2880 llvm_unreachable("Unimplemented option");
2881 }
2882
2883 return error;
2884 }
2885
2886 void OptionParsingStarting(ExecutionContext *execution_context) override {}
2887
2889 return m_permissions;
2890 }
2892};
2893
2895public:
2898 interpreter, "configure",
2899 "Configure the options for the breakpoint"
2900 " name provided. "
2901 "If you provide a breakpoint id, the options will be copied from "
2902 "the breakpoint, otherwise only the options specified will be set "
2903 "on the name.",
2904 "breakpoint name configure <command-options> "
2905 "<breakpoint-name-list>",
2906 eCommandAllowsDummyTarget) {
2908
2914 m_option_group.Finalize();
2915 }
2916
2918
2919 Options *GetOptions() override { return &m_option_group; }
2920
2921protected:
2922 void DoExecute(Args &command, CommandReturnObject &result) override {
2923
2924 const size_t argc = command.GetArgumentCount();
2925 if (argc == 0) {
2926 result.AppendError("no names provided");
2927 return;
2928 }
2929
2930 Target *target = GetTarget();
2931 assert(target && "target guaranteed by eCommandAllowsDummyTarget");
2932 std::unique_lock<std::recursive_mutex> lock;
2933 target->GetBreakpointList().GetListMutex(lock);
2934
2935 // Make a pass through first to see that all the names are legal.
2936 for (auto &entry : command.entries()) {
2937 Status error;
2938 if (!BreakpointID::StringIsBreakpointName(entry.ref(), error)) {
2939 result.AppendErrorWithFormat("Invalid breakpoint name: %s - %s",
2940 entry.c_str(), error.AsCString());
2941 return;
2942 }
2943 }
2944 // Now configure them, we already pre-checked the names so we don't need to
2945 // check the error:
2946 BreakpointSP bp_sp;
2947 if (m_bp_id.m_breakpoint.OptionWasSet()) {
2948 lldb::break_id_t bp_id =
2949 m_bp_id.m_breakpoint.GetValueAs<uint64_t>().value_or(0);
2950 bp_sp = target->GetBreakpointByID(bp_id);
2951 if (!bp_sp) {
2952 result.AppendErrorWithFormatv("Could not find specified breakpoint {0}",
2953 bp_id);
2954 return;
2955 }
2956 }
2957
2958 Status error;
2959 for (auto &entry : command.entries()) {
2960 llvm::StringRef name(entry.ref());
2961 BreakpointName *bp_name = target->FindBreakpointName(name, true, error);
2962 if (!bp_name)
2963 continue;
2964 if (m_bp_id.m_help_string.OptionWasSet())
2965 bp_name->SetHelp(m_bp_id.m_help_string.GetValueAs<llvm::StringRef>()
2966 .value_or("")
2967 .str()
2968 .c_str());
2969
2970 if (bp_sp)
2971 target->ConfigureBreakpointName(*bp_name, bp_sp->GetOptions(),
2972 m_access_options.GetPermissions());
2973 else
2974 target->ConfigureBreakpointName(*bp_name,
2975 m_bp_opts.GetBreakpointOptions(),
2976 m_access_options.GetPermissions());
2977 }
2979 }
2980
2981private:
2982 BreakpointNameOptionGroup m_bp_id; // Only using the id part of this.
2986};
2987
2989public:
2992 interpreter, "add", "Add a name to the breakpoints provided.",
2993 "breakpoint name add <command-options> <breakpoint-id-list>",
2994 eCommandAllowsDummyTarget) {
2996
2998 m_option_group.Finalize();
2999 }
3000
3002
3003 void
3009
3010 Options *GetOptions() override { return &m_option_group; }
3011
3012protected:
3013 void DoExecute(Args &command, CommandReturnObject &result) override {
3014 if (!m_name_options.m_name.OptionWasSet()) {
3015 result.AppendError("no name option provided");
3016 return;
3017 }
3018
3019 Target *target =
3020 m_name_options.m_use_dummy ? &GetDummyTarget() : GetTarget();
3021
3022 std::unique_lock<std::recursive_mutex> lock;
3023 target->GetBreakpointList().GetListMutex(lock);
3024
3025 const BreakpointList &breakpoints = target->GetBreakpointList();
3026
3027 size_t num_breakpoints = breakpoints.GetSize();
3028 if (num_breakpoints == 0) {
3029 result.AppendError("no breakpoints, cannot add names");
3030 return;
3031 }
3032
3033 // Particular breakpoint selected; disable that breakpoint.
3034 BreakpointIDList valid_bp_ids;
3036 command, target, result, &valid_bp_ids,
3038
3039 if (result.Succeeded()) {
3040 if (valid_bp_ids.GetSize() == 0) {
3041 result.AppendError("no breakpoints specified, cannot add names");
3042 return;
3043 }
3044 size_t num_valid_ids = valid_bp_ids.GetSize();
3045 const char *bp_name = m_name_options.m_name.GetCurrentValue();
3046 Status error; // This error reports illegal names, but we've already
3047 // checked that, so we don't need to check it again here.
3048 for (size_t index = 0; index < num_valid_ids; index++) {
3049 lldb::break_id_t bp_id =
3050 valid_bp_ids.GetBreakpointIDAtIndex(index).GetBreakpointID();
3051 BreakpointSP bp_sp = breakpoints.FindBreakpointByID(bp_id);
3052 target->AddNameToBreakpoint(bp_sp, bp_name, error);
3053 }
3054 }
3055 }
3056
3057private:
3060};
3061
3063public:
3066 interpreter, "delete",
3067 "Delete a name from the breakpoints provided.",
3068 "breakpoint name delete <command-options> <breakpoint-id-list>",
3069 eCommandAllowsDummyTarget) {
3071
3073 m_option_group.Finalize();
3074 }
3075
3077
3078 void
3084
3085 Options *GetOptions() override { return &m_option_group; }
3086
3087protected:
3088 void DoExecute(Args &command, CommandReturnObject &result) override {
3089 if (!m_name_options.m_name.OptionWasSet()) {
3090 result.AppendError("no name option provided");
3091 return;
3092 }
3093
3094 Target *target =
3095 m_name_options.m_use_dummy ? &GetDummyTarget() : GetTarget();
3096
3097 std::unique_lock<std::recursive_mutex> lock;
3098 target->GetBreakpointList().GetListMutex(lock);
3099
3100 const BreakpointList &breakpoints = target->GetBreakpointList();
3101
3102 size_t num_breakpoints = breakpoints.GetSize();
3103 if (num_breakpoints == 0) {
3104 result.AppendError("no breakpoints, cannot delete names");
3105 return;
3106 }
3107
3108 // Particular breakpoint selected; disable that breakpoint.
3109 BreakpointIDList valid_bp_ids;
3111 command, target, result, &valid_bp_ids,
3113
3114 if (result.Succeeded()) {
3115 if (valid_bp_ids.GetSize() == 0) {
3116 result.AppendError("no breakpoints specified, cannot delete names");
3117 return;
3118 }
3119 llvm::StringRef bp_name(m_name_options.m_name.GetCurrentValueAsRef());
3120 size_t num_valid_ids = valid_bp_ids.GetSize();
3121 for (size_t index = 0; index < num_valid_ids; index++) {
3122 lldb::break_id_t bp_id =
3123 valid_bp_ids.GetBreakpointIDAtIndex(index).GetBreakpointID();
3124 BreakpointSP bp_sp = breakpoints.FindBreakpointByID(bp_id);
3125 target->RemoveNameFromBreakpoint(bp_sp, bp_name);
3126 }
3127 }
3128 }
3129
3130private:
3133};
3134
3136public:
3138 : CommandObjectParsed(interpreter, "list",
3139 "List either the names for a breakpoint or info "
3140 "about a given name. With no arguments, lists all "
3141 "names",
3142 "breakpoint name list <command-options>",
3143 eCommandAllowsDummyTarget) {
3145 m_option_group.Finalize();
3146 }
3147
3149
3150 Options *GetOptions() override { return &m_option_group; }
3151
3152protected:
3153 void DoExecute(Args &command, CommandReturnObject &result) override {
3154 Target *target =
3155 m_name_options.m_use_dummy ? &GetDummyTarget() : GetTarget();
3156
3157 std::vector<std::string> name_list;
3158 if (command.empty()) {
3159 target->GetBreakpointNames(name_list);
3160 } else {
3161 for (const Args::ArgEntry &arg : command) {
3162 name_list.push_back(arg.c_str());
3163 }
3164 }
3165
3166 if (name_list.empty()) {
3167 result.AppendMessage("No breakpoint names found.");
3168 } else {
3169 for (const std::string &name : name_list) {
3170 // First print out the options for the name:
3171 Status error;
3172 BreakpointName *bp_name =
3173 target->FindBreakpointName(name, false, error);
3174 if (bp_name) {
3175 StreamString s;
3176 result.AppendMessageWithFormatv("Name: {0}", name);
3177 if (bp_name->GetDescription(&s, eDescriptionLevelFull)) {
3178 result.AppendMessage(s.GetString());
3179 }
3180
3181 std::unique_lock<std::recursive_mutex> lock;
3182 target->GetBreakpointList().GetListMutex(lock);
3183
3184 BreakpointList &breakpoints = target->GetBreakpointList();
3185 bool any_set = false;
3186 for (BreakpointSP bp_sp : breakpoints.Breakpoints()) {
3187 if (bp_sp->MatchesName(name.c_str())) {
3188 StreamString s;
3189 any_set = true;
3190 bp_sp->GetDescription(&s, eDescriptionLevelBrief);
3191 s.EOL();
3192 result.AppendMessage(s.GetString());
3193 }
3194 }
3195 if (!any_set)
3196 result.AppendMessage("No breakpoints using this name.");
3197 } else {
3198 result.AppendMessageWithFormatv("Name: {0} not found.", name);
3199 }
3200 }
3201 }
3202 }
3203
3204private:
3207};
3208
3209// CommandObjectBreakpointName
3211public:
3214 interpreter, "name", "Commands to manage breakpoint names") {
3215
3216
3218 R"(
3219Breakpoint names provide a general tagging mechanism for breakpoints. Each
3220breakpoint name can be added to any number of breakpoints, and each breakpoint
3221can have any number of breakpoint names attached to it. For instance:
3222
3223 (lldb) break name add -N MyName 1-10
3224
3225adds the name MyName to breakpoints 1-10, and:
3226
3227 (lldb) break set -n myFunc -N Name1 -N Name2
3228
3229adds two names to the breakpoint set at myFunc.
3230
3231They have a number of interrelated uses:
3232
32331) They provide a stable way to refer to a breakpoint (e.g. in another
3234breakpoint's action). Using the breakpoint ID for this purpose is fragile, since
3235it depends on the order of breakpoint creation. Giving a name to the breakpoint
3236you want to act on, and then referring to it by name, is more robust:
3237
3238 (lldb) break set -n myFunc -N BKPT1
3239 (lldb) break set -n myOtherFunc -C "break disable BKPT1"
3240
32412) This is actually just a specific use of a more general feature of breakpoint
3242names. The <breakpt-id-list> argument type used to specify one or more
3243breakpoints in most of the commands that deal with breakpoints also accepts
3244breakpoint names. That allows you to refer to one breakpoint in a stable
3245manner, but also makes them a convenient grouping mechanism, allowing you to
3246easily act on a group of breakpoints by using their name, for instance disabling
3247them all in one action:
3248
3249 (lldb) break set -n myFunc -N Group1
3250 (lldb) break set -n myOtherFunc -N Group1
3251 (lldb) break disable Group1
3252
32533) But breakpoint names are also entities in their own right, and can be
3254configured with all the modifiable attributes of a breakpoint. Then when you
3255add a breakpoint name to a breakpoint, the breakpoint will be configured to
3256match the state of the breakpoint name. The link between the name and the
3257breakpoints sharing it remains live, so if you change the configuration on the
3258name, it will also change the configurations on the breakpoints:
3259
3260 (lldb) break name configure -i 10 IgnoreSome
3261 (lldb) break set -n myFunc -N IgnoreSome
3262 (lldb) break list IgnoreSome
3263 2: name = 'myFunc', locations = 0 (pending) Options: ignore: 10 enabled
3264 Names:
3265 IgnoreSome
3266 (lldb) break name configure -i 5 IgnoreSome
3267 (lldb) break list IgnoreSome
3268 2: name = 'myFunc', locations = 0 (pending) Options: ignore: 5 enabled
3269 Names:
3270 IgnoreSome
3271
3272Options that are not configured on a breakpoint name don't affect the value of
3273those options on the breakpoints they are added to. So for instance, if Name1
3274has the -i option configured and Name2 the -c option, adding both names to a
3275breakpoint will set the -i option from Name1 and the -c option from Name2, and
3276the other options will be unaltered.
3277
3278If you add multiple names to a breakpoint which have configured values for
3279the same option, the last name added's value wins.
3280
3281The "liveness" of these settings is one way, from name to breakpoint.
3282If you use "break modify" to change an option that is also configured on a name
3283which that breakpoint has, the "break modify" command will override the setting
3284for that breakpoint, but won't change the value configured in the name or on the
3285other breakpoints sharing that name.
3286
32874) Breakpoint names are also a convenient way to copy option sets from one
3288breakpoint to another. Using the -B option to "breakpoint name configure" makes
3289a name configured with all the options of the original breakpoint. Then
3290adding that name to another breakpoint copies over all the values from the
3291original breakpoint to the new one.
3292
32935) You can also use breakpoint names to hide breakpoints from the breakpoint
3294operations that act on all breakpoints: "break delete", "break disable" and
3295"break list". You do that by specifying a "false" value for the
3296--allow-{list,delete,disable} options to "breakpoint name configure" and then
3297adding that name to a breakpoint.
3298
3299This won't keep the breakpoint from being deleted or disabled if you refer to it
3300specifically by ID. The point of the feature is to make sure users don't
3301inadvertently delete or disable useful breakpoints (e.g. ones an IDE is using
3302for its own purposes) as part of a "delete all" or "disable all" operation. The
3303list hiding is because it's confusing for people to see breakpoints they
3304didn't set.
3305
3306)");
3307 CommandObjectSP add_command_object(
3308 new CommandObjectBreakpointNameAdd(interpreter));
3309 CommandObjectSP delete_command_object(
3310 new CommandObjectBreakpointNameDelete(interpreter));
3311 CommandObjectSP list_command_object(
3312 new CommandObjectBreakpointNameList(interpreter));
3313 CommandObjectSP configure_command_object(
3314 new CommandObjectBreakpointNameConfigure(interpreter));
3315
3316 LoadSubCommand("add", add_command_object);
3317 LoadSubCommand("delete", delete_command_object);
3318 LoadSubCommand("list", list_command_object);
3319 LoadSubCommand("configure", configure_command_object);
3320 }
3321
3322 ~CommandObjectBreakpointName() override = default;
3323};
3324
3325// CommandObjectBreakpointRead
3326#pragma mark Read::CommandOptions
3327#define LLDB_OPTIONS_breakpoint_read
3328#include "CommandOptions.inc"
3329
3330#pragma mark Read
3331
3333public:
3335 : CommandObjectParsed(interpreter, "breakpoint read",
3336 "Read and set the breakpoints previously saved to "
3337 "a file with \"breakpoint write\". ",
3338 nullptr, eCommandAllowsDummyTarget) {}
3339
3340 ~CommandObjectBreakpointRead() override = default;
3341
3342 Options *GetOptions() override { return &m_options; }
3343
3344 class CommandOptions : public Options {
3345 public:
3346 CommandOptions() = default;
3347
3348 ~CommandOptions() override = default;
3349
3350 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
3351 ExecutionContext *execution_context) override {
3352 Status error;
3353 const int short_option = m_getopt_table[option_idx].val;
3354 const char *long_option =
3355 m_getopt_table[option_idx].definition->long_option;
3356
3357 switch (short_option) {
3358 case 'f':
3359 m_filename.assign(std::string(option_arg));
3360 break;
3361 case 'N': {
3362 Status name_error;
3363 if (!BreakpointID::StringIsBreakpointName(llvm::StringRef(option_arg),
3364 name_error)) {
3366 option_arg, short_option, long_option, name_error.AsCString()));
3367 }
3368 m_names.push_back(std::string(option_arg));
3369 break;
3370 }
3371 default:
3372 llvm_unreachable("Unimplemented option");
3373 }
3374
3375 return error;
3376 }
3377
3378 void OptionParsingStarting(ExecutionContext *execution_context) override {
3379 m_filename.clear();
3380 m_names.clear();
3381 }
3382
3383 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
3384 return llvm::ArrayRef(g_breakpoint_read_options);
3385 }
3386
3388 CompletionRequest &request, OptionElementVector &opt_element_vector,
3389 int opt_element_index, CommandInterpreter &interpreter) override {
3390 int opt_arg_pos = opt_element_vector[opt_element_index].opt_arg_pos;
3391 int opt_defs_index = opt_element_vector[opt_element_index].opt_defs_index;
3392
3393 switch (GetDefinitions()[opt_defs_index].short_option) {
3394 case 'f':
3396 interpreter, lldb::eDiskFileCompletion, request, nullptr);
3397 break;
3398
3399 case 'N':
3400 std::optional<FileSpec> file_spec;
3401 const llvm::StringRef dash_f("-f");
3402 for (int arg_idx = 0; arg_idx < opt_arg_pos; arg_idx++) {
3403 if (dash_f == request.GetParsedLine().GetArgumentAtIndex(arg_idx)) {
3404 file_spec.emplace(
3405 request.GetParsedLine().GetArgumentAtIndex(arg_idx + 1));
3406 break;
3407 }
3408 }
3409 if (!file_spec)
3410 return;
3411
3412 FileSystem::Instance().Resolve(*file_spec);
3413 Status error;
3414 StructuredData::ObjectSP input_data_sp =
3416 if (!error.Success())
3417 return;
3418
3419 StructuredData::Array *bkpt_array = input_data_sp->GetAsArray();
3420 if (!bkpt_array)
3421 return;
3422
3423 const size_t num_bkpts = bkpt_array->GetSize();
3424 for (size_t i = 0; i < num_bkpts; i++) {
3425 StructuredData::ObjectSP bkpt_object_sp =
3426 bkpt_array->GetItemAtIndex(i);
3427 if (!bkpt_object_sp)
3428 return;
3429
3430 StructuredData::Dictionary *bkpt_dict =
3431 bkpt_object_sp->GetAsDictionary();
3432 if (!bkpt_dict)
3433 return;
3434
3435 StructuredData::ObjectSP bkpt_data_sp =
3437 if (!bkpt_data_sp)
3438 return;
3439
3440 bkpt_dict = bkpt_data_sp->GetAsDictionary();
3441 if (!bkpt_dict)
3442 return;
3443
3444 StructuredData::Array *names_array;
3445
3446 if (!bkpt_dict->GetValueForKeyAsArray("Names", names_array))
3447 return;
3448
3449 size_t num_names = names_array->GetSize();
3450
3451 for (size_t i = 0; i < num_names; i++) {
3452 if (std::optional<llvm::StringRef> maybe_name =
3453 names_array->GetItemAtIndexAsString(i))
3454 request.TryCompleteCurrentArg(*maybe_name);
3455 }
3456 }
3457 }
3458 }
3459
3460 std::string m_filename;
3461 std::vector<std::string> m_names;
3462 };
3463
3464protected:
3465 void DoExecute(Args &command, CommandReturnObject &result) override {
3466 Target *target = GetTarget();
3467 assert(target && "target guaranteed by eCommandAllowsDummyTarget");
3468 std::unique_lock<std::recursive_mutex> lock;
3469 target->GetBreakpointList().GetListMutex(lock);
3470
3471 FileSpec input_spec(m_options.m_filename);
3472 FileSystem::Instance().Resolve(input_spec);
3473 BreakpointIDList new_bps;
3475 input_spec, m_options.m_names, new_bps);
3476
3477 if (!error.Success()) {
3478 result.AppendError(error.AsCString());
3479 return;
3480 }
3481
3482 Stream &output_stream = result.GetOutputStream();
3483
3484 size_t num_breakpoints = new_bps.GetSize();
3485 if (num_breakpoints == 0) {
3486 result.AppendMessage("No breakpoints added.");
3487 } else {
3488 // No breakpoint selected; show info about all currently set breakpoints.
3489 result.AppendMessage("New breakpoints:");
3490 for (size_t i = 0; i < num_breakpoints; ++i) {
3491 BreakpointID bp_id = new_bps.GetBreakpointIDAtIndex(i);
3492 Breakpoint *bp = target->GetBreakpointList()
3494 .get();
3495 if (bp)
3497 false);
3498 }
3499 }
3500 }
3501
3502private:
3504};
3505
3506// CommandObjectBreakpointWrite
3507#pragma mark Write::CommandOptions
3508#define LLDB_OPTIONS_breakpoint_write
3509#include "CommandOptions.inc"
3510
3511#pragma mark Write
3513public:
3515 : CommandObjectParsed(interpreter, "breakpoint write",
3516 "Write the breakpoints listed to a file that can "
3517 "be read in with \"breakpoint read\". "
3518 "If given no arguments, writes all breakpoints.",
3519 nullptr, eCommandAllowsDummyTarget) {
3521 }
3522
3523 ~CommandObjectBreakpointWrite() override = default;
3524
3525 void
3531
3532 Options *GetOptions() override { return &m_options; }
3533
3534 class CommandOptions : public Options {
3535 public:
3536 CommandOptions() = default;
3537
3538 ~CommandOptions() override = default;
3539
3540 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
3541 ExecutionContext *execution_context) override {
3542 Status error;
3543 const int short_option = m_getopt_table[option_idx].val;
3544
3545 switch (short_option) {
3546 case 'f':
3547 m_filename.assign(std::string(option_arg));
3548 break;
3549 case 'a':
3550 m_append = true;
3551 break;
3552 default:
3553 llvm_unreachable("Unimplemented option");
3554 }
3555
3556 return error;
3557 }
3558
3559 void OptionParsingStarting(ExecutionContext *execution_context) override {
3560 m_filename.clear();
3561 m_append = false;
3562 }
3563
3564 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
3565 return llvm::ArrayRef(g_breakpoint_write_options);
3566 }
3567
3568 // Instance variables to hold the values for command options.
3569
3570 std::string m_filename;
3571 bool m_append = false;
3572 };
3573
3574protected:
3575 void DoExecute(Args &command, CommandReturnObject &result) override {
3576 Target *target = GetTarget();
3577 assert(target && "target guaranteed by eCommandAllowsDummyTarget");
3578 std::unique_lock<std::recursive_mutex> lock;
3579 target->GetBreakpointList().GetListMutex(lock);
3580
3581 BreakpointIDList valid_bp_ids;
3582 if (!command.empty()) {
3584 command, m_exe_ctx, result, &valid_bp_ids,
3586
3587 if (!result.Succeeded()) {
3589 return;
3590 }
3591 }
3592 FileSpec file_spec(m_options.m_filename);
3593 FileSystem::Instance().Resolve(file_spec);
3594 Status error = target->SerializeBreakpointsToFile(file_spec, valid_bp_ids,
3595 m_options.m_append);
3596 if (!error.Success()) {
3597 result.AppendErrorWithFormat("error serializing breakpoints: %s",
3598 error.AsCString());
3599 }
3600 }
3601
3602private:
3604};
3605
3606#pragma mark override add
3607#define LLDB_OPTIONS_breakpoint_override_add
3608#include "CommandOptions.inc"
3609
3611public:
3613 : CommandObjectParsed(interpreter, "breakpoint override add",
3614 "Add a scripted breakpoint override resolver.",
3615 nullptr, eCommandAllowsDummyTarget),
3616 m_python_class_options("breakpoint override resolver", true, 'P') {
3617 // We're picking up all the normal options, commands and disable.
3621 m_all_options.Append(&m_options, llvm::ArrayRef<llvm::StringRef>());
3622 m_all_options.Finalize();
3623 }
3624
3626
3628 public:
3629 CommandOptions() = default;
3630
3631 ~CommandOptions() override = default;
3632
3633 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
3634 ExecutionContext *execution_context) override {
3635 Status error;
3636 const int short_option = GetDefinitions()[option_idx].short_option;
3637
3638 switch (short_option) {
3639 case 'd':
3640 m_description.assign(std::string(option_arg));
3641 break;
3642 case 'm': {
3643 uint64_t this_mask = (uint64_t)OptionArgParser::ToOptionEnum(
3644 option_arg,
3645 g_breakpoint_override_add_options[option_idx].enum_values,
3646 eResolverUnknown, error);
3647 if (error.Success())
3648 m_mask |= this_mask;
3649 } break;
3650 default:
3651 llvm_unreachable("Unimplemented option");
3652 }
3653
3654 return error;
3655 }
3656
3657 void OptionParsingStarting(ExecutionContext *execution_context) override {
3658 m_description.clear();
3659 m_mask = 0;
3660 }
3661
3662 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
3663 return llvm::ArrayRef(g_breakpoint_override_add_options);
3664 }
3665
3666 // Instance variables to hold the values for command options.
3667
3668 std::string m_description;
3669 uint64_t m_mask;
3670 };
3671 Options *GetOptions() override { return &m_all_options; }
3672
3673protected:
3674 void DoExecute(Args &command, CommandReturnObject &result) override {
3675 Target *target =
3676 m_dummy_options.m_use_dummy ? &GetDummyTarget() : GetTarget();
3677 // If no mask was provided, then the default is file and line:
3678 if (m_options.m_mask == 0)
3679 m_options.m_mask = eResolverFileAndLine;
3680 llvm::Expected<lldb::user_id_t> id = target->AddBreakpointResolverOverride(
3681 m_python_class_options.GetName(), m_options.m_mask,
3682 m_python_class_options.GetStructuredData(), m_options.m_description);
3683 if (id) {
3684 result.AppendMessageWithFormatv("{0}", *id);
3686 } else {
3687 result.AppendErrorWithFormatv("could not add resolver: {0}.",
3688 llvm::toString(id.takeError()));
3689 }
3690 }
3691
3692private:
3697};
3698
3700public:
3702 : CommandObjectParsed(interpreter, "breakpoint override delete",
3703 "Delete a scripted breakpoint override resolver.",
3704 nullptr, eCommandAllowsDummyTarget) {
3707 m_all_options.Finalize();
3708 }
3709
3711
3712 Options *GetOptions() override { return &m_all_options; }
3713
3714protected:
3715 void DoExecute(Args &command, CommandReturnObject &result) override {
3716 Target *target =
3717 m_dummy_options.m_use_dummy ? &GetDummyTarget() : GetTarget();
3718
3719 const size_t argc = command.GetArgumentCount();
3720 if (argc == 0) {
3721 if (m_interpreter.Confirm("Delete all breakpoint overrides?", false)) {
3723 }
3725 return;
3726 }
3727
3728 for (auto &entry : command.entries()) {
3729 uint64_t id;
3730 bool success;
3731 if (!entry.ref().getAsInteger(0, id))
3732 success = target->RemoveBreakpointResolverOverride(id);
3733 else {
3734 result.AppendErrorWithFormatv("Index not an integer: {0}", entry.ref());
3736 return;
3737 }
3738 if (!success) {
3739 result.AppendErrorWithFormatv("Cannot delete override: {0}", id);
3741 return;
3742 }
3743 }
3745 }
3746
3747private:
3750};
3751
3753public:
3756 interpreter, "breakpoint override list",
3757 "List the current scripted breakpoint override resolvers.", nullptr,
3758 eCommandAllowsDummyTarget) {
3761 m_all_options.Finalize();
3762 }
3763
3765
3766 Options *GetOptions() override { return &m_all_options; }
3767
3768protected:
3769 void DoExecute(Args &command, CommandReturnObject &result) override {
3770 Target *target =
3771 m_dummy_options.m_use_dummy ? &GetDummyTarget() : GetTarget();
3772
3773 const size_t argc = command.GetArgumentCount();
3774 std::vector<uint64_t> idxs;
3775 if (argc != 0) {
3776 for (auto &entry : command.entries()) {
3777 uint64_t id;
3778 if (!entry.ref().getAsInteger(0, id)) {
3779 idxs.push_back(id);
3780 } else {
3781 result.AppendErrorWithFormatv("Index not an integer: {0}",
3782 entry.ref());
3784 return;
3785 }
3786 }
3787 }
3789 result.GetOutputStream(), idxs,
3790 GetCommandInterpreter().GetDebugger().GetTerminalWidth(),
3791 GetCommandInterpreter().GetDebugger().GetUseColor());
3792
3793 if (idxs.empty()) {
3795 } else {
3797 Stream &error_strm = result.GetErrorStream();
3798 if (idxs.size() == 1) {
3799 error_strm << llvm::formatv("error: invalid index: {0}", idxs[0]);
3800 return;
3801 }
3802 error_strm << "error: invalid indices: ";
3803 auto begin = idxs.begin();
3804 error_strm << llvm::formatv("{0}", *begin);
3805 idxs.erase(begin);
3806 for (auto elem : idxs)
3807 error_strm << llvm::formatv(", {0}", elem);
3808 }
3809 }
3810
3811private:
3814};
3816public:
3819 interpreter, "override",
3820 "Commands to manage breakpoint override resolvers") {
3821
3823 R"(
3824Breakpoint override resolvers allow you to intercept breakpoint requests and
3825re-implement them using a custom breakpoint resolver. Override resolvers are
3826implemented by a scripted breakpoint resolver that implements the
3827'overrides_resolver' interface. It takes an SBStructuredData with the
3828serialized form of the original breakpoint resolver. If it returns true, then
3829the provided resolver will be substituted for the one lldb would have produced
3830by default.
3831
3832Add new override resolvers using:
3833
3834 (lldb) breakpoint override add -c class_name
3835
3836This returns the ID of the resolver you added.
3837
3838List the currently added override resolvers using:
3839
3840 (lldb) breakpoint override list
3841
3842Delete an added resolver using:
3843
3844 (lldb) breakpoint override delete <id>
3845
3846)");
3847 CommandObjectSP add_command_object(
3848 new CommandObjectBreakpointOverrideAdd(interpreter));
3849 CommandObjectSP delete_command_object(
3850 new CommandObjectBreakpointOverrideDelete(interpreter));
3851 CommandObjectSP list_command_object(
3852 new CommandObjectBreakpointOverrideList(interpreter));
3853
3854 LoadSubCommand("add", add_command_object);
3855 LoadSubCommand("delete", delete_command_object);
3856 LoadSubCommand("list", list_command_object);
3857 }
3858
3859 ~CommandObjectBreakpointOverride() override = default;
3860};
3861
3862// CommandObjectMultiwordBreakpoint
3863#pragma mark MultiwordBreakpoint
3864
3866 CommandInterpreter &interpreter)
3868 interpreter, "breakpoint",
3869 "Commands for operating on breakpoints (see 'help b' for shorthand.)",
3870 "breakpoint <subcommand> [<command-options>]") {
3871 CommandObjectSP list_command_object(
3872 new CommandObjectBreakpointList(interpreter));
3873 CommandObjectSP enable_command_object(
3874 new CommandObjectBreakpointEnable(interpreter));
3875 CommandObjectSP disable_command_object(
3876 new CommandObjectBreakpointDisable(interpreter));
3877 CommandObjectSP clear_command_object(
3878 new CommandObjectBreakpointClear(interpreter));
3879 CommandObjectSP delete_command_object(
3880 new CommandObjectBreakpointDelete(interpreter));
3881 CommandObjectSP set_command_object(
3882 new CommandObjectBreakpointSet(interpreter));
3883 CommandObjectSP add_command_object(
3884 new CommandObjectBreakpointAdd(interpreter));
3885 CommandObjectSP command_command_object(
3886 new CommandObjectBreakpointCommand(interpreter));
3887 CommandObjectSP modify_command_object(
3888 new CommandObjectBreakpointModify(interpreter));
3889 CommandObjectSP name_command_object(
3890 new CommandObjectBreakpointName(interpreter));
3891 CommandObjectSP write_command_object(
3892 new CommandObjectBreakpointWrite(interpreter));
3893 CommandObjectSP read_command_object(
3894 new CommandObjectBreakpointRead(interpreter));
3895 CommandObjectSP override_command_object(
3896 new CommandObjectBreakpointOverride(interpreter));
3897
3898 list_command_object->SetCommandName("breakpoint list");
3899 enable_command_object->SetCommandName("breakpoint enable");
3900 disable_command_object->SetCommandName("breakpoint disable");
3901 clear_command_object->SetCommandName("breakpoint clear");
3902 delete_command_object->SetCommandName("breakpoint delete");
3903 set_command_object->SetCommandName("breakpoint set");
3904 add_command_object->SetCommandName("breakpoint add");
3905 command_command_object->SetCommandName("breakpoint command");
3906 modify_command_object->SetCommandName("breakpoint modify");
3907 name_command_object->SetCommandName("breakpoint name");
3908 write_command_object->SetCommandName("breakpoint write");
3909 read_command_object->SetCommandName("breakpoint read");
3910 override_command_object->SetCommandName("breakpoint override");
3911
3912 LoadSubCommand("list", list_command_object);
3913 LoadSubCommand("enable", enable_command_object);
3914 LoadSubCommand("disable", disable_command_object);
3915 LoadSubCommand("clear", clear_command_object);
3916 LoadSubCommand("delete", delete_command_object);
3917 LoadSubCommand("set", set_command_object);
3918 LoadSubCommand("add", add_command_object);
3919 LoadSubCommand("command", command_command_object);
3920 LoadSubCommand("modify", modify_command_object);
3921 LoadSubCommand("name", name_command_object);
3922 LoadSubCommand("write", write_command_object);
3923 LoadSubCommand("read", read_command_object);
3924 LoadSubCommand("override", override_command_object);
3925}
3926
3928
3930 Args &args, const ExecutionContext &exe_ctx, bool allow_locations,
3931 CommandReturnObject &result, BreakpointIDList *valid_ids,
3932 BreakpointName::Permissions ::PermissionKinds purpose) {
3933 // args can be strings representing 1). integers (for breakpoint ids)
3934 // 2). the full breakpoint & location
3935 // canonical representation
3936 // 3). the word "to" or a hyphen,
3937 // representing a range (in which case there
3938 // had *better* be an entry both before &
3939 // after of one of the first two types.
3940 // 4). A breakpoint name
3941 // If args is empty, we will use the last created breakpoint (if there is
3942 // one.)
3943
3944 Target &target = exe_ctx.GetTargetRef();
3945 Args temp_args;
3946
3947 if (args.empty()) {
3948 if (target.GetLastCreatedBreakpoint()) {
3949 valid_ids->AddBreakpointID(BreakpointID(
3952 } else {
3953 result.AppendError(
3954 "No breakpoint specified and no last created breakpoint.");
3955 }
3956 return;
3957 }
3958
3959 // Create a new Args variable to use; copy any non-breakpoint-id-ranges stuff
3960 // directly from the old ARGS to the new TEMP_ARGS. Do not copy breakpoint
3961 // id range strings over; instead generate a list of strings for all the
3962 // breakpoint ids in the range, and shove all of those breakpoint id strings
3963 // into TEMP_ARGS.
3964
3965 if (llvm::Error err = BreakpointIDList::FindAndReplaceIDRanges(
3966 args, exe_ctx, allow_locations, purpose, temp_args)) {
3967 result.SetError(std::move(err));
3968 return;
3969 }
3971
3972 // NOW, convert the list of breakpoint id strings in TEMP_ARGS into an actual
3973 // BreakpointIDList:
3974
3975 for (llvm::StringRef temp_arg : temp_args.GetArgumentArrayRef())
3976 if (auto bp_id = BreakpointID::ParseCanonicalReference(temp_arg))
3977 valid_ids->AddBreakpointID(*bp_id);
3978
3979 // At this point, all of the breakpoint ids that the user passed in have
3980 // been converted to breakpoint IDs and put into valid_ids.
3981
3982 // Now that we've converted everything from args into a list of breakpoint
3983 // ids, go through our tentative list of breakpoint id's and verify that
3984 // they correspond to valid/currently set breakpoints.
3985
3986 const size_t count = valid_ids->GetSize();
3987 for (size_t i = 0; i < count; ++i) {
3988 BreakpointID cur_bp_id = valid_ids->GetBreakpointIDAtIndex(i);
3989 Breakpoint *breakpoint =
3990 target.GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();
3991 if (breakpoint != nullptr) {
3992 lldb::break_id_t cur_loc_id = cur_bp_id.GetLocationID();
3993 // GetLocationID returns 0 when the location isn't specified.
3994 if (cur_loc_id != 0 && !breakpoint->FindLocationByID(cur_loc_id)) {
3995 StreamString id_str;
3997 &id_str, cur_bp_id.GetBreakpointID(), cur_bp_id.GetLocationID());
3998 i = valid_ids->GetSize() + 1;
3999 result.AppendErrorWithFormat(
4000 "'%s' is not a currently valid breakpoint/location id",
4001 id_str.GetData());
4002 }
4003 } else {
4004 i = valid_ids->GetSize() + 1;
4005 result.AppendErrorWithFormat(
4006 "'%d' is not a currently valid breakpoint ID",
4007 cur_bp_id.GetBreakpointID());
4008 }
4009 }
4010}
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:83
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.
bool GetMatchingFileLine(llvm::StringRef filename, uint32_t line_number, BreakpointLocationCollection &loc_coll)
Find breakpoint locations which match the (filename, line_number) description.
static const char * GetSerializationKey()
Definition Breakpoint.h:162
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 class to manage flag bits.
Definition Debugger.h:100
bool GetUseColor() const
Definition Debugger.cpp:543
"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:56
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:485
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.
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:782
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:748
lldb::BreakpointSP GetBreakpointByID(lldb::break_id_t break_id)
Definition Target.cpp:439
BreakpointList & GetBreakpointList(bool internal=false)
Definition Target.cpp:425
SourceManager & GetSourceManager()
Definition Target.cpp:3167
lldb::user_id_t AddBreakpointResolverOverride(BreakpointResolverOverrideUP override_up)
Add a breakpoint override resolver. This version can't fail.
Definition Target.h:1071
Debugger & GetDebugger() const
Definition Target.h:1356
void AddNameToBreakpoint(BreakpointID &id, llvm::StringRef name, Status &error)
Definition Target.cpp:859
void DisableAllowedBreakpoints()
Definition Target.cpp:1188
void RemoveNameFromBreakpoint(lldb::BreakpointSP &bp_sp, llvm::StringRef name)
Definition Target.cpp:924
bool RemoveBreakpointByID(lldb::break_id_t break_id)
Definition Target.cpp:1212
void DescribeBreakpointOverrides(Stream &stream, std::vector< lldb::user_id_t > &idxs, uint32_t terminal_width, bool use_color)
Describe the breakpoint overrides.
Definition Target.cpp:991
void ClearBreakpointResolverOverrides()
Definition Target.h:1089
bool RemoveBreakpointResolverOverride(lldb::user_id_t override_id)
Definition Target.h:1084
void ConfigureBreakpointName(BreakpointName &bp_name, const BreakpointOptions &options, const BreakpointName::Permissions &permissions)
Definition Target.cpp:929
Status SerializeBreakpointsToFile(const FileSpec &file, const BreakpointIDList &bp_ids, bool append)
Definition Target.cpp:1273
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:765
void EnableAllowedBreakpoints()
Definition Target.cpp:1205
void RemoveAllowedBreakpoints()
Definition Target.cpp:1157
lldb::BreakpointSP CreateAddressInModuleBreakpoint(lldb::addr_t file_addr, bool internal, const FileSpec &file_spec, bool request_hardware)
Definition Target.cpp:599
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:510
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:493
void GetBreakpointNames(std::vector< std::string > &names)
Definition Target.cpp:951
bool IsDummyTarget() const
Definition Target.h:691
Status CreateBreakpointsFromFile(const FileSpec &file, BreakpointIDList &new_bps)
Definition Target.cpp:1365
BreakpointName * FindBreakpointName(llvm::StringRef name, bool can_create, Status &error)
Definition Target.cpp:891
lldb::BreakpointSP GetLastCreatedBreakpoint()
Definition Target.h:867
#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
BreakpointConditionMode
Modes for evaluating breakpoint conditions.
@ eBreakpointConditionModeDefault
Use the mode specified by the target.breakpoints-condition-mode setting.
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:88
@ 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:85
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)