From 6969c5019ad1aba2010b9aa86f5e008d3e215bcf Mon Sep 17 00:00:00 2001 From: ergo720 <45463469+ergo720@users.noreply.github.com> Date: Fri, 8 Dec 2023 14:45:52 +0100 Subject: [PATCH] Log a message when the breakpoint handler is successfully hooked by the debugger Otherwise, users might think that breakpoints won't work if the first hook attempt failed (e.g. when the guest has yet to initialize the IDT) --- lib86cpu/dbg/debugger.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib86cpu/dbg/debugger.cpp b/lib86cpu/dbg/debugger.cpp index 6554b35..6325c05 100644 --- a/lib86cpu/dbg/debugger.cpp +++ b/lib86cpu/dbg/debugger.cpp @@ -305,8 +305,15 @@ dbg_add_exp_hook(cpu_ctx_t *cpu_ctx) return; } - hook_add(cpu_ctx->cpu, cpu_ctx->cpu->bp_addr, reinterpret_cast(&dbg_exp_handler)); - hook_add(cpu_ctx->cpu, cpu_ctx->cpu->db_addr, reinterpret_cast(&dbg_exp_handler)); + uint8_t status = (hook_add(cpu_ctx->cpu, cpu_ctx->cpu->bp_addr, reinterpret_cast(&dbg_exp_handler)) == lc86_status::success); + status &= (hook_add(cpu_ctx->cpu, cpu_ctx->cpu->db_addr, reinterpret_cast(&dbg_exp_handler)) == lc86_status::success); + + if (status) { + LOG(log_level::info, "Successfully installed hook for the exception handler"); + } + else { + LOG(log_level::warn, "Failed to install hook for the exception handler: hook_add failed"); + } } static std::vector>