Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pierre Muller <muller@cerbere.u-strasbg.fr>
To: gdb-patches <gdb-patches@sources.redhat.com>
Subject: [RFC/RFA] Add hardware watchpoint support for cygwin target.
Date: Sat, 17 Nov 2001 10:47:00 -0000	[thread overview]
Message-ID: <4.2.0.58.20011128183252.00acd198@ics.u-strasbg.fr> (raw)

[-- Attachment #1: Type: text/plain, Size: 1899 bytes --]


    Following DJ Delorie's suggestion to use
CONTEXT_DEBUG_REGISTERS, I tested the
use of i386 debug registers to set hardware watchpoints.

   It works successfully on my Win2000 box here.

But te are some annoying things,
the most annoying is that an exception seems to be generated
on read access of the watched area even if you only set a normal
watchpoint (which should use a write-only debug feature).

    This results in lost of garbage written on output due
to the fact that mention function is called for watchpoints
even if the value remains unchanged and thus no stop is done...
    It is unclear to me if this is a bug in the breakpoint code or
if i386 code should take care of this issue.

   To Eli:
    If you test this patch, that contains a call to i386_cleanup_dregs(),
you can test the failure if you comment the call out...

PS:  the patch should be a Dos style text file,
Eudora seems completely unable to send Unix style text file....
Hopefully this will not create other problems.

2001-11-28 Pierre Muller  <muller@ics.u-strasbg.fr>

	* win32-nat.c (CONTEXT_DEBUG_DR macro): Add use of CONTEXT_DEBUG_REGISTERS.
	(dr variable): New static array containing a local copy of debug registers.
	(debug_registers_changed): Non zero whenever the debug registers where changed and
	need to be written to inferior.
	(cygwin_set_dr, cygwin_set_dr7, cygwin_get_dr6): New functions used by i386-nat code.
	(thread_rec): Set dr array if id is the thread of current_event .
	(child_continue, child_resume): Change the debug registers for all threads 
	if debug_registers_changed.
	* config/i386/cygwin.mh: Add use of i386-nat.o file.
	Link nm.h to new nm-cygwin.h file.
	+ config/i386/nm-cygwin.h: New file.





Pierre Muller
Institut Charles Sadron
6,rue Boussingault
F 67083 STRASBOURG CEDEX (France)
mailto:muller@ics.u-strasbg.fr
Phone : (33)-3-88-41-40-07  Fax : (33)-3-88-41-40-99 

[-- Attachment #2: Type: text/plain, Size: 4644 bytes --]

Index: win32-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/win32-nat.c,v
retrieving revision 1.40
diff -r1.40 win32-nat.c
71c71,72
< #define CONTEXT_DEBUGGER_DR CONTEXT_DEBUGGER | CONTEXT_EXTENDED_REGISTERS
---
> #define CONTEXT_DEBUGGER_DR CONTEXT_DEBUGGER | CONTEXT_DEBUG_REGISTERS \
> 	| CONTEXT_EXTENDED_REGISTERS
73c74
< #define CONTEXT_DEBUGGER_DR CONTEXT_DEBUGGER
---
> #define CONTEXT_DEBUGGER_DR CONTEXT_DEBUGGER | CONTEXT_DEBUG_REGISTERS
75a77,79
> static unsigned dr[8];
> static int debug_registers_changed = 0;
> 
235a240,249
> 	    if (id == current_event.dwThreadId)
> 	      {
> 		/* Copy dr values from that thread.  */
> 		dr[0] = th->context.Dr0;
> 		dr[1] = th->context.Dr1;
> 		dr[2] = th->context.Dr2;
> 		dr[3] = th->context.Dr3;
> 		dr[6] = th->context.Dr6;
> 		dr[7] = th->context.Dr7;
> 	      }
877a892,904
> 	  if (debug_registers_changed)
>             {
>               /* Only change the value of the debug registers.  */
>               th->context.ContextFlags = CONTEXT_DEBUG_REGISTERS;
>               th->context.Dr0 = dr[0];
>               th->context.Dr1 = dr[1];
>               th->context.Dr2 = dr[2];
>               th->context.Dr3 = dr[3];
>               th->context.Dr6 = dr[6];
>               th->context.Dr7 = dr[7];
> 	      CHECK (SetThreadContext (th->h, &th->context));
>               th->context.ContextFlags = 0;
> 	    }
882a910
>   debug_registers_changed = 0;
1061a1090
>   int i;
1065a1095,1097
>   debug_registers_changed = 0;
>   for (i = 0; i <= 7; i++)
>     dr[i] = 0;
1344a1377
>   i386_cleanup_dregs();
1411a1445
> 
1431a1466,1474
> 	  if (debug_registers_changed)
> 	    {
> 	      th->context.Dr0 = dr[0];
> 	      th->context.Dr1 = dr[1];
> 	      th->context.Dr2 = dr[2];
> 	      th->context.Dr3 = dr[3];
> 	      th->context.Dr6 = dr[6];
> 	      th->context.Dr7 = dr[7];
> 	    }
1563a1607,1641
> 
> /* Hardware watchpoint support, adapted from go32-nat.c code.  */
> 
> /* Pass the address ADDR to the inferior in the I'th debug register.
>    Here we just store the address in dr array, the registers will be
>    actually set up when child_continue is called.  */
> void
> cygwin_set_dr (int i, CORE_ADDR addr)
> {
>   if (i < 0 || i > 3)
>     internal_error (__FILE__, __LINE__,
> 		    "Invalid register %d in cygwin_set_dr.\n", i);
>   dr[i] = (unsigned) addr;
>   debug_registers_changed = 1;
> }
> 
> /* Pass the value VAL to the inferior in the DR7 debug control
>    register.  Here we just store the address in D_REGS, the watchpoint
>    will be actually set up in child_wait.  */
> void
> cygwin_set_dr7 (unsigned val)
> {
>   dr[7] = val;
>   debug_registers_changed = 1;
> }
> 
> /* Get the value of the DR6 debug status register from the inferior.
>    Here we just return the value stored in D_REGS, as we've got it
>    from the last go32_wait call.  */
> unsigned
> cygwin_get_dr6 (void)
> {
>   return dr[6];
> }
> 
Index: config/i386/cygwin.mh
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/cygwin.mh,v
retrieving revision 1.4
diff -r1.4 cygwin.mh
4,5c4,5
< NATDEPFILES= win32-nat.o corelow.o
< NAT_FILE=../none/nm-none.h
---
> NATDEPFILES= i386-nat.o win32-nat.o corelow.o
> NAT_FILE=nm-cygwin.h
/* Native definitions for Intel x86 running CYGWIN.
   Copyright (C) 2001 Free Software Foundation, Inc.

   This file is part of GDB.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.  */

#define NO_PTRACE_H

#define I386_USE_GENERIC_WATCHPOINTS

#include "i386/nm-i386.h"

/* Support for hardware-assisted breakpoints and watchpoints.  */

#define I386_DR_LOW_SET_CONTROL(VAL)	cygwin_set_dr7 (VAL)
extern void cygwin_set_dr7 (unsigned);

#define I386_DR_LOW_SET_ADDR(N,ADDR)	cygwin_set_dr (N,ADDR)
extern void cygwin_set_dr (int, CORE_ADDR);

#define I386_DR_LOW_RESET_ADDR(N)

#define I386_DR_LOW_GET_STATUS()	cygwin_get_dr6 ()
extern unsigned cygwin_get_dr6 (void);

[-- Attachment #3: Type: text/plain, Size: 176 bytes --]



Pierre Muller
Institut Charles Sadron
6,rue Boussingault
F 67083 STRASBOURG CEDEX (France)
mailto:muller@ics.u-strasbg.fr
Phone : (33)-3-88-41-40-07  Fax : (33)-3-88-41-40-99

WARNING: multiple messages have this Message-ID
From: Pierre Muller <muller@cerbere.u-strasbg.fr>
To: gdb-patches <gdb-patches@sources.redhat.com>
Subject: [RFC/RFA] Add hardware watchpoint support for cygwin target.
Date: Wed, 28 Nov 2001 09:44:00 -0000	[thread overview]
Message-ID: <4.2.0.58.20011128183252.00acd198@ics.u-strasbg.fr> (raw)
Message-ID: <20011128094400.uvkmz--eiI6TIrVLXXbvD8r4dlH8RsHBDIeiYhmpkxs@z> (raw)

    Following DJ Delorie's suggestion to use
CONTEXT_DEBUG_REGISTERS, I tested the
use of i386 debug registers to set hardware watchpoints.

   It works successfully on my Win2000 box here.

But te are some annoying things,
the most annoying is that an exception seems to be generated
on read access of the watched area even if you only set a normal
watchpoint (which should use a write-only debug feature).

    This results in lost of garbage written on output due
to the fact that mention function is called for watchpoints
even if the value remains unchanged and thus no stop is done...
    It is unclear to me if this is a bug in the breakpoint code or
if i386 code should take care of this issue.

   To Eli:
    If you test this patch, that contains a call to i386_cleanup_dregs(),
you can test the failure if you comment the call out...

PS:  the patch should be a Dos style text file,
Eudora seems completely unable to send Unix style text file....
Hopefully this will not create other problems.

2001-11-28 Pierre Muller  <muller@ics.u-strasbg.fr>

	* win32-nat.c (CONTEXT_DEBUG_DR macro): Add use of CONTEXT_DEBUG_REGISTERS.
	(dr variable): New static array containing a local copy of debug registers.
	(debug_registers_changed): Non zero whenever the debug registers where changed and
	need to be written to inferior.
	(cygwin_set_dr, cygwin_set_dr7, cygwin_get_dr6): New functions used by i386-nat code.
	(thread_rec): Set dr array if id is the thread of current_event .
	(child_continue, child_resume): Change the debug registers for all threads 
	if debug_registers_changed.
	* config/i386/cygwin.mh: Add use of i386-nat.o file.
	Link nm.h to new nm-cygwin.h file.
	+ config/i386/nm-cygwin.h: New file.





Pierre Muller
Institut Charles Sadron
6,rue Boussingault
F 67083 STRASBOURG CEDEX (France)
mailto:muller@ics.u-strasbg.fr
Phone : (33)-3-88-41-40-07  Fax : (33)-3-88-41-40-99 
Index: win32-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/win32-nat.c,v
retrieving revision 1.40
diff -r1.40 win32-nat.c
71c71,72
< #define CONTEXT_DEBUGGER_DR CONTEXT_DEBUGGER | CONTEXT_EXTENDED_REGISTERS
---
> #define CONTEXT_DEBUGGER_DR CONTEXT_DEBUGGER | CONTEXT_DEBUG_REGISTERS \
> 	| CONTEXT_EXTENDED_REGISTERS
73c74
< #define CONTEXT_DEBUGGER_DR CONTEXT_DEBUGGER
---
> #define CONTEXT_DEBUGGER_DR CONTEXT_DEBUGGER | CONTEXT_DEBUG_REGISTERS
75a77,79
> static unsigned dr[8];
> static int debug_registers_changed = 0;
> 
235a240,249
> 	    if (id == current_event.dwThreadId)
> 	      {
> 		/* Copy dr values from that thread.  */
> 		dr[0] = th->context.Dr0;
> 		dr[1] = th->context.Dr1;
> 		dr[2] = th->context.Dr2;
> 		dr[3] = th->context.Dr3;
> 		dr[6] = th->context.Dr6;
> 		dr[7] = th->context.Dr7;
> 	      }
877a892,904
> 	  if (debug_registers_changed)
>             {
>               /* Only change the value of the debug registers.  */
>               th->context.ContextFlags = CONTEXT_DEBUG_REGISTERS;
>               th->context.Dr0 = dr[0];
>               th->context.Dr1 = dr[1];
>               th->context.Dr2 = dr[2];
>               th->context.Dr3 = dr[3];
>               th->context.Dr6 = dr[6];
>               th->context.Dr7 = dr[7];
> 	      CHECK (SetThreadContext (th->h, &th->context));
>               th->context.ContextFlags = 0;
> 	    }
882a910
>   debug_registers_changed = 0;
1061a1090
>   int i;
1065a1095,1097
>   debug_registers_changed = 0;
>   for (i = 0; i <= 7; i++)
>     dr[i] = 0;
1344a1377
>   i386_cleanup_dregs();
1411a1445
> 
1431a1466,1474
> 	  if (debug_registers_changed)
> 	    {
> 	      th->context.Dr0 = dr[0];
> 	      th->context.Dr1 = dr[1];
> 	      th->context.Dr2 = dr[2];
> 	      th->context.Dr3 = dr[3];
> 	      th->context.Dr6 = dr[6];
> 	      th->context.Dr7 = dr[7];
> 	    }
1563a1607,1641
> 
> /* Hardware watchpoint support, adapted from go32-nat.c code.  */
> 
> /* Pass the address ADDR to the inferior in the I'th debug register.
>    Here we just store the address in dr array, the registers will be
>    actually set up when child_continue is called.  */
> void
> cygwin_set_dr (int i, CORE_ADDR addr)
> {
>   if (i < 0 || i > 3)
>     internal_error (__FILE__, __LINE__,
> 		    "Invalid register %d in cygwin_set_dr.\n", i);
>   dr[i] = (unsigned) addr;
>   debug_registers_changed = 1;
> }
> 
> /* Pass the value VAL to the inferior in the DR7 debug control
>    register.  Here we just store the address in D_REGS, the watchpoint
>    will be actually set up in child_wait.  */
> void
> cygwin_set_dr7 (unsigned val)
> {
>   dr[7] = val;
>   debug_registers_changed = 1;
> }
> 
> /* Get the value of the DR6 debug status register from the inferior.
>    Here we just return the value stored in D_REGS, as we've got it
>    from the last go32_wait call.  */
> unsigned
> cygwin_get_dr6 (void)
> {
>   return dr[6];
> }
> 
Index: config/i386/cygwin.mh
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/cygwin.mh,v
retrieving revision 1.4
diff -r1.4 cygwin.mh
4,5c4,5
< NATDEPFILES= win32-nat.o corelow.o
< NAT_FILE=../none/nm-none.h
---
> NATDEPFILES= i386-nat.o win32-nat.o corelow.o
> NAT_FILE=nm-cygwin.h
/* Native definitions for Intel x86 running CYGWIN.
   Copyright (C) 2001 Free Software Foundation, Inc.

   This file is part of GDB.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.  */

#define NO_PTRACE_H

#define I386_USE_GENERIC_WATCHPOINTS

#include "i386/nm-i386.h"

/* Support for hardware-assisted breakpoints and watchpoints.  */

#define I386_DR_LOW_SET_CONTROL(VAL)	cygwin_set_dr7 (VAL)
extern void cygwin_set_dr7 (unsigned);

#define I386_DR_LOW_SET_ADDR(N,ADDR)	cygwin_set_dr (N,ADDR)
extern void cygwin_set_dr (int, CORE_ADDR);

#define I386_DR_LOW_RESET_ADDR(N)

#define I386_DR_LOW_GET_STATUS()	cygwin_get_dr6 ()
extern unsigned cygwin_get_dr6 (void);
From eliz@is.elta.co.il Wed Nov 28 10:05:00 2001
From: "Eli Zaretskii" <eliz@is.elta.co.il>
To: orjan.friberg@axis.com
Cc: gdb-patches@sources.redhat.com
Subject: Re: [RFC]: Solib search (Was: Re: Cross solib support; continued)
Date: Wed, 28 Nov 2001 10:05:00 -0000
Message-id: <2950-Wed28Nov2001200425+0200-eliz@is.elta.co.il>
References: <3BEAA3A0.586B3046@axis.com> <20011108110955.A12240@nevyn.them.org> <3C03AB51.DB27B3D4@axis.com> <3405-Tue27Nov2001175932+0200-eliz@is.elta.co.il> <3C04B5A9.1F054A9F@axis.com> <7458-Wed28Nov2001183554+0200-eliz@is.elta.co.il> <3C052245.8C02668E@axis.com>
X-SW-Source: 2001-11/msg00538.html
Content-length: 884

> Date: Wed, 28 Nov 2001 18:43:33 +0100
> From: Orjan Friberg <orjan.friberg@axis.com>
> 
> I was trying to address the situation where in_pathname contains several
> leading slashes; then your suggested code (and my original code also)
> would terminate too early.  I guess we don't normally care about
> multiple leading slashes since it's a valid path, but in this case we
> need to get rid of all of them to make it a relative path.
> 
> This code should cut it:
> 
>   if (found_file < 0 && IS_ABSOLUTE_PATH (in_pathname))
>     {
>       /* First, get rid of any drive letters etc.  */
>       while (!IS_DIR_SEPARATOR (*in_pathname))
>         in_pathname++;
> 
>       /* Next, get rid of all leading dir separators.  */
>       while (IS_DIR_SEPARATOR (*in_pathname))
>         in_pathname++;
>     }

Yes, this does what you want, AFAICS.

Thanks for explaining the issue.


             reply	other threads:[~2001-11-28 17:44 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-17 10:47 Pierre Muller [this message]
2001-11-28  9:44 ` Pierre Muller
2001-11-28 10:13 ` Eli Zaretskii
2001-11-17 16:07   ` Eli Zaretskii
2001-11-17 20:21   ` Christopher Faylor
2001-11-17 22:30     ` muller
2001-11-17 23:01       ` Christopher Faylor
2001-11-28 17:27         ` Christopher Faylor
2001-11-28 14:31       ` muller
2001-11-19  8:29     ` Eli Zaretskii
2001-11-21 15:15       ` Pierre Muller
2001-11-21 23:08         ` Christopher Faylor
2001-11-30  9:04           ` Christopher Faylor
2001-11-30  7:11         ` Pierre Muller
2001-11-29  0:12       ` Eli Zaretskii
2001-11-29  0:26       ` Pierre Muller
2001-11-19 11:30         ` Pierre Muller
2001-11-28 11:30     ` Christopher Faylor
2001-12-06  0:37     ` Pierre Muller
2001-12-06 13:30       ` Andrew Cagney
2001-12-07 16:59       ` Christopher Faylor
2001-12-10  2:23         ` Pierre Muller
2001-12-10 11:33           ` Christopher Faylor
2001-12-11  0:15             ` Eli Zaretskii
2001-12-11  1:04               ` Pierre Muller
2001-11-28 13:55   ` muller
2001-11-17 21:08     ` muller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4.2.0.58.20011128183252.00acd198@ics.u-strasbg.fr \
    --to=muller@cerbere.u-strasbg.fr \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox