From 3fc89b371766de464d41c262be2c52115e3e37e0 Mon Sep 17 00:00:00 2001 From: Charlie Birks Date: Wed, 9 Oct 2019 13:04:34 +0100 Subject: [PATCH] Replace GetLocalVariable with GetLocalVariables --- renderdoc/android/jdwp.cpp | 26 ++++++++++++++++++++------ renderdoc/android/jdwp.h | 6 ++---- renderdoc/android/jdwp_connection.cpp | 11 +++-------- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/renderdoc/android/jdwp.cpp b/renderdoc/android/jdwp.cpp index a3f02f6d4..6c175761f 100644 --- a/renderdoc/android/jdwp.cpp +++ b/renderdoc/android/jdwp.cpp @@ -213,16 +213,30 @@ bool InjectLibraries(const std::string &deviceID, Network::Socket *sock) if(vulkanLoaderMethod) { - int32_t slotIdx = - conn.GetLocalVariable(vulkanLoaderClass, vulkanLoaderMethod, "librarySearchPath"); + std::vector slots = conn.GetLocalVariables(vulkanLoaderClass, vulkanLoaderMethod); + + int32_t slotIdx = -1; + + for(const VariableSlot &s : slots) + { + if(s.name == "librarySearchPath") + { + slotIdx = s.slot; + break; + } + } // Android 9 doesn't return names and changed how slots are indexed, try an offset from this if(slotIdx == -1) { - slotIdx = conn.GetLocalVariable(vulkanLoaderClass, vulkanLoaderMethod, "this"); - - if(slotIdx != -1) - slotIdx += 4; + for(const VariableSlot &s : slots) + { + if(s.name == "this") + { + slotIdx = s.slot + 4; + break; + } + } } // as a default, use the 4th slot as it's the 4th argument argument (0 is this), if symbols diff --git a/renderdoc/android/jdwp.h b/renderdoc/android/jdwp.h index a64d16c93..0ccd53351 100644 --- a/renderdoc/android/jdwp.h +++ b/renderdoc/android/jdwp.h @@ -516,10 +516,8 @@ public: methodID GetMethod(referenceTypeID type, const std::string &name, const std::string &signature = "", referenceTypeID *methClass = NULL); - // get a local variable slot. If signature is empty, it's ignored for matching. Returns -1 if not - // found - int32_t GetLocalVariable(referenceTypeID type, methodID method, const std::string &name, - const std::string &signature = ""); + // get local variable slots + std::vector GetLocalVariables(referenceTypeID type, methodID method); // get a thread's stack frames std::vector GetCallStack(threadID thread); diff --git a/renderdoc/android/jdwp_connection.cpp b/renderdoc/android/jdwp_connection.cpp index 38bce83e1..a38668702 100644 --- a/renderdoc/android/jdwp_connection.cpp +++ b/renderdoc/android/jdwp_connection.cpp @@ -267,14 +267,13 @@ methodID Connection::GetMethod(referenceTypeID type, const std::string &name, return {}; } -int32_t Connection::GetLocalVariable(referenceTypeID type, methodID method, const std::string &name, - const std::string &signature) +std::vector Connection::GetLocalVariables(referenceTypeID type, methodID method) { Command cmd(CommandSet::Method, 2); cmd.GetData().Write(type).Write(method); if(!SendReceive(cmd)) - return -1; + return {}; int32_t argumentCount = 0; std::vector slots; @@ -286,11 +285,7 @@ int32_t Connection::GetLocalVariable(referenceTypeID type, methodID method, cons }); data.Done(); - for(const VariableSlot &s : slots) - if(s.name == name && (signature == "" || signature == s.signature)) - return s.slot; - - return -1; + return slots; } fieldID Connection::GetField(referenceTypeID type, const std::string &name,