1313#include " OutputRedirector.h"
1414#include " RunInTerminal.h"
1515#include " Watchpoint.h"
16-
1716#include " lldb/API/SBDeclaration.h"
1817#include " lldb/API/SBInstruction.h"
1918#include " lldb/API/SBListener.h"
2019#include " lldb/API/SBMemoryRegionInfo.h"
2120#include " lldb/API/SBStream.h"
2221#include " lldb/API/SBStringList.h"
2322#include " lldb/Host/Config.h"
24-
2523#include " llvm/ADT/ArrayRef.h"
2624#include " llvm/ADT/DenseMap.h"
25+ #include " llvm/ADT/DenseSet.h"
2726#include " llvm/ADT/ScopeExit.h"
2827#include " llvm/ADT/SetVector.h"
2928#include " llvm/ADT/StringExtras.h"
3837#include " llvm/Support/Path.h"
3938#include " llvm/Support/PrettyStackTrace.h"
4039#include " llvm/Support/raw_ostream.h"
41-
40+ #include < algorithm>
41+ #include < array>
4242#include < cassert>
4343#include < climits>
4444#include < cstdarg>
4545#include < cstdio>
4646#include < cstdlib>
4747#include < cstring>
48+ #include < map>
49+ #include < memory>
4850#include < optional>
51+ #include < set>
4952#include < sys/stat.h>
5053#include < sys/types.h>
54+ #include < thread>
55+ #include < vector>
56+
5157#if defined(_WIN32)
5258// We need to #define NOMINMAX in order to skip `min()` and `max()` macro
5359// definitions that conflict with other system headers.
6874#include < sys/prctl.h>
6975#endif
7076
71- #include < algorithm>
72- #include < array>
73- #include < map>
74- #include < memory>
75- #include < set>
76- #include < thread>
77- #include < vector>
78-
7977#if defined(_WIN32)
8078#ifndef PATH_MAX
8179#define PATH_MAX MAX_PATH
@@ -2706,16 +2704,14 @@ void request_setBreakpoints(const llvm::json::Object &request) {
27062704 if (bp_obj) {
27072705 SourceBreakpoint src_bp (g_dap, *bp_obj);
27082706 request_bps.try_emplace (src_bp.line , src_bp);
2709- const auto [kv , inserted] =
2707+ const auto [iv , inserted] =
27102708 g_dap.source_breakpoints [path].try_emplace (src_bp.line , src_bp);
27112709 // We check if this breakpoint already exists to update it
2712- if (inserted) {
2713- kv->getSecond ().SetBreakpoint (path.data ());
2714- } else {
2715- kv->getSecond ().UpdateBreakpoint (src_bp);
2716- }
2717-
2718- AppendBreakpoint (&kv->getSecond (), response_breakpoints, path,
2710+ if (inserted)
2711+ iv->getSecond ().SetBreakpoint (path.data ());
2712+ else
2713+ iv->getSecond ().UpdateBreakpoint (src_bp);
2714+ AppendBreakpoint (&iv->getSecond (), response_breakpoints, path,
27192715 src_bp.line );
27202716 }
27212717 }
@@ -2803,14 +2799,14 @@ void request_setExceptionBreakpoints(const llvm::json::Object &request) {
28032799
28042800 for (const auto &value : *filters) {
28052801 const auto filter = GetAsString (value);
2806- auto exc_bp = g_dap.GetExceptionBreakpoint (std::string (filter));
2802+ auto * exc_bp = g_dap.GetExceptionBreakpoint (std::string (filter));
28072803 if (exc_bp) {
28082804 exc_bp->SetBreakpoint ();
28092805 unset_filters.erase (std::string (filter));
28102806 }
28112807 }
28122808 for (const auto &filter : unset_filters) {
2813- auto exc_bp = g_dap.GetExceptionBreakpoint (filter);
2809+ auto * exc_bp = g_dap.GetExceptionBreakpoint (filter);
28142810 if (exc_bp)
28152811 exc_bp->ClearBreakpoint ();
28162812 }
@@ -2907,22 +2903,21 @@ void request_setFunctionBreakpoints(const llvm::json::Object &request) {
29072903 // There is no call to remove function breakpoints other than calling this
29082904 // function with a smaller or empty "breakpoints" list.
29092905 const auto name_iter = g_dap.function_breakpoints .keys ();
2910- llvm::SetVector <llvm::StringRef> seen (name_iter.begin (), name_iter.end ());
2906+ llvm::DenseSet <llvm::StringRef> seen (name_iter.begin (), name_iter.end ());
29112907 for (const auto &value : *breakpoints) {
29122908 const auto *bp_obj = value.getAsObject ();
29132909 if (!bp_obj)
29142910 continue ;
29152911 FunctionBreakpoint fn_bp (g_dap, *bp_obj);
2916- const auto [kv , inserted] = g_dap.function_breakpoints .try_emplace (
2912+ const auto [it , inserted] = g_dap.function_breakpoints .try_emplace (
29172913 fn_bp.functionName , g_dap, *bp_obj);
2918- if (inserted) {
2919- kv->second .SetBreakpoint ();
2920- } else {
2921- kv->second .UpdateBreakpoint (fn_bp);
2922- }
2914+ if (inserted)
2915+ it->second .SetBreakpoint ();
2916+ else
2917+ it->second .UpdateBreakpoint (fn_bp);
29232918
2924- AppendBreakpoint (&kv ->second , response_breakpoints);
2925- seen.remove (fn_bp.functionName );
2919+ AppendBreakpoint (&it ->second , response_breakpoints);
2920+ seen.erase (fn_bp.functionName );
29262921 }
29272922
29282923 // Remove any breakpoints that are no longer in our list
@@ -3183,9 +3178,8 @@ void request_setDataBreakpoints(const llvm::json::Object &request) {
31833178 if (breakpoints) {
31843179 for (const auto &bp : *breakpoints) {
31853180 const auto *bp_obj = bp.getAsObject ();
3186- if (bp_obj) {
3181+ if (bp_obj)
31873182 watchpoints.emplace_back (g_dap, *bp_obj);
3188- }
31893183 }
31903184 }
31913185 // If two watchpoints start at the same address, the latter overwrite the
@@ -4740,7 +4734,7 @@ void request_setInstructionBreakpoints(const llvm::json::Object &request) {
47404734 // Disable any instruction breakpoints that aren't in this request.
47414735 // There is no call to remove instruction breakpoints other than calling this
47424736 // function with a smaller or empty "breakpoints" list.
4743- llvm::SetVector <lldb::addr_t > seen;
4737+ llvm::DenseSet <lldb::addr_t > seen;
47444738 for (const auto &addr : g_dap.instruction_breakpoints )
47454739 seen.insert (addr.first );
47464740
@@ -4750,15 +4744,14 @@ void request_setInstructionBreakpoints(const llvm::json::Object &request) {
47504744 continue ;
47514745 // Read instruction breakpoint request.
47524746 InstructionBreakpoint inst_bp (g_dap, *bp_obj);
4753- const auto [kv , inserted] = g_dap.instruction_breakpoints .try_emplace (
4747+ const auto [iv , inserted] = g_dap.instruction_breakpoints .try_emplace (
47544748 inst_bp.instructionAddressReference , g_dap, *bp_obj);
4755- if (inserted) {
4756- kv->second .SetBreakpoint ();
4757- } else {
4758- kv->second .UpdateBreakpoint (inst_bp);
4759- }
4760- AppendBreakpoint (&kv->second , response_breakpoints);
4761- seen.remove (inst_bp.instructionAddressReference );
4749+ if (inserted)
4750+ iv->second .SetBreakpoint ();
4751+ else
4752+ iv->second .UpdateBreakpoint (inst_bp);
4753+ AppendBreakpoint (&iv->second , response_breakpoints);
4754+ seen.erase (inst_bp.instructionAddressReference );
47624755 }
47634756
47644757 for (const auto &addr : seen) {
0 commit comments