Re: [RFC] GDB patches for hw watchpoints

Daniel Jacobowitz
2005-09-18T01:20:54Z

On Wed, Aug 17, 2005 at 12:27:46PM -0500, Manoj Iyer wrote:
>
> I am submitting this patch on behalf of Ben Elliston <bje@au1.ibm.com>,
> this patch implements hardware watchpoints on PPC platform. Please review
> and comment, so I can commit.
>
> 2005-05-04 Ben Elliston <bje@au.ibm.com>
>
> * config/powerpc/nm-linux.h
> (HAVE_NONSTEPPABLE_WATCHPOINT): Define.
> (TARGET_REGION_OK_FOR_HW_WATCHPOINT): Likewise.
> (TARGET_CAN_USE_HARDWARE_WATCHPOINT): Likewise.
> (STOPPED_BY_WATCHPOINT): Likewise.
> (target_insert_watchpoint): Likewise.
> (target_remove_watchpoint): Likewise.
> (ppc_linux_insert_watchpoint): Declare.
> (ppc_linux_remove_watchpoint): Likewise.
> * ppc-linux-nat.c (PTRACE_GET_DEBUGREG): Define, if not already.
> (PTRACE_SET_DEBUGREG): Likewise.
> (PTRACE_GETSINGOINFO): Likewise.
> (ppc_linux_insert_watchpoint): New.
> (ppc_linux_remove_watchpoint): Likewise.
> (ppc_linux_stopped_by_watchpoint): Likewise.
> (ppc_linux_check_watch_resources): Likewise.

Mark raised a valid concern about the use of the NM file for this;
the problem has now been fixed, so you can do this without touching
nm-linux.h.

Eli asked a valid question about how the entire process works.

Also, I had trouble believing that this interface was sufficiently
portable among the many PowerPC variants (which have at least two
different debug register schemes), so I went and checked. Support for
these ptrace operations is not in the kernel.org kernel. Where is it,
and how's it supposed to work?

> + errno = 0;
> + ptrace (PTRACE_GETSIGINFO, tid, (PTRACE_TYPE_ARG3) 0, &siginfo);
> +
> + if (errno != 0 || siginfo.si_signo != SIGTRAP ||
> + (siginfo.si_code & 0xffff) != 0x0004)
> + return 0;

Hmm, if you're using siginfos for this, then at least some PPCs ought to
be able to tell you where the fault occured.

> +int
> +ppc_linux_check_watch_resources (int type, int cnt, int ot)
> +{
> + /* PPC has one DABR (hardware watchpoint) register. */
> + return (cnt <= 1);
> +}

Some have none. I don't know what other variations there may be.

--
Daniel Jacobowitz
CodeSourcery, LLC