Skip to content

Commit

Permalink
Log a message when the breakpoint handler is successfully hooked by t…
Browse files Browse the repository at this point in the history
…he 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)
  • Loading branch information
ergo720 committed Dec 8, 2023
1 parent 1e99b39 commit 6969c50
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib86cpu/dbg/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<hook_t>(&dbg_exp_handler));
hook_add(cpu_ctx->cpu, cpu_ctx->cpu->db_addr, reinterpret_cast<hook_t>(&dbg_exp_handler));
uint8_t status = (hook_add(cpu_ctx->cpu, cpu_ctx->cpu->bp_addr, reinterpret_cast<hook_t>(&dbg_exp_handler)) == lc86_status::success);
status &= (hook_add(cpu_ctx->cpu, cpu_ctx->cpu->db_addr, reinterpret_cast<hook_t>(&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<std::pair<addr_t, std::string>>
Expand Down

0 comments on commit 6969c50

Please sign in to comment.