aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Clayton <bclayton@google.com>2020-10-12 14:29:33 +0100
committerGitHub <noreply@github.com>2020-10-12 09:29:33 -0400
commitdcc09a1feb3cc87929103b8777fd5a0c7384236f (patch)
tree4f34ed89adac56108c1bb77ce8b305eb856da2e2 /src
parent42663e1137b5538a5c15dbee53c6aa8e07dd75eb (diff)
downloadamber-dcc09a1feb3cc87929103b8777fd5a0c7384236f.tar.gz
Debugger tests (#915)
Diffstat (limited to 'src')
-rw-r--r--src/vulkan/engine_vulkan_debugger.cc23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/vulkan/engine_vulkan_debugger.cc b/src/vulkan/engine_vulkan_debugger.cc
index 5309bca..9129b32 100644
--- a/src/vulkan/engine_vulkan_debugger.cc
+++ b/src/vulkan/engine_vulkan_debugger.cc
@@ -16,6 +16,8 @@
#if AMBER_ENABLE_VK_DEBUGGING
+#include <stdlib.h>
+
#include <chrono> // NOLINT(build/c++11)
#include <condition_variable> // NOLINT(build/c++11)
#include <fstream>
@@ -427,7 +429,7 @@ class Client {
private:
struct SourceCache {
- std::unordered_map<int, SourceLines> by_ref;
+ std::unordered_map<int64_t, SourceLines> by_ref;
std::unordered_map<std::string, SourceLines> by_path;
};
@@ -533,7 +535,7 @@ class Thread : public debug::Thread {
public:
Thread(VirtualFileStore* virtual_files,
std::shared_ptr<dap::Session> session,
- int threadId,
+ dap::integer threadId,
int lane,
std::shared_ptr<const debug::ThreadScript> script)
: virtual_files_(virtual_files),
@@ -816,10 +818,20 @@ class VkDebugger : public Engine::Debugger {
/// Connect establishes the connection to the shader debugger. Must be
/// called before any of the |debug::Events| methods.
Result Connect() {
+ auto port_str = getenv("VK_DEBUGGER_PORT");
+ if (!port_str) {
+ return Result("The environment variable VK_DEBUGGER_PORT was not set\n");
+ }
+ int port = atoi(port_str);
+ if (port == 0) {
+ return Result("Could not parse port number from VK_DEBUGGER_PORT ('" +
+ std::string(port_str) + "')");
+ }
+
constexpr int kMaxAttempts = 10;
// The socket might take a while to open - retry connecting.
for (int attempt = 0; attempt < kMaxAttempts; attempt++) {
- auto connection = dap::net::connect("localhost", 19020);
+ auto connection = dap::net::connect("localhost", port);
if (!connection) {
std::this_thread::sleep_for(std::chrono::seconds(1));
continue;
@@ -887,7 +899,8 @@ class VkDebugger : public Engine::Debugger {
return Result();
}
- return Result("Unable to connect to debugger");
+ return Result("Unable to connect to debugger on port " +
+ std::to_string(port));
}
// Flush checks that all breakpoints were hit, waits for all threads to
@@ -1117,7 +1130,7 @@ class VkDebugger : public Engine::Debugger {
std::shared_ptr<const debug::ThreadScript>,
InvocationKey::Hash>;
using ThreadVector = std::vector<std::unique_ptr<Thread>>;
- using ThreadMap = std::unordered_map<int, std::unique_ptr<Thread>>;
+ using ThreadMap = std::unordered_map<int64_t, std::unique_ptr<Thread>>;
VirtualFileStore* const virtual_files_;
std::shared_ptr<dap::Session> session_;
std::mutex threads_mutex_;