@@ -233,7 +233,6 @@ struct DAP {
233
233
// / @}
234
234
235
235
ExceptionBreakpoint *GetExceptionBreakpoint (const std::string &filter);
236
- ExceptionBreakpoint *GetExceptionBreakpoint (const lldb::break_id_t bp_id);
237
236
238
237
// / Redirect stdout and stderr fo the IDE's console output.
239
238
// /
@@ -392,11 +391,20 @@ struct DAP {
392
391
393
392
void SetThreadFormat (llvm::StringRef format);
394
393
394
+ // Check to see if we have hit the <BreakpointType> breakpoint and return the
395
+ // last breakpoint. but only do so if all breakpoints that were hit are of
396
+ // <BreakpointType>.
397
+ // Caller uses this to set the reason accordingly. i.e. If all the breakpoints
398
+ // are exception breakpoints then reason is 'exception'; if all the
399
+ // breakpoints are function breakpoints then reason is 'function breakpoint';
400
+ // if all the breakpoints are instruction breakpoints then reason =
401
+ // 'instruction breakpoint'; if there are combination of one more breakpoints,
402
+ // then the reason will be 'breakpoint'.
395
403
template <typename BreakpointType>
396
404
BreakpointType *GetBreakpointFromStopReason (lldb::SBThread &thread) {
397
- // Check to see if have hit the <BreakpointType> breakpoint and change the
398
- // reason accordingly, but only do so if all breakpoints that were
399
- // hit are of <BreakpointType>.
405
+ // Check to see if we have hit the <BreakpointType> breakpoint and change
406
+ // the reason accordingly, but only do so if all breakpoints that were hit
407
+ // are of <BreakpointType>.
400
408
const auto num = thread.GetStopReasonDataCount ();
401
409
BreakpointType *bp = nullptr ;
402
410
for (size_t i = 0 ; i < num; i += 2 ) {
@@ -416,47 +424,31 @@ struct DAP {
416
424
template <>
417
425
FunctionBreakpoint *
418
426
GetBreakpoint<FunctionBreakpoint>(const lldb::break_id_t bp_id) {
419
- for (auto &bp : function_breakpoints) {
420
- if (bp.second .bp .GetID () == bp_id)
421
- return &bp.second ;
422
- }
423
- return nullptr ;
427
+ auto it = std::find_if (
428
+ function_breakpoints.begin (), function_breakpoints.end (),
429
+ [bp_id](const auto &bp) { return bp.second .bp .GetID () == bp_id; });
430
+ return it != function_breakpoints.end () ? &it->second : nullptr ;
424
431
}
425
432
426
433
template <>
427
434
InstructionBreakpoint *
428
435
GetBreakpoint<InstructionBreakpoint>(const lldb::break_id_t bp_id) {
429
- for (auto &bp : instruction_breakpoints) {
430
- if (bp.second .bp .GetID () == bp_id)
431
- return &bp.second ;
432
- }
433
- return nullptr ;
436
+ auto it = std::find_if (
437
+ instruction_breakpoints.begin (), instruction_breakpoints.end (),
438
+ [bp_id](const auto &bp) { return bp.second .bp .GetID () == bp_id; });
439
+ return it != instruction_breakpoints.end () ? &it->second : nullptr ;
434
440
}
435
441
436
442
template <>
437
443
ExceptionBreakpoint *
438
444
GetBreakpoint<ExceptionBreakpoint>(const lldb::break_id_t bp_id) {
439
- // See comment in the other GetExceptionBreakpoint().
440
445
PopulateExceptionBreakpoints ();
441
446
442
- for (auto &bp : *exception_breakpoints) {
443
- if (bp.bp .GetID () == bp_id)
444
- return &bp;
445
- }
446
- return nullptr ;
447
+ auto it = std::find_if (
448
+ exception_breakpoints->begin (), exception_breakpoints->end (),
449
+ [bp_id](const auto &bp) { return bp.bp .GetID () == bp_id; });
450
+ return it != exception_breakpoints->end () ? &*it : nullptr ;
447
451
}
448
-
449
- FunctionBreakpoint *GetFunctionBPFromStopReason (lldb::SBThread &thread);
450
-
451
- FunctionBreakpoint *GetFunctionBreakPoint (const lldb::break_id_t bp_id);
452
-
453
- void WaitWorkerThreadsToExit ();
454
-
455
- private:
456
- // Send the JSON in "json_str" to the "out" stream. Correctly send the
457
- // "Content-Length:" field followed by the length, followed by the raw
458
- // JSON bytes.
459
- void SendJSON (const std::string &json_str);
460
452
};
461
453
462
454
} // namespace lldb_dap
0 commit comments