[Lldb-commits] [lldb] [lldb-dap] Refactoring breakpoints to not use the `g_dap` reference. (PR #115208)
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Thu Nov 7 01:13:46 PST 2024
================
@@ -2701,28 +2702,21 @@ void request_setBreakpoints(const llvm::json::Object &request) {
// to an empty array.
if (breakpoints) {
for (const auto &bp : *breakpoints) {
- auto bp_obj = bp.getAsObject();
+ const auto *bp_obj = bp.getAsObject();
if (bp_obj) {
- SourceBreakpoint src_bp(*bp_obj);
- request_bps[src_bp.line] = src_bp;
-
+ SourceBreakpoint src_bp(g_dap, *bp_obj);
+ request_bps.try_emplace(src_bp.line, src_bp);
+ const auto [kv, inserted] =
+ g_dap.source_breakpoints[path].try_emplace(src_bp.line, src_bp);
// We check if this breakpoint already exists to update it
- auto existing_source_bps = g_dap.source_breakpoints.find(path);
- if (existing_source_bps != g_dap.source_breakpoints.end()) {
- const auto &existing_bp =
- existing_source_bps->second.find(src_bp.line);
- if (existing_bp != existing_source_bps->second.end()) {
- existing_bp->second.UpdateBreakpoint(src_bp);
- AppendBreakpoint(&existing_bp->second, response_breakpoints, path,
- src_bp.line);
- continue;
- }
+ if (inserted) {
+ kv->getSecond().SetBreakpoint(path.data());
+ } else {
+ kv->getSecond().UpdateBreakpoint(src_bp);
}
----------------
labath wrote:
```suggestion
if (inserted)
kv->getSecond().SetBreakpoint(path.data());
else
kv->getSecond().UpdateBreakpoint(src_bp);
```
We don't use braces on statements that fit on a single line. https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements
https://github.com/llvm/llvm-project/pull/115208
More information about the lldb-commits
mailing list