Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Christopher Faylor <cgf-use-the-mailinglist-please@sourceware.org>
To: Pedro Alves <pedro_alves@portugalmail.pt>, gdb-patches@sourceware.org
Subject: Re: [win32] Fix watchpoint support
Date: Fri, 23 Nov 2007 01:13:00 -0000	[thread overview]
Message-ID: <20071123011301.GA31259@ednor.casa.cgf.cx> (raw)
In-Reply-To: <47437D49.6080600@portugalmail.pt>

On Wed, Nov 21, 2007 at 12:35:21AM +0000, Pedro Alves wrote:
> Hi,
>
> The current watchpoint support for native debugging on win32 systems
> doesn't work reliably.  Quite often, we'd miss that the inferior
> stopped due to a watchpoint triggering, because Windows wouldn't
> report in DR6 which watchpoint triggered.  Take a look at this
> "set debug infrun 1; maint show-debug-regs 1" snippet [1]:
>
> infrun: TARGET_WAITKIND_STOPPED
> infrun: stop_pc = 0x40108e
> stopped_data_addr:
>            CONTROL (DR7): 000d0101          STATUS (DR6): 00000000
>                                                           ^^^^^^^^
>            DR0: addr=0x00403010, ref.count=1  DR1: addr=0x00000000, 
> ref.count=0
>            DR2: addr=0x00000000, ref.count=0  DR3: addr=0x00000000, 
> ref.count=0
> infrun: random signal 5
> ^^^^^^^^^^^^^^^^^^^^^^^
>
> Program received signal SIGTRAP, Trace/breakpoint trap.
> infrun: stop_stepping
> remove_watchpoint (addr=403010, len=4, type=data-write):
>            CONTROL (DR7): 000d0100          STATUS (DR6): 00000000
>            DR0: addr=0x00000000, ref.count=0  DR1: addr=0x00000000, 
> ref.count=0
>            DR2: addr=0x00000000, ref.count=0  DR3: addr=0x00000000, 
> ref.count=0
> main () at watch.c:11
> 11        printf ("count %d\n", count);
>
> 0x00403010 in that example is the address of a variable that
> was just written to.
>
> [1] Full example here:
> http://cygwin.com/ml/cygwin/2007-10/msg00057.html
>
> I ended up tracing the problem to win32_continue (gdb/win32-nat.c).
> Currently, it looks somewhat like this:
>
> 1 win32_continue(TID)
> 2       ContinueDebugEvent(current_TID)
> 3       foreach thread in threads do
> 4              if thread == TID
> 5                     ResumeThread(TID)
> 6                     SetThreadContext(TID, DEBUG_REGS)
> 7              fi
> 8       hcaerof
>
> The first problem is that we shoudn't be calling
> SetThreadContext after ResumeThread (5,6) -- it should
> be the other way around.

Yes, that's clearly a bug.  It seems to have been introduced by the
debug register handling.

>2007-11-21  Pedro Alves  <pedro_alves@portugalmail.pt>
>
>	* win32-nat.c (win32_add_thread): Set Dr6 to 0xffff0ff0.
>	(win32_continue): Resume threads and set the debug registers
>	before calling ContinueDebugEvent.

I'm not clear on how this differs from your other patch.  It seems to do
many of the same things.  The principles are ok but it doesn't seem like
it could be applied in addition to the suspend count handling patch.

cgf


  parent reply	other threads:[~2007-11-23  1:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-21  0:35 Pedro Alves
2007-11-21 15:22 ` Pierre Muller
2007-11-21 23:33   ` Pedro Alves
2007-11-23  1:13 ` Christopher Faylor [this message]
2007-11-24 12:22   ` Pedro Alves

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=20071123011301.GA31259@ednor.casa.cgf.cx \
    --to=cgf-use-the-mailinglist-please@sourceware.org \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro_alves@portugalmail.pt \
    /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