Vulkan/Debug: Don't accumulate function breakpoints
A `SetFunctionBreakpointsRequest` contains the full list of breakpoints. Clear the list in the context before adding the new list.
Also add a `getFunctionBreakpoints()` accessor so you can enumerate the list of function breakpoints.
Bug: b/145351270
Change-Id: Ia7fad403eace7a95a15671e2ce90b8e083da3ce7
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/48694
Tested-by: Ben Clayton <bclayton@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
diff --git a/src/Vulkan/Debug/Context.cpp b/src/Vulkan/Debug/Context.cpp
index b311e2f..2a9916e 100644
--- a/src/Vulkan/Debug/Context.cpp
+++ b/src/Vulkan/Debug/Context.cpp
@@ -399,6 +399,11 @@
return ctx->variables.get(id);
}
+void Context::Lock::clearFunctionBreakpoints()
+{
+ ctx->functionBreakpoints.clear();
+}
+
void Context::Lock::addFunctionBreakpoint(const std::string &name)
{
ctx->functionBreakpoints.emplace(name);
@@ -414,5 +419,10 @@
return ctx->functionBreakpoints.count(name) > 0;
}
+std::unordered_set<std::string> Context::Lock::getFunctionBreakpoints()
+{
+ return ctx->functionBreakpoints;
+}
+
} // namespace dbg
} // namespace vk
diff --git a/src/Vulkan/Debug/Context.hpp b/src/Vulkan/Debug/Context.hpp
index 64e7e55..acc3ea2 100644
--- a/src/Vulkan/Debug/Context.hpp
+++ b/src/Vulkan/Debug/Context.hpp
@@ -19,6 +19,7 @@
#include <memory>
#include <string>
+#include <unordered_set>
#include <vector>
namespace vk {
@@ -118,6 +119,9 @@
// references.
std::shared_ptr<Variables> get(ID<Variables>);
+ // clearFunctionBreakpoints() removes all function breakpoints.
+ void clearFunctionBreakpoints();
+
// addFunctionBreakpoint() adds a breakpoint to the start of the
// function with the given name.
void addFunctionBreakpoint(const std::string &name);
@@ -131,6 +135,9 @@
// name has a function breakpoint set.
bool isFunctionBreakpoint(const std::string &name);
+ // getFunctionBreakpoints() returns all the set function breakpoints.
+ std::unordered_set<std::string> getFunctionBreakpoints();
+
private:
Lock(const Lock &) = delete;
Lock &operator=(const Lock &) = delete;
diff --git a/src/Vulkan/Debug/Server.cpp b/src/Vulkan/Debug/Server.cpp
index 9dd05ce..b89a79d 100644
--- a/src/Vulkan/Debug/Server.cpp
+++ b/src/Vulkan/Debug/Server.cpp
@@ -115,6 +115,7 @@
}
{
auto lock = ctx->lock();
+ lock.clearFunctionBreakpoints();
for(auto const &reqBP : req.breakpoints)
{
lock.addFunctionBreakpoint(reqBP.name.c_str());