This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Remote watchpoint support.


Mark Salter wrote:
> 
> I'm adding hw break/watchpoint support to a remote target. I'm using
> the Z-packet support that is in remote.c to install/remove the
> watchpoints and breakpoints. When a watchpoint is triggered by a
> read access, GDB needs a way to tell if the target stopped because
> of the watchpoint. This is done through a target specific function:
> 
>   CORE_ADDR target_stopped_data_address(void)
> 
> which returns the address of the data access which triggered the
> watchpoint. If the target did not stop because of a watchpoint,
> target_stopped_data_address should return zero. Past implementations
> of watchpoints for remote targets have relied on special registers
> returned in the 'g' packet to determine the data address.
> 
> Rather than having gdb deal with the debug support registers directly,
> I would like to add a remote protocol packet that can be used to
> query the target for this address.
> 
> Comments?
> 
> --Mark

That really sounds like more of a gdb thing.  xxx-tdep.c should have
the knowledge about the registers, though, not remote.c.


> gdb/ChangeLog:
> 
> 2000-10-30  Mark Salter  <msalter@redhat.com>
> 
>         * remote.c (remote_stopped_data_address): New function to query
>         remote target for address of access that tripped a watchpoint.
> 
> gdb/doc/ChangeLog:
> 
> 2000-10-30  Mark Salter  <msalter@redhat.com>
> 
>         * gdb.texinfo (Top): Add description of qWaddr packet.
> 
> Index: remote.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/remote.c,v
> retrieving revision 1.26
> diff -p -c -r1.26 remote.c
> *** remote.c    2000/10/23 22:49:28     1.26
> --- remote.c    2000/10/30 13:55:28
> *************** remote_remove_hw_breakpoint (CORE_ADDR a
> *** 4483,4488 ****
> --- 4483,4509 ----
>         return 0;
>       }
>     internal_error ("remote_remove_watchpoint: reached end of function");
> + }
> +
> + /* Query target for data address that triggered a watchpoint.
> +  */
> + CORE_ADDR
> + remote_stopped_data_address (void)
> + {
> +   char *buf = alloca (PBUFSIZ);
> +   char *tmp;
> +   ULONGEST addr;
> +
> +   putpkt("qWaddr");
> +   getpkt (buf, PBUFSIZ, 0);
> +
> +   if (buf[0] == '\0' || buf [0] == 'E')
> +     return (CORE_ADDR)0;
> +
> +   for (addr = 0, tmp = buf; *tmp; tmp++)
> +     addr = addr * 16 + fromhex (*tmp);
> +
> +   return (CORE_ADDR)addr;
>   }
> 
>   /* Some targets are only capable of doing downloads, and afterwards
> Index: gdb.texinfo
> ===================================================================
> RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
> retrieving revision 1.28
> diff -p -c -r1.28 gdb.texinfo
> *** gdb.texinfo 2000/10/16 07:34:02     1.28
> --- gdb.texinfo 2000/10/30 13:56:29
> *************** Indicate a badly formed request.
> *** 9580,9585 ****
> --- 9580,9598 ----
>   @tab
>   When @samp{q}@samp{Rcmd} is not recognized.
> 
> + @item get watchpoint data addr
> + @tab @code{q}@code{Waddr}
> + @tab
> + Get address of data access that caused target to stop because of a
> + watchpoint. Zero if target stopped for some reason other than a
> + watchpoint.
> + @item
> + @tab reply @code{E}@var{NN}
> + @tab An error (such as memory fault)
> + @item
> + @tab reply @var{addr}
> + @tab
> +
>   @end multitable
> 
>   The following @samp{g}/@samp{G} packets have previously been defined.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]