Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Raphael Zulliger <zulliger@indel.ch>,
	       "gdb@sourceware.org" <gdb@sourceware.org>
Subject: Re: Non-stop mode for Windows (mingw)
Date: Mon, 19 Sep 2016 10:17:00 -0000	[thread overview]
Message-ID: <9bd24124-be7c-2257-7518-8cba0345e195@redhat.com> (raw)
In-Reply-To: <45100db8-5b69-6a7a-e6cc-bad09e686f46@indel.ch>

On 09/19/2016 07:25 AM, Raphael Zulliger wrote:
> According to empirical tests and by looking at the GDB sources,
> 'windows-nat.c' and, therefore, GDB running on Windows (mingw) does not
> support non-stop debugging.
> 
> - What's the technical reason behind this? Was it just not ported to
> that platform so far? 

This.

> Wasn't it done because it's tricky?

- What would be needed to support it?

First, implement "maint set target-async on" support.  That is,
support background execution commands, like "continue&", even
in all-stop mode.  non-stop mode requires target-async support.

This basically means two things:

#1 - Implement support for TARGET_WNOHANG in windows_wait, returning
  TARGET_WAITKIND_IGNORE when there's no event to process.

The easiest is to return TARGET_WAITKIND_IGNORE when WaitForDebugEvent
times out.  We currently loop locally instead.

#2 - Somehow wake up gdb's main event loop whenever there's a 
target event to process.

The easiest though least efficient way would be constantly force the event
loop to poll, by always calling mark_async_event_handler when windows_wait
is called.  Essentially, telling the event loop code that there's maybe
some event to process.  If there's no actually event to return, then #1
above kicks in.

You'd probably want to avoid the large time out inside windows_nat
though.  So I'd try passing 0 as time out time to WaitForDebugEvent,
to effect a real poll, and then use the event loop's timer events
support to poll at some frequency instead of constantly.

To avoid the polling you'd probably need to move the WaitForDebugEvent
calls to a separate thread.  You'd then install a waitable event in gdb's event
loop, which the WaitForDebugEvent thread would set.  You'd use serial_event
for this (gdb/ser-event.h), which is basically a thin wrapper around SetEvent.



Then for non-stop, you'll want to support debugging one stopped thread
while the others are left running.  The main problem I think is that
WaitForDebugEvent implicitly suspends all threads.  In principle, it might
be possible to SuspendThread the event thread and call ContinueDebugEvent
immediately after WaitForDebugEvent returns the event.  First change exception
handling and DBG_CONTINUE / DBG_EXCEPTION_NOT_HANDLED is an open
question then though.

> (Is the main required thing that
> 'displaced single stepping' is required for non-stop mode?)

No.  Non-stop can work correctly without that nowadays -- gdb pauses
all threads, removes a breakpoint, step the thread over the breakpoint,
and then re-resumes threads that were originally running.  So
displaced stepping is considered an optimization nowadays, rather
than a requirement.

In any case, the displaced stepping implementation is mostly
architecture-specific, rather than OS specific, so the x86 Windows port
just needs to wire in the existing x86 displaced stepping support.

Thanks,
Pedro Alves


      reply	other threads:[~2016-09-19 10:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-19  6:25 Raphael Zulliger
2016-09-19 10:17 ` Pedro Alves [this message]

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=9bd24124-be7c-2257-7518-8cba0345e195@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb@sourceware.org \
    --cc=zulliger@indel.ch \
    /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