From 3fce9f6fdd27925307b4693683a4f6660b8c4841 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sat, 5 Nov 2022 10:26:34 +0100 Subject: [PATCH] Enable branch tracing for hardware breakpoints --- src/common/utils/hardware_breakpoint.cpp | 11 +++++++++++ src/common/utils/hardware_breakpoint.hpp | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/src/common/utils/hardware_breakpoint.cpp b/src/common/utils/hardware_breakpoint.cpp index 6a5e39f9..8d39d7fc 100644 --- a/src/common/utils/hardware_breakpoint.cpp +++ b/src/common/utils/hardware_breakpoint.cpp @@ -89,6 +89,17 @@ namespace utils::hardware_breakpoint } } + void set_branch_tracing(const bool enabled, CONTEXT& context) + { + set_bits(context.Dr7, 8, 1, enabled ? 1 : 0); + } + + void set_branch_tracing(const bool enabled, const uint32_t thread_id) + { + debug_context context(thread_id); + set_branch_tracing(enabled, context); + } + uint32_t activate(const uint64_t address, uint32_t length, const condition cond, CONTEXT& context) { const auto index = find_free_index(context); diff --git a/src/common/utils/hardware_breakpoint.hpp b/src/common/utils/hardware_breakpoint.hpp index e37fdea0..0e66f77a 100644 --- a/src/common/utils/hardware_breakpoint.hpp +++ b/src/common/utils/hardware_breakpoint.hpp @@ -11,6 +11,10 @@ namespace utils::hardware_breakpoint read_write = 3 }; + + void set_branch_tracing(bool enabled, CONTEXT& context); + void set_branch_tracing(bool enabled, uint32_t thread_id = GetCurrentThreadId()); + uint32_t activate(uint64_t address, uint32_t length, condition cond, CONTEXT& context); uint32_t activate(void* address, uint32_t length, condition cond, uint32_t thread_id = GetCurrentThreadId()); uint32_t activate(uint64_t address, uint32_t length, condition cond, uint32_t thread_id = GetCurrentThreadId());