While gdb doesn't care either way, it seems more correct to report the address of the watchpoint hit, rather than the beginning of the watchpoint region.
Adjust all virtualization hosts which construct a dummy CPUWatchpoint structure. Signed-off-by: Richard Henderson <[email protected]> --- gdbstub/system.c | 4 ++-- target/arm/hvf/hvf.c | 1 + target/arm/kvm.c | 1 + target/i386/kvm/kvm.c | 4 ++-- target/ppc/kvm.c | 4 ++-- target/s390x/kvm/kvm.c | 2 +- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/gdbstub/system.c b/gdbstub/system.c index 724fd24c00..b36e957b95 100644 --- a/gdbstub/system.c +++ b/gdbstub/system.c @@ -166,10 +166,10 @@ static void gdb_vm_state_change(void *opaque, bool running, RunState state) } trace_gdbstub_hit_watchpoint(type, gdb_get_cpu_index(cpu), - cpu->watchpoint_hit->vaddr); + cpu->watchpoint_hit->hitaddr); g_string_printf(buf, "T%02xthread:%s;%swatch:%" VADDR_PRIx ";", GDB_SIGNAL_TRAP, tid->str, type, - cpu->watchpoint_hit->vaddr); + cpu->watchpoint_hit->hitaddr); cpu->watchpoint_hit = NULL; goto send_packet; } else { diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index da3ec521fc..70edb2f219 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -2375,6 +2375,7 @@ static int hvf_handle_exception(CPUState *cpu, hv_vcpu_exit_exception_t *excp) if (!wp) { error_report("EXCP_DEBUG but unknown hw watchpoint"); } + wp->hitaddr = excp->virtual_address; cpu->watchpoint_hit = wp; break; } diff --git a/target/arm/kvm.c b/target/arm/kvm.c index d40a6a9859..ebe4ecbb77 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -1519,6 +1519,7 @@ static bool kvm_arm_handle_debug(ARMCPU *cpu, { CPUWatchpoint *wp = find_hw_watchpoint(cs, debug_exit->far); if (wp) { + wp->hitaddr = debug_exit->far; cs->watchpoint_hit = wp; return true; } diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 8161831de2..51ff5cd767 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -6264,13 +6264,13 @@ static int kvm_handle_debug(X86CPU *cpu, case 0x1: ret = EXCP_DEBUG; cs->watchpoint_hit = &hw_watchpoint; - hw_watchpoint.vaddr = hw_breakpoint[n].addr; + hw_watchpoint.hitaddr = hw_breakpoint[n].addr; hw_watchpoint.flags = BP_MEM_WRITE; break; case 0x3: ret = EXCP_DEBUG; cs->watchpoint_hit = &hw_watchpoint; - hw_watchpoint.vaddr = hw_breakpoint[n].addr; + hw_watchpoint.hitaddr = hw_breakpoint[n].addr; hw_watchpoint.flags = BP_MEM_ACCESS; break; } diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 1a093e1f83..2a98ed89c8 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -1589,11 +1589,11 @@ static int kvm_handle_hw_breakpoint(CPUState *cs, KVMPPC_DEBUG_WATCH_WRITE)) { BreakpointFlags flag = 0; - n = find_hw_watchpoint(arch_info->address, &flag); + n = find_hw_watchpoint(arch_info->address, &flag); if (n >= 0) { handle = DEBUG_RETURN_GDB; cs->watchpoint_hit = &hw_watchpoint; - hw_watchpoint.vaddr = hw_debug_points[n].addr; + hw_watchpoint.hitaddr = arch_info->address; hw_watchpoint.flags = flag; } } diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index 6f7f75f601..89e90a84ec 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -1864,7 +1864,7 @@ static int kvm_arch_handle_debug_exit(S390CPU *cpu) case KVM_HW_WP_WRITE: if (find_hw_breakpoint(arch_info->addr, -1, arch_info->type)) { cs->watchpoint_hit = &hw_watchpoint; - hw_watchpoint.vaddr = arch_info->addr; + hw_watchpoint.hitaddr = arch_info->addr; hw_watchpoint.flags = BP_MEM_WRITE; ret = EXCP_DEBUG; } -- 2.43.0
