aboutsummaryrefslogtreecommitdiff
path: root/lib/xray/xray_arm.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/xray/xray_arm.cc')
-rw-r--r--lib/xray/xray_arm.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/xray/xray_arm.cc b/lib/xray/xray_arm.cc
index d89322e833e5..f5e2cd2a93c2 100644
--- a/lib/xray/xray_arm.cc
+++ b/lib/xray/xray_arm.cc
@@ -19,6 +19,8 @@
#include <atomic>
#include <cassert>
+extern "C" void __clear_cache(void* start, void* end);
+
namespace __xray {
uint64_t cycleFrequency() XRAY_NEVER_INSTRUMENT {
@@ -116,8 +118,8 @@ inline static bool patchSled(const bool Enable, const uint32_t FuncId,
// B #20
uint32_t *FirstAddress = reinterpret_cast<uint32_t *>(Sled.Address);
+ uint32_t *CurAddress = FirstAddress + 1;
if (Enable) {
- uint32_t *CurAddress = FirstAddress + 1;
CurAddress =
Write32bitLoadR0(CurAddress, reinterpret_cast<uint32_t>(FuncId));
CurAddress =
@@ -125,6 +127,7 @@ inline static bool patchSled(const bool Enable, const uint32_t FuncId,
*CurAddress = uint32_t(PatchOpcodes::PO_BlxIp);
CurAddress++;
*CurAddress = uint32_t(PatchOpcodes::PO_PopR0Lr);
+ CurAddress++;
std::atomic_store_explicit(
reinterpret_cast<std::atomic<uint32_t> *>(FirstAddress),
uint32_t(PatchOpcodes::PO_PushR0Lr), std::memory_order_release);
@@ -133,6 +136,8 @@ inline static bool patchSled(const bool Enable, const uint32_t FuncId,
reinterpret_cast<std::atomic<uint32_t> *>(FirstAddress),
uint32_t(PatchOpcodes::PO_B20), std::memory_order_release);
}
+ __clear_cache(reinterpret_cast<char*>(FirstAddress),
+ reinterpret_cast<char*>(CurAddress));
return true;
}