72 Args &old_args,
Target *target,
bool allow_locations,
73 BreakpointName::Permissions ::PermissionKinds purpose,
Args &new_args) {
74 llvm::StringRef range_from;
75 llvm::StringRef range_to;
76 llvm::StringRef current_arg;
77 std::set<std::string> names_found;
79 for (
size_t i = 0; i < old_args.
size(); ++i) {
80 bool is_range =
false;
82 current_arg = old_args[i].ref();
83 if (!allow_locations && current_arg.contains(
'.')) {
85 return llvm::createStringError(
86 llvm::inconvertibleErrorCode(),
87 "Breakpoint locations not allowed, saw location: %s.",
88 current_arg.str().c_str());
93 std::tie(range_from, range_to) =
95 if (!range_from.empty() && !range_to.empty()) {
98 if (!
error.Success()) {
100 return llvm::createStringError(llvm::inconvertibleErrorCode(),
103 names_found.insert(std::string(current_arg));
104 }
else if ((i + 2 < old_args.
size()) &&
108 range_from = current_arg;
109 range_to = old_args[i + 2].ref();
114 llvm::StringRef tmp_str = old_args[i].ref();
115 auto [prefix, suffix] = tmp_str.split(
'.');
122 if (!breakpoint_sp) {
124 return llvm::createStringError(llvm::inconvertibleErrorCode(),
125 "'%d' is not a valid breakpoint ID.\n",
126 bp_id->GetBreakpointID());
128 const size_t num_locations = breakpoint_sp->GetNumLocations();
129 for (
size_t j = 0; j < num_locations; ++j) {
131 breakpoint_sp->GetLocationAtIndex(j).get();
134 &canonical_id_str, bp_id->GetBreakpointID(), bp_loc->
GetID());
151 return llvm::createStringError(llvm::inconvertibleErrorCode(),
152 "'%s' is not a valid breakpoint ID.\n",
153 range_from.str().c_str());
159 return llvm::createStringError(llvm::inconvertibleErrorCode(),
160 "'%s' is not a valid breakpoint ID.\n",
161 range_to.str().c_str());
163 break_id_t start_bp_id = start_bp->GetBreakpointID();
164 break_id_t start_loc_id = start_bp->GetLocationID();
165 break_id_t end_bp_id = end_bp->GetBreakpointID();
166 break_id_t end_loc_id = end_bp->GetLocationID();
172 return llvm::createStringError(llvm::inconvertibleErrorCode(),
173 "Invalid breakpoint id range: Either "
174 "both ends of range must specify"
175 " a breakpoint location, or neither can "
176 "specify a breakpoint location.");
190 if (start_bp_id != end_bp_id) {
192 return llvm::createStringError(
193 llvm::inconvertibleErrorCode(),
194 "Invalid range: Ranges that specify particular breakpoint "
196 " must be within the same major breakpoint; you specified two"
197 " different major breakpoints, %d and %d.\n",
198 start_bp_id, end_bp_id);
203 const size_t num_breakpoints = breakpoints.
GetSize();
204 for (
size_t j = 0; j < num_breakpoints; ++j) {
208 if ((cur_bp_id < start_bp_id) || (cur_bp_id > end_bp_id))
213 if ((cur_bp_id == start_bp_id) &&
215 for (
size_t k = 0; k < num_locations; ++k) {
217 if ((bp_loc->
GetID() >= start_loc_id) &&
218 (bp_loc->
GetID() <= end_loc_id)) {
225 }
else if ((cur_bp_id == end_bp_id) &&
227 for (
size_t k = 0; k < num_locations; ++k) {
229 if (bp_loc->
GetID() <= end_loc_id) {
246 if (target && !names_found.empty()) {
249 auto iter = names_found.begin();
250 while (iter != names_found.end()) {
255 iter = names_found.erase(iter);
260 if (!names_found.empty()) {
262 for (
const std::string &name : names_found) {
263 if (bkpt_sp->MatchesName(name.c_str())) {
273 return llvm::Error::success();