RE: [RFA] Use i386_use_watchpoints for go32v2, bds and windows native

Pierre Muller
2009-02-09T07:33:43Z

From Eli Zaretskii
> Envoyé : Monday, February 09, 2009 5:10 AM
> À : Pierre Muller
> Cc : gdb-patches@sourceware.org
> Objet : Re: [RFA] Use i386_use_watchpoints for go32v2, bds and windows
> native
>
> > From: "Pierre Muller" <muller@ics.u-strasbg.fr>
> > Date: Mon, 9 Feb 2009 00:22:50 +0100
> >
> > The correction of this problem is easy, as it is already
> implemented
> > for linux.
> > The patch only adds
> > #define I386_WATCHPOINTS_IN_TARGET_VECTOR
> > to all config/i386/nm-*.h
> > that defines I386_USE_GENERIC_WATCHPOINTS
> > before including nm-i386.h
> > and add the corresponding call
> > to i386_use_watchpoints (target)
> > in the native file when the target vector gets
> > defined.
> >
> > I found only three places where this happens:
> > nm-go32.h with native go32-nat.c
> > nm-fbsd.h with native i386bsd-nat.c
> > and
> > nm-cygwin.h and nm-cygwin64.h with native windows-nat.c
>
> I don't necessarily object, but could you please explain what does
> each of these two changes do? That is, what does defining
> I386_WATCHPOINTS_IN_TARGET_VECTOR accomplish, and why we need to call
> i386_use_watchpoints?

The function i386_use_watchpoints
simply sets the target vector fields related to hardware watchpoints.
But this change alone is useless as the mechanism used to set
hardware watchpoints in gdb relies on macros
called target_insert_watchpoint or target_remove_watchpoint
(plus others), macros that are set in nm-i386.h
to call directly i386_insert_watchpoint/i386_remove_watchpoint,
unless the macro I386_WATCHPOINTS_IN_TARGET_VECTOR is also
defined when parsing that header.

If target_xxx_watchpoint are set by nm-i386.h header,
'target remote' or 'target extended-remote' do not
work as expected for remote hardware watchpoints because
instead of calling remove_insert_watchpoint and similar,
which generate the Z2 to Z4 packets, it still
calls the native i386_insert_watchpoint.

You might argue that this is not very useful for djgpp
native, but there are other points in favor of that patch:
- the patch removes completely the use of
this native definitions of target_xxxx_wqatchpoint
macros and are as such supported by the ARI list.
- the 'set debug target 1' command also is affected
by that patch.
Before the patch no watchpoint messages are printed out,
while they are after.

The above applies to all targets concerned by the patch.

By the way, should I split this into three independent
patches for each target or is it better if I leave it as
one single piece?