summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBen McMorran <bemcmorr@microsoft.com>2023-07-12 18:25:12 (GMT)
committerBrad King <brad.king@kitware.com>2023-07-13 12:44:52 (GMT)
commit60b6383993013e720092025032a5844caac03111 (patch)
treebffca6b3e487e18b8df4ec2283ffe532ad4f651c /Source
parentd769c59d783f0ffc46d61bb4715b5fb3a68181a8 (diff)
downloadCMake-60b6383993013e720092025032a5844caac03111.zip
CMake-60b6383993013e720092025032a5844caac03111.tar.gz
CMake-60b6383993013e720092025032a5844caac03111.tar.bz2
Debugger: Always clear existing breakpoints on setBreakpoints
Fixes: #25063
Diffstat (limited to 'Source')
-rw-r--r--Source/cmDebuggerBreakpointManager.cxx21
-rw-r--r--Source/cmDebuggerBreakpointManager.h2
2 files changed, 18 insertions, 5 deletions
diff --git a/Source/cmDebuggerBreakpointManager.cxx b/Source/cmDebuggerBreakpointManager.cxx
index 152f0f5..4ae6728 100644
--- a/Source/cmDebuggerBreakpointManager.cxx
+++ b/Source/cmDebuggerBreakpointManager.cxx
@@ -6,6 +6,7 @@
#include <cstddef>
#include <cstdint>
#include <memory>
+#include <utility>
#include <cm3p/cppdap/optional.h>
#include <cm3p/cppdap/session.h>
@@ -78,12 +79,14 @@ cmDebuggerBreakpointManager::HandleSetBreakpointsRequest(
cmSystemTools::GetActualCaseForPath(request.source.path.value());
const dap::array<dap::SourceBreakpoint> defaultValue{};
const auto& breakpoints = request.breakpoints.value(defaultValue);
+
+ if (Breakpoints.find(sourcePath) != Breakpoints.end()) {
+ Breakpoints[sourcePath].clear();
+ }
+ response.breakpoints.resize(breakpoints.size());
+
if (ListFileFunctionLines.find(sourcePath) != ListFileFunctionLines.end()) {
// The file has loaded, we can validate breakpoints.
- if (Breakpoints.find(sourcePath) != Breakpoints.end()) {
- Breakpoints[sourcePath].clear();
- }
- response.breakpoints.resize(breakpoints.size());
for (size_t i = 0; i < breakpoints.size(); i++) {
int64_t correctedLine =
CalibrateBreakpointLine(sourcePath, breakpoints[i].line);
@@ -106,7 +109,6 @@ cmDebuggerBreakpointManager::HandleSetBreakpointsRequest(
// The file has not loaded, validate breakpoints later.
ListFilePendingValidations.emplace(sourcePath);
- response.breakpoints.resize(breakpoints.size());
for (size_t i = 0; i < breakpoints.size(); i++) {
Breakpoints[sourcePath].emplace_back(NextBreakpointId++,
breakpoints[i].line);
@@ -191,6 +193,15 @@ std::vector<int64_t> cmDebuggerBreakpointManager::GetBreakpoints(
return breakpoints;
}
+size_t cmDebuggerBreakpointManager::GetBreakpointCount() const
+{
+ size_t count = 0;
+ for (auto const& pair : Breakpoints) {
+ count += pair.second.size();
+ }
+ return count;
+}
+
void cmDebuggerBreakpointManager::ClearAll()
{
std::unique_lock<std::mutex> lock(Mutex);
diff --git a/Source/cmDebuggerBreakpointManager.h b/Source/cmDebuggerBreakpointManager.h
index a4e5df5..747722f 100644
--- a/Source/cmDebuggerBreakpointManager.h
+++ b/Source/cmDebuggerBreakpointManager.h
@@ -4,6 +4,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
+#include <cstddef>
#include <cstdint>
#include <mutex>
#include <string>
@@ -55,6 +56,7 @@ public:
std::vector<cmListFileFunction> const& functions);
std::vector<int64_t> GetBreakpoints(std::string const& sourcePath,
int64_t line);
+ size_t GetBreakpointCount() const;
void ClearAll();
};