From 28d02149f5e61052844e253cad1e2ee408eb2fcf Mon Sep 17 00:00:00 2001 From: RavaliYatham Date: Fri, 21 May 2021 10:11:02 -0700 Subject: [PATCH] Get hashCode from JLM Fixes: #56 Signed-off-by: Ravali Yatham --- perf-tool/src/agentOptions.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/perf-tool/src/agentOptions.cpp b/perf-tool/src/agentOptions.cpp index b6510a6..3000590 100644 --- a/perf-tool/src/agentOptions.cpp +++ b/perf-tool/src/agentOptions.cpp @@ -332,6 +332,8 @@ void modifyJLM(const std::string& function, const std::string& command) auto javaMonitors = json::array(); auto rawMonitors = json::array(); char *crt = dump->begin + dumpOffset; + char str[32]; + jint hash; while(crt < dump->end) { if ((*crt) & (JVMTI_MONITOR_JAVA | JVMTI_MONITOR_RAW)) @@ -360,6 +362,10 @@ void modifyJLM(const std::string& function, const std::string& command) crt += sizeof(uint64_t); jMon["monitorName"] = crt; crt += strlen(crt) + 1; + hash = h2n.convert(*(uint32_t*)crt); + sprintf(str, "0x%x", hash); + jMon["monitorHash"] = str; + crt += sizeof(uint32_t); if (monType & JVMTI_MONITOR_JAVA) javaMonitors.push_back(jMon); else @@ -369,7 +375,7 @@ void modifyJLM(const std::string& function, const std::string& command) { int monNameDistance = 2*sizeof(char) + 5*sizeof(uint32_t) + 2*sizeof(uint64_t); char *monName = crt + monNameDistance; - crt += monNameDistance + strlen(monName) + 1; + crt += monNameDistance + strlen(monName) + 1 + sizeof(uint32_t); } } jvmti->Deallocate((unsigned char*)dump);