diff --git a/cpu-exec.c b/cpu-exec.c index 191d9e4288da818edadc200a78cd16105ca41463..8d86527b80a0d30e33397038a0ce5857425a90ba 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -183,6 +183,16 @@ static inline TranslationBlock *tb_find_fast(void) return tb; } +static CPUDebugExcpHandler *debug_excp_handler; + +CPUDebugExcpHandler *cpu_set_debug_excp_handler(CPUDebugExcpHandler *handler) +{ + CPUDebugExcpHandler *old_handler = debug_excp_handler; + + debug_excp_handler = handler; + return old_handler; +} + static void cpu_handle_debug_exception(CPUState *env) { CPUWatchpoint *wp; @@ -190,6 +200,9 @@ static void cpu_handle_debug_exception(CPUState *env) if (!env->watchpoint_hit) for (wp = env->watchpoints; wp != NULL; wp = wp->next) wp->flags &= ~BP_WATCHPOINT_HIT; + + if (debug_excp_handler) + debug_excp_handler(env); } /* main execution loop */ diff --git a/exec-all.h b/exec-all.h index e3da98a7fc98cbc12dceb6bc63926410a768e9b8..aec318ba892af7028240cfb39b88324a3eb7b735 100644 --- a/exec-all.h +++ b/exec-all.h @@ -387,4 +387,8 @@ static inline int kqemu_is_ok(CPUState *env) } #endif + +typedef void (CPUDebugExcpHandler)(CPUState *env); + +CPUDebugExcpHandler *cpu_set_debug_excp_handler(CPUDebugExcpHandler *handler); #endif