This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA v2] (x86) Fix watchpoint using hardware breakpoint for some distro
Hello,
Earlier you said that TRAP_HWBKPT was the only case that was different
from current kernels, but turns out that's not accurate. And now
I'm left wondering what do those kernels report for the other cases
you haven't confirmed yet, like hw breakpoints, software breakpoints,
and regular single steps. We need a complete picture to figure out
what the best fix is.
Here's a more complete picture:
Ubuntu 16.04
| what | si_code | value |
|------------------------------------------+-------------|-------|
| software breakpoints (int3) | SI_KERNEL | 0x80 |
| single-steps | TRAP_TRACE | 2 |
| single-stepping a syscall | TRAP_BRKPT | 1 |
| user sent SIGTRAP | 0 | 0 |
| exec SIGTRAP (when no PTRACE_EVENT_EXEC) | 0 | 0 |
| hardware breakpoints/watchpoints | TRAP_HWBKPT | 4 |
CentOs 5.11
| what | si_code | value |
|------------------------------------------+-------------|-------|
| software breakpoints (int3) | SI_KERNEL | 0x80 |
| single-steps | TRAP_TRACE | 2 |
| single-stepping a syscall | TRAP_BRKPT | 1 |
| user sent SIGTRAP | 0 | 0 |
| exec SIGTRAP (when no PTRACE_EVENT_EXEC) | 0 | 0 |
| hardware breakpoints/watchpoints | TRAP_HWBKPT | 1 |
E.g., if hw breakpoints and watchpoints report the same si_code,
how do hw breakpoints work with your patch?
In handle_signal_stop function, there's a check done in order to see if
there's a breakpoint/watchpoint/catchpoint/etc which handle this stop
event and check if there's a breakpoint/watchpoint/catchpoint where the
inferior is stopped:
/* See if there is a breakpoint/watchpoint/catchpoint/etc. that
handles this event. */
ecs->event_thread->control.stop_bpstat
= bpstat_stop_status (get_current_regcache ()->aspace (),
stop_pc, ecs->ptid, &ecs->ws);
Do you think that having a fix handling both cases in save_stop_reason
would be better (hardware breakpoint & watchpoint) ?
else
{
if (hardware_breakpoint_inserted_here_p (regcache->aspace
(), pc))
lp->stop_reason = TARGET_STOPPED_BY_HW_BREAKPOINT;
else
check_stopped_by_watchpoint (lp);
}
Rather than my initial proposal:
else
{
check_stopped_by_watchpoint (lp);
}
Regards
Thanks,
Pedro Alves