public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Tom Tromey <tromey@adacore.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 1/2] Move some Windows operations to worker thread
Date: Wed, 03 Aug 2022 16:33:50 +0300	[thread overview]
Message-ID: <83a68l5u4h.fsf@gnu.org> (raw)
In-Reply-To: <20220803130822.735057-2-tromey@adacore.com> (message from Tom Tromey via Gdb-patches on Wed, 3 Aug 2022 07:08:21 -0600)

> Date: Wed,  3 Aug 2022 07:08:21 -0600
> From: Tom Tromey via Gdb-patches <gdb-patches@sourceware.org>
> Cc: Tom Tromey <tromey@adacore.com>
> 
> On Windows, certain debugging APIs can only be called from the thread
> that started (or attached) to the inferior.  Also, there is no way on
> Windows to wait for a debug event in addition to other events.
> Therefore, in order to implement target async for Windows, gdb will
> have to call some functions in a worker thread.
> 
> This patch implements the worker thread and moves the necessary
> operations there.  Target async isn't yet implemented, so this patch
> does not cause any visible changes.

Thanks!

> +  HANDLE bg_thread = CreateThread (nullptr, 0, fn, this, 0, nullptr);

That zero in the 2nd argument of CreateThread means the worker thread
will get the same stack size as the value recorded in the GDB
executable file's header, which is 12MB according to my reading of
gdb/Makefile, at least in my build?  That's unlikely to be required
for this thread, so I suggest to specify a non-zero value there
instead.  I guess 64KB should be enough?

The downside of leaving it at zero is that the OS reserves the
addresses of the entire stack space as for the GDB process, which
could then prevent GDB from allocating enough memory for other
purposes.  And if we could start several such worker threads (is that
possible in some usage scenario?), then we could simply run out of
memory for no good reason, and the next thread will fail to start.

  reply	other threads:[~2022-08-03 13:33 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-03 13:08 [PATCH 0/2] Implement target async for Windows Tom Tromey
2022-08-03 13:08 ` [PATCH 1/2] Move some Windows operations to worker thread Tom Tromey
2022-08-03 13:33   ` Eli Zaretskii [this message]
2022-08-03 18:47     ` Tom Tromey
2022-08-03 19:16       ` Eli Zaretskii
2022-08-03 13:08 ` [PATCH 2/2] Implement target async for Windows Tom Tromey
2022-11-04 14:28   ` Jon Turney
2022-11-08 18:38     ` Tom Tromey
2022-11-13 14:45       ` Jon Turney
2022-11-04 14:59   ` Jon Turney
2022-11-08 18:52     ` Tom Tromey
2022-11-17 14:33       ` Jon Turney
2022-11-17 18:38         ` Tom Tromey
2022-11-17 18:43           ` Tom Tromey
2022-08-03 13:34 ` [PATCH 0/2] " Eli Zaretskii
2022-08-03 18:54   ` Tom Tromey
2022-08-03 19:17     ` Eli Zaretskii
2022-08-22 18:03 ` Tom Tromey

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=83a68l5u4h.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@adacore.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).